From owner-svn-src-stable-10@freebsd.org Sun Mar 19 15:56:07 2017 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 8D097D13CA0; Sun, 19 Mar 2017 15:56:07 +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 6511A13A; Sun, 19 Mar 2017 15:56:07 +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 v2JFu6xw002653; Sun, 19 Mar 2017 15:56:06 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2JFu6SU002650; Sun, 19 Mar 2017 15:56:06 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201703191556.v2JFu6SU002650@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 19 Mar 2017 15:56:06 +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: r315562 - in stable/10/sys: kern sys 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.23 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, 19 Mar 2017 15:56:07 -0000 Author: kib Date: Sun Mar 19 15:56:06 2017 New Revision: 315562 URL: https://svnweb.freebsd.org/changeset/base/315562 Log: MFC r315155: Ktracing kevent(2) calls with unusual arguments might leads to an overly large allocation requests. PR: 217435 Modified: stable/10/sys/kern/kern_event.c stable/10/sys/kern/kern_ktrace.c stable/10/sys/sys/ktrace.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/kern_event.c ============================================================================== --- stable/10/sys/kern/kern_event.c Sun Mar 19 15:53:17 2017 (r315561) +++ stable/10/sys/kern/kern_event.c Sun Mar 19 15:56:06 2017 (r315562) @@ -825,6 +825,15 @@ done2: return (error); } +static size_t +kev_iovlen(int n, u_int kgio) +{ + + if (n < 0 || n >= kgio / sizeof(struct kevent)) + return (kgio); + return (n * sizeof(struct kevent)); +} + #ifndef _SYS_SYSPROTO_H_ struct kevent_args { int fd; @@ -848,6 +857,7 @@ sys_kevent(struct thread *td, struct kev struct iovec ktriov; struct uio *ktruioin = NULL; struct uio *ktruioout = NULL; + u_int kgio; #endif if (uap->timeout != NULL) { @@ -860,13 +870,15 @@ sys_kevent(struct thread *td, struct kev #ifdef KTRACE if (KTRPOINT(td, KTR_GENIO)) { + kgio = ktr_geniosize; ktriov.iov_base = uap->changelist; - ktriov.iov_len = uap->nchanges * sizeof(struct kevent); + ktriov.iov_len = kev_iovlen(uap->nchanges, kgio); ktruio = (struct uio){ .uio_iov = &ktriov, .uio_iovcnt = 1, .uio_segflg = UIO_USERSPACE, .uio_rw = UIO_READ, .uio_td = td }; ktruioin = cloneuio(&ktruio); ktriov.iov_base = uap->eventlist; + ktriov.iov_len = kev_iovlen(uap->nevents, kgio); ktriov.iov_len = uap->nevents * sizeof(struct kevent); ktruioout = cloneuio(&ktruio); } @@ -877,9 +889,9 @@ sys_kevent(struct thread *td, struct kev #ifdef KTRACE if (ktruioin != NULL) { - ktruioin->uio_resid = uap->nchanges * sizeof(struct kevent); + ktruioin->uio_resid = kev_iovlen(uap->nchanges, kgio); ktrgenio(uap->fd, UIO_WRITE, ktruioin, 0); - ktruioout->uio_resid = td->td_retval[0] * sizeof(struct kevent); + ktruioout->uio_resid = kev_iovlen(td->td_retval[0], kgio); ktrgenio(uap->fd, UIO_READ, ktruioout, error); } #endif Modified: stable/10/sys/kern/kern_ktrace.c ============================================================================== --- stable/10/sys/kern/kern_ktrace.c Sun Mar 19 15:53:17 2017 (r315561) +++ stable/10/sys/kern/kern_ktrace.c Sun Mar 19 15:56:06 2017 (r315562) @@ -132,7 +132,7 @@ static SYSCTL_NODE(_kern, OID_AUTO, ktra static u_int ktr_requestpool = KTRACE_REQUEST_POOL; TUNABLE_INT("kern.ktrace.request_pool", &ktr_requestpool); -static u_int ktr_geniosize = PAGE_SIZE; +u_int ktr_geniosize = PAGE_SIZE; TUNABLE_INT("kern.ktrace.genio_size", &ktr_geniosize); SYSCTL_UINT(_kern_ktrace, OID_AUTO, genio_size, CTLFLAG_RW, &ktr_geniosize, 0, "Maximum size of genio event payload"); Modified: stable/10/sys/sys/ktrace.h ============================================================================== --- stable/10/sys/sys/ktrace.h Sun Mar 19 15:53:17 2017 (r315561) +++ stable/10/sys/sys/ktrace.h Sun Mar 19 15:56:06 2017 (r315562) @@ -276,7 +276,7 @@ void ktrcapfail(enum ktr_cap_fail_type, ktrstruct("sockaddr", (s), ((struct sockaddr *)(s))->sa_len) #define ktrstat(s) \ ktrstruct("stat", (s), sizeof(struct stat)) - +extern u_int ktr_geniosize; #else #include From owner-svn-src-stable-10@freebsd.org Sun Mar 19 20:04:58 2017 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 6E3C4D13DE9; Sun, 19 Mar 2017 20:04:58 +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 2F5891AD0; Sun, 19 Mar 2017 20:04:58 +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 v2JK4v3U005469; Sun, 19 Mar 2017 20:04:57 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2JK4viC005468; Sun, 19 Mar 2017 20:04:57 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201703192004.v2JK4viC005468@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Sun, 19 Mar 2017 20:04:57 +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: r315582 - stable/10/contrib/one-true-awk 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.23 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, 19 Mar 2017 20:04:58 -0000 Author: pfg Date: Sun Mar 19 20:04:57 2017 New Revision: 315582 URL: https://svnweb.freebsd.org/changeset/base/315582 Log: MFC r315426, MFV r315425: one-true-awk: have calloc(3) do the multiplication. Modified: stable/10/contrib/one-true-awk/b.c Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/one-true-awk/b.c ============================================================================== --- stable/10/contrib/one-true-awk/b.c Sun Mar 19 20:04:23 2017 (r315581) +++ stable/10/contrib/one-true-awk/b.c Sun Mar 19 20:04:57 2017 (r315582) @@ -140,7 +140,7 @@ fa *mkdfa(const char *s, int anchor) /* f->accept = poscnt-1; /* penter has computed number of positions in re */ cfoll(f, p1); /* set up follow sets */ freetr(p1); - if ((f->posns[0] = (int *) calloc(1, *(f->re[0].lfollow)*sizeof(int))) == NULL) + if ((f->posns[0] = (int *) calloc(*(f->re[0].lfollow), sizeof(int))) == NULL) overflo("out of space in makedfa"); if ((f->posns[1] = (int *) calloc(1, sizeof(int))) == NULL) overflo("out of space in makedfa"); @@ -160,7 +160,7 @@ int makeinit(fa *f, int anchor) f->reset = 0; k = *(f->re[0].lfollow); xfree(f->posns[2]); - if ((f->posns[2] = (int *) calloc(1, (k+1)*sizeof(int))) == NULL) + if ((f->posns[2] = (int *) calloc(k+1, sizeof(int))) == NULL) overflo("out of space in makeinit"); for (i=0; i <= k; i++) { (f->posns[2])[i] = (f->re[0].lfollow)[i]; @@ -375,7 +375,7 @@ void cfoll(fa *f, Node *v) /* enter foll setvec[i] = 0; setcnt = 0; follow(v); /* computes setvec and setcnt */ - if ((p = (int *) calloc(1, (setcnt+1)*sizeof(int))) == NULL) + if ((p = (int *) calloc(setcnt+1, sizeof(int))) == NULL) overflo("out of space building follow set"); f->re[info(v)].lfollow = p; *p = setcnt; @@ -549,7 +549,7 @@ int pmatch(fa *f, const char *p0) /* lon for (i = 2; i <= f->curstat; i++) xfree(f->posns[i]); k = *f->posns[0]; - if ((f->posns[2] = (int *) calloc(1, (k+1)*sizeof(int))) == NULL) + if ((f->posns[2] = (int *) calloc(k+1, sizeof(int))) == NULL) overflo("out of space in pmatch"); for (i = 0; i <= k; i++) (f->posns[2])[i] = (f->posns[0])[i]; @@ -606,7 +606,7 @@ int nematch(fa *f, const char *p0) /* no for (i = 2; i <= f->curstat; i++) xfree(f->posns[i]); k = *f->posns[0]; - if ((f->posns[2] = (int *) calloc(1, (k+1)*sizeof(int))) == NULL) + if ((f->posns[2] = (int *) calloc(k+1, sizeof(int))) == NULL) overflo("out of state space"); for (i = 0; i <= k; i++) (f->posns[2])[i] = (f->posns[0])[i]; @@ -943,7 +943,7 @@ int cgoto(fa *f, int s, int c) for (i = 0; i < NCHARS; i++) f->gototab[f->curstat][i] = 0; xfree(f->posns[f->curstat]); - if ((p = (int *) calloc(1, (setcnt+1)*sizeof(int))) == NULL) + if ((p = (int *) calloc(setcnt+1, sizeof(int))) == NULL) overflo("out of space in cgoto"); f->posns[f->curstat] = p; From owner-svn-src-stable-10@freebsd.org Sun Mar 19 22:14:23 2017 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 833D9D135BC; Sun, 19 Mar 2017 22:14:23 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4B67919C7; Sun, 19 Mar 2017 22:14:23 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2JMEMLQ059256; Sun, 19 Mar 2017 22:14:22 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2JMEM0U059255; Sun, 19 Mar 2017 22:14:22 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201703192214.v2JMEM0U059255@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Sun, 19 Mar 2017 22:14:22 +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: r315593 - stable/10/etc 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.23 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, 19 Mar 2017 22:14:23 -0000 Author: ngie Date: Sun Mar 19 22:14:22 2017 New Revision: 315593 URL: https://svnweb.freebsd.org/changeset/base/315593 Log: MFC r311601: Move the mibII module up so uncommenting the bridge module works Add a note about how module ordering and dependent modules Modified: stable/10/etc/snmpd.config Directory Properties: stable/10/ (props changed) Modified: stable/10/etc/snmpd.config ============================================================================== --- stable/10/etc/snmpd.config Sun Mar 19 22:13:40 2017 (r315592) +++ stable/10/etc/snmpd.config Sun Mar 19 22:14:22 2017 (r315593) @@ -122,6 +122,14 @@ snmpEnableAuthenTraps = 2 # order to use the enclosed variables, e.g. `usmUserStatus.$(engine).$(user1)` # can only be used if %usm is uncommented. # +# Modules are loaded in the order listed, so they must be before any +# dependent modules, e.g. "mibII" vs "bridge". +# + +# +# MIB-2 module +# +begemotSnmpdModulePath."mibII" = "/usr/lib/snmp_mibII.so" # # Bridge module @@ -136,11 +144,6 @@ snmpEnableAuthenTraps = 2 #begemotSnmpdModulePath."hostres" = "/usr/lib/snmp_hostres.so" # -# MIB-2 module -# -begemotSnmpdModulePath."mibII" = "/usr/lib/snmp_mibII.so" - -# # Netgraph module # #begemotSnmpdModulePath."netgraph" = "/usr/lib/snmp_netgraph.so" From owner-svn-src-stable-10@freebsd.org Mon Mar 20 00:55:26 2017 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 B5F1DD14A1A; Mon, 20 Mar 2017 00:55:26 +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 907CF815; Mon, 20 Mar 2017 00:55:26 +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 v2K0tPj5025318; Mon, 20 Mar 2017 00:55:25 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2K0tPug025310; Mon, 20 Mar 2017 00:55:25 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201703200055.v2K0tPug025310@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Mon, 20 Mar 2017 00:55:25 +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: r315600 - in stable/10: usr.bin/mkimg usr.sbin/mpsutil usr.sbin/nscd usr.sbin/ypbind 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.23 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, 20 Mar 2017 00:55:26 -0000 Author: pfg Date: Mon Mar 20 00:55:24 2017 New Revision: 315600 URL: https://svnweb.freebsd.org/changeset/base/315600 Log: MFC r315212, r315213, r315214, r315215: mkimg(1): let calloc(3) do the multiplication. nscd(8): let calloc(3) do the multiplying. mpsutil(8): let calloc(3) do the multiplying. ypbind(8): let calloc(3) do the multiplying. MFC after: 1 week Modified: stable/10/usr.bin/mkimg/qcow.c stable/10/usr.sbin/mpsutil/mps_cmd.c stable/10/usr.sbin/nscd/cachelib.c stable/10/usr.sbin/nscd/config.c stable/10/usr.sbin/nscd/hashtable.h stable/10/usr.sbin/nscd/nscd.c stable/10/usr.sbin/ypbind/yp_ping.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.bin/mkimg/qcow.c ============================================================================== --- stable/10/usr.bin/mkimg/qcow.c Mon Mar 20 00:54:45 2017 (r315599) +++ stable/10/usr.bin/mkimg/qcow.c Mon Mar 20 00:55:24 2017 (r315600) @@ -217,7 +217,7 @@ qcow_write(int fd, u_int version) ofs = clstrsz * l2clno; nclstrs = 1 + clstr_l1tblsz + clstr_rctblsz; - l1tbl = calloc(1, clstrsz * clstr_l1tblsz); + l1tbl = calloc(clstr_l1tblsz, clstrsz); if (l1tbl == NULL) { error = ENOMEM; goto out; @@ -248,7 +248,7 @@ qcow_write(int fd, u_int version) } while (n < clstr_rcblks); if (rcclno > 0) { - rctbl = calloc(1, clstrsz * clstr_rctblsz); + rctbl = calloc(clstr_rctblsz, clstrsz); if (rctbl == NULL) { error = ENOMEM; goto out; @@ -298,7 +298,7 @@ qcow_write(int fd, u_int version) l1tbl = NULL; if (rcclno > 0) { - rcblk = calloc(1, clstrsz * clstr_rcblks); + rcblk = calloc(clstr_rcblks, clstrsz); if (rcblk == NULL) { error = ENOMEM; goto out; Modified: stable/10/usr.sbin/mpsutil/mps_cmd.c ============================================================================== --- stable/10/usr.sbin/mpsutil/mps_cmd.c Mon Mar 20 00:54:45 2017 (r315599) +++ stable/10/usr.sbin/mpsutil/mps_cmd.c Mon Mar 20 00:55:24 2017 (r315600) @@ -486,7 +486,7 @@ mps_firmware_get(int fd, unsigned char * } size = reply.ActualImageSize; - *firmware = calloc(1, sizeof(unsigned char) * size); + *firmware = calloc(size, sizeof(unsigned char)); if (*firmware == NULL) { warn("calloc"); return (-1); Modified: stable/10/usr.sbin/nscd/cachelib.c ============================================================================== --- stable/10/usr.sbin/nscd/cachelib.c Mon Mar 20 00:54:45 2017 (r315599) +++ stable/10/usr.sbin/nscd/cachelib.c Mon Mar 20 00:55:24 2017 (r315600) @@ -487,8 +487,8 @@ init_cache(struct cache_params const *pa assert(params != NULL); memcpy(&retval->params, params, sizeof(struct cache_params)); - retval->entries = calloc(1, - sizeof(*retval->entries) * INITIAL_ENTRIES_CAPACITY); + retval->entries = calloc(INITIAL_ENTRIES_CAPACITY, + sizeof(*retval->entries)); assert(retval->entries != NULL); retval->entries_capacity = INITIAL_ENTRIES_CAPACITY; @@ -540,8 +540,8 @@ register_cache_entry(struct cache_ *the_ new_capacity = the_cache->entries_capacity + ENTRIES_CAPACITY_STEP; - new_entries = calloc(1, - sizeof(*new_entries) * new_capacity); + new_entries = calloc(new_capacity, + sizeof(*new_entries)); assert(new_entries != NULL); memcpy(new_entries, the_cache->entries, @@ -582,8 +582,8 @@ register_cache_entry(struct cache_ *the_ else policies_size = 2; - new_common_entry->policies = calloc(1, - sizeof(*new_common_entry->policies) * policies_size); + new_common_entry->policies = calloc(policies_size, + sizeof(*new_common_entry->policies)); assert(new_common_entry->policies != NULL); new_common_entry->policies_size = policies_size; Modified: stable/10/usr.sbin/nscd/config.c ============================================================================== --- stable/10/usr.sbin/nscd/config.c Mon Mar 20 00:54:45 2017 (r315599) +++ stable/10/usr.sbin/nscd/config.c Mon Mar 20 00:55:24 2017 (r315600) @@ -274,9 +274,8 @@ add_configuration_entry(struct configura struct configuration_entry **new_entries; config->entries_capacity *= 2; - new_entries = calloc(1, - sizeof(*new_entries) * - config->entries_capacity); + new_entries = calloc(config->entries_capacity, + sizeof(*new_entries)); assert(new_entries != NULL); memcpy(new_entries, config->entries, sizeof(struct configuration_entry *) * @@ -522,9 +521,8 @@ init_configuration(void) assert(retval != NULL); retval->entries_capacity = INITIAL_ENTRIES_CAPACITY; - retval->entries = calloc(1, - sizeof(*retval->entries) * - retval->entries_capacity); + retval->entries = calloc(retval->entries_capacity, + sizeof(*retval->entries)); assert(retval->entries != NULL); pthread_rwlock_init(&retval->rwlock, NULL); Modified: stable/10/usr.sbin/nscd/hashtable.h ============================================================================== --- stable/10/usr.sbin/nscd/hashtable.h Mon Mar 20 00:54:45 2017 (r315599) +++ stable/10/usr.sbin/nscd/hashtable.h Mon Mar 20 00:55:24 2017 (r315600) @@ -75,8 +75,8 @@ typedef unsigned int hashtable_index_t; #define HASHTABLE_INIT(table, type, field, _entries_size) \ do { \ hashtable_index_t var; \ - (table)->entries = calloc(1, \ - sizeof(*(table)->entries) * (_entries_size)); \ + (table)->entries = calloc(_entries_size, \ + sizeof(*(table)->entries)); \ (table)->entries_size = (_entries_size); \ for (var = 0; var < HASHTABLE_ENTRIES_COUNT(table); ++var) {\ (table)->entries[var].field.capacity = \ Modified: stable/10/usr.sbin/nscd/nscd.c ============================================================================== --- stable/10/usr.sbin/nscd/nscd.c Mon Mar 20 00:54:45 2017 (r315599) +++ stable/10/usr.sbin/nscd/nscd.c Mon Mar 20 00:55:24 2017 (r315600) @@ -828,8 +828,8 @@ main(int argc, char *argv[]) } if (s_configuration->threads_num > 1) { - threads = calloc(1, sizeof(*threads) * - s_configuration->threads_num); + threads = calloc(s_configuration->threads_num, + sizeof(*threads)); for (i = 0; i < s_configuration->threads_num; ++i) { thread_args = malloc( sizeof(*thread_args)); Modified: stable/10/usr.sbin/ypbind/yp_ping.c ============================================================================== --- stable/10/usr.sbin/ypbind/yp_ping.c Mon Mar 20 00:54:45 2017 (r315599) +++ stable/10/usr.sbin/ypbind/yp_ping.c Mon Mar 20 00:55:24 2017 (r315600) @@ -226,7 +226,7 @@ __yp_ping(struct in_addr *restricted_add int validsrvs = 0; /* Set up handles. */ - reqs = calloc(1, sizeof(struct ping_req *) * cnt); + reqs = calloc(cnt, sizeof(struct ping_req *)); xid_seed = time(NULL) ^ getpid(); for (i = 0; i < cnt; i++) { From owner-svn-src-stable-10@freebsd.org Mon Mar 20 03:00:23 2017 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 C90FAD14569; Mon, 20 Mar 2017 03:00:23 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A3B791CAB; Mon, 20 Mar 2017 03:00:23 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2K30MDp074492; Mon, 20 Mar 2017 03:00:22 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2K30MOX074491; Mon, 20 Mar 2017 03:00:22 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201703200300.v2K30MOX074491@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Mon, 20 Mar 2017 03:00:22 +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: r315606 - stable/10/lib/libcam 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.23 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, 20 Mar 2017 03:00:23 -0000 Author: ngie Date: Mon Mar 20 03:00:22 2017 New Revision: 315606 URL: https://svnweb.freebsd.org/changeset/base/315606 Log: MFC r315132,r315133,r315186: r315132: Use .Dv when referencing NULL This is the correct markup macro, as opposed to .Va (variable names) While here, annotate several bare references to `NULL` with .Dv. r315133: lib/libcam/cam.3: fix manpage warnings - spelling: "mis-named" should be "misnamed". - delete spaces interspersed in literal representation of `struct cam_device` as hard-tabs separate the types and fields. - Add commas after `e.g.`. r315186: lib/libcam/cam.3: note that cam_freeccb(3) with ccb == NULL is a no-op This allows me to accurately test this scenario, and for others to rely on the behavior, instead of relying on knowledge obtained via code inspection. Wording borrowed from free(3). Requested by: ken (D9928) Modified: stable/10/lib/libcam/cam.3 Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libcam/cam.3 ============================================================================== --- stable/10/lib/libcam/cam.3 Mon Mar 20 03:00:19 2017 (r315605) +++ stable/10/lib/libcam/cam.3 Mon Mar 20 03:00:22 2017 (r315606) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 10, 1998 +.Dd March 11, 2017 .Dt CAM 3 .Os .Sh NAME @@ -132,7 +132,7 @@ Many of the CAM library functions use th structure: .Bd -literal struct cam_device { - char device_path[MAXPATHLEN+1];/* + char device_path[MAXPATHLEN+1];/* * Pathname of the * device given by the * user. This may be @@ -151,7 +151,7 @@ struct cam_device { */ char device_name[DEV_IDLEN+1];/* * Name of the device, - * e.g. 'pass' + * e.g., 'pass' */ uint32_t dev_unit_num; /* Unit number of the passthrough * device associated with this @@ -159,7 +159,7 @@ struct cam_device { */ char sim_name[SIM_IDLEN+1];/* - * Controller name, e.g.'ahc' + * Controller name, e.g., 'ahc' */ uint32_t sim_unit_number; /* Controller unit number */ uint32_t bus_id; /* Controller bus number */ @@ -208,7 +208,7 @@ structure. If the .Ar device argument is -.Va NULL , +.Dv NULL , .Fn cam_open_spec_device will allocate space for the .Va cam_device @@ -258,7 +258,9 @@ argument, as with .Fn cam_open_spec_device and .Fn cam_open_btl , -should be NULL if the user wants the CAM library to allocate space for the +should be +.Dv NULL +if the user wants the CAM library to allocate space for the .Va cam_device structure. .Fn cam_close_device @@ -300,6 +302,11 @@ structure. .Fn cam_freeccb frees CCBs allocated by .Fn cam_getccb . +If +.Va ccb +is +.Dv NULL , +no action is taken. .Pp .Fn cam_path_string takes as arguments a @@ -365,11 +372,14 @@ and .Fn cam_open_pass return a pointer to a .Va cam_device -structure, or NULL if there was an error. +structure, or +.Dv NULL +if there was an error. .Pp .Fn cam_getccb -returns an allocated and partially initialized CCB, or NULL if allocation -of the CCB failed. +returns an allocated and partially initialized CCB, or +.Dv NULL +if allocation of the CCB failed. .Pp .Fn cam_send_ccb returns a value of -1 if an error occurred, and @@ -386,7 +396,9 @@ that is passed into .Fn cam_device_dup returns a copy of the .Va device -passed in, or NULL if an error occurred. +passed in, or +.Dv NULL +if an error occurred. .Pp .Fn cam_get_device returns 0 for success, and -1 to indicate failure. @@ -422,4 +434,4 @@ require a definitive way to identify a d .Xr pass 4 device. .Pp -Some of the functions are possibly mis-named or poorly named. +Some of the functions are possibly misnamed or poorly named. From owner-svn-src-stable-10@freebsd.org Mon Mar 20 03:01:24 2017 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 A2820D14722; Mon, 20 Mar 2017 03:01:24 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 625EBFF; Mon, 20 Mar 2017 03:01:24 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2K31N8V076122; Mon, 20 Mar 2017 03:01:23 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2K31Njo076121; Mon, 20 Mar 2017 03:01:23 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201703200301.v2K31Njo076121@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Mon, 20 Mar 2017 03:01:23 +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: r315608 - stable/10/lib/libcam 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.23 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, 20 Mar 2017 03:01:24 -0000 Author: ngie Date: Mon Mar 20 03:01:23 2017 New Revision: 315608 URL: https://svnweb.freebsd.org/changeset/base/315608 Log: MFC r315202: lib/libcam/cam_cdbparse.3: fix manpage warnings - Add comma before and after 'e.g.'; remove surrounding parentheses that were unnecessary after this change [1]. - Add .Mt when referencing ken and Peter Dufault's email addresses [2]. - Sprinkle around .An use where proper [2]. Bump .Dd for the change Modified: stable/10/lib/libcam/cam_cdbparse.3 Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libcam/cam_cdbparse.3 ============================================================================== --- stable/10/lib/libcam/cam_cdbparse.3 Mon Mar 20 03:01:21 2017 (r315607) +++ stable/10/lib/libcam/cam_cdbparse.3 Mon Mar 20 03:01:23 2017 (r315608) @@ -61,7 +61,7 @@ .\" SUCH DAMAGE. .\" .\" -.Dd October 13, 1998 +.Dd March 13, 2017 .Dt CAM_CDBPARSE 3 .Os .Sh NAME @@ -170,12 +170,11 @@ layer. These functions may be used in new applications, but users may find it easier to use the various SCSI CCB building functions included with the .Xr cam 3 -library. -(e.g.\& +library, e.g., \& .Fn cam_fill_csio , .Fn scsi_start_stop , and -.Fn scsi_read_write ) +.Fn scsi_read_write . .Pp .Fn csio_build builds up a @@ -522,17 +521,18 @@ implemented for the old layer. The encoding/decoding functions in the old .Tn SCSI -code were written by Peter Dufault. +code were written by +.An Peter Dufault Aq Mt dufault@hda.com . .Pp Many systems have comparable interfaces to permit a user to construct a SCSI command in user space. .Pp The old .Va scsireq -data structure was almost identical to the SGI /dev/scsi data -structure. -If anyone knows the name of the authors it should -go here; Peter Dufault first read about it in a 1989 Sun Expert magazine. +data structure was almost identical to the SGI /dev/scsi data structure. +If anyone knows the name of the authors it should go here; +Peter Dufault +first read about it in a 1989 Sun Expert magazine. .Pp The new CCB data structures are derived from the CAM-2 and CAM-3 specifications. @@ -545,11 +545,14 @@ led to the original .Fx .Tn SCSI library and the related kernel ioctl. -If anyone needs that for compatibility contact dufault@hda.com. +If anyone needs that for compatibility, contact +.Mt dufault@hda.com . .Sh AUTHORS -Kenneth Merry implemented the CAM versions of these encoding and decoding -functions. -This current work is based upon earlier work by Peter Dufault. +.An -nosplit +.An Kenneth Merry Aq Mt ken@FreeBSD.org +implemented the CAM versions of these encoding and decoding functions. +This current work is based upon earlier work by +.An Peter Dufault Aq Mt dufault@hda.com . .Sh BUGS There should probably be a function that encodes both the CDB and the data buffer portions of a From owner-svn-src-stable-10@freebsd.org Mon Mar 20 03:06:42 2017 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 912DCD1493E; Mon, 20 Mar 2017 03:06:42 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 509F9AEC; Mon, 20 Mar 2017 03:06:42 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2K36f2J079406; Mon, 20 Mar 2017 03:06:41 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2K36fcn079404; Mon, 20 Mar 2017 03:06:41 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201703200306.v2K36fcn079404@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Mon, 20 Mar 2017 03:06: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: r315610 - in stable/10/sbin/dhclient: . tests 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.23 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, 20 Mar 2017 03:06:42 -0000 Author: ngie Date: Mon Mar 20 03:06:41 2017 New Revision: 315610 URL: https://svnweb.freebsd.org/changeset/base/315610 Log: MFC r315199,r315200,r315203: r315199: sbin/dhclient: fix a memory leak in parse_client_lease_statement(..) The memory stored by `lease` would have previously been leaked if an unterminated lease declaration was found in an early-return code path. CID: 1007114 r315200: Fix -Wunused-but-set-warning with `ret` While here, resolve Coverity warnings by demonstrating that vfprintf's return value is being explicitly ignored. Tested with: clang, gcc 4.2.1, gcc 6.3.0 r315203: sbin/dhclient: fix `vendor` storage leak in parse_option_decl(..) This ensures the storage isn't leaked when non-NULL and the function returns early, prior to the `free(vendor)` later on in the function. CID: 1007111-1007113 Modified: stable/10/sbin/dhclient/clparse.c stable/10/sbin/dhclient/tests/fake.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/dhclient/clparse.c ============================================================================== --- stable/10/sbin/dhclient/clparse.c Mon Mar 20 03:06:37 2017 (r315609) +++ stable/10/sbin/dhclient/clparse.c Mon Mar 20 03:06:41 2017 (r315610) @@ -510,6 +510,7 @@ parse_client_lease_statement(FILE *cfile token = peek_token(&val, cfile); if (token == EOF) { parse_warn("unterminated lease declaration."); + free_client_lease(lease); return; } if (token == RBRACE) @@ -711,6 +712,7 @@ parse_option_decl(FILE *cfile, struct op parse_warn("expecting identifier after '.'"); if (token != SEMI) skip_to_semi(cfile); + free(vendor); return (NULL); } @@ -723,6 +725,7 @@ parse_option_decl(FILE *cfile, struct op if (!universe) { parse_warn("no vendor named %s.", vendor); skip_to_semi(cfile); + free(vendor); return (NULL); } } else { @@ -744,6 +747,7 @@ parse_option_decl(FILE *cfile, struct op parse_warn("no option named %s for vendor %s", val, vendor); skip_to_semi(cfile); + free(vendor); return (NULL); } Modified: stable/10/sbin/dhclient/tests/fake.c ============================================================================== --- stable/10/sbin/dhclient/tests/fake.c Mon Mar 20 03:06:37 2017 (r315609) +++ stable/10/sbin/dhclient/tests/fake.c Mon Mar 20 03:06:41 2017 (r315610) @@ -14,7 +14,7 @@ error(char *fmt, ...) va_list ap; va_start(ap, fmt); - vfprintf(stderr, fmt, ap); + (void)vfprintf(stderr, fmt, ap); va_end(ap); fprintf(stderr, "\n"); @@ -24,11 +24,10 @@ error(char *fmt, ...) int warning(char *fmt, ...) { - int ret; va_list ap; va_start(ap, fmt); - ret = vfprintf(stderr, fmt, ap); + (void)vfprintf(stderr, fmt, ap); va_end(ap); fprintf(stderr, "\n"); From owner-svn-src-stable-10@freebsd.org Mon Mar 20 03:13:04 2017 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 5DE0DD14B57; Mon, 20 Mar 2017 03:13:04 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2A99E108B; Mon, 20 Mar 2017 03:13:04 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2K3D3Xk083499; Mon, 20 Mar 2017 03:13:03 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2K3D32g083498; Mon, 20 Mar 2017 03:13:03 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201703200313.v2K3D32g083498@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Mon, 20 Mar 2017 03:13:03 +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: r315612 - stable/10/contrib/bsnmp/snmpd 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.23 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, 20 Mar 2017 03:13:04 -0000 Author: ngie Date: Mon Mar 20 03:13:03 2017 New Revision: 315612 URL: https://svnweb.freebsd.org/changeset/base/315612 Log: MFC r315206: bsnmpd: fix segfault when trans_insert_port(..) is called with multiple out of order addresses Move `port->transport` initialization before the TAILQ_FOREACH(..) loop to ensure that the value is properly initialized before it's inserted into the TAILQ. PR: 217760 Modified: stable/10/contrib/bsnmp/snmpd/main.c Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/bsnmp/snmpd/main.c ============================================================================== --- stable/10/contrib/bsnmp/snmpd/main.c Mon Mar 20 03:13:00 2017 (r315611) +++ stable/10/contrib/bsnmp/snmpd/main.c Mon Mar 20 03:13:03 2017 (r315612) @@ -765,13 +765,13 @@ trans_insert_port(struct transport *t, s { struct tport *p; + port->transport = t; TAILQ_FOREACH(p, &t->table, link) { if (asn_compare_oid(&p->index, &port->index) > 0) { TAILQ_INSERT_BEFORE(p, port, link); return; } } - port->transport = t; TAILQ_INSERT_TAIL(&t->table, port, link); } From owner-svn-src-stable-10@freebsd.org Mon Mar 20 08:16:06 2017 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 AB145D14A4E; Mon, 20 Mar 2017 08:16:06 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7A7931EDC; Mon, 20 Mar 2017 08:16:06 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2K8G5Y0004808; Mon, 20 Mar 2017 08:16:05 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2K8G51C004807; Mon, 20 Mar 2017 08:16:05 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201703200816.v2K8G51C004807@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Mon, 20 Mar 2017 08:16:05 +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: r315625 - stable/10/sys/net 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.23 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, 20 Mar 2017 08:16:06 -0000 Author: ae Date: Mon Mar 20 08:16:05 2017 New Revision: 315625 URL: https://svnweb.freebsd.org/changeset/base/315625 Log: MFC r315192: Ignore ifnet renaming in the bpf ifnet departure handler. PR: 213015 Modified: stable/10/sys/net/bpf.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/net/bpf.c ============================================================================== --- stable/10/sys/net/bpf.c Mon Mar 20 08:10:58 2017 (r315624) +++ stable/10/sys/net/bpf.c Mon Mar 20 08:16:05 2017 (r315625) @@ -2581,6 +2581,10 @@ bpf_ifdetach(void *arg __unused, struct struct bpf_if *bp, *bp_temp; int nmatched = 0; + /* Ignore ifnet renaming. */ + if (ifp->if_flags & IFF_RENAMING) + return; + BPF_LOCK(); /* * Find matching entries in free list. From owner-svn-src-stable-10@freebsd.org Tue Mar 21 01:24:58 2017 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 02ACCD14CCC; Tue, 21 Mar 2017 01:24:58 +0000 (UTC) (envelope-from vangyzen@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 B779C8EB; Tue, 21 Mar 2017 01:24:57 +0000 (UTC) (envelope-from vangyzen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2L1OujZ028425; Tue, 21 Mar 2017 01:24:56 GMT (envelope-from vangyzen@FreeBSD.org) Received: (from vangyzen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2L1OuYv028422; Tue, 21 Mar 2017 01:24:56 GMT (envelope-from vangyzen@FreeBSD.org) Message-Id: <201703210124.v2L1OuYv028422@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: vangyzen set sender to vangyzen@FreeBSD.org using -f From: Eric van Gyzen Date: Tue, 21 Mar 2017 01:24: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: r315658 - in stable/10/sys: compat/freebsd32 compat/linux 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.23 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: Tue, 21 Mar 2017 01:24:58 -0000 Author: vangyzen Date: Tue Mar 21 01:24:56 2017 New Revision: 315658 URL: https://svnweb.freebsd.org/changeset/base/315658 Log: MFC r315510 nanosleep: plug a kernel memory disclosure nanosleep() updates rmtp on EINVAL. In that case, kern_nanosleep() has not updated rmt, so sys_nanosleep() updates the user-space rmtp by copying garbage from its stack frame. This is not only a kernel memory disclosure, it's also not POSIX-compliant. Fix it to update rmtp only on EINTR. Security: possibly Sponsored by: Dell EMC Modified: stable/10/sys/compat/freebsd32/freebsd32_misc.c stable/10/sys/compat/linux/linux_time.c stable/10/sys/kern/kern_time.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/compat/freebsd32/freebsd32_misc.c ============================================================================== --- stable/10/sys/compat/freebsd32/freebsd32_misc.c Tue Mar 21 01:23:34 2017 (r315657) +++ stable/10/sys/compat/freebsd32/freebsd32_misc.c Tue Mar 21 01:24:56 2017 (r315658) @@ -2367,7 +2367,7 @@ freebsd32_nanosleep(struct thread *td, s !useracc((caddr_t)uap->rmtp, sizeof(rmt), VM_PROT_WRITE)) return (EFAULT); error = kern_nanosleep(td, &rqt, &rmt); - if (error && uap->rmtp) { + if (error == EINTR && uap->rmtp) { int error2; CP(rmt, rmt32, tv_sec); Modified: stable/10/sys/compat/linux/linux_time.c ============================================================================== --- stable/10/sys/compat/linux/linux_time.c Tue Mar 21 01:23:34 2017 (r315657) +++ stable/10/sys/compat/linux/linux_time.c Tue Mar 21 01:24:56 2017 (r315658) @@ -490,7 +490,7 @@ linux_nanosleep(struct thread *td, struc return (error); } error = kern_nanosleep(td, &rqts, rmtp); - if (args->rmtp != NULL) { + if (error == EINTR && args->rmtp != NULL) { native_to_linux_timespec(&lrmts, rmtp); error2 = copyout(&lrmts, args->rmtp, sizeof(lrmts)); if (error2 != 0) { @@ -552,7 +552,7 @@ linux_clock_nanosleep(struct thread *td, return (error); } error = kern_nanosleep(td, &rqts, rmtp); - if (args->rmtp != NULL) { + if (error == EINTR && args->rmtp != NULL) { /* XXX. Not for TIMER_ABSTIME */ native_to_linux_timespec(&lrmts, rmtp); error2 = copyout(&lrmts, args->rmtp, sizeof(lrmts)); Modified: stable/10/sys/kern/kern_time.c ============================================================================== --- stable/10/sys/kern/kern_time.c Tue Mar 21 01:23:34 2017 (r315657) +++ stable/10/sys/kern/kern_time.c Tue Mar 21 01:24:56 2017 (r315658) @@ -546,7 +546,7 @@ sys_nanosleep(struct thread *td, struct !useracc((caddr_t)uap->rmtp, sizeof(rmt), VM_PROT_WRITE)) return (EFAULT); error = kern_nanosleep(td, &rqt, &rmt); - if (error && uap->rmtp) { + if (error == EINTR && uap->rmtp) { int error2; error2 = copyout(&rmt, uap->rmtp, sizeof(rmt)); From owner-svn-src-stable-10@freebsd.org Tue Mar 21 05:15:11 2017 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 87056D15D2F; Tue, 21 Mar 2017 05:15:11 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 536C328D; Tue, 21 Mar 2017 05:15:11 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2L5FAbk023144; Tue, 21 Mar 2017 05:15:10 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2L5FA0Y023143; Tue, 21 Mar 2017 05:15:10 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201703210515.v2L5FA0Y023143@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Tue, 21 Mar 2017 05:15:10 +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: r315661 - stable/10/tools/build/mk 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.23 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: Tue, 21 Mar 2017 05:15:11 -0000 Author: ngie Date: Tue Mar 21 05:15:10 2017 New Revision: 315661 URL: https://svnweb.freebsd.org/changeset/base/315661 Log: MFC r314241,r315228: r314241: Fill in MK_RESCUE by finding paths in ${DESTDIR}/rescue and adding them to OLD_FILES/OLD_DIRS, as necessary. r315228: Redirect standard error from find /rescue to /dev/null This mutes noise from find when /rescue doesn't exist. Modified: stable/10/tools/build/mk/OptionalObsoleteFiles.inc Directory Properties: stable/10/ (props changed) Modified: stable/10/tools/build/mk/OptionalObsoleteFiles.inc ============================================================================== --- stable/10/tools/build/mk/OptionalObsoleteFiles.inc Tue Mar 21 05:13:14 2017 (r315660) +++ stable/10/tools/build/mk/OptionalObsoleteFiles.inc Tue Mar 21 05:15:10 2017 (r315661) @@ -4438,9 +4438,14 @@ OLD_FILES+=usr/tests/usr.sbin/etcupdate/ OLD_DIRS+=usr/tests/usr.sbin/etcupdate .endif -#.if ${MK_RESCUE} == no -# to be filled in or replaced with a special target -#.endif +.if ${MK_RESCUE} == no +. if exists(${DESTDIR}${TESTSBASE}) +RESCUE_DIRS!=find ${DESTDIR}/rescue -type d 2>/dev/null | sed -e 's,^${DESTDIR}/,,'; echo +OLD_DIRS+=${RESCUE_DIRS} +RESCUE_FILES!=find ${DESTDIR}/rescue \! -type d 2>/dev/null | sed -e 's,^${DESTDIR}/,,'; echo +OLD_FILES+=${RESCUE_FILES} +. endif +.endif .if ${MK_ROUTED} == no OLD_FILES+=rescue/routed From owner-svn-src-stable-10@freebsd.org Tue Mar 21 09:27:26 2017 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 8FEECD14E08; Tue, 21 Mar 2017 09:27:26 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 43A7FD8D; Tue, 21 Mar 2017 09:27:26 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2L9RPfC027535; Tue, 21 Mar 2017 09:27:25 GMT (envelope-from royger@FreeBSD.org) Received: (from royger@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2L9RP8i027532; Tue, 21 Mar 2017 09:27:25 GMT (envelope-from royger@FreeBSD.org) Message-Id: <201703210927.v2L9RP8i027532@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: royger set sender to royger@FreeBSD.org using -f From: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Date: Tue, 21 Mar 2017 09:27:25 +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: r315675 - in stable/10/sys: dev/xen/control xen/xenstore 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.23 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: Tue, 21 Mar 2017 09:27:26 -0000 Author: royger Date: Tue Mar 21 09:27:24 2017 New Revision: 315675 URL: https://svnweb.freebsd.org/changeset/base/315675 Log: MFC r314841: xenstore: fix suspension when using the xenstore device Submitted by: Liuyingdong Reviewed by: royger Modified: stable/10/sys/dev/xen/control/control.c stable/10/sys/xen/xenstore/xenstore.c stable/10/sys/xen/xenstore/xenstorevar.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/xen/control/control.c ============================================================================== --- stable/10/sys/dev/xen/control/control.c Tue Mar 21 09:24:07 2017 (r315674) +++ stable/10/sys/dev/xen/control/control.c Tue Mar 21 09:27:24 2017 (r315675) @@ -343,6 +343,10 @@ xctrl_suspend() #endif int suspend_cancelled; + EVENTHANDLER_INVOKE(power_suspend_early); + xs_lock(); + stop_all_proc(); + xs_unlock(); EVENTHANDLER_INVOKE(power_suspend); if (smp_started) { @@ -429,6 +433,8 @@ xctrl_suspend() thread_unlock(curthread); } + resume_all_proc(); + EVENTHANDLER_INVOKE(power_resume); if (bootverbose) Modified: stable/10/sys/xen/xenstore/xenstore.c ============================================================================== --- stable/10/sys/xen/xenstore/xenstore.c Tue Mar 21 09:24:07 2017 (r315674) +++ stable/10/sys/xen/xenstore/xenstore.c Tue Mar 21 09:27:24 2017 (r315675) @@ -1657,3 +1657,20 @@ xs_unregister_watch(struct xs_watch *wat sx_xunlock(&xs.xenwatch_mutex); } } + +void +xs_lock(void) +{ + + sx_xlock(&xs.request_mutex); + return; +} + +void +xs_unlock(void) +{ + + sx_xunlock(&xs.request_mutex); + return; +} + Modified: stable/10/sys/xen/xenstore/xenstorevar.h ============================================================================== --- stable/10/sys/xen/xenstore/xenstorevar.h Tue Mar 21 09:24:07 2017 (r315674) +++ stable/10/sys/xen/xenstore/xenstorevar.h Tue Mar 21 09:27:24 2017 (r315675) @@ -338,4 +338,15 @@ void xs_unregister_watch(struct xs_watch */ struct sbuf *xs_join(const char *, const char *); +/** + * Lock the xenstore request mutex. + */ +void xs_lock(void); + +/** + * Unlock the xenstore request mutex. + */ +void xs_unlock(void); + #endif /* _XEN_XENSTORE_XENSTOREVAR_H */ + From owner-svn-src-stable-10@freebsd.org Tue Mar 21 09:39:01 2017 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 82E4DD151E1; Tue, 21 Mar 2017 09:39:01 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 56E671338; Tue, 21 Mar 2017 09:39:01 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2L9d0vn031645; Tue, 21 Mar 2017 09:39:00 GMT (envelope-from royger@FreeBSD.org) Received: (from royger@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2L9cxcI031636; Tue, 21 Mar 2017 09:38:59 GMT (envelope-from royger@FreeBSD.org) Message-Id: <201703210938.v2L9cxcI031636@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: royger set sender to royger@FreeBSD.org using -f From: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Date: Tue, 21 Mar 2017 09:38: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: r315676 - in stable/10/sys: dev/xen/blkfront dev/xen/control dev/xen/netfront xen xen/xenbus 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.23 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: Tue, 21 Mar 2017 09:39:01 -0000 Author: royger Date: Tue Mar 21 09:38:59 2017 New Revision: 315676 URL: https://svnweb.freebsd.org/changeset/base/315676 Log: MFC r314840: xen: add support for canceled suspend Submitted by: Liuyingdong Reviewed by: royger Modified: stable/10/sys/dev/xen/blkfront/blkfront.c stable/10/sys/dev/xen/control/control.c stable/10/sys/dev/xen/netfront/netfront.c stable/10/sys/xen/xen-os.h stable/10/sys/xen/xenbus/xenbusb.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/xen/blkfront/blkfront.c ============================================================================== --- stable/10/sys/dev/xen/blkfront/blkfront.c Tue Mar 21 09:27:24 2017 (r315675) +++ stable/10/sys/dev/xen/blkfront/blkfront.c Tue Mar 21 09:38:59 2017 (r315676) @@ -1533,6 +1533,11 @@ xbd_resume(device_t dev) { struct xbd_softc *sc = device_get_softc(dev); + if (xen_suspend_cancelled) { + sc->xbd_state = XBD_STATE_CONNECTED; + return (0); + } + DPRINTK("xbd_resume: %s\n", xenbus_get_node(dev)); xbd_free(sc); Modified: stable/10/sys/dev/xen/control/control.c ============================================================================== --- stable/10/sys/dev/xen/control/control.c Tue Mar 21 09:27:24 2017 (r315675) +++ stable/10/sys/dev/xen/control/control.c Tue Mar 21 09:38:59 2017 (r315676) @@ -151,6 +151,7 @@ __FBSDID("$FreeBSD$"); #include #include +bool xen_suspend_cancelled; /*--------------------------- Forward Declarations --------------------------*/ /** Function signature for shutdown event handlers. */ typedef void (xctrl_shutdown_handler_t)(void); @@ -341,7 +342,6 @@ xctrl_suspend() #ifdef SMP cpuset_t cpu_suspend_map; #endif - int suspend_cancelled; EVENTHANDLER_INVOKE(power_suspend_early); xs_lock(); @@ -396,16 +396,20 @@ xctrl_suspend() intr_suspend(); xen_hvm_suspend(); - suspend_cancelled = HYPERVISOR_suspend(0); + xen_suspend_cancelled = !!HYPERVISOR_suspend(0); - xen_hvm_resume(suspend_cancelled != 0); - intr_resume(suspend_cancelled != 0); + if (!xen_suspend_cancelled) { + xen_hvm_resume(false); + } + intr_resume(xen_suspend_cancelled != 0); enable_intr(); /* * Reset grant table info. */ - gnttab_resume(); + if (!xen_suspend_cancelled) { + gnttab_resume(); + } #ifdef SMP /* Send an IPI_BITMAP in case there are pending bitmap IPIs. */ Modified: stable/10/sys/dev/xen/netfront/netfront.c ============================================================================== --- stable/10/sys/dev/xen/netfront/netfront.c Tue Mar 21 09:27:24 2017 (r315675) +++ stable/10/sys/dev/xen/netfront/netfront.c Tue Mar 21 09:38:59 2017 (r315676) @@ -509,6 +509,15 @@ netfront_resume(device_t dev) { struct netfront_info *info = device_get_softc(dev); + if (xen_suspend_cancelled) { + XN_RX_LOCK(info); + XN_TX_LOCK(info); + netfront_carrier_on(info); + XN_TX_UNLOCK(info); + XN_RX_UNLOCK(info); + return (0); + } + info->xn_resume = true; netif_disconnect_backend(info); return (0); Modified: stable/10/sys/xen/xen-os.h ============================================================================== --- stable/10/sys/xen/xen-os.h Tue Mar 21 09:27:24 2017 (r315675) +++ stable/10/sys/xen/xen-os.h Tue Mar 21 09:38:59 2017 (r315676) @@ -57,6 +57,8 @@ extern int xen_disable_pv_disks; extern int xen_disable_pv_nics; #endif +extern bool xen_suspend_cancelled; + enum xen_domain_type { XEN_NATIVE, /* running on bare hardware */ XEN_PV_DOMAIN, /* running in a PV domain */ Modified: stable/10/sys/xen/xenbus/xenbusb.c ============================================================================== --- stable/10/sys/xen/xenbus/xenbusb.c Tue Mar 21 09:27:24 2017 (r315675) +++ stable/10/sys/xen/xenbus/xenbusb.c Tue Mar 21 09:38:59 2017 (r315676) @@ -791,6 +791,11 @@ xenbusb_resume(device_t dev) if (device_get_state(kids[i]) == DS_NOTPRESENT) continue; + if (xen_suspend_cancelled) { + DEVICE_RESUME(kids[i]); + continue; + } + ivars = device_get_ivars(kids[i]); xs_unregister_watch(&ivars->xd_otherend_watch); From owner-svn-src-stable-10@freebsd.org Wed Mar 22 01:11:15 2017 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 665AED16BAF; Wed, 22 Mar 2017 01:11:15 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1D08C18B9; Wed, 22 Mar 2017 01:11:15 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2M1BEXQ020911; Wed, 22 Mar 2017 01:11:14 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2M1BEsj020908; Wed, 22 Mar 2017 01:11:14 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201703220111.v2M1BEsj020908@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Wed, 22 Mar 2017 01:11:13 +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: r315696 - in stable/10: etc/mtree lib/libcam lib/libcam/tests 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.23 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, 22 Mar 2017 01:11:15 -0000 Author: ngie Date: Wed Mar 22 01:11:13 2017 New Revision: 315696 URL: https://svnweb.freebsd.org/changeset/base/315696 Log: MFC r315320: Start adding basic tests for cam(3) This change contains several negative and positive tests for: - cam_open_device - cam_close_device - cam_getccb - cam_freeccb This also contains a test for the failure case noted in bug 217649, i.e., O_RDWR must be specified because pass(4) requires it. This test unfortunately cannot assume that cam-capable devices are present, so the user must explicitly provide a device via `test_suites.FreeBSD.cam_test_device`. In the future, a test kernel module might be shipped, or ctl(4) might be used, as a test device when testing out libcam, which will allow the tests to do away with having to specify an explicit test device. Added: stable/10/lib/libcam/tests/ - copied from r315320, head/lib/libcam/tests/ Modified: stable/10/etc/mtree/BSD.tests.dist stable/10/lib/libcam/Makefile stable/10/lib/libcam/tests/Makefile Directory Properties: stable/10/ (props changed) Modified: stable/10/etc/mtree/BSD.tests.dist ============================================================================== --- stable/10/etc/mtree/BSD.tests.dist Wed Mar 22 01:04:20 2017 (r315695) +++ stable/10/etc/mtree/BSD.tests.dist Wed Mar 22 01:11:13 2017 (r315696) @@ -306,6 +306,8 @@ ttyio .. .. + libcam + .. libcrypt .. libmp Modified: stable/10/lib/libcam/Makefile ============================================================================== --- stable/10/lib/libcam/Makefile Wed Mar 22 01:04:20 2017 (r315695) +++ stable/10/lib/libcam/Makefile Wed Mar 22 01:11:13 2017 (r315696) @@ -43,4 +43,10 @@ CFLAGS+= -I${.CURDIR} -I${SRCTOP}/sys SHLIB_MAJOR= 6 +.include + +.if ${MK_TESTS} != "no" +SUBDIR+= tests +.endif + .include Modified: stable/10/lib/libcam/tests/Makefile ============================================================================== --- head/lib/libcam/tests/Makefile Wed Mar 15 18:00:54 2017 (r315320) +++ stable/10/lib/libcam/tests/Makefile Wed Mar 22 01:11:13 2017 (r315696) @@ -2,7 +2,9 @@ ATF_TESTS_C+= libcam_test -LIBADD+= cam +LDADD+= -lcam + +DPADD+= ${LIBCAM} WARNS?= 6 From owner-svn-src-stable-10@freebsd.org Wed Mar 22 07:54:31 2017 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 0D1C8D172CF; Wed, 22 Mar 2017 07:54:31 +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 CE0F31CDA; Wed, 22 Mar 2017 07:54:30 +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 v2M7sT1w086588; Wed, 22 Mar 2017 07:54:29 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2M7sTmP086587; Wed, 22 Mar 2017 07:54:29 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703220754.v2M7sTmP086587@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 22 Mar 2017 07:54:29 +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: r315705 - stable/10/sys/geom 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.23 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, 22 Mar 2017 07:54:31 -0000 Author: mav Date: Wed Mar 22 07:54:29 2017 New Revision: 315705 URL: https://svnweb.freebsd.org/changeset/base/315705 Log: MFC r314908: When chunking large DIOCGDELETE, do it on stripe edge. Modified: stable/10/sys/geom/geom_dev.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/geom/geom_dev.c ============================================================================== --- stable/10/sys/geom/geom_dev.c Wed Mar 22 07:53:57 2017 (r315704) +++ stable/10/sys/geom/geom_dev.c Wed Mar 22 07:54:29 2017 (r315705) @@ -480,7 +480,7 @@ g_dev_ioctl(struct cdev *dev, u_long cmd { struct g_consumer *cp; struct g_provider *pp; - off_t offset, length, chunk; + off_t offset, length, chunk, odd; int i, error; cp = dev->si_drv2; @@ -540,6 +540,13 @@ g_dev_ioctl(struct cdev *dev, u_long cmd g_dev_del_max_sectors * cp->provider->sectorsize) { chunk = g_dev_del_max_sectors * cp->provider->sectorsize; + if (cp->provider->stripesize > 0) { + odd = (offset + chunk + + cp->provider->stripeoffset) % + cp->provider->stripesize; + if (chunk > odd) + chunk -= odd; + } } error = g_delete_data(cp, offset, chunk); length -= chunk; From owner-svn-src-stable-10@freebsd.org Wed Mar 22 17:49:57 2017 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 6CED0D18D8F; Wed, 22 Mar 2017 17:49:57 +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 2E1E51758; Wed, 22 Mar 2017 17:49:57 +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 v2MHnuw8028128; Wed, 22 Mar 2017 17:49:56 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2MHnuoM028127; Wed, 22 Mar 2017 17:49:56 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201703221749.v2MHnuoM028127@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Wed, 22 Mar 2017 17:49: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: r315722 - stable/10/bin/kill 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.23 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, 22 Mar 2017 17:49:57 -0000 Author: bdrewery Date: Wed Mar 22 17:49:56 2017 New Revision: 315722 URL: https://svnweb.freebsd.org/changeset/base/315722 Log: MFC r314714: Don't kill pid -1 on overflow from strtol(3). Modified: stable/10/bin/kill/kill.c Directory Properties: stable/10/ (props changed) Modified: stable/10/bin/kill/kill.c ============================================================================== --- stable/10/bin/kill/kill.c Wed Mar 22 17:46:08 2017 (r315721) +++ stable/10/bin/kill/kill.c Wed Mar 22 17:49:56 2017 (r315722) @@ -67,7 +67,9 @@ static void usage(void); int main(int argc, char *argv[]) { - int errors, numsig, pid; + long pidl; + pid_t pid; + int errors, numsig; char *ep; if (argc < 2) @@ -138,8 +140,10 @@ main(int argc, char *argv[]) else #endif { - pid = strtol(*argv, &ep, 10); - if (!**argv || *ep) + pidl = strtol(*argv, &ep, 10); + /* Check for overflow of pid_t. */ + pid = (pid_t)pidl; + if (!**argv || *ep || pid != pidl) errx(2, "illegal process id: %s", *argv); } if (kill(pid, numsig) == -1) { From owner-svn-src-stable-10@freebsd.org Wed Mar 22 18:33:51 2017 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 CE4D4D184B6; Wed, 22 Mar 2017 18:33:51 +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 9AC8C1608; Wed, 22 Mar 2017 18:33:51 +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 v2MIXofQ049783; Wed, 22 Mar 2017 18:33:50 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2MIXofn049782; Wed, 22 Mar 2017 18:33:50 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201703221833.v2MIXofn049782@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Wed, 22 Mar 2017 18:33: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: r315730 - stable/10/sys/sys 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.23 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, 22 Mar 2017 18:33:51 -0000 Author: bdrewery Date: Wed Mar 22 18:33:50 2017 New Revision: 315730 URL: https://svnweb.freebsd.org/changeset/base/315730 Log: Bump __FreeBSD_version for libmd changes in r314143. Modified: stable/10/sys/sys/param.h Modified: stable/10/sys/sys/param.h ============================================================================== --- stable/10/sys/sys/param.h Wed Mar 22 18:33:29 2017 (r315729) +++ stable/10/sys/sys/param.h Wed Mar 22 18:33:50 2017 (r315730) @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1003511 /* Master, propagated to newvers */ +#define __FreeBSD_version 1003512 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From owner-svn-src-stable-10@freebsd.org Wed Mar 22 18:35:50 2017 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 59828D1853C; Wed, 22 Mar 2017 18:35:50 +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 0F7D117BE; Wed, 22 Mar 2017 18:35:49 +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 v2MIZnlJ049930; Wed, 22 Mar 2017 18:35:49 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2MIZnV6049928; Wed, 22 Mar 2017 18:35:49 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201703221835.v2MIZnV6049928@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Wed, 22 Mar 2017 18:35: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: r315731 - in stable/10: . lib/libmd 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.23 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, 22 Mar 2017 18:35:50 -0000 Author: bdrewery Date: Wed Mar 22 18:35:48 2017 New Revision: 315731 URL: https://svnweb.freebsd.org/changeset/base/315731 Log: MFC r314709,r314790,r314794: r314709: Fix bootstrapping mtree after r313404 for older systems. r314790: Added comments for why nmtree/libmd are bootstrapped. r314794: Fix bootstrapping libmd on older systems after r314709. PR: 217673 Modified: stable/10/Makefile.inc1 stable/10/lib/libmd/Makefile Directory Properties: stable/10/ (props changed) Modified: stable/10/Makefile.inc1 ============================================================================== --- stable/10/Makefile.inc1 Wed Mar 22 18:33:50 2017 (r315730) +++ stable/10/Makefile.inc1 Wed Mar 22 18:35:48 2017 (r315731) @@ -1323,10 +1323,14 @@ ${_bt}-usr.bin/yacc: ${_bt}-lib/liby _crunch= usr.sbin/crunch .endif -.if ${BOOTSTRAPPING} < 1000026 -_nmtree= lib/libnetbsd \ +# r245440 mtree -N support added +# r313404 requires sha384.h for libnetbsd, added to libmd in r292782 +.if ${BOOTSTRAPPING} < 1003512 +_nmtree= lib/libmd \ + lib/libnetbsd \ usr.sbin/nmtree +${_bt}-lib/libnetbsd: ${_bt}-lib/libmd ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd .endif Modified: stable/10/lib/libmd/Makefile ============================================================================== --- stable/10/lib/libmd/Makefile Wed Mar 22 18:33:50 2017 (r315730) +++ stable/10/lib/libmd/Makefile Wed Mar 22 18:35:48 2017 (r315731) @@ -52,6 +52,13 @@ CLEANFILES+= md[245]hl.c md[245].ref md[ sha256.ref sha256hl.c sha384hl.c sha384.ref \ sha512.ref sha512hl.c sha512t256.ref sha512thl.c +# Need src tree sys/md5.h for MD5FileChunk prototype on older systems. +SRCS+= sys/md5.h +CLEANDIRS= sys +CFLAGS+= -I. +sys/md5.h: ${.CURDIR}/../../sys/${.TARGET} .NOMETA + ln -sf ${.ALLSRC} ${.TARGET} + # Define WEAK_REFS to provide weak aliases for libmd symbols # # Note that the same sources are also used internally by libcrypt, From owner-svn-src-stable-10@freebsd.org Thu Mar 23 04:47:44 2017 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 E13A7D19F76; Thu, 23 Mar 2017 04:47:44 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B09E910BD; Thu, 23 Mar 2017 04:47:44 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2N4lhlQ005938; Thu, 23 Mar 2017 04:47:43 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N4lhDI005937; Thu, 23 Mar 2017 04:47:43 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201703230447.v2N4lhDI005937@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Thu, 23 Mar 2017 04:47: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: r315781 - stable/10/rescue/rescue 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.23 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, 23 Mar 2017 04:47:45 -0000 Author: ngie Date: Thu Mar 23 04:47:43 2017 New Revision: 315781 URL: https://svnweb.freebsd.org/changeset/base/315781 Log: MFC r315654: Fix linking /rescue/rescue to multiple programs in usr.bin after r315113 I meant for the line that conditionally added in /usr/bin/nc support to be `+=', not `=`. This restores hardlinks for all programs in usr.bin specified before nc(1), e.g., bunzip2 and tar. Pointyhat to: ngie Modified: stable/10/rescue/rescue/Makefile Directory Properties: stable/10/ (props changed) Modified: stable/10/rescue/rescue/Makefile ============================================================================== --- stable/10/rescue/rescue/Makefile Thu Mar 23 04:43:04 2017 (r315780) +++ stable/10/rescue/rescue/Makefile Thu Mar 23 04:47:43 2017 (r315781) @@ -220,7 +220,7 @@ CRUNCH_LIBS+= -lcrypto CRUNCH_LIBS+= -lmd .if ${MK_NETCAT} != "no" -CRUNCH_PROGS_usr.bin= nc +CRUNCH_PROGS_usr.bin+= nc .endif CRUNCH_PROGS_usr.bin+= vi From owner-svn-src-stable-10@freebsd.org Thu Mar 23 04:50:51 2017 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 AD9C0D19206; Thu, 23 Mar 2017 04:50:51 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6C9E4160F; Thu, 23 Mar 2017 04:50:51 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2N4ooE1006414; Thu, 23 Mar 2017 04:50:50 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N4ooZ8006413; Thu, 23 Mar 2017 04:50:50 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201703230450.v2N4ooZ8006413@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Thu, 23 Mar 2017 04:50: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: r315786 - stable/10/lib/libkvm 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.23 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, 23 Mar 2017 04:50:51 -0000 Author: ngie Date: Thu Mar 23 04:50:50 2017 New Revision: 315786 URL: https://svnweb.freebsd.org/changeset/base/315786 Log: MFC r315363,r315365: r315363: Fix manlint errors - Add missing comma after kvm_dpcpu_setcpu .Nm macro use (multiple .Nm entries should be separated by commas) - Add missing section for kvm_dpcpu_setcpu Xr. r315365: Tweak r315363 slightly I noticed after commit that kvm_dpcpu_setcpu was defined in the manpage. Thus, the correct macro for the function reference is .Fn, not .Xr. Modified: stable/10/lib/libkvm/kvm_getpcpu.3 Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libkvm/kvm_getpcpu.3 ============================================================================== --- stable/10/lib/libkvm/kvm_getpcpu.3 Thu Mar 23 04:50:44 2017 (r315785) +++ stable/10/lib/libkvm/kvm_getpcpu.3 Thu Mar 23 04:50:50 2017 (r315786) @@ -28,11 +28,11 @@ .\" .\" $FreeBSD$ .\" -.Dd February 12, 2014 +.Dd March 15, 2017 .Dt KVM_GETPCPU 3 .Os .Sh NAME -.Nm kvm_dpcpu_setcpu +.Nm kvm_dpcpu_setcpu , .Nm kvm_getmaxcpu , .Nm kvm_getpcpu .Nd access per-CPU data @@ -120,7 +120,7 @@ Symbols for dynamic per-CPU data are acc as with other symbols. .Nm libkvm maintains a notion of the "current CPU", set by -.Xr kvm_dpcpu_setcpu , +.Fn kvm_dpcpu_setcpu , which defaults to 0. Once another CPU is selected, .Xr kvm_nlist 3 From owner-svn-src-stable-10@freebsd.org Thu Mar 23 04:54:33 2017 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 2F89BD194C3; Thu, 23 Mar 2017 04:54:33 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F2F1D1C78; Thu, 23 Mar 2017 04:54:32 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2N4sWNH010411; Thu, 23 Mar 2017 04:54:32 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N4sWxx010410; Thu, 23 Mar 2017 04:54:32 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201703230454.v2N4sWxx010410@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Thu, 23 Mar 2017 04:54: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: r315787 - stable/10/lib/libkvm 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.23 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, 23 Mar 2017 04:54:33 -0000 Author: ngie Date: Thu Mar 23 04:54:31 2017 New Revision: 315787 URL: https://svnweb.freebsd.org/changeset/base/315787 Log: MFC r315360: Return NULL instead of 0 on failure in _kvm_open, kvm_open{,2,files} This is being done for the following reasons: - kvm_open(3), etc says they will return NULL. - NULL by definition is (void*)0 per POSIX, but can be redefined, depending on the compiler, etc. Modified: stable/10/lib/libkvm/kvm.c Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libkvm/kvm.c ============================================================================== --- stable/10/lib/libkvm/kvm.c Thu Mar 23 04:50:50 2017 (r315786) +++ stable/10/lib/libkvm/kvm.c Thu Mar 23 04:54:31 2017 (r315787) @@ -224,7 +224,7 @@ failed: if (errout != 0) strlcpy(errout, kd->errbuf, _POSIX2_LINE_MAX); (void)kvm_close(kd); - return (0); + return (NULL); } kvm_t * @@ -235,7 +235,7 @@ kvm_openfiles(const char *uf, const char if ((kd = calloc(1, sizeof(*kd))) == NULL) { (void)strlcpy(errout, strerror(errno), _POSIX2_LINE_MAX); - return (0); + return (NULL); } kd->program = 0; return (_kvm_open(kd, uf, mf, flag, errout)); @@ -251,7 +251,7 @@ kvm_open(const char *uf, const char *mf, if (errstr != NULL) (void)fprintf(stderr, "%s: %s\n", errstr, strerror(errno)); - return (0); + return (NULL); } kd->program = errstr; return (_kvm_open(kd, uf, mf, flag, NULL)); From owner-svn-src-stable-10@freebsd.org Thu Mar 23 06:29:49 2017 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 06CB8D19D25; Thu, 23 Mar 2017 06:29:49 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CA4B11439; Thu, 23 Mar 2017 06:29: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 v2N6TlgJ048116; Thu, 23 Mar 2017 06:29:47 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N6TlJR048115; Thu, 23 Mar 2017 06:29:47 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703230629.v2N6TlJR048115@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 23 Mar 2017 06:29: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: r315806 - stable/10/sys/dev/cxgb/ulp/tom 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.23 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, 23 Mar 2017 06:29:49 -0000 Author: mav Date: Thu Mar 23 06:29:47 2017 New Revision: 315806 URL: https://svnweb.freebsd.org/changeset/base/315806 Log: MFC r314952: Fix unused variable when built without INVARIANT_SUPPORT. Modified: stable/10/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c ============================================================================== --- stable/10/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c Thu Mar 23 06:28:34 2017 (r315805) +++ stable/10/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c Thu Mar 23 06:29:47 2017 (r315806) @@ -1621,10 +1621,9 @@ fixup_and_send_ofo(struct toepcb *toep) struct mbuf *m; struct toedev *tod = toep->tp_tod; struct adapter *sc = tod->tod_softc; - struct inpcb *inp = toep->tp_inp; unsigned int tid = toep->tp_tid; - inp_lock_assert(inp); + inp_lock_assert(toep->tp_inp); while ((m = mbufq_dequeue(&toep->out_of_order_queue)) != NULL) { struct ofld_hdr *oh = mtod(m, void *); From owner-svn-src-stable-10@freebsd.org Thu Mar 23 06:34:46 2017 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 91C28D1920D; Thu, 23 Mar 2017 06:34:46 +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 5E8CE1D39; Thu, 23 Mar 2017 06:34:46 +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 v2N6Yj3s052018; Thu, 23 Mar 2017 06:34:45 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N6YjkX052017; Thu, 23 Mar 2017 06:34:45 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703230634.v2N6YjkX052017@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 23 Mar 2017 06:34:45 +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: r315809 - stable/10/sys/dev/mpt 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.23 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, 23 Mar 2017 06:34:46 -0000 Author: mav Date: Thu Mar 23 06:34:45 2017 New Revision: 315809 URL: https://svnweb.freebsd.org/changeset/base/315809 Log: MFC r303874 (by trasz): Remove NULL check after M_WAITOK allocation from mpt(4). Modified: stable/10/sys/dev/mpt/mpt_pci.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/mpt/mpt_pci.c ============================================================================== --- stable/10/sys/dev/mpt/mpt_pci.c Thu Mar 23 06:34:15 2017 (r315808) +++ stable/10/sys/dev/mpt/mpt_pci.c Thu Mar 23 06:34:45 2017 (r315809) @@ -654,10 +654,6 @@ mpt_dma_mem_alloc(struct mpt_softc *mpt) len = sizeof (request_t) * MPT_MAX_REQUESTS(mpt); mpt->request_pool = (request_t *)malloc(len, M_DEVBUF, M_WAITOK|M_ZERO); - if (mpt->request_pool == NULL) { - mpt_prt(mpt, "cannot allocate request pool\n"); - return (1); - } /* * Create a parent dma tag for this device. From owner-svn-src-stable-10@freebsd.org Thu Mar 23 06:37:24 2017 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 ADB71D19359; Thu, 23 Mar 2017 06:37:24 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 63437C; Thu, 23 Mar 2017 06:37:24 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2N6bNSF052238; Thu, 23 Mar 2017 06:37:23 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N6bNgd052237; Thu, 23 Mar 2017 06:37:23 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703230637.v2N6bNgd052237@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 23 Mar 2017 06:37:23 +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: r315811 - stable/10/sys/dev/mpt 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.23 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, 23 Mar 2017 06:37:24 -0000 Author: mav Date: Thu Mar 23 06:37:23 2017 New Revision: 315811 URL: https://svnweb.freebsd.org/changeset/base/315811 Log: MFC r308423 (by scottl): Fix the fallout from r308268 (mpt driver causes endless witness warnings in VMWare and elsewhere) with the precision of a dull, rusty butter knife. Modified: stable/10/sys/dev/mpt/mpt.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/mpt/mpt.c ============================================================================== --- stable/10/sys/dev/mpt/mpt.c Thu Mar 23 06:36:55 2017 (r315810) +++ stable/10/sys/dev/mpt/mpt.c Thu Mar 23 06:37:23 2017 (r315811) @@ -2695,7 +2695,11 @@ mpt_configure_ioc(struct mpt_softc *mpt, */ mpt->max_cam_seg_cnt = min(mpt->max_seg_cnt, (MAXPHYS / PAGE_SIZE) + 1); + /* XXX Lame Locking! */ + MPT_UNLOCK(mpt); error = mpt_dma_buf_alloc(mpt); + MPT_LOCK(mpt); + if (error != 0) { mpt_prt(mpt, "mpt_dma_buf_alloc() failed!\n"); return (EIO); @@ -2745,6 +2749,7 @@ mpt_configure_ioc(struct mpt_softc *mpt, * retrieved, we are responsible for re-downloading * the firmware after any hard-reset. */ + MPT_UNLOCK(mpt); mpt->fw_image_size = mpt->ioc_facts.FWImageSize; error = mpt_dma_tag_create(mpt, mpt->parent_dmat, 1, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, @@ -2752,6 +2757,7 @@ mpt_configure_ioc(struct mpt_softc *mpt, &mpt->fw_dmat); if (error != 0) { mpt_prt(mpt, "cannot create firmware dma tag\n"); + MPT_LOCK(mpt); return (ENOMEM); } error = bus_dmamem_alloc(mpt->fw_dmat, @@ -2760,6 +2766,7 @@ mpt_configure_ioc(struct mpt_softc *mpt, if (error != 0) { mpt_prt(mpt, "cannot allocate firmware memory\n"); bus_dma_tag_destroy(mpt->fw_dmat); + MPT_LOCK(mpt); return (ENOMEM); } mi.mpt = mpt; @@ -2768,6 +2775,7 @@ mpt_configure_ioc(struct mpt_softc *mpt, mpt->fw_image, mpt->fw_image_size, mpt_map_rquest, &mi, 0); mpt->fw_phys = mi.phys; + MPT_LOCK(mpt); error = mpt_upload_fw(mpt); if (error != 0) { mpt_prt(mpt, "firmware upload failed.\n"); From owner-svn-src-stable-10@freebsd.org Thu Mar 23 06:41:20 2017 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 52809D195E6; Thu, 23 Mar 2017 06:41:20 +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 E7E563DB; Thu, 23 Mar 2017 06:41:19 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2N6fJ6p054120; Thu, 23 Mar 2017 06:41:19 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N6fD4h054070; Thu, 23 Mar 2017 06:41:13 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703230641.v2N6fD4h054070@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 23 Mar 2017 06:41:13 +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: r315813 - in stable/10/sys: cam cam/ctl cam/scsi dev/aac dev/aacraid dev/advansys dev/aha dev/ahb dev/ahci dev/aic dev/aic7xxx dev/amr dev/arcmsr dev/ata dev/buslogic dev/ciss dev/dpt 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.23 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, 23 Mar 2017 06:41:20 -0000 Author: mav Date: Thu Mar 23 06:41:13 2017 New Revision: 315813 URL: https://svnweb.freebsd.org/changeset/base/315813 Log: MFC r311305 (by asomers): Always null-terminate ccb_pathinq.(sim_vid|hba_vid|dev_name) The sim_vid, hba_vid, and dev_name fields of struct ccb_pathinq are fixed-length strings. AFAICT the only place they're read is in sbin/camcontrol/camcontrol.c, which assumes they'll be null-terminated. However, the kernel doesn't null-terminate them. A bunch of copy-pasted code uses strncpy to write them, and doesn't guarantee null-termination. For at least 4 drivers (mpr, mps, ciss, and hyperv), the hba_vid field actually overflows. You can see the result by doing "camcontrol negotiate da0 -v". This change null-terminates those fields everywhere they're set in the kernel. It also shortens a few strings to ensure they'll fit within the 16-character field. PR: 215474 Reported by: Coverity CID: 1009997 1010000 1010001 1010002 1010003 1010004 1010005 CID: 1331519 1010006 1215097 1010007 1288967 1010008 1306000 CID: 1211924 1010009 1010010 1010011 1010012 1010013 1010014 CID: 1147190 1010017 1010016 1010018 1216435 1010020 1010021 CID: 1010022 1009666 1018185 1010023 1010025 1010026 1010027 CID: 1010028 1010029 1010030 1010031 1010033 1018186 1018187 CID: 1010035 1010036 1010042 1010041 1010040 1010039 Modified: stable/10/sys/cam/cam_xpt.c stable/10/sys/cam/ctl/ctl_frontend_cam_sim.c stable/10/sys/cam/scsi/scsi_low.c stable/10/sys/dev/aac/aac_cam.c stable/10/sys/dev/aacraid/aacraid_cam.c stable/10/sys/dev/advansys/advansys.c stable/10/sys/dev/advansys/adwcam.c stable/10/sys/dev/aha/aha.c stable/10/sys/dev/ahb/ahb.c stable/10/sys/dev/ahci/ahci.c stable/10/sys/dev/ahci/ahciem.c stable/10/sys/dev/aic/aic.c stable/10/sys/dev/aic7xxx/aic79xx_osm.c stable/10/sys/dev/aic7xxx/aic7xxx_osm.c stable/10/sys/dev/amr/amr_cam.c stable/10/sys/dev/arcmsr/arcmsr.c stable/10/sys/dev/ata/ata-all.c stable/10/sys/dev/buslogic/bt.c stable/10/sys/dev/ciss/ciss.c stable/10/sys/dev/dpt/dpt_scsi.c stable/10/sys/dev/esp/ncr53c9x.c stable/10/sys/dev/firewire/sbp.c stable/10/sys/dev/firewire/sbp_targ.c stable/10/sys/dev/hpt27xx/hpt27xx_osm_bsd.c stable/10/sys/dev/hptiop/hptiop.c stable/10/sys/dev/hptmv/entry.c stable/10/sys/dev/hptnr/hptnr_osm_bsd.c stable/10/sys/dev/hptrr/hptrr_osm_bsd.c stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c stable/10/sys/dev/iir/iir.c stable/10/sys/dev/isci/isci_controller.c stable/10/sys/dev/iscsi_initiator/isc_cam.c stable/10/sys/dev/isp/isp_freebsd.c stable/10/sys/dev/mfi/mfi_cam.c stable/10/sys/dev/mly/mly.c stable/10/sys/dev/mpr/mpr_sas.c stable/10/sys/dev/mps/mps_sas.c stable/10/sys/dev/mpt/mpt_cam.c stable/10/sys/dev/mrsas/mrsas_cam.c stable/10/sys/dev/mvs/mvs.c stable/10/sys/dev/pms/freebsd/driver/ini/src/agtiapi.c stable/10/sys/dev/ppbus/vpo.c stable/10/sys/dev/siis/siis.c stable/10/sys/dev/sym/sym_hipd.c stable/10/sys/dev/trm/trm.c stable/10/sys/dev/twa/tw_osl_cam.c stable/10/sys/dev/tws/tws_cam.c stable/10/sys/dev/virtio/scsi/virtio_scsi.c stable/10/sys/powerpc/ps3/ps3cdrom.c stable/10/sys/powerpc/pseries/phyp_vscsi.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/cam_xpt.c ============================================================================== --- stable/10/sys/cam/cam_xpt.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/cam/cam_xpt.c Thu Mar 23 06:41:13 2017 (r315813) @@ -5144,9 +5144,9 @@ xptaction(struct cam_sim *sim, union ccb cpi->max_target = 0; cpi->max_lun = 0; cpi->initiator_id = 0; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "", HBA_IDLEN); - strncpy(cpi->dev_name, sim->sim_name, DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "", HBA_IDLEN); + strlcpy(cpi->dev_name, sim->sim_name, DEV_IDLEN); cpi->unit_number = sim->unit_number; cpi->bus_id = sim->bus_id; cpi->base_transfer_speed = 0; Modified: stable/10/sys/cam/ctl/ctl_frontend_cam_sim.c ============================================================================== --- stable/10/sys/cam/ctl/ctl_frontend_cam_sim.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/cam/ctl/ctl_frontend_cam_sim.c Thu Mar 23 06:41:13 2017 (r315813) @@ -786,9 +786,9 @@ cfcs_action(struct cam_sim *sim, union c cpi->hpath_id = 0; cpi->initiator_id = 0; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "FreeBSD", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "FreeBSD", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = 0; cpi->bus_id = 0; cpi->base_transfer_speed = 800000; Modified: stable/10/sys/cam/scsi/scsi_low.c ============================================================================== --- stable/10/sys/cam/scsi/scsi_low.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/cam/scsi/scsi_low.c Thu Mar 23 06:41:13 2017 (r315813) @@ -741,9 +741,9 @@ settings_out: cpi->transport_version = 2; cpi->protocol = PROTO_SCSI; cpi->protocol_version = SCSI_REV_2; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "SCSI_LOW", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "SCSI_LOW", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->ccb_h.status = CAM_REQ_CMP; xpt_done(ccb); Modified: stable/10/sys/dev/aac/aac_cam.c ============================================================================== --- stable/10/sys/dev/aac/aac_cam.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/aac/aac_cam.c Thu Mar 23 06:41:13 2017 (r315813) @@ -317,9 +317,9 @@ aac_cam_action(struct cam_sim *sim, unio cpi->initiator_id = camsc->inf->InitiatorBusId; cpi->bus_id = camsc->inf->BusNumber; cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "Adaptec", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "Adaptec", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->transport = XPORT_SPI; cpi->transport_version = 2; Modified: stable/10/sys/dev/aacraid/aacraid_cam.c ============================================================================== --- stable/10/sys/dev/aacraid/aacraid_cam.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/aacraid/aacraid_cam.c Thu Mar 23 06:41:13 2017 (r315813) @@ -1039,9 +1039,9 @@ aac_cam_action(struct cam_sim *sim, unio cpi->transport_version = 0; cpi->protocol_version = SCSI_REV_SPC2; #endif - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "PMC-Sierra", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "PMC-Sierra", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); ccb->ccb_h.status = CAM_REQ_CMP; xpt_done(ccb); Modified: stable/10/sys/dev/advansys/advansys.c ============================================================================== --- stable/10/sys/dev/advansys/advansys.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/advansys/advansys.c Thu Mar 23 06:41:13 2017 (r315813) @@ -429,9 +429,9 @@ adv_action(struct cam_sim *sim, union cc cpi->initiator_id = adv->scsi_id; cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "Advansys", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "Advansys", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->ccb_h.status = CAM_REQ_CMP; cpi->transport = XPORT_SPI; Modified: stable/10/sys/dev/advansys/adwcam.c ============================================================================== --- stable/10/sys/dev/advansys/adwcam.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/advansys/adwcam.c Thu Mar 23 06:41:13 2017 (r315813) @@ -710,9 +710,9 @@ adw_action(struct cam_sim *sim, union cc cpi->initiator_id = adw->initiator_id; cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "AdvanSys", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "AdvanSys", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->transport = XPORT_SPI; cpi->transport_version = 2; Modified: stable/10/sys/dev/aha/aha.c ============================================================================== --- stable/10/sys/dev/aha/aha.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/aha/aha.c Thu Mar 23 06:41:13 2017 (r315813) @@ -949,9 +949,9 @@ ahaaction(struct cam_sim *sim, union ccb cpi->initiator_id = aha->scsi_id; cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "Adaptec", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "Adaptec", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->transport = XPORT_SPI; cpi->transport_version = 2; Modified: stable/10/sys/dev/ahb/ahb.c ============================================================================== --- stable/10/sys/dev/ahb/ahb.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/ahb/ahb.c Thu Mar 23 06:41:13 2017 (r315813) @@ -1179,9 +1179,9 @@ ahbaction(struct cam_sim *sim, union ccb cpi->initiator_id = ahb->scsi_id; cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "Adaptec", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "Adaptec", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->transport = XPORT_SPI; cpi->transport_version = 2; Modified: stable/10/sys/dev/ahci/ahci.c ============================================================================== --- stable/10/sys/dev/ahci/ahci.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/ahci/ahci.c Thu Mar 23 06:41:13 2017 (r315813) @@ -2637,9 +2637,9 @@ ahciaction(struct cam_sim *sim, union cc cpi->initiator_id = 0; cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 150000; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "AHCI", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "AHCI", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->transport = XPORT_SATA; cpi->transport_version = XPORT_VERSION_UNSPECIFIED; Modified: stable/10/sys/dev/ahci/ahciem.c ============================================================================== --- stable/10/sys/dev/ahci/ahciem.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/ahci/ahciem.c Thu Mar 23 06:41:13 2017 (r315813) @@ -578,9 +578,9 @@ ahciemaction(struct cam_sim *sim, union cpi->initiator_id = 0; cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 150000; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "AHCI", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "AHCI", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->transport = XPORT_SATA; cpi->transport_version = XPORT_VERSION_UNSPECIFIED; Modified: stable/10/sys/dev/aic/aic.c ============================================================================== --- stable/10/sys/dev/aic/aic.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/aic/aic.c Thu Mar 23 06:41:13 2017 (r315813) @@ -281,9 +281,9 @@ aic_action(struct cam_sim *sim, union cc cpi->initiator_id = aic->initiator; cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "Adaptec", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "Adaptec", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->transport = XPORT_SPI; cpi->transport_version = 2; Modified: stable/10/sys/dev/aic7xxx/aic79xx_osm.c ============================================================================== --- stable/10/sys/dev/aic7xxx/aic79xx_osm.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/aic7xxx/aic79xx_osm.c Thu Mar 23 06:41:13 2017 (r315813) @@ -699,9 +699,9 @@ ahd_action(struct cam_sim *sim, union cc } cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "Adaptec", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "Adaptec", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->protocol = PROTO_SCSI; cpi->protocol_version = SCSI_REV_2; Modified: stable/10/sys/dev/aic7xxx/aic7xxx_osm.c ============================================================================== --- stable/10/sys/dev/aic7xxx/aic7xxx_osm.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/aic7xxx/aic7xxx_osm.c Thu Mar 23 06:41:13 2017 (r315813) @@ -797,9 +797,9 @@ ahc_action(struct cam_sim *sim, union cc } cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "Adaptec", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "Adaptec", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->protocol = PROTO_SCSI; cpi->protocol_version = SCSI_REV_2; Modified: stable/10/sys/dev/amr/amr_cam.c ============================================================================== --- stable/10/sys/dev/amr/amr_cam.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/amr/amr_cam.c Thu Mar 23 06:41:13 2017 (r315813) @@ -323,9 +323,9 @@ amr_cam_action(struct cam_sim *sim, unio cpi->max_target = AMR_MAX_TARGETS; cpi->max_lun = 0 /* AMR_MAX_LUNS*/; cpi->initiator_id = 7; /* XXX variable? */ - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "LSI", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "LSI", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 132 * 1024; /* XXX */ Modified: stable/10/sys/dev/arcmsr/arcmsr.c ============================================================================== --- stable/10/sys/dev/arcmsr/arcmsr.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/arcmsr/arcmsr.c Thu Mar 23 06:41:13 2017 (r315813) @@ -2901,9 +2901,9 @@ static void arcmsr_action(struct cam_sim cpi->max_lun = ARCMSR_MAX_TARGETLUN; /* 0-7 */ cpi->initiator_id = ARCMSR_SCSI_INITIATOR_ID; /* 255 */ cpi->bus_id = cam_sim_bus(psim); - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "ARCMSR", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(psim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "ARCMSR", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(psim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(psim); #ifdef CAM_NEW_TRAN_CODE if(acb->adapter_bus_speed == ACB_BUS_SPEED_12G) Modified: stable/10/sys/dev/ata/ata-all.c ============================================================================== --- stable/10/sys/dev/ata/ata-all.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/ata/ata-all.c Thu Mar 23 06:41:13 2017 (r315813) @@ -1162,9 +1162,9 @@ ataaction(struct cam_sim *sim, union ccb cpi->base_transfer_speed = 150000; else cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "ATA", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "ATA", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); if (ch->flags & ATA_SATA) cpi->transport = XPORT_SATA; Modified: stable/10/sys/dev/buslogic/bt.c ============================================================================== --- stable/10/sys/dev/buslogic/bt.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/buslogic/bt.c Thu Mar 23 06:41:13 2017 (r315813) @@ -1369,9 +1369,9 @@ btaction(struct cam_sim *sim, union ccb cpi->initiator_id = bt->scsi_id; cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "BusLogic", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "BusLogic", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->ccb_h.status = CAM_REQ_CMP; cpi->transport = XPORT_SPI; Modified: stable/10/sys/dev/ciss/ciss.c ============================================================================== --- stable/10/sys/dev/ciss/ciss.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/ciss/ciss.c Thu Mar 23 06:41:13 2017 (r315813) @@ -3026,9 +3026,9 @@ ciss_cam_action(struct cam_sim *sim, uni cpi->max_target = sc->ciss_cfg->max_logical_supported; cpi->max_lun = 0; /* 'logical drive' channel only */ cpi->initiator_id = sc->ciss_cfg->max_logical_supported; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "msmith@freebsd.org", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "CISS", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 132 * 1024; /* XXX what to set this to? */ Modified: stable/10/sys/dev/dpt/dpt_scsi.c ============================================================================== --- stable/10/sys/dev/dpt/dpt_scsi.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/dpt/dpt_scsi.c Thu Mar 23 06:41:13 2017 (r315813) @@ -1027,9 +1027,9 @@ dpt_action(struct cam_sim *sim, union cc cpi->initiator_id = dpt->hostid[cam_sim_bus(sim)]; cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "DPT", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "DPT", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->transport = XPORT_SPI; cpi->transport_version = 2; Modified: stable/10/sys/dev/esp/ncr53c9x.c ============================================================================== --- stable/10/sys/dev/esp/ncr53c9x.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/esp/ncr53c9x.c Thu Mar 23 06:41:13 2017 (r315813) @@ -1013,9 +1013,9 @@ ncr53c9x_action(struct cam_sim *sim, uni cpi->max_target = sc->sc_ntarg - 1; cpi->max_lun = 7; cpi->initiator_id = sc->sc_id; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "NCR", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "NCR", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->bus_id = 0; cpi->base_transfer_speed = 3300; Modified: stable/10/sys/dev/firewire/sbp.c ============================================================================== --- stable/10/sys/dev/firewire/sbp.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/firewire/sbp.c Thu Mar 23 06:41:13 2017 (r315813) @@ -2553,9 +2553,9 @@ END_DEBUG cpi->initiator_id = SBP_INITIATOR; cpi->bus_id = sim->bus_id; cpi->base_transfer_speed = 400 * 1000 / 8; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "SBP", HBA_IDLEN); - strncpy(cpi->dev_name, sim->sim_name, DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "SBP", HBA_IDLEN); + strlcpy(cpi->dev_name, sim->sim_name, DEV_IDLEN); cpi->unit_number = sim->unit_number; cpi->transport = XPORT_SPI; /* XX should have a FireWire */ cpi->transport_version = 2; Modified: stable/10/sys/dev/firewire/sbp_targ.c ============================================================================== --- stable/10/sys/dev/firewire/sbp_targ.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/firewire/sbp_targ.c Thu Mar 23 06:41:13 2017 (r315813) @@ -1335,9 +1335,9 @@ sbp_targ_action1(struct cam_sim *sim, un cpi->initiator_id = 7; /* XXX */ cpi->bus_id = sim->bus_id; cpi->base_transfer_speed = 400 * 1000 / 8; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "SBP_TARG", HBA_IDLEN); - strncpy(cpi->dev_name, sim->sim_name, DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "SBP_TARG", HBA_IDLEN); + strlcpy(cpi->dev_name, sim->sim_name, DEV_IDLEN); cpi->unit_number = sim->unit_number; cpi->ccb_h.status = CAM_REQ_CMP; Modified: stable/10/sys/dev/hpt27xx/hpt27xx_osm_bsd.c ============================================================================== --- stable/10/sys/dev/hpt27xx/hpt27xx_osm_bsd.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/hpt27xx/hpt27xx_osm_bsd.c Thu Mar 23 06:41:13 2017 (r315813) @@ -934,9 +934,9 @@ static void hpt_action(struct cam_sim *s cpi->initiator_id = osm_max_targets; cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "HPT ", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "HPT ", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->transport = XPORT_SPI; cpi->transport_version = 2; cpi->protocol = PROTO_SCSI; Modified: stable/10/sys/dev/hptiop/hptiop.c ============================================================================== --- stable/10/sys/dev/hptiop/hptiop.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/hptiop/hptiop.c Thu Mar 23 06:41:13 2017 (r315813) @@ -2362,9 +2362,9 @@ scsi_done: cpi->initiator_id = hba->max_devices; cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "HPT ", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "HPT ", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->transport = XPORT_SPI; cpi->transport_version = 2; cpi->protocol = PROTO_SCSI; Modified: stable/10/sys/dev/hptmv/entry.c ============================================================================== --- stable/10/sys/dev/hptmv/entry.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/hptmv/entry.c Thu Mar 23 06:41:13 2017 (r315813) @@ -2417,9 +2417,9 @@ hpt_action(struct cam_sim *sim, union cc cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "HPT ", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "HPT ", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->transport = XPORT_SPI; cpi->transport_version = 2; Modified: stable/10/sys/dev/hptnr/hptnr_osm_bsd.c ============================================================================== --- stable/10/sys/dev/hptnr/hptnr_osm_bsd.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/hptnr/hptnr_osm_bsd.c Thu Mar 23 06:41:13 2017 (r315813) @@ -1134,9 +1134,9 @@ static void hpt_action(struct cam_sim *s cpi->initiator_id = osm_max_targets; cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "HPT ", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "HPT ", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->transport = XPORT_SPI; cpi->transport_version = 2; cpi->protocol = PROTO_SCSI; Modified: stable/10/sys/dev/hptrr/hptrr_osm_bsd.c ============================================================================== --- stable/10/sys/dev/hptrr/hptrr_osm_bsd.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/hptrr/hptrr_osm_bsd.c Thu Mar 23 06:41:13 2017 (r315813) @@ -782,9 +782,9 @@ static void hpt_action(struct cam_sim *s cpi->initiator_id = osm_max_targets; cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "HPT ", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "HPT ", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->transport = XPORT_SPI; cpi->transport_version = 2; cpi->protocol = PROTO_SCSI; Modified: stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Thu Mar 23 06:41:13 2017 (r315813) @@ -266,10 +266,10 @@ static const struct hyperv_guid gBlkVscD }; static struct storvsc_driver_props g_drv_props_table[] = { - {"blkvsc", "Hyper-V IDE Storage Interface", + {"blkvsc", "Hyper-V IDE", BLKVSC_MAX_IDE_DISKS_PER_TARGET, BLKVSC_MAX_IO_REQUESTS, 20*PAGE_SIZE}, - {"storvsc", "Hyper-V SCSI Storage Interface", + {"storvsc", "Hyper-V SCSI", STORVSC_MAX_LUNS_PER_TARGET, STORVSC_MAX_IO_REQUESTS, 20*PAGE_SIZE} }; @@ -1451,9 +1451,9 @@ storvsc_action(struct cam_sim *sim, unio cpi->transport_version = 0; cpi->protocol = PROTO_SCSI; cpi->protocol_version = SCSI_REV_SPC2; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, sc->hs_drv_props->drv_name, HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, sc->hs_drv_props->drv_name, HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); ccb->ccb_h.status = CAM_REQ_CMP; Modified: stable/10/sys/dev/iir/iir.c ============================================================================== --- stable/10/sys/dev/iir/iir.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/iir/iir.c Thu Mar 23 06:41:13 2017 (r315813) @@ -1366,12 +1366,12 @@ iir_action( struct cam_sim *sim, union c cpi->initiator_id = (bus == gdt->sc_virt_bus ? 127 : gdt->sc_bus_id[bus]); cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); if (gdt->sc_vendor == INTEL_VENDOR_ID_IIR) - strncpy(cpi->hba_vid, "Intel Corp.", HBA_IDLEN); + strlcpy(cpi->hba_vid, "Intel Corp.", HBA_IDLEN); else - strncpy(cpi->hba_vid, "ICP vortex ", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->hba_vid, "ICP vortex ", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->transport = XPORT_SPI; cpi->transport_version = 2; cpi->protocol = PROTO_SCSI; Modified: stable/10/sys/dev/isci/isci_controller.c ============================================================================== --- stable/10/sys/dev/isci/isci_controller.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/isci/isci_controller.c Thu Mar 23 06:41:13 2017 (r315813) @@ -691,9 +691,9 @@ void isci_action(struct cam_sim *sim, un cpi->bus_id = bus; cpi->initiator_id = SCI_MAX_REMOTE_DEVICES; cpi->base_transfer_speed = 300000; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "Intel Corp.", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "Intel Corp.", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->transport = XPORT_SAS; cpi->transport_version = 0; cpi->protocol = PROTO_SCSI; Modified: stable/10/sys/dev/iscsi_initiator/isc_cam.c ============================================================================== --- stable/10/sys/dev/iscsi_initiator/isc_cam.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/iscsi_initiator/isc_cam.c Thu Mar 23 06:41:13 2017 (r315813) @@ -75,9 +75,9 @@ _inq(struct cam_sim *sim, union ccb *ccb cpi->max_lun = sp->opt.maxluns - 1; cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 3300; // 40000; // XXX: - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "iSCSI", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "iSCSI", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->ccb_h.status = CAM_REQ_CMP; #if defined(KNOB_VALID_ADDRESS) Modified: stable/10/sys/dev/isp/isp_freebsd.c ============================================================================== --- stable/10/sys/dev/isp/isp_freebsd.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/isp/isp_freebsd.c Thu Mar 23 06:41:13 2017 (r315813) @@ -3921,9 +3921,9 @@ isp_action(struct cam_sim *sim, union cc } cpi->protocol = PROTO_SCSI; cpi->protocol_version = SCSI_REV_2; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "Qlogic", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "Qlogic", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->ccb_h.status = CAM_REQ_CMP; xpt_done(ccb); Modified: stable/10/sys/dev/mfi/mfi_cam.c ============================================================================== --- stable/10/sys/dev/mfi/mfi_cam.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/mfi/mfi_cam.c Thu Mar 23 06:41:13 2017 (r315813) @@ -223,9 +223,9 @@ mfip_cam_action(struct cam_sim *sim, uni cpi->max_target = MFI_SCSI_MAX_TARGETS; cpi->max_lun = MFI_SCSI_MAX_LUNS; cpi->initiator_id = MFI_SCSI_INITIATOR_ID; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "LSI", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "LSI", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 150000; Modified: stable/10/sys/dev/mly/mly.c ============================================================================== --- stable/10/sys/dev/mly/mly.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/mly/mly.c Thu Mar 23 06:41:13 2017 (r315813) @@ -2076,9 +2076,9 @@ mly_cam_action(struct cam_sim *sim, unio cpi->max_target = MLY_MAX_TARGETS - 1; cpi->max_lun = MLY_MAX_LUNS - 1; cpi->initiator_id = sc->mly_controllerparam->initiator_id; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "FreeBSD", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "Mylex", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 132 * 1024; /* XXX what to set this to? */ Modified: stable/10/sys/dev/mpr/mpr_sas.c ============================================================================== --- stable/10/sys/dev/mpr/mpr_sas.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/mpr/mpr_sas.c Thu Mar 23 06:41:13 2017 (r315813) @@ -987,9 +987,9 @@ mprsas_action(struct cam_sim *sim, union cpi->max_target = sassc->maxtargets - 1; cpi->max_lun = 255; cpi->initiator_id = sassc->maxtargets - 1; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "Avago Tech (LSI)", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "Avago Tech", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->bus_id = cam_sim_bus(sim); /* Modified: stable/10/sys/dev/mps/mps_sas.c ============================================================================== --- stable/10/sys/dev/mps/mps_sas.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/mps/mps_sas.c Thu Mar 23 06:41:13 2017 (r315813) @@ -943,9 +943,9 @@ mpssas_action(struct cam_sim *sim, union cpi->max_target = sassc->maxtargets - 1; cpi->max_lun = 255; cpi->initiator_id = sassc->maxtargets - 1; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "Avago Tech (LSI)", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "Avago Tech", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 150000; Modified: stable/10/sys/dev/mpt/mpt_cam.c ============================================================================== --- stable/10/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:41:13 2017 (r315813) @@ -3583,9 +3583,9 @@ mpt_action(struct cam_sim *sim, union cc } else { cpi->target_sprt = 0; } - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "LSI", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "LSI", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->ccb_h.status = CAM_REQ_CMP; break; Modified: stable/10/sys/dev/mrsas/mrsas_cam.c ============================================================================== --- stable/10/sys/dev/mrsas/mrsas_cam.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/mrsas/mrsas_cam.c Thu Mar 23 06:41:13 2017 (r315813) @@ -356,9 +356,9 @@ mrsas_action(struct cam_sim *sim, union ccb->cpi.bus_id = cam_sim_bus(sim); ccb->cpi.initiator_id = MRSAS_SCSI_INITIATOR_ID; ccb->cpi.base_transfer_speed = 150000; - strncpy(ccb->cpi.sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(ccb->cpi.hba_vid, "AVAGO", HBA_IDLEN); - strncpy(ccb->cpi.dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(ccb->cpi.sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(ccb->cpi.hba_vid, "AVAGO", HBA_IDLEN); + strlcpy(ccb->cpi.dev_name, cam_sim_name(sim), DEV_IDLEN); ccb->cpi.transport = XPORT_SPI; ccb->cpi.transport_version = 2; ccb->cpi.protocol = PROTO_SCSI; Modified: stable/10/sys/dev/mvs/mvs.c ============================================================================== --- stable/10/sys/dev/mvs/mvs.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/mvs/mvs.c Thu Mar 23 06:41:13 2017 (r315813) @@ -2412,9 +2412,9 @@ mvsaction(struct cam_sim *sim, union ccb cpi->initiator_id = 0; cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 150000; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "Marvell", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "Marvell", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->transport = XPORT_SATA; cpi->transport_version = XPORT_VERSION_UNSPECIFIED; Modified: stable/10/sys/dev/pms/freebsd/driver/ini/src/agtiapi.c ============================================================================== --- stable/10/sys/dev/pms/freebsd/driver/ini/src/agtiapi.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/pms/freebsd/driver/ini/src/agtiapi.c Thu Mar 23 06:41:13 2017 (r315813) @@ -1839,9 +1839,9 @@ static void agtiapi_cam_action( struct c cpi->max_lun = AGTIAPI_MAX_LUN; cpi->maxio = 1024 *1024; /* Max supported I/O size, in bytes. */ cpi->initiator_id = 255; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "PMC", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "PMC", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->bus_id = cam_sim_bus(sim); // rate is set when XPT_GET_TRAN_SETTINGS is processed Modified: stable/10/sys/dev/ppbus/vpo.c ============================================================================== --- stable/10/sys/dev/ppbus/vpo.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/ppbus/vpo.c Thu Mar 23 06:41:13 2017 (r315813) @@ -390,9 +390,9 @@ vpo_action(struct cam_sim *sim, union cc cpi->initiator_id = VP0_INITIATOR; cpi->bus_id = sim->bus_id; cpi->base_transfer_speed = 93; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "Iomega", HBA_IDLEN); - strncpy(cpi->dev_name, sim->sim_name, DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "Iomega", HBA_IDLEN); + strlcpy(cpi->dev_name, sim->sim_name, DEV_IDLEN); cpi->unit_number = sim->unit_number; cpi->transport = XPORT_PPB; cpi->transport_version = 0; Modified: stable/10/sys/dev/siis/siis.c ============================================================================== --- stable/10/sys/dev/siis/siis.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/siis/siis.c Thu Mar 23 06:41:13 2017 (r315813) @@ -1952,9 +1952,9 @@ siisaction(struct cam_sim *sim, union cc cpi->initiator_id = 0; cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 150000; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "SIIS", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "SIIS", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->transport = XPORT_SATA; cpi->transport_version = XPORT_VERSION_UNSPECIFIED; Modified: stable/10/sys/dev/sym/sym_hipd.c ============================================================================== --- stable/10/sys/dev/sym/sym_hipd.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/sym/sym_hipd.c Thu Mar 23 06:41:13 2017 (r315813) @@ -8049,9 +8049,9 @@ static void sym_action2(struct cam_sim * cpi->bus_id = cam_sim_bus(sim); cpi->initiator_id = np->myaddr; cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "Symbios", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "Symbios", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->protocol = PROTO_SCSI; Modified: stable/10/sys/dev/trm/trm.c ============================================================================== --- stable/10/sys/dev/trm/trm.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/trm/trm.c Thu Mar 23 06:41:13 2017 (r315813) @@ -651,9 +651,9 @@ trm_action(struct cam_sim *psim, union c cpi->initiator_id = pACB->AdaptSCSIID; cpi->bus_id = cam_sim_bus(psim); cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "Tekram_TRM", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(psim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "Tekram_TRM", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(psim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(psim); cpi->transport = XPORT_SPI; cpi->transport_version = 2; Modified: stable/10/sys/dev/twa/tw_osl_cam.c ============================================================================== --- stable/10/sys/dev/twa/tw_osl_cam.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/twa/tw_osl_cam.c Thu Mar 23 06:41:13 2017 (r315813) @@ -422,9 +422,9 @@ twa_action(struct cam_sim *sim, union cc path_inq->bus_id = cam_sim_bus(sim); path_inq->initiator_id = TW_CL_MAX_NUM_UNITS; path_inq->base_transfer_speed = 100000; - strncpy(path_inq->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(path_inq->hba_vid, "3ware", HBA_IDLEN); - strncpy(path_inq->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(path_inq->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(path_inq->hba_vid, "3ware", HBA_IDLEN); + strlcpy(path_inq->dev_name, cam_sim_name(sim), DEV_IDLEN); path_inq->transport = XPORT_SPI; path_inq->transport_version = 2; path_inq->protocol = PROTO_SCSI; Modified: stable/10/sys/dev/tws/tws_cam.c ============================================================================== --- stable/10/sys/dev/tws/tws_cam.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/tws/tws_cam.c Thu Mar 23 06:41:13 2017 (r315813) @@ -309,9 +309,9 @@ tws_action(struct cam_sim *sim, union cc ccb->cpi.bus_id = cam_sim_bus(sim); ccb->cpi.initiator_id = TWS_SCSI_INITIATOR_ID; ccb->cpi.base_transfer_speed = 6000000; - strncpy(ccb->cpi.sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(ccb->cpi.hba_vid, "3ware", HBA_IDLEN); - strncpy(ccb->cpi.dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(ccb->cpi.sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(ccb->cpi.hba_vid, "3ware", HBA_IDLEN); + strlcpy(ccb->cpi.dev_name, cam_sim_name(sim), DEV_IDLEN); #if (__FreeBSD_version >= 700000 ) ccb->cpi.transport = XPORT_SPI; ccb->cpi.transport_version = 2; Modified: stable/10/sys/dev/virtio/scsi/virtio_scsi.c ============================================================================== --- stable/10/sys/dev/virtio/scsi/virtio_scsi.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/dev/virtio/scsi/virtio_scsi.c Thu Mar 23 06:41:13 2017 (r315813) @@ -917,9 +917,9 @@ vtscsi_cam_path_inquiry(struct vtscsi_so cpi->max_lun = sc->vtscsi_max_lun; cpi->initiator_id = VTSCSI_INITIATOR_ID; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "VirtIO", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "VirtIO", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->bus_id = cam_sim_bus(sim); Modified: stable/10/sys/powerpc/ps3/ps3cdrom.c ============================================================================== --- stable/10/sys/powerpc/ps3/ps3cdrom.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/powerpc/ps3/ps3cdrom.c Thu Mar 23 06:41:13 2017 (r315813) @@ -421,9 +421,9 @@ ps3cdrom_action(struct cam_sim *sim, uni cpi->bus_id = cam_sim_bus(sim); cpi->unit_number = cam_sim_unit(sim); cpi->base_transfer_speed = 150000; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "Sony", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "Sony", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->transport = XPORT_SPI; cpi->transport_version = 2; cpi->protocol = PROTO_SCSI; Modified: stable/10/sys/powerpc/pseries/phyp_vscsi.c ============================================================================== --- stable/10/sys/powerpc/pseries/phyp_vscsi.c Thu Mar 23 06:40:20 2017 (r315812) +++ stable/10/sys/powerpc/pseries/phyp_vscsi.c Thu Mar 23 06:41:13 2017 (r315813) @@ -428,9 +428,9 @@ vscsi_cam_action(struct cam_sim *sim, un cpi->max_target = 0; cpi->max_lun = ~(lun_id_t)(0); cpi->initiator_id = ~0; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "IBM", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "IBM", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 150000; From owner-svn-src-stable-10@freebsd.org Thu Mar 23 06:42:28 2017 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 7D532D196BC; Thu, 23 Mar 2017 06:42: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 4CB8CA95; Thu, 23 Mar 2017 06:42: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 v2N6gRvV056559; Thu, 23 Mar 2017 06:42:27 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N6gR2Q056558; Thu, 23 Mar 2017 06:42:27 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703230642.v2N6gR2Q056558@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 23 Mar 2017 06:42: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: r315815 - stable/10/sys/dev/mpt 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.23 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, 23 Mar 2017 06:42:28 -0000 Author: mav Date: Thu Mar 23 06:42:27 2017 New Revision: 315815 URL: https://svnweb.freebsd.org/changeset/base/315815 Log: MFC r314966: Report FC link speed. Modified: stable/10/sys/dev/mpt/mpt_cam.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/mpt/mpt_cam.c ============================================================================== --- stable/10/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:41:58 2017 (r315814) +++ stable/10/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:42:27 2017 (r315815) @@ -433,7 +433,23 @@ mpt_read_config_info_fc(struct mpt_softc } mpt2host_config_page_fc_port_0(&mpt->mpt_fcport_page0); - mpt->mpt_fcport_speed = mpt->mpt_fcport_page0.CurrentSpeed; + switch (mpt->mpt_fcport_page0.CurrentSpeed) { + case MPI_FCPORTPAGE0_CURRENT_SPEED_1GBIT: + mpt->mpt_fcport_speed = 1; + break; + case MPI_FCPORTPAGE0_CURRENT_SPEED_2GBIT: + mpt->mpt_fcport_speed = 2; + break; + case MPI_FCPORTPAGE0_CURRENT_SPEED_10GBIT: + mpt->mpt_fcport_speed = 10; + break; + case MPI_FCPORTPAGE0_CURRENT_SPEED_4GBIT: + mpt->mpt_fcport_speed = 4; + break; + default: + mpt->mpt_fcport_speed = 0; + break; + } switch (mpt->mpt_fcport_page0.Flags & MPI_FCPORTPAGE0_FLAGS_ATTACH_TYPE_MASK) { @@ -3465,8 +3481,10 @@ mpt_action(struct cam_sim *sim, union cc cts->protocol_version = SCSI_REV_SPC; cts->transport = XPORT_FC; cts->transport_version = 0; - fc->valid = CTS_FC_VALID_SPEED; - fc->bitrate = 100000; + if (mpt->mpt_fcport_speed != 0) { + fc->valid = CTS_FC_VALID_SPEED; + fc->bitrate = 100000 * mpt->mpt_fcport_speed; + } } else if (mpt->is_sas) { struct ccb_trans_settings_sas *sas = &cts->xport_specific.sas; From owner-svn-src-stable-10@freebsd.org Thu Mar 23 06:45:58 2017 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 DCBA7D1987A; Thu, 23 Mar 2017 06:45:58 +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 92319E3F; Thu, 23 Mar 2017 06:45:58 +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 v2N6jvfc056848; Thu, 23 Mar 2017 06:45:57 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N6jv1Y056846; Thu, 23 Mar 2017 06:45:57 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703230645.v2N6jv1Y056846@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 23 Mar 2017 06:45:57 +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: r315817 - stable/10/sys/dev/mpt 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.23 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, 23 Mar 2017 06:45:59 -0000 Author: mav Date: Thu Mar 23 06:45:57 2017 New Revision: 315817 URL: https://svnweb.freebsd.org/changeset/base/315817 Log: MFC r314968: Report some more data in XPT_PATH_INQ. I am not sure they are used anywhere, but why not. Modified: stable/10/sys/dev/mpt/mpt.h stable/10/sys/dev/mpt/mpt_cam.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/mpt/mpt.h ============================================================================== --- stable/10/sys/dev/mpt/mpt.h Thu Mar 23 06:45:11 2017 (r315816) +++ stable/10/sys/dev/mpt/mpt.h Thu Mar 23 06:45:57 2017 (r315817) @@ -614,6 +614,7 @@ struct mpt_softc { struct { char wwnn[19]; char wwpn[19]; + uint32_t portid; } fc; } scinfo; Modified: stable/10/sys/dev/mpt/mpt_cam.c ============================================================================== --- stable/10/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:45:11 2017 (r315816) +++ stable/10/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:45:57 2017 (r315817) @@ -475,6 +475,12 @@ mpt_read_config_info_fc(struct mpt_softc break; } + mpt->scinfo.fc.wwnn = ((uint64_t)mpt->mpt_fcport_page0.WWNN.High << 32) + | mpt->mpt_fcport_page0.WWNN.Low; + mpt->scinfo.fc.wwpn = ((uint64_t)mpt->mpt_fcport_page0.WWPN.High << 32) + | mpt->mpt_fcport_page0.WWPN.Low; + mpt->scinfo.fc.portid = mpt->mpt_fcport_page0.PortIdentifier; + mpt_lprt(mpt, MPT_PRT_INFO, "FC Port Page 0: Topology <%s> WWNN 0x%08x%08x WWPN 0x%08x%08x " "Speed %u-Gbit\n", topology, @@ -3566,6 +3572,11 @@ mpt_action(struct cam_sim *sim, union cc cpi->transport = XPORT_FC; cpi->transport_version = 0; cpi->protocol_version = SCSI_REV_SPC; + cpi->xport_specific.fc.wwnn = mpt->scinfo.fc.wwnn; + cpi->xport_specific.fc.wwpn = mpt->scinfo.fc.wwpn; + cpi->xport_specific.fc.port = mpt->scinfo.fc.portid; + cpi->xport_specific.fc.bitrate = + 100000 * mpt->mpt_fcport_speed; } else if (mpt->is_sas) { cpi->hba_misc = PIM_NOBUSRESET | PIM_UNMAPPED; cpi->base_transfer_speed = 300000; From owner-svn-src-stable-10@freebsd.org Thu Mar 23 06:47:49 2017 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 E85F5D199BF; Thu, 23 Mar 2017 06:47:49 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C084C10FF; Thu, 23 Mar 2017 06:47:49 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2N6lmCa057023; Thu, 23 Mar 2017 06:47:48 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N6lmsC057020; Thu, 23 Mar 2017 06:47:48 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703230647.v2N6lmsC057020@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 23 Mar 2017 06:47: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: r315819 - stable/10/sys/dev/mpt 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.23 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, 23 Mar 2017 06:47:50 -0000 Author: mav Date: Thu Mar 23 06:47:48 2017 New Revision: 315819 URL: https://svnweb.freebsd.org/changeset/base/315819 Log: MFC r314967: Add support for XPT_GET_SIM_KNOB in FC mode. Modified: stable/10/sys/dev/mpt/mpt.h stable/10/sys/dev/mpt/mpt_cam.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/mpt/mpt.h ============================================================================== --- stable/10/sys/dev/mpt/mpt.h Thu Mar 23 06:47:08 2017 (r315818) +++ stable/10/sys/dev/mpt/mpt.h Thu Mar 23 06:47:48 2017 (r315819) @@ -612,8 +612,8 @@ struct mpt_softc { unsigned int initiator_id; } spi; struct { - char wwnn[19]; - char wwpn[19]; + uint64_t wwnn; + uint64_t wwpn; uint32_t portid; } fc; } scinfo; Modified: stable/10/sys/dev/mpt/mpt_cam.c ============================================================================== --- stable/10/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:47:08 2017 (r315818) +++ stable/10/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:47:48 2017 (r315819) @@ -482,31 +482,20 @@ mpt_read_config_info_fc(struct mpt_softc mpt->scinfo.fc.portid = mpt->mpt_fcport_page0.PortIdentifier; mpt_lprt(mpt, MPT_PRT_INFO, - "FC Port Page 0: Topology <%s> WWNN 0x%08x%08x WWPN 0x%08x%08x " + "FC Port Page 0: Topology <%s> WWNN 0x%16jx WWPN 0x%16jx " "Speed %u-Gbit\n", topology, - mpt->mpt_fcport_page0.WWNN.High, - mpt->mpt_fcport_page0.WWNN.Low, - mpt->mpt_fcport_page0.WWPN.High, - mpt->mpt_fcport_page0.WWPN.Low, + (uintmax_t)mpt->scinfo.fc.wwnn, (uintmax_t)mpt->scinfo.fc.wwpn, mpt->mpt_fcport_speed); MPT_UNLOCK(mpt); ctx = device_get_sysctl_ctx(mpt->dev); tree = device_get_sysctl_tree(mpt->dev); - snprintf(mpt->scinfo.fc.wwnn, sizeof (mpt->scinfo.fc.wwnn), - "0x%08x%08x", mpt->mpt_fcport_page0.WWNN.High, - mpt->mpt_fcport_page0.WWNN.Low); - - snprintf(mpt->scinfo.fc.wwpn, sizeof (mpt->scinfo.fc.wwpn), - "0x%08x%08x", mpt->mpt_fcport_page0.WWPN.High, - mpt->mpt_fcport_page0.WWPN.Low); - - SYSCTL_ADD_STRING(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "wwnn", CTLFLAG_RD, mpt->scinfo.fc.wwnn, 0, + SYSCTL_ADD_QUAD(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, + "wwnn", CTLFLAG_RD, &mpt->scinfo.fc.wwnn, "World Wide Node Name"); - SYSCTL_ADD_STRING(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "wwpn", CTLFLAG_RD, mpt->scinfo.fc.wwpn, 0, + SYSCTL_ADD_QUAD(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, + "wwpn", CTLFLAG_RD, &mpt->scinfo.fc.wwpn, "World Wide Port Name"); MPT_LOCK(mpt); @@ -3528,6 +3517,36 @@ mpt_action(struct cam_sim *sim, union cc KASSERT(ccb->ccb_h.status, ("zero ccb sts at %d", __LINE__)); break; } + case XPT_GET_SIM_KNOB: + { + struct ccb_sim_knob *kp = &ccb->knob; + + if (mpt->is_fc) { + kp->xport_specific.fc.wwnn = mpt->scinfo.fc.wwnn; + kp->xport_specific.fc.wwpn = mpt->scinfo.fc.wwpn; + switch (mpt->role) { + case MPT_ROLE_NONE: + kp->xport_specific.fc.role = KNOB_ROLE_NONE; + break; + case MPT_ROLE_INITIATOR: + kp->xport_specific.fc.role = KNOB_ROLE_INITIATOR; + break; + case MPT_ROLE_TARGET: + kp->xport_specific.fc.role = KNOB_ROLE_TARGET; + break; + case MPT_ROLE_BOTH: + kp->xport_specific.fc.role = KNOB_ROLE_BOTH; + break; + } + kp->xport_specific.fc.valid = + KNOB_VALID_ADDRESS | KNOB_VALID_ROLE; + ccb->ccb_h.status = CAM_REQ_CMP; + } else { + ccb->ccb_h.status = CAM_REQ_INVALID; + } + xpt_done(ccb); + break; + } case XPT_PATH_INQ: /* Path routing inquiry */ { struct ccb_pathinq *cpi = &ccb->cpi; From owner-svn-src-stable-10@freebsd.org Thu Mar 23 06:49:03 2017 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 0C036D19AFD; Thu, 23 Mar 2017 06:49:03 +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 C0D0714BE; Thu, 23 Mar 2017 06:49:02 +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 v2N6n1g8057180; Thu, 23 Mar 2017 06:49:01 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N6n1HA057178; Thu, 23 Mar 2017 06:49:01 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703230649.v2N6n1HA057178@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 23 Mar 2017 06:49:01 +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: r315821 - stable/10/sys/dev/mpt 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.23 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, 23 Mar 2017 06:49:03 -0000 Author: mav Date: Thu Mar 23 06:49:01 2017 New Revision: 315821 URL: https://svnweb.freebsd.org/changeset/base/315821 Log: MFC r314998: Fix FC target mode in mpt(4), broken in multiple ways. - Not set BufferLength caused receive of empty ATIOs. - CDB length guessing was broken at least for RC16. - mpt_req_untimeout() was called with wrong req parameter. - Sense data reporting was broken in several ways. With this change my LSI7204EP-LC can pass at least basic tests as target. The code is still far from perfect, but finally I found second hw/driver after isp(4) that really can work in CAM target mode. Modified: stable/10/sys/dev/mpt/mpt.h stable/10/sys/dev/mpt/mpt_cam.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/mpt/mpt.h ============================================================================== --- stable/10/sys/dev/mpt/mpt.h Thu Mar 23 06:48:31 2017 (r315820) +++ stable/10/sys/dev/mpt/mpt.h Thu Mar 23 06:49:01 2017 (r315821) @@ -949,24 +949,6 @@ void mpt_prtc(struct mpt_softc *, const __printflike(2, 3); /**************************** Target Mode Related ***************************/ -static __inline int mpt_cdblen(uint8_t, int); -static __inline int -mpt_cdblen(uint8_t cdb0, int maxlen) -{ - int group = cdb0 >> 5; - switch (group) { - case 0: - return (6); - case 1: - return (10); - case 4: - case 5: - return (12); - default: - return (16); - } -} - #ifdef INVARIANTS static __inline request_t * mpt_tag_2_req(struct mpt_softc *, uint32_t); static __inline request_t * Modified: stable/10/sys/dev/mpt/mpt_cam.c ============================================================================== --- stable/10/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:48:31 2017 (r315820) +++ stable/10/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:49:01 2017 (r315821) @@ -145,7 +145,7 @@ static void mpt_target_start_io(struct m static cam_status mpt_abort_target_ccb(struct mpt_softc *, union ccb *); static int mpt_abort_target_cmd(struct mpt_softc *, request_t *); static void mpt_scsi_tgt_status(struct mpt_softc *, union ccb *, request_t *, - uint8_t, uint8_t const *); + uint8_t, uint8_t const *, u_int); static void mpt_scsi_tgt_tsk_mgmt(struct mpt_softc *, request_t *, mpt_task_mgmt_t, tgt_resource_t *, int); @@ -4168,6 +4168,7 @@ mpt_post_target_command(struct mpt_softc fc = req->req_vbuf; fc->BufferCount = 1; fc->Function = MPI_FUNCTION_TARGET_CMD_BUFFER_POST; + fc->BufferLength = MIN(MPT_REQUEST_AREA - MPT_RQSL(mpt), UINT8_MAX); fc->MsgContext = htole32(req->index | mpt->scsi_tgt_handler_id); cb = &fc->Buffer[0]; @@ -4458,8 +4459,6 @@ mpt_target_start_io(struct mpt_softc *mp ccb->ccb_h.status |= CAM_RELEASE_SIMQ; } } else { - uint8_t *sp = NULL, sense[MPT_SENSE_SIZE]; - /* * XXX: I don't know why this seems to happen, but * XXX: completing the CCB seems to make things happy. @@ -4476,12 +4475,10 @@ mpt_target_start_io(struct mpt_softc *mp xpt_done(ccb); return; } - if (ccb->ccb_h.flags & CAM_SEND_SENSE) { - sp = sense; - memcpy(sp, &csio->sense_data, - min(csio->sense_len, MPT_SENSE_SIZE)); - } - mpt_scsi_tgt_status(mpt, ccb, cmd_req, csio->scsi_status, sp); + mpt_scsi_tgt_status(mpt, ccb, cmd_req, csio->scsi_status, + (void *)&csio->sense_data, + (ccb->ccb_h.flags & CAM_SEND_SENSE) ? + csio->sense_len : 0); } } @@ -4503,7 +4500,7 @@ mpt_scsi_tgt_local(struct mpt_softc *mpt tgt = MPT_TGT_STATE(mpt, cmd_req); if (length == 0 || tgt->resid == 0) { tgt->resid = 0; - mpt_scsi_tgt_status(mpt, NULL, cmd_req, 0, NULL); + mpt_scsi_tgt_status(mpt, NULL, cmd_req, 0, NULL, 0); return; } @@ -4656,7 +4653,7 @@ mpt_abort_target_cmd(struct mpt_softc *m static void mpt_scsi_tgt_status(struct mpt_softc *mpt, union ccb *ccb, request_t *cmd_req, - uint8_t status, uint8_t const *sense_data) + uint8_t status, uint8_t const *sense_data, u_int sense_len) { uint8_t *cmd_vbuf; mpt_tgt_state_t *tgt; @@ -4730,37 +4727,22 @@ mpt_scsi_tgt_status(struct mpt_softc *mp */ memset(rsp, 0, sizeof (MPI_TARGET_FCP_RSP_BUFFER)); - rsp[2] = status; + rsp[2] = htobe32(status); +#define MIN_FCP_RESPONSE_SIZE 24 +#ifndef WE_TRUST_AUTO_GOOD_STATUS + resplen = MIN_FCP_RESPONSE_SIZE; +#endif if (tgt->resid) { - rsp[2] |= 0x800; /* XXXX NEED MNEMONIC!!!! */ + rsp[2] |= htobe32(0x800); /* XXXX NEED MNEMONIC!!!! */ rsp[3] = htobe32(tgt->resid); -#ifdef WE_TRUST_AUTO_GOOD_STATUS - resplen = sizeof (MPI_TARGET_FCP_RSP_BUFFER); -#endif + resplen = MIN_FCP_RESPONSE_SIZE; } - if (status == SCSI_STATUS_CHECK_COND) { - int i; - - rsp[2] |= 0x200; /* XXXX NEED MNEMONIC!!!! */ - rsp[4] = htobe32(MPT_SENSE_SIZE); - if (sense_data) { - memcpy(&rsp[8], sense_data, MPT_SENSE_SIZE); - } else { - mpt_prt(mpt, "mpt_scsi_tgt_status: CHECK CONDI" - "TION but no sense data?\n"); - memset(&rsp, 0, MPT_SENSE_SIZE); - } - for (i = 8; i < (8 + (MPT_SENSE_SIZE >> 2)); i++) { - rsp[i] = htobe32(rsp[i]); - } -#ifdef WE_TRUST_AUTO_GOOD_STATUS - resplen = sizeof (MPI_TARGET_FCP_RSP_BUFFER); -#endif + if (sense_len > 0) { + rsp[2] |= htobe32(0x200); /* XXXX NEED MNEMONIC!!!! */ + rsp[4] = htobe32(sense_len); + memcpy(&rsp[6], sense_data, sense_len); + resplen = MIN_FCP_RESPONSE_SIZE + sense_len; } -#ifndef WE_TRUST_AUTO_GOOD_STATUS - resplen = sizeof (MPI_TARGET_FCP_RSP_BUFFER); -#endif - rsp[2] = htobe32(rsp[2]); } else if (mpt->is_sas) { PTR_MPI_TARGET_SSP_CMD_BUFFER ssp = (PTR_MPI_TARGET_SSP_CMD_BUFFER) cmd_vbuf; @@ -4795,9 +4777,9 @@ mpt_scsi_tgt_status(struct mpt_softc *mp } mpt_lprt(mpt, MPT_PRT_DEBUG, - "STATUS_CCB %p (wit%s sense) tag %x req %p:%u resid %u\n", - ccb, sense_data?"h" : "hout", ccb? ccb->csio.tag_id : -1, req, - req->serno, tgt->resid); + "STATUS_CCB %p (with%s sense) tag %x req %p:%u resid %u\n", + ccb, sense_len > 0 ? "" : "out", ccb ? ccb->csio.tag_id : -1, + req, req->serno, tgt->resid); if (ccb) { ccb->ccb_h.status = CAM_SIM_QUEUED | CAM_REQ_INPROG; mpt_req_timeout(req, SBT_1S * 60, mpt_timeout, ccb); @@ -4816,7 +4798,7 @@ mpt_scsi_tgt_tsk_mgmt(struct mpt_softc * inot = (struct ccb_immediate_notify *) STAILQ_FIRST(&trtp->inots); if (inot == NULL) { mpt_lprt(mpt, MPT_PRT_WARN, "no INOTSs- sending back BSY\n"); - mpt_scsi_tgt_status(mpt, NULL, req, SCSI_STATUS_BUSY, NULL); + mpt_scsi_tgt_status(mpt, NULL, req, SCSI_STATUS_BUSY, NULL, 0); return; } STAILQ_REMOVE_HEAD(&trtp->inots, sim_links.stqe); @@ -4929,8 +4911,8 @@ mpt_scsi_tgt_atio(struct mpt_softc *mpt, default: mpt_prt(mpt, "CORRUPTED TASK MGMT BITS: 0x%x\n", fc->FcpCntl[2]); - mpt_scsi_tgt_status(mpt, 0, req, - SCSI_STATUS_OK, 0); + mpt_scsi_tgt_status(mpt, NULL, req, + SCSI_STATUS_OK, NULL, 0); return; } } else { @@ -5004,23 +4986,21 @@ mpt_scsi_tgt_atio(struct mpt_softc *mpt, * REPORT LUNS gets illegal command. * All other commands get 'no such device'. */ - uint8_t *sp, cond, buf[MPT_SENSE_SIZE]; + uint8_t sense[MPT_SENSE_SIZE]; size_t len; - memset(buf, 0, MPT_SENSE_SIZE); - cond = SCSI_STATUS_CHECK_COND; - buf[0] = 0xf0; - buf[2] = 0x5; - buf[7] = 0x8; - sp = buf; + memset(sense, 0, sizeof(sense)); + sense[0] = 0xf0; + sense[2] = 0x5; + sense[7] = 0x8; tgt->tag_id = MPT_MAKE_TAGID(mpt, req, ioindex); switch (cdbp[0]) { case INQUIRY: { if (cdbp[1] != 0) { - buf[12] = 0x26; - buf[13] = 0x01; + sense[12] = 0x26; + sense[13] = 0x01; break; } len = min(tgt->resid, cdbp[4]); @@ -5033,27 +5013,28 @@ mpt_scsi_tgt_atio(struct mpt_softc *mpt, } case REQUEST_SENSE: { - buf[2] = 0x0; + sense[2] = 0x0; len = min(tgt->resid, cdbp[4]); - len = min(len, sizeof (buf)); + len = min(len, sizeof (sense)); mpt_lprt(mpt, MPT_PRT_DEBUG, "local reqsense %ld bytes\n", (long) len); mpt_scsi_tgt_local(mpt, req, lun, 1, - buf, len); + sense, len); return; } case REPORT_LUNS: mpt_lprt(mpt, MPT_PRT_DEBUG, "REPORT LUNS\n"); - buf[12] = 0x26; + sense[12] = 0x26; return; default: mpt_lprt(mpt, MPT_PRT_DEBUG, "CMD 0x%x to unmanaged lun %u\n", cdbp[0], lun); - buf[12] = 0x25; + sense[12] = 0x25; break; } - mpt_scsi_tgt_status(mpt, NULL, req, cond, sp); + mpt_scsi_tgt_status(mpt, NULL, req, + SCSI_STATUS_CHECK_COND, sense, sizeof(sense)); return; } /* otherwise, leave trtp NULL */ @@ -5068,8 +5049,8 @@ mpt_scsi_tgt_atio(struct mpt_softc *mpt, if (trtp == NULL) { mpt_prt(mpt, "task mgmt function %x but no listener\n", fct); - mpt_scsi_tgt_status(mpt, 0, req, - SCSI_STATUS_OK, 0); + mpt_scsi_tgt_status(mpt, NULL, req, + SCSI_STATUS_OK, NULL, 0); } else { mpt_scsi_tgt_tsk_mgmt(mpt, req, fct, trtp, GET_INITIATOR_INDEX(reply_desc)); @@ -5085,7 +5066,7 @@ mpt_scsi_tgt_atio(struct mpt_softc *mpt, mpt->tenabled? "QUEUE FULL" : "BUSY"); mpt_scsi_tgt_status(mpt, NULL, req, mpt->tenabled? SCSI_STATUS_QUEUE_FULL : SCSI_STATUS_BUSY, - NULL); + NULL, 0); return; } STAILQ_REMOVE_HEAD(&trtp->atios, sim_links.stqe); @@ -5096,7 +5077,7 @@ mpt_scsi_tgt_atio(struct mpt_softc *mpt, atiop->ccb_h.target_lun = lun; atiop->sense_len = 0; atiop->init_id = GET_INITIATOR_INDEX(reply_desc); - atiop->cdb_len = mpt_cdblen(cdbp[0], 16); + atiop->cdb_len = 16; memcpy(atiop->cdb_io.cdb_bytes, cdbp, atiop->cdb_len); /* @@ -5177,8 +5158,6 @@ mpt_scsi_tgt_reply_handler(struct mpt_so break; case TGT_STATE_MOVING_DATA: { - uint8_t *sp = NULL, sense[MPT_SENSE_SIZE]; - ccb = tgt->ccb; if (tgt->req == NULL) { panic("mpt: turbo target reply with null " @@ -5198,12 +5177,12 @@ mpt_scsi_tgt_reply_handler(struct mpt_so mpt_free_request(mpt, tgt->req); tgt->req = NULL; mpt_scsi_tgt_status(mpt, NULL, req, - 0, NULL); + 0, NULL, 0); return (TRUE); } tgt->ccb = NULL; tgt->nxfers++; - mpt_req_untimeout(req, mpt_timeout, ccb); + mpt_req_untimeout(tgt->req, mpt_timeout, ccb); mpt_lprt(mpt, MPT_PRT_DEBUG, "TARGET_ASSIST %p (req %p:%u) done tag 0x%x\n", ccb, tgt->req, tgt->req->serno, ccb->csio.tag_id); @@ -5239,13 +5218,11 @@ mpt_scsi_tgt_reply_handler(struct mpt_so /* * Otherwise, send status (and sense) */ - if (ccb->ccb_h.flags & CAM_SEND_SENSE) { - sp = sense; - memcpy(sp, &ccb->csio.sense_data, - min(ccb->csio.sense_len, MPT_SENSE_SIZE)); - } mpt_scsi_tgt_status(mpt, ccb, req, - ccb->csio.scsi_status, sp); + ccb->csio.scsi_status, + (void *)&ccb->csio.sense_data, + (ccb->ccb_h.flags & CAM_SEND_SENSE) ? + ccb->csio.sense_len : 0); break; } case TGT_STATE_SENDING_STATUS: @@ -5266,7 +5243,7 @@ mpt_scsi_tgt_reply_handler(struct mpt_so TGT_STATE_MOVING_DATA_AND_STATUS) { tgt->nxfers++; } - mpt_req_untimeout(req, mpt_timeout, ccb); + mpt_req_untimeout(tgt->req, mpt_timeout, ccb); if (ccb->ccb_h.flags & CAM_SEND_SENSE) { ccb->ccb_h.status |= CAM_SENT_SENSE; } From owner-svn-src-stable-10@freebsd.org Thu Mar 23 06:50:47 2017 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 EA6DAD19DC1; Thu, 23 Mar 2017 06:50:47 +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 9D61F18F1; Thu, 23 Mar 2017 06:50:47 +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 v2N6ok5f057428; Thu, 23 Mar 2017 06:50:46 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N6okA7057426; Thu, 23 Mar 2017 06:50:46 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703230650.v2N6okA7057426@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 23 Mar 2017 06:50: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: r315824 - stable/10/sys/dev/mpt 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.23 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, 23 Mar 2017 06:50:48 -0000 Author: mav Date: Thu Mar 23 06:50:46 2017 New Revision: 315824 URL: https://svnweb.freebsd.org/changeset/base/315824 Log: MFC r315002: Improve residuals reporting in target mode. Modified: stable/10/sys/dev/mpt/mpt.h stable/10/sys/dev/mpt/mpt_cam.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/mpt/mpt.h ============================================================================== --- stable/10/sys/dev/mpt/mpt.h Thu Mar 23 06:50:13 2017 (r315823) +++ stable/10/sys/dev/mpt/mpt.h Thu Mar 23 06:50:46 2017 (r315824) @@ -331,8 +331,8 @@ typedef struct mpt_config_params { /**************************** MPI Target State Info ***************************/ typedef struct { uint32_t reply_desc; /* current reply descriptor */ - uint32_t resid; /* current data residual */ uint32_t bytes_xfered; /* current relative offset */ + int resid; /* current data residual */ union ccb *ccb; /* pointer to currently active ccb */ request_t *req; /* pointer to currently active assist request */ uint32_t Modified: stable/10/sys/dev/mpt/mpt_cam.c ============================================================================== --- stable/10/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:50:13 2017 (r315823) +++ stable/10/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:50:46 2017 (r315824) @@ -4430,6 +4430,7 @@ mpt_target_start_io(struct mpt_softc *mp /* * XXX Should be done after data transfer completes? */ + csio->resid = csio->dxfer_len - ta->DataLength; tgt->resid -= csio->dxfer_len; tgt->bytes_xfered += csio->dxfer_len; @@ -4732,7 +4733,11 @@ mpt_scsi_tgt_status(struct mpt_softc *mp #ifndef WE_TRUST_AUTO_GOOD_STATUS resplen = MIN_FCP_RESPONSE_SIZE; #endif - if (tgt->resid) { + if (tgt->resid < 0) { + rsp[2] |= htobe32(0x400); /* XXXX NEED MNEMONIC!!!! */ + rsp[3] = htobe32(-tgt->resid); + resplen = MIN_FCP_RESPONSE_SIZE; + } else if (tgt->resid > 0) { rsp[2] |= htobe32(0x800); /* XXXX NEED MNEMONIC!!!! */ rsp[3] = htobe32(tgt->resid); resplen = MIN_FCP_RESPONSE_SIZE; From owner-svn-src-stable-10@freebsd.org Thu Mar 23 06:52:30 2017 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 D4A3ED19EF7; Thu, 23 Mar 2017 06:52:30 +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 947CE1E08; Thu, 23 Mar 2017 06:52:30 +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 v2N6qTGf061290; Thu, 23 Mar 2017 06:52:29 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N6qTA6061288; Thu, 23 Mar 2017 06:52:29 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703230652.v2N6qTA6061288@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 23 Mar 2017 06:52:29 +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: r315826 - stable/10/sys/dev/mpt 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.23 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, 23 Mar 2017 06:52:30 -0000 Author: mav Date: Thu Mar 23 06:52:29 2017 New Revision: 315826 URL: https://svnweb.freebsd.org/changeset/base/315826 Log: MFC r315004: Add PIM_EXTLUNS support to mpt(4). Target mode is still limited to 256 LUNs due to the way driver is written, but initiator can now use full 8 byte LUN space. Modified: stable/10/sys/dev/mpt/mpt_cam.c stable/10/sys/dev/mpt/mpt_debug.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/mpt/mpt_cam.c ============================================================================== --- stable/10/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:51:53 2017 (r315825) +++ stable/10/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:52:29 2017 (r315826) @@ -133,7 +133,7 @@ static void mpt_recovery_thread(void *ar static void mpt_recover_commands(struct mpt_softc *mpt); static int mpt_scsi_send_tmf(struct mpt_softc *, u_int, u_int, u_int, - u_int, u_int, u_int, int); + target_id_t, lun_id_t, u_int, int); static void mpt_fc_post_els(struct mpt_softc *mpt, request_t *, int); static void mpt_post_target_command(struct mpt_softc *, request_t *, int); @@ -2133,13 +2133,7 @@ mpt_start(struct cam_sim *sim, union ccb /* Which physical device to do the I/O on */ mpt_req->TargetID = tgt; - /* We assume a single level LUN type */ - if (ccb->ccb_h.target_lun >= MPT_MAX_LUNS) { - mpt_req->LUN[0] = 0x40 | ((ccb->ccb_h.target_lun >> 8) & 0x3f); - mpt_req->LUN[1] = ccb->ccb_h.target_lun & 0xff; - } else { - mpt_req->LUN[1] = ccb->ccb_h.target_lun; - } + be64enc(mpt_req->LUN, CAM_EXTLUN_BYTE_SWIZZLE(ccb->ccb_h.target_lun)); /* Set the direction of the transfer */ if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) { @@ -3585,7 +3579,8 @@ mpt_action(struct cam_sim *sim, union cc */ cpi->protocol = PROTO_SCSI; if (mpt->is_fc) { - cpi->hba_misc = PIM_NOBUSRESET | PIM_UNMAPPED; + cpi->hba_misc = PIM_NOBUSRESET | PIM_UNMAPPED | + PIM_EXTLUNS; cpi->base_transfer_speed = 100000; cpi->hba_inquiry = PI_TAG_ABLE; cpi->transport = XPORT_FC; @@ -3597,14 +3592,16 @@ mpt_action(struct cam_sim *sim, union cc cpi->xport_specific.fc.bitrate = 100000 * mpt->mpt_fcport_speed; } else if (mpt->is_sas) { - cpi->hba_misc = PIM_NOBUSRESET | PIM_UNMAPPED; + cpi->hba_misc = PIM_NOBUSRESET | PIM_UNMAPPED | + PIM_EXTLUNS; cpi->base_transfer_speed = 300000; cpi->hba_inquiry = PI_TAG_ABLE; cpi->transport = XPORT_SAS; cpi->transport_version = 0; cpi->protocol_version = SCSI_REV_SPC2; } else { - cpi->hba_misc = PIM_SEQSCAN | PIM_UNMAPPED; + cpi->hba_misc = PIM_SEQSCAN | PIM_UNMAPPED | + PIM_EXTLUNS; cpi->base_transfer_speed = 3300; cpi->hba_inquiry = PI_SDTR_ABLE|PI_TAG_ABLE|PI_WIDE_16; cpi->transport = XPORT_SPI; @@ -3913,7 +3910,8 @@ mpt_recovery_thread(void *arg) static int mpt_scsi_send_tmf(struct mpt_softc *mpt, u_int type, u_int flags, - u_int channel, u_int target, u_int lun, u_int abort_ctx, int sleep_ok) + u_int channel, target_id_t target, lun_id_t lun, u_int abort_ctx, + int sleep_ok) { MSG_SCSI_TASK_MGMT *tmf_req; int error; @@ -3941,12 +3939,7 @@ mpt_scsi_send_tmf(struct mpt_softc *mpt, tmf_req->MsgFlags = flags; tmf_req->MsgContext = htole32(mpt->tmf_req->index | scsi_tmf_handler_id); - if (lun > MPT_MAX_LUNS) { - tmf_req->LUN[0] = 0x40 | ((lun >> 8) & 0x3f); - tmf_req->LUN[1] = lun & 0xff; - } else { - tmf_req->LUN[1] = lun; - } + be64enc(tmf_req->LUN, CAM_EXTLUN_BYTE_SWIZZLE(lun)); tmf_req->TaskMsgContext = abort_ctx; mpt_lprt(mpt, MPT_PRT_DEBUG, @@ -4413,13 +4406,7 @@ mpt_target_start_io(struct mpt_softc *mp ta->Function = MPI_FUNCTION_TARGET_ASSIST; ta->MsgContext = htole32(req->index | mpt->scsi_tgt_handler_id); ta->ReplyWord = htole32(tgt->reply_desc); - if (csio->ccb_h.target_lun > MPT_MAX_LUNS) { - ta->LUN[0] = - 0x40 | ((csio->ccb_h.target_lun >> 8) & 0x3f); - ta->LUN[1] = csio->ccb_h.target_lun & 0xff; - } else { - ta->LUN[1] = csio->ccb_h.target_lun; - } + be64enc(ta->LUN, CAM_EXTLUN_BYTE_SWIZZLE(csio->ccb_h.target_lun)); ta->RelativeOffset = tgt->bytes_xfered; ta->DataLength = ccb->csio.dxfer_len; @@ -4485,7 +4472,7 @@ mpt_target_start_io(struct mpt_softc *mp static void mpt_scsi_tgt_local(struct mpt_softc *mpt, request_t *cmd_req, - uint32_t lun, int send, uint8_t *data, size_t length) + lun_id_t lun, int send, uint8_t *data, size_t length) { mpt_tgt_state_t *tgt; PTR_MSG_TARGET_ASSIST_REQUEST ta; @@ -4525,12 +4512,7 @@ mpt_scsi_tgt_local(struct mpt_softc *mpt ta->Function = MPI_FUNCTION_TARGET_ASSIST; ta->MsgContext = htole32(req->index | mpt->scsi_tgt_handler_id); ta->ReplyWord = htole32(tgt->reply_desc); - if (lun > MPT_MAX_LUNS) { - ta->LUN[0] = 0x40 | ((lun >> 8) & 0x3f); - ta->LUN[1] = lun & 0xff; - } else { - ta->LUN[1] = lun; - } + be64enc(ta->LUN, CAM_EXTLUN_BYTE_SWIZZLE(lun)); ta->RelativeOffset = 0; ta->DataLength = length; @@ -4957,21 +4939,7 @@ mpt_scsi_tgt_atio(struct mpt_softc *mpt, itag = sp->Tag; } - /* - * Generate a simple lun - */ - switch (lunptr[0] & 0xc0) { - case 0x40: - lun = ((lunptr[0] & 0x3f) << 8) | lunptr[1]; - break; - case 0: - lun = lunptr[1]; - break; - default: - mpt_lprt(mpt, MPT_PRT_ERROR, "cannot handle this type lun\n"); - lun = 0xffff; - break; - } + lun = CAM_EXTLUN_BYTE_SWIZZLE(be64dec(lunptr)); /* * Deal with non-enabled or bad luns here. Modified: stable/10/sys/dev/mpt/mpt_debug.c ============================================================================== --- stable/10/sys/dev/mpt/mpt_debug.c Thu Mar 23 06:51:53 2017 (r315825) +++ stable/10/sys/dev/mpt/mpt_debug.c Thu Mar 23 06:52:29 2017 (r315826) @@ -536,7 +536,7 @@ mpt_print_scsi_io_request(MSG_SCSI_IO_RE printf("\tBus: %d\n", msg->Bus); printf("\tTargetID %d\n", msg->TargetID); printf("\tSenseBufferLength %d\n", msg->SenseBufferLength); - printf("\tLUN: 0x%0x\n", msg->LUN[1]); + printf("\tLUN: 0x%jx\n", (uintmax_t)be64dec(msg->LUN)); printf("\tControl 0x%08x ", msg->Control); #define MPI_PRINT_FIELD(x) \ case MPI_SCSIIO_CONTROL_ ## x : \ @@ -585,7 +585,7 @@ mpt_print_scsi_tmf_request(MSG_SCSI_TASK { mpt_print_request_hdr((MSG_REQUEST_HEADER *)msg); - printf("\tLun 0x%02x\n", msg->LUN[1]); + printf("\tLun 0x%jx\n", (uintmax_t)be64dec(msg->LUN)); printf("\tTaskType %s\n", mpt_scsi_tm_type(msg->TaskType)); printf("\tTaskMsgContext 0x%08x\n", msg->TaskMsgContext); } @@ -600,7 +600,7 @@ mpt_print_scsi_target_assist_request(PTR printf("\tTargetAssist 0x%02x\n", msg->TargetAssistFlags); printf("\tQueueTag 0x%04x\n", msg->QueueTag); printf("\tReplyWord 0x%08x\n", msg->ReplyWord); - printf("\tLun 0x%02x\n", msg->LUN[1]); + printf("\tLun 0x%jx\n", (uintmax_t)be64dec(msg->LUN)); printf("\tRelativeOff 0x%08x\n", msg->RelativeOffset); printf("\tDataLength 0x%08x\n", msg->DataLength); mpt_dump_sgl(msg->SGL, 0); @@ -616,7 +616,7 @@ mpt_print_scsi_target_status_send_reques printf("\tStatusFlags 0x%02x\n", msg->StatusFlags); printf("\tQueueTag 0x%04x\n", msg->QueueTag); printf("\tReplyWord 0x%08x\n", msg->ReplyWord); - printf("\tLun 0x%02x\n", msg->LUN[1]); + printf("\tLun 0x%jx\n", (uintmax_t)be64dec(msg->LUN)); x.u.Simple = msg->StatusDataSGE; mpt_dump_sgl(&x, 0); } From owner-svn-src-stable-10@freebsd.org Thu Mar 23 06:55:33 2017 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 DD197D19190; Thu, 23 Mar 2017 06:55:33 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A93F63CB; Thu, 23 Mar 2017 06:55:33 +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 v2N6tWR9061536; Thu, 23 Mar 2017 06:55:32 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N6tWTx061534; Thu, 23 Mar 2017 06:55:32 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703230655.v2N6tWTx061534@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 23 Mar 2017 06:55: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: r315828 - stable/10/sys/dev/mpt 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.23 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, 23 Mar 2017 06:55:34 -0000 Author: mav Date: Thu Mar 23 06:55:32 2017 New Revision: 315828 URL: https://svnweb.freebsd.org/changeset/base/315828 Log: MFC r315067: Partially fix target task management requests handling. - XPT_NOTIFY_ACKNOWLEDGE was not handled, causing stuck requests. - XPT_ABORT was not even trying to abort active ATIOs/INOTs. - Initiator's tag was not stored and not used where needed. - List of TM request types needed update. - mpt_scsi_tgt_status() missed some useful debugging. After this change global TM requests, such as reset, should work properly. ABORT TASK (ABTS) requests are still not passes to CTL, that is not good and should be fixed. Modified: stable/10/sys/dev/mpt/mpt.h stable/10/sys/dev/mpt/mpt_cam.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/mpt/mpt.h ============================================================================== --- stable/10/sys/dev/mpt/mpt.h Thu Mar 23 06:53:31 2017 (r315827) +++ stable/10/sys/dev/mpt/mpt.h Thu Mar 23 06:55:32 2017 (r315828) @@ -338,7 +338,8 @@ typedef struct { uint32_t is_local : 1, nxfers : 31; - uint32_t tag_id; + uint32_t tag_id; /* Our local tag. */ + uint16_t itag; /* Initiator tag. */ enum { TGT_STATE_NIL, TGT_STATE_LOADING, @@ -1053,11 +1054,13 @@ mpt_req_not_spcl(struct mpt_softc *mpt, * Task Management Types, purely for internal consumption */ typedef enum { - MPT_ABORT_TASK_SET=1234, + MPT_QUERY_TASK_SET=1234, + MPT_ABORT_TASK_SET, MPT_CLEAR_TASK_SET, + MPT_QUERY_ASYNC_EVENT, + MPT_LOGICAL_UNIT_RESET, MPT_TARGET_RESET, MPT_CLEAR_ACA, - MPT_TERMINATE_TASK, MPT_NIL_TMT_VALUE=5678 } mpt_task_mgmt_t; Modified: stable/10/sys/dev/mpt/mpt_cam.c ============================================================================== --- stable/10/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:53:31 2017 (r315827) +++ stable/10/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:55:32 2017 (r315828) @@ -2937,7 +2937,10 @@ mpt_fc_els_reply_handler(struct mpt_soft } else if (rctl == ABTS && type == 0) { uint16_t rx_id = le16toh(rp->Rxid); uint16_t ox_id = le16toh(rp->Oxid); + mpt_tgt_state_t *tgt; request_t *tgt_req = NULL; + union ccb *ccb; + uint32_t ct_id; mpt_prt(mpt, "ELS: ABTS OX_ID 0x%x RX_ID 0x%x from 0x%08x%08x\n", @@ -2950,47 +2953,37 @@ mpt_fc_els_reply_handler(struct mpt_soft } else { tgt_req = mpt->tgt_cmd_ptrs[rx_id]; } - if (tgt_req) { - mpt_tgt_state_t *tgt = MPT_TGT_STATE(mpt, tgt_req); - union ccb *ccb; - uint32_t ct_id; - - /* - * Check to make sure we have the correct command - * The reply descriptor in the target state should - * should contain an IoIndex that should match the - * RX_ID. - * - * It'd be nice to have OX_ID to crosscheck with - * as well. - */ - ct_id = GET_IO_INDEX(tgt->reply_desc); - - if (ct_id != rx_id) { - mpt_lprt(mpt, MPT_PRT_ERROR, "ABORT Mismatch: " - "RX_ID received=0x%x; RX_ID in cmd=0x%x\n", - rx_id, ct_id); - goto skip; - } - - ccb = tgt->ccb; - if (ccb) { - mpt_prt(mpt, - "CCB (%p): lun %u flags %x status %x\n", - ccb, ccb->ccb_h.target_lun, - ccb->ccb_h.flags, ccb->ccb_h.status); - } - mpt_prt(mpt, "target state 0x%x resid %u xfrd %u rpwrd " - "%x nxfers %x\n", tgt->state, - tgt->resid, tgt->bytes_xfered, tgt->reply_desc, - tgt->nxfers); - skip: - if (mpt_abort_target_cmd(mpt, tgt_req)) { - mpt_prt(mpt, "unable to start TargetAbort\n"); - } - } else { + if (tgt_req == NULL) { mpt_prt(mpt, "no back pointer for RX_ID 0x%x\n", rx_id); + goto skip; } + tgt = MPT_TGT_STATE(mpt, tgt_req); + + /* Check to make sure we have the correct command. */ + ct_id = GET_IO_INDEX(tgt->reply_desc); + if (ct_id != rx_id) { + mpt_lprt(mpt, MPT_PRT_ERROR, "ABORT Mismatch: " + "RX_ID received=0x%x, in cmd=0x%x\n", rx_id, ct_id); + goto skip; + } + if (tgt->itag != ox_id) { + mpt_lprt(mpt, MPT_PRT_ERROR, "ABORT Mismatch: " + "OX_ID received=0x%x, in cmd=0x%x\n", ox_id, tgt->itag); + goto skip; + } + + if ((ccb = tgt->ccb) != NULL) { + mpt_prt(mpt, "CCB (%p): lun %jx flags %x status %x\n", + ccb, (uintmax_t)ccb->ccb_h.target_lun, + ccb->ccb_h.flags, ccb->ccb_h.status); + } + mpt_prt(mpt, "target state 0x%x resid %u xfrd %u rpwrd " + "%x nxfers %x\n", tgt->state, tgt->resid, + tgt->bytes_xfered, tgt->reply_desc, tgt->nxfers); + if (mpt_abort_target_cmd(mpt, tgt_req)) + mpt_prt(mpt, "unable to start TargetAbort\n"); + +skip: memset(elsbuf, 0, 5 * (sizeof (U32))); elsbuf[0] = htobe32(0); elsbuf[1] = htobe32((ox_id << 16) | rx_id); @@ -3652,7 +3645,6 @@ mpt_action(struct cam_sim *sim, union cc } break; } - case XPT_NOTIFY_ACKNOWLEDGE: /* recycle notify ack */ case XPT_IMMEDIATE_NOTIFY: /* Add Immediate Notify Resource */ case XPT_ACCEPT_TARGET_IO: /* Add Accept Target IO Resource */ { @@ -3678,17 +3670,24 @@ mpt_action(struct cam_sim *sim, union cc "Put FREE ATIO %p lun %d\n", ccb, lun); STAILQ_INSERT_TAIL(&trtp->atios, &ccb->ccb_h, sim_links.stqe); - } else if (ccb->ccb_h.func_code == XPT_IMMEDIATE_NOTIFY) { + } else { mpt_lprt(mpt, MPT_PRT_DEBUG1, "Put FREE INOT lun %d\n", lun); STAILQ_INSERT_TAIL(&trtp->inots, &ccb->ccb_h, sim_links.stqe); - } else { - mpt_lprt(mpt, MPT_PRT_ALWAYS, "Got Notify ACK\n"); } mpt_set_ccb_status(ccb, CAM_REQ_INPROG); return; } + case XPT_NOTIFY_ACKNOWLEDGE: /* Task management request done. */ + { + request_t *req = MPT_TAG_2_REQ(mpt, ccb->cna2.tag_id); + + mpt_lprt(mpt, MPT_PRT_DEBUG, "Got Notify ACK\n"); + mpt_scsi_tgt_status(mpt, NULL, req, 0, NULL, 0); + mpt_set_ccb_status(ccb, CAM_REQ_CMP); + break; + } case XPT_CONT_TARGET_IO: mpt_target_start_io(mpt, ccb); return; @@ -4556,40 +4555,44 @@ mpt_abort_target_ccb(struct mpt_softc *m { struct mpt_hdr_stailq *lp; struct ccb_hdr *srch; - int found = 0; union ccb *accb = ccb->cab.abort_ccb; tgt_resource_t *trtp; + mpt_tgt_state_t *tgt; + request_t *req; + uint32_t tag; mpt_lprt(mpt, MPT_PRT_DEBUG, "aborting ccb %p\n", accb); - - if (ccb->ccb_h.target_lun == CAM_LUN_WILDCARD) { + if (ccb->ccb_h.target_lun == CAM_LUN_WILDCARD) trtp = &mpt->trt_wildcard; - } else { + else trtp = &mpt->trt[ccb->ccb_h.target_lun]; - } - if (accb->ccb_h.func_code == XPT_ACCEPT_TARGET_IO) { lp = &trtp->atios; - } else if (accb->ccb_h.func_code == XPT_IMMEDIATE_NOTIFY) { - lp = &trtp->inots; + tag = accb->atio.tag_id; } else { - return (CAM_REQ_INVALID); + lp = &trtp->inots; + tag = accb->cin1.tag_id; } + /* Search the CCB among queued. */ STAILQ_FOREACH(srch, lp, sim_links.stqe) { - if (srch == &accb->ccb_h) { - found = 1; - STAILQ_REMOVE(lp, srch, ccb_hdr, sim_links.stqe); - break; - } - } - if (found) { + if (srch != &accb->ccb_h) + continue; + STAILQ_REMOVE(lp, srch, ccb_hdr, sim_links.stqe); accb->ccb_h.status = CAM_REQ_ABORTED; xpt_done(accb); return (CAM_REQ_CMP); } - mpt_prt(mpt, "mpt_abort_tgt_ccb: CCB %p not found\n", ccb); - return (CAM_PATH_INVALID); + + /* Search the CCB among running. */ + req = MPT_TAG_2_REQ(mpt, tag); + tgt = MPT_TGT_STATE(mpt, req); + if (tgt->tag_id == tag) { + mpt_abort_target_cmd(mpt, req); + return (CAM_REQ_CMP); + } + + return (CAM_UA_ABORT); } /* @@ -4685,6 +4688,7 @@ mpt_scsi_tgt_status(struct mpt_softc *mp paddr += MPT_RQSL(mpt); memset(tp, 0, sizeof (*tp)); + tp->StatusCode = status; tp->Function = MPI_FUNCTION_TARGET_STATUS_SEND; if (mpt->is_fc) { PTR_MPI_TARGET_FCP_CMD_BUFFER fc = @@ -4737,7 +4741,6 @@ mpt_scsi_tgt_status(struct mpt_softc *mp } else { PTR_MPI_TARGET_SCSI_SPI_CMD_BUFFER sp = (PTR_MPI_TARGET_SCSI_SPI_CMD_BUFFER) cmd_vbuf; - tp->StatusCode = status; tp->QueueTag = htole16(sp->Tag); memcpy(tp->LUN, sp->LogicalUnitNumber, sizeof (tp->LUN)); } @@ -4752,12 +4755,11 @@ mpt_scsi_tgt_status(struct mpt_softc *mp tp->MsgFlags |= TARGET_STATUS_SEND_FLAGS_AUTO_GOOD_STATUS; } else { tp->StatusDataSGE.u.Address32 = htole32((uint32_t) paddr); - fl = - MPI_SGE_FLAGS_HOST_TO_IOC | - MPI_SGE_FLAGS_SIMPLE_ELEMENT | - MPI_SGE_FLAGS_LAST_ELEMENT | - MPI_SGE_FLAGS_END_OF_LIST | - MPI_SGE_FLAGS_END_OF_BUFFER; + fl = MPI_SGE_FLAGS_HOST_TO_IOC | + MPI_SGE_FLAGS_SIMPLE_ELEMENT | + MPI_SGE_FLAGS_LAST_ELEMENT | + MPI_SGE_FLAGS_END_OF_LIST | + MPI_SGE_FLAGS_END_OF_BUFFER; fl <<= MPI_SGE_FLAGS_SHIFT; fl |= resplen; tp->StatusDataSGE.FlagsLength = htole32(fl); @@ -4765,8 +4767,10 @@ mpt_scsi_tgt_status(struct mpt_softc *mp mpt_lprt(mpt, MPT_PRT_DEBUG, "STATUS_CCB %p (with%s sense) tag %x req %p:%u resid %u\n", - ccb, sense_len > 0 ? "" : "out", ccb ? ccb->csio.tag_id : -1, + ccb, sense_len > 0 ? "" : "out", tgt->tag_id, req, req->serno, tgt->resid); + if (mpt->verbose > MPT_PRT_DEBUG) + mpt_print_request(req->req_vbuf); if (ccb) { ccb->ccb_h.status = CAM_SIM_QUEUED | CAM_REQ_INPROG; mpt_req_timeout(req, SBT_1S * 60, mpt_timeout, ccb); @@ -4793,36 +4797,40 @@ mpt_scsi_tgt_tsk_mgmt(struct mpt_softc * "Get FREE INOT %p lun %d\n", inot, inot->ccb_h.target_lun); inot->initiator_id = init_id; /* XXX */ + inot->tag_id = tgt->tag_id; + inot->seq_id = 0; /* * This is a somewhat grotesque attempt to map from task management * to old style SCSI messages. God help us all. */ switch (fc) { + case MPT_QUERY_TASK_SET: + inot->arg = MSG_QUERY_TASK_SET; + break; case MPT_ABORT_TASK_SET: - inot->arg = MSG_ABORT_TAG; + inot->arg = MSG_ABORT_TASK_SET; break; case MPT_CLEAR_TASK_SET: inot->arg = MSG_CLEAR_TASK_SET; break; + case MPT_QUERY_ASYNC_EVENT: + inot->arg = MSG_QUERY_ASYNC_EVENT; + break; + case MPT_LOGICAL_UNIT_RESET: + inot->arg = MSG_LOGICAL_UNIT_RESET; + break; case MPT_TARGET_RESET: inot->arg = MSG_TARGET_RESET; break; case MPT_CLEAR_ACA: inot->arg = MSG_CLEAR_ACA; break; - case MPT_TERMINATE_TASK: - inot->arg = MSG_ABORT_TAG; - break; default: inot->arg = MSG_NOOP; break; } - /* - * XXX KDM we need the sequence/tag number for the target of the - * task management operation, especially if it is an abort. - */ tgt->ccb = (union ccb *) inot; - inot->ccb_h.status = CAM_MESSAGE_RECV|CAM_DEV_QFRZN; + inot->ccb_h.status = CAM_MESSAGE_RECV; xpt_done((union ccb *)inot); } @@ -4843,7 +4851,6 @@ mpt_scsi_tgt_atio(struct mpt_softc *mpt, tgt_resource_t *trtp = NULL; U8 *lunptr; U8 *vbuf; - U16 itag; U16 ioindex; mpt_task_mgmt_t fct = MPT_NIL_TMT_VALUE; uint8_t *cdbp; @@ -4853,6 +4860,12 @@ mpt_scsi_tgt_atio(struct mpt_softc *mpt, */ vbuf = req->req_vbuf; vbuf += MPT_RQSL(mpt); + if (mpt->verbose >= MPT_PRT_DEBUG) { + mpt_dump_data(mpt, "mpt_scsi_tgt_atio response", vbuf, + max(sizeof (MPI_TARGET_FCP_CMD_BUFFER), + max(sizeof (MPI_TARGET_SSP_CMD_BUFFER), + sizeof (MPI_TARGET_SCSI_SPI_CMD_BUFFER)))); + } /* * Get our state pointer set up. @@ -4866,12 +4879,16 @@ mpt_scsi_tgt_atio(struct mpt_softc *mpt, tgt->state = TGT_STATE_IN_CAM; tgt->reply_desc = reply_desc; ioindex = GET_IO_INDEX(reply_desc); - if (mpt->verbose >= MPT_PRT_DEBUG) { - mpt_dump_data(mpt, "mpt_scsi_tgt_atio response", vbuf, - max(sizeof (MPI_TARGET_FCP_CMD_BUFFER), - max(sizeof (MPI_TARGET_SSP_CMD_BUFFER), - sizeof (MPI_TARGET_SCSI_SPI_CMD_BUFFER)))); - } + + /* + * The tag we construct here allows us to find the + * original request that the command came in with. + * + * This way we don't have to depend on anything but the + * tag to find things when CCBs show back up from CAM. + */ + tgt->tag_id = MPT_MAKE_TAGID(mpt, req, ioindex); + if (mpt->is_fc) { PTR_MPI_TARGET_FCP_CMD_BUFFER fc; fc = (PTR_MPI_TARGET_FCP_CMD_BUFFER) vbuf; @@ -4880,21 +4897,27 @@ mpt_scsi_tgt_atio(struct mpt_softc *mpt, * Task Management Request */ switch (fc->FcpCntl[2]) { + case 0x1: + fct = MPT_QUERY_TASK_SET; + break; case 0x2: fct = MPT_ABORT_TASK_SET; break; case 0x4: fct = MPT_CLEAR_TASK_SET; break; + case 0x8: + fct = MPT_QUERY_ASYNC_EVENT; + break; + case 0x10: + fct = MPT_LOGICAL_UNIT_RESET; + break; case 0x20: fct = MPT_TARGET_RESET; break; case 0x40: fct = MPT_CLEAR_ACA; break; - case 0x80: - fct = MPT_TERMINATE_TASK; - break; default: mpt_prt(mpt, "CORRUPTED TASK MGMT BITS: 0x%x\n", fc->FcpCntl[2]); @@ -4924,19 +4947,19 @@ mpt_scsi_tgt_atio(struct mpt_softc *mpt, tgt->resid = be32toh(fc->FcpDl); cdbp = fc->FcpCdb; lunptr = fc->FcpLun; - itag = be16toh(fc->OptionalOxid); + tgt->itag = fc->OptionalOxid; } else if (mpt->is_sas) { PTR_MPI_TARGET_SSP_CMD_BUFFER ssp; ssp = (PTR_MPI_TARGET_SSP_CMD_BUFFER) vbuf; cdbp = ssp->CDB; lunptr = ssp->LogicalUnitNumber; - itag = ssp->InitiatorTag; + tgt->itag = ssp->InitiatorTag; } else { PTR_MPI_TARGET_SCSI_SPI_CMD_BUFFER sp; sp = (PTR_MPI_TARGET_SCSI_SPI_CMD_BUFFER) vbuf; cdbp = sp->CDB; lunptr = sp->LogicalUnitNumber; - itag = sp->Tag; + tgt->itag = sp->Tag; } lun = CAM_EXTLUN_BYTE_SWIZZLE(be64dec(lunptr)); @@ -4966,7 +4989,6 @@ mpt_scsi_tgt_atio(struct mpt_softc *mpt, sense[0] = 0xf0; sense[2] = 0x5; sense[7] = 0x8; - tgt->tag_id = MPT_MAKE_TAGID(mpt, req, ioindex); switch (cdbp[0]) { case INQUIRY: @@ -5049,19 +5071,10 @@ mpt_scsi_tgt_atio(struct mpt_softc *mpt, atiop->ccb_h.status = CAM_CDB_RECVD; atiop->ccb_h.target_lun = lun; atiop->sense_len = 0; + atiop->tag_id = tgt->tag_id; atiop->init_id = GET_INITIATOR_INDEX(reply_desc); atiop->cdb_len = 16; memcpy(atiop->cdb_io.cdb_bytes, cdbp, atiop->cdb_len); - - /* - * The tag we construct here allows us to find the - * original request that the command came in with. - * - * This way we don't have to depend on anything but the - * tag to find things when CCBs show back up from CAM. - */ - atiop->tag_id = MPT_MAKE_TAGID(mpt, req, ioindex); - tgt->tag_id = atiop->tag_id; if (tag_action) { atiop->tag_action = tag_action; atiop->ccb_h.flags |= CAM_TAG_ACTION_VALID; @@ -5075,7 +5088,7 @@ mpt_scsi_tgt_atio(struct mpt_softc *mpt, (i == (atiop->cdb_len - 1))? '>' : ' '); } mpt_prtc(mpt, " itag %x tag %x rdesc %x dl=%u\n", - itag, atiop->tag_id, tgt->reply_desc, tgt->resid); + tgt->itag, tgt->tag_id, tgt->reply_desc, tgt->resid); } xpt_done((union ccb *)atiop); @@ -5087,9 +5100,9 @@ mpt_tgt_dump_tgt_state(struct mpt_softc mpt_tgt_state_t *tgt = MPT_TGT_STATE(mpt, req); mpt_prt(mpt, "req %p:%u tgt:rdesc 0x%x resid %u xfrd %u ccb %p treq %p " - "nx %d tag 0x%08x state=%d\n", req, req->serno, tgt->reply_desc, - tgt->resid, tgt->bytes_xfered, tgt->ccb, tgt->req, tgt->nxfers, - tgt->tag_id, tgt->state); + "nx %d tag 0x%08x itag 0x%04x state=%d\n", req, req->serno, + tgt->reply_desc, tgt->resid, tgt->bytes_xfered, tgt->ccb, + tgt->req, tgt->nxfers, tgt->tag_id, tgt->itag, tgt->state); } static void @@ -5240,7 +5253,7 @@ mpt_scsi_tgt_reply_handler(struct mpt_so tgt->ccb = NULL; } else { mpt_lprt(mpt, MPT_PRT_DEBUG, - "TARGET_STATUS non-CAM for req %p:%u\n", + "TARGET_STATUS non-CAM for req %p:%u\n", tgt->req, tgt->req->serno); } TAILQ_REMOVE(&mpt->request_pending_list, From owner-svn-src-stable-10@freebsd.org Thu Mar 23 07:56:14 2017 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 DA32BD19EF5; Thu, 23 Mar 2017 07:56:14 +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 9908B1F0C; Thu, 23 Mar 2017 07:56:14 +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 v2N7uDrl085811; Thu, 23 Mar 2017 07:56:13 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N7uDHr085810; Thu, 23 Mar 2017 07:56:13 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201703230756.v2N7uDHr085810@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 23 Mar 2017 07:56:13 +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: r315831 - stable/10/sys/dev/firewire 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.23 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, 23 Mar 2017 07:56:15 -0000 Author: avg Date: Thu Mar 23 07:56:13 2017 New Revision: 315831 URL: https://svnweb.freebsd.org/changeset/base/315831 Log: MFC r314864: firewire/sbp: try to improve locking, plus a few style nits Modified: stable/10/sys/dev/firewire/sbp.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/firewire/sbp.c ============================================================================== --- stable/10/sys/dev/firewire/sbp.c Thu Mar 23 07:56:07 2017 (r315830) +++ stable/10/sys/dev/firewire/sbp.c Thu Mar 23 07:56:13 2017 (r315831) @@ -455,7 +455,6 @@ sbp_alloc_lun(struct sbp_target *target) int maxlun, lun, i; sbp = target->sbp; - SBP_LOCK_ASSERT(sbp); crom_init_context(&cc, target->fwdev->csrrom); /* XXX shoud parse appropriate unit directories only */ maxlun = -1; @@ -588,7 +587,9 @@ END_DEBUG goto next; } callout_init_mtx(&ocb->timer, &sbp->mtx, 0); + SBP_LOCK(sbp); sbp_free_ocb(sdev, ocb); + SBP_UNLOCK(sbp); } next: crom_next(&cc); @@ -718,9 +719,8 @@ END_DEBUG && crom_has_specver((fwdev)->csrrom, CSRVAL_ANSIT10, CSRVAL_T10SBP2)) static void -sbp_probe_target(void *arg) +sbp_probe_target(struct sbp_target *target) { - struct sbp_target *target = (struct sbp_target *)arg; struct sbp_softc *sbp = target->sbp; struct sbp_dev *sdev; int i, alive; @@ -732,8 +732,6 @@ SBP_DEBUG(1) (!alive) ? " not " : ""); END_DEBUG - sbp = target->sbp; - SBP_LOCK_ASSERT(sbp); sbp_alloc_lun(target); /* XXX untimeout mgm_ocb and dequeue */ @@ -749,7 +747,9 @@ END_DEBUG sbp_probe_lun(sdev); sbp_show_sdev_info(sdev); + SBP_LOCK(sbp); sbp_abort_all_ocbs(sdev, CAM_SCSI_BUS_RESET); + SBP_UNLOCK(sbp); switch (sdev->status) { case SBP_DEV_RESET: /* new or revived target */ @@ -804,9 +804,9 @@ SBP_DEBUG(0) printf("sbp_post_busreset\n"); END_DEBUG SBP_LOCK(sbp); - if ((sbp->sim->flags & SIMQ_FREEZED) == 0) { + if ((sbp->flags & SIMQ_FREEZED) == 0) { xpt_freeze_simq(sbp->sim, /*count*/1); - sbp->sim->flags |= SIMQ_FREEZED; + sbp->flags |= SIMQ_FREEZED; } microtime(&sbp->last_busreset); SBP_UNLOCK(sbp); @@ -831,19 +831,15 @@ END_DEBUG sbp_cold --; SBP_LOCK(sbp); -#if 0 - /* - * XXX don't let CAM the bus rest. - * CAM tries to do something with freezed (DEV_RETRY) devices. - */ - xpt_async(AC_BUS_RESET, sbp->path, /*arg*/ NULL); -#endif /* Garbage Collection */ for(i = 0 ; i < SBP_NUM_TARGETS ; i ++){ target = &sbp->targets[i]; + if (target->fwdev == NULL) + continue; + STAILQ_FOREACH(fwdev, &sbp->fd.fc->devices, link) - if (target->fwdev == NULL || target->fwdev == fwdev) + if (target->fwdev == fwdev) break; if (fwdev == NULL) { /* device has removed in lower driver */ @@ -851,6 +847,7 @@ END_DEBUG sbp_free_target(target); } } + /* traverse device list */ STAILQ_FOREACH(fwdev, &sbp->fd.fc->devices, link) { SBP_DEBUG(0) @@ -877,12 +874,24 @@ END_DEBUG continue; } } - sbp_probe_target((void *)target); + + /* + * It is safe to drop the lock here as the target is already + * reserved, so there should be no contenders for it. + * And the target is not yet exposed, so there should not be + * any other accesses to it. + * Finally, the list being iterated is protected somewhere else. + */ + SBP_UNLOCK(sbp); + sbp_probe_target(target); + SBP_LOCK(sbp); if (target->num_lun == 0) sbp_free_target(target); } - xpt_release_simq(sbp->sim, /*run queue*/TRUE); - sbp->sim->flags &= ~SIMQ_FREEZED; + if ((sbp->flags & SIMQ_FREEZED) != 0) { + xpt_release_simq(sbp->sim, /*run queue*/TRUE); + sbp->flags &= ~SIMQ_FREEZED; + } SBP_UNLOCK(sbp); } @@ -989,30 +998,36 @@ sbp_next_dev(struct sbp_target *target, static void sbp_cam_scan_lun(struct cam_periph *periph, union ccb *ccb) { + struct sbp_softc *sbp; struct sbp_target *target; struct sbp_dev *sdev; sdev = (struct sbp_dev *) ccb->ccb_h.ccb_sdev_ptr; target = sdev->target; - SBP_LOCK_ASSERT(target->sbp); + sbp = target->sbp; + SBP_LOCK(sbp); SBP_DEBUG(0) - device_printf(sdev->target->sbp->fd.dev, + device_printf(sbp->fd.dev, "%s:%s\n", __func__, sdev->bustgtlun); END_DEBUG if ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) { sdev->status = SBP_DEV_ATTACHED; } else { - device_printf(sdev->target->sbp->fd.dev, + device_printf(sbp->fd.dev, "%s:%s failed\n", __func__, sdev->bustgtlun); } sdev = sbp_next_dev(target, sdev->lun_id + 1); if (sdev == NULL) { + SBP_UNLOCK(sbp); free(ccb, M_SBP); return; } /* reuse ccb */ xpt_setup_ccb(&ccb->ccb_h, sdev->path, SCAN_PRI); ccb->ccb_h.ccb_sdev_ptr = sdev; + ccb->ccb_h.flags |= CAM_DEV_QFREEZE; + SBP_UNLOCK(sbp); + xpt_action(ccb); xpt_release_devq(sdev->path, sdev->freeze, TRUE); sdev->freeze = 1; @@ -1041,6 +1056,8 @@ END_DEBUG printf("sbp_cam_scan_target: malloc failed\n"); return; } + SBP_UNLOCK(target->sbp); + xpt_setup_ccb(&ccb->ccb_h, sdev->path, SCAN_PRI); ccb->ccb_h.func_code = XPT_SCAN_LUN; ccb->ccb_h.cbfcnp = sbp_cam_scan_lun; @@ -1050,6 +1067,8 @@ END_DEBUG /* The scan is in progress now. */ xpt_action(ccb); + + SBP_LOCK(target->sbp); xpt_release_devq(sdev->path, sdev->freeze, TRUE); sdev->freeze = 1; } @@ -2015,8 +2034,8 @@ END_DEBUG sbp->fd.post_explore = sbp_post_explore; if (fc->status != -1) { - sbp_post_busreset((void *)sbp); - sbp_post_explore((void *)sbp); + sbp_post_busreset(sbp); + sbp_post_explore(sbp); } SBP_LOCK(sbp); xpt_async(AC_BUS_RESET, sbp->path, /*arg*/ NULL); From owner-svn-src-stable-10@freebsd.org Thu Mar 23 07:57:43 2017 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 8A2EBD19FFA; Thu, 23 Mar 2017 07:57:43 +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 583DD1C4; Thu, 23 Mar 2017 07:57:43 +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 v2N7vg2v085970; Thu, 23 Mar 2017 07:57:42 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N7vgPf085969; Thu, 23 Mar 2017 07:57:42 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201703230757.v2N7vgPf085969@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 23 Mar 2017 07:57: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: r315833 - 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.23 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, 23 Mar 2017 07:57:43 -0000 Author: avg Date: Thu Mar 23 07:57:42 2017 New Revision: 315833 URL: https://svnweb.freebsd.org/changeset/base/315833 Log: MFC r314912: MFV r314910: 7843 get_clones_stat() is suboptimal for lots of clones Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c Thu Mar 23 07:57:37 2017 (r315832) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c Thu Mar 23 07:57:42 2017 (r315833) @@ -1766,11 +1766,22 @@ get_clones_stat(dsl_dataset_t *ds, nvlis zap_cursor_t zc; zap_attribute_t za; nvlist_t *propval = fnvlist_alloc(); - nvlist_t *val = fnvlist_alloc(); + nvlist_t *val; ASSERT(dsl_pool_config_held(ds->ds_dir->dd_pool)); /* + * We use nvlist_alloc() instead of fnvlist_alloc() because the + * latter would allocate the list with NV_UNIQUE_NAME flag. + * As a result, every time a clone name is appended to the list + * it would be (linearly) searched for for a duplicate name. + * We already know that all clone names must be unique and we + * want avoid the quadratic complexity of double-checking that + * because we can have a large number of clones. + */ + VERIFY0(nvlist_alloc(&val, 0, KM_SLEEP)); + + /* * There may be missing entries in ds_next_clones_obj * due to a bug in a previous version of the code. * Only trust it if it has the right number of entries. From owner-svn-src-stable-10@freebsd.org Thu Mar 23 08:00:47 2017 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 5191DD19468; Thu, 23 Mar 2017 08:00:47 +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 1E0BC872; Thu, 23 Mar 2017 08:00:47 +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 v2N80kZW086226; Thu, 23 Mar 2017 08:00:46 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N80kIo086225; Thu, 23 Mar 2017 08:00:46 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201703230800.v2N80kIo086225@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 23 Mar 2017 08:00: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: r315835 - 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.23 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, 23 Mar 2017 08:00:47 -0000 Author: avg Date: Thu Mar 23 08:00:45 2017 New Revision: 315835 URL: https://svnweb.freebsd.org/changeset/base/315835 Log: MFC r314913: MFV r314911: 7867 ARC space accounting leak Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Thu Mar 23 08:00:16 2017 (r315834) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Thu Mar 23 08:00:45 2017 (r315835) @@ -2610,6 +2610,12 @@ arc_hdr_free_on_write(arc_buf_hdr_t *hdr size, hdr); } (void) refcount_remove_many(&state->arcs_size, size, hdr); + if (type == ARC_BUFC_METADATA) { + arc_space_return(size, ARC_SPACE_META); + } else { + ASSERT(type == ARC_BUFC_DATA); + arc_space_return(size, ARC_SPACE_DATA); + } l2arc_free_data_on_write(hdr->b_l1hdr.b_pdata, size, type); } From owner-svn-src-stable-10@freebsd.org Thu Mar 23 08:02:30 2017 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 74D69D19666; Thu, 23 Mar 2017 08:02:30 +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 41AB6C20; Thu, 23 Mar 2017 08:02:30 +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 v2N82Tnt089994; Thu, 23 Mar 2017 08:02:29 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N82Tf9089993; Thu, 23 Mar 2017 08:02:29 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201703230802.v2N82Tf9089993@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 23 Mar 2017 08:02:29 +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: r315837 - 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.23 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, 23 Mar 2017 08:02:30 -0000 Author: avg Date: Thu Mar 23 08:02:29 2017 New Revision: 315837 URL: https://svnweb.freebsd.org/changeset/base/315837 Log: MFC r315074: actually implement proc:::lwp-exit probe Modified: stable/10/sys/kern/kern_thread.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/kern_thread.c ============================================================================== --- stable/10/sys/kern/kern_thread.c Thu Mar 23 08:02:23 2017 (r315836) +++ stable/10/sys/kern/kern_thread.c Thu Mar 23 08:02:29 2017 (r315837) @@ -415,6 +415,7 @@ thread_exit(void) KASSERT(p != NULL, ("thread exiting without a process")); CTR3(KTR_PROC, "thread_exit: thread %p (pid %ld, %s)", td, (long)p->p_pid, td->td_name); + SDT_PROBE0(proc, , , lwp__exit); KASSERT(TAILQ_EMPTY(&td->td_sigqueue.sq_list), ("signal pending")); #ifdef AUDIT From owner-svn-src-stable-10@freebsd.org Thu Mar 23 08:08:40 2017 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 7C739D1976E; Thu, 23 Mar 2017 08:08:40 +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 49252F5F; Thu, 23 Mar 2017 08:08:40 +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 v2N88dcV090523; Thu, 23 Mar 2017 08:08:39 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N88d6f090521; Thu, 23 Mar 2017 08:08:39 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201703230808.v2N88d6f090521@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 23 Mar 2017 08:08:39 +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: r315839 - 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.23 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, 23 Mar 2017 08:08:40 -0000 Author: avg Date: Thu Mar 23 08:08:39 2017 New Revision: 315839 URL: https://svnweb.freebsd.org/changeset/base/315839 Log: MFC r315075: trace thread running state when a thread is run for the first time Modified: stable/10/sys/kern/sched_4bsd.c stable/10/sys/kern/sched_ule.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/sched_4bsd.c ============================================================================== --- stable/10/sys/kern/sched_4bsd.c Thu Mar 23 08:08:34 2017 (r315838) +++ stable/10/sys/kern/sched_4bsd.c Thu Mar 23 08:08:39 2017 (r315839) @@ -1659,6 +1659,10 @@ sched_fork_exit(struct thread *td) lock_profile_obtain_lock_success(&sched_lock.lock_object, 0, 0, __FILE__, __LINE__); THREAD_LOCK_ASSERT(td, MA_OWNED | MA_NOTRECURSED); + + KTR_STATE1(KTR_SCHED, "thread", sched_tdname(td), "running", + "prio:%d", td->td_priority); + SDT_PROBE0(sched, , , on__cpu); } char * Modified: stable/10/sys/kern/sched_ule.c ============================================================================== --- stable/10/sys/kern/sched_ule.c Thu Mar 23 08:08:34 2017 (r315838) +++ stable/10/sys/kern/sched_ule.c Thu Mar 23 08:08:39 2017 (r315839) @@ -2728,6 +2728,10 @@ sched_fork_exit(struct thread *td) TDQ_LOCK_ASSERT(tdq, MA_OWNED | MA_NOTRECURSED); lock_profile_obtain_lock_success( &TDQ_LOCKPTR(tdq)->lock_object, 0, 0, __FILE__, __LINE__); + + KTR_STATE1(KTR_SCHED, "thread", sched_tdname(td), "running", + "prio:%d", td->td_priority); + SDT_PROBE0(sched, , , on__cpu); } /* From owner-svn-src-stable-10@freebsd.org Thu Mar 23 08:10:44 2017 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 02E1AD198BF; Thu, 23 Mar 2017 08:10:44 +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 C312E12D5; Thu, 23 Mar 2017 08:10:43 +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 v2N8AgwZ090751; Thu, 23 Mar 2017 08:10:42 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N8AgLn090750; Thu, 23 Mar 2017 08:10:42 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201703230810.v2N8AgLn090750@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 23 Mar 2017 08:10: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: r315841 - stable/10/sys/dev/aacraid 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.23 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, 23 Mar 2017 08:10:44 -0000 Author: avg Date: Thu Mar 23 08:10:42 2017 New Revision: 315841 URL: https://svnweb.freebsd.org/changeset/base/315841 Log: MFC r315083: aacraid: fix build with AACRAID_DEBUG=2 Modified: stable/10/sys/dev/aacraid/aacraid_cam.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/aacraid/aacraid_cam.c ============================================================================== --- stable/10/sys/dev/aacraid/aacraid_cam.c Thu Mar 23 08:10:25 2017 (r315840) +++ stable/10/sys/dev/aacraid/aacraid_cam.c Thu Mar 23 08:10:42 2017 (r315841) @@ -244,6 +244,7 @@ aac_cam_probe(device_t dev) { struct aac_softc *sc; struct aac_cam *camsc; + struct aac_softc *sc; camsc = (struct aac_cam *)device_get_softc(dev); if (!camsc->inf) @@ -1137,6 +1138,7 @@ aac_container_complete(struct aac_comman { struct aac_softc *sc; union ccb *ccb; + struct aac_softc *sc; u_int32_t status; sc = cm->cm_sc; @@ -1146,7 +1148,7 @@ aac_container_complete(struct aac_comman if (cm->cm_flags & AAC_CMD_RESET) { ccb->ccb_h.status = CAM_SCSI_BUS_RESET; - } else if (status == ST_OK) { + } else if (status == ST_OK) { ccb->ccb_h.status = CAM_REQ_CMP; } else if (status == ST_NOT_READY) { ccb->ccb_h.status = CAM_BUSY; From owner-svn-src-stable-10@freebsd.org Thu Mar 23 08:16:31 2017 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 C255CD19BCE; Thu, 23 Mar 2017 08:16:31 +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 70F011A3D; Thu, 23 Mar 2017 08:16:31 +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 v2N8GUcF094637; Thu, 23 Mar 2017 08:16:30 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N8GUoL094630; Thu, 23 Mar 2017 08:16:30 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201703230816.v2N8GUoL094630@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 23 Mar 2017 08:16:30 +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: r315844 - in stable/10/sys: cddl/compat/opensolaris/kern cddl/compat/opensolaris/sys cddl/contrib/opensolaris/uts/common/fs cddl/contrib/opensolaris/uts/common/fs/zfs cddl/contrib/opens... 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.23 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, 23 Mar 2017 08:16:31 -0000 Author: avg Date: Thu Mar 23 08:16:29 2017 New Revision: 315844 URL: https://svnweb.freebsd.org/changeset/base/315844 Log: MFC r314048,r314194: reimplement zfsctl (.zfs) support Deleted: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/gfs.c stable/10/sys/cddl/contrib/opensolaris/uts/common/sys/gfs.h Modified: stable/10/sys/cddl/compat/opensolaris/kern/opensolaris_lookup.c stable/10/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c stable/10/sys/cddl/compat/opensolaris/sys/pathname.h stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ctldir.h stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_vfsops.h stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c stable/10/sys/conf/files stable/10/sys/modules/zfs/Makefile Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cddl/compat/opensolaris/kern/opensolaris_lookup.c ============================================================================== --- stable/10/sys/cddl/compat/opensolaris/kern/opensolaris_lookup.c Thu Mar 23 08:15:11 2017 (r315843) +++ stable/10/sys/cddl/compat/opensolaris/kern/opensolaris_lookup.c Thu Mar 23 08:16:29 2017 (r315844) @@ -62,55 +62,3 @@ lookupnameat(char *dirname, enum uio_seg vn_lock(startvp, ltype | LK_RETRY); return (error); } - -int -traverse(vnode_t **cvpp, int lktype) -{ - vnode_t *cvp; - vnode_t *tvp; - vfs_t *vfsp; - int error; - - cvp = *cvpp; - tvp = NULL; - - /* - * If this vnode is mounted on, then we transparently indirect - * to the vnode which is the root of the mounted file system. - * Before we do this we must check that an unmount is not in - * progress on this vnode. - */ - - for (;;) { - /* - * Reached the end of the mount chain? - */ - vfsp = vn_mountedvfs(cvp); - if (vfsp == NULL) - break; - error = vfs_busy(vfsp, 0); - - /* - * tvp is NULL for *cvpp vnode, which we can't unlock. - */ - if (tvp != NULL) - vput(cvp); - else - vrele(cvp); - if (error) - return (error); - - /* - * The read lock must be held across the call to VFS_ROOT() to - * prevent a concurrent unmount from destroying the vfs. - */ - error = VFS_ROOT(vfsp, lktype, &tvp); - vfs_unbusy(vfsp); - if (error != 0) - return (error); - cvp = tvp; - } - - *cvpp = cvp; - return (0); -} Modified: stable/10/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c ============================================================================== --- stable/10/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c Thu Mar 23 08:15:11 2017 (r315843) +++ stable/10/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c Thu Mar 23 08:16:29 2017 (r315844) @@ -196,10 +196,17 @@ mount_snapshot(kthread_t *td, vnode_t ** td->td_ucred = cr; if (error != 0) { + /* + * Clear VI_MOUNT and decrement the use count "atomically", + * under the vnode lock. This is not strictly required, + * but makes it easier to reason about the life-cycle and + * ownership of the covered vnode. + */ + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); VI_LOCK(vp); vp->v_iflag &= ~VI_MOUNT; VI_UNLOCK(vp); - vrele(vp); + vput(vp); vfs_unbusy(mp); vfs_freeopts(mp->mnt_optnew); vfs_mount_destroy(mp); Modified: stable/10/sys/cddl/compat/opensolaris/sys/pathname.h ============================================================================== --- stable/10/sys/cddl/compat/opensolaris/sys/pathname.h Thu Mar 23 08:15:11 2017 (r315843) +++ stable/10/sys/cddl/compat/opensolaris/sys/pathname.h Thu Mar 23 08:16:29 2017 (r315844) @@ -34,20 +34,9 @@ #include #include -typedef struct pathname { - char *pn_buf; /* underlying storage */ - char *pn_path; /* remaining pathname */ - size_t pn_pathlen; /* remaining length */ - size_t pn_bufsize; /* total size of pn_buf */ -} pathname_t; - -#define pn_alloc(pnp) panic("pn_alloc() called") -#define pn_free(pnp) panic("pn_free() called") - int lookupname(char *, enum uio_seg, enum symfollow, vnode_t **, vnode_t **); int lookupnameat(char *, enum uio_seg, enum symfollow, vnode_t **, vnode_t **, vnode_t *); -int traverse(vnode_t **, int); #endif /* _KERNEL */ Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ctldir.h ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ctldir.h Thu Mar 23 08:15:11 2017 (r315843) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ctldir.h Thu Mar 23 08:16:29 2017 (r315844) @@ -44,7 +44,7 @@ extern "C" { void zfsctl_create(zfsvfs_t *); void zfsctl_destroy(zfsvfs_t *); -vnode_t *zfsctl_root(znode_t *); +int zfsctl_root(zfsvfs_t *, int, vnode_t **); void zfsctl_init(void); void zfsctl_fini(void); boolean_t zfsctl_is_node(vnode_t *); @@ -53,10 +53,6 @@ int zfsctl_rename_snapshot(const char *f int zfsctl_destroy_snapshot(const char *snapname, int force); int zfsctl_umount_snapshots(vfs_t *, int, cred_t *); -int zfsctl_root_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, pathname_t *pnp, - int flags, vnode_t *rdir, cred_t *cr, caller_context_t *ct, - int *direntflags, pathname_t *realpnp); - int zfsctl_lookup_objset(vfs_t *vfsp, uint64_t objsetid, zfsvfs_t **zfsvfsp); #define ZFSCTL_INO_ROOT 0x1 Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_vfsops.h ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_vfsops.h Thu Mar 23 08:15:11 2017 (r315843) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_vfsops.h Thu Mar 23 08:16:29 2017 (r315844) @@ -68,7 +68,7 @@ struct zfsvfs { krwlock_t z_teardown_inactive_lock; list_t z_all_znodes; /* all vnodes in the fs */ kmutex_t z_znodes_lock; /* lock for z_all_znodes */ - vnode_t *z_ctldir; /* .zfs directory pointer */ + struct zfsctl_root *z_ctldir; /* .zfs directory pointer */ boolean_t z_show_ctldir; /* expose .zfs in the root dir */ boolean_t z_issnap; /* true if this is a snapshot */ boolean_t z_vscan; /* virus scan on/off */ 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 Thu Mar 23 08:15:11 2017 (r315843) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c Thu Mar 23 08:16:29 2017 (r315844) @@ -70,136 +70,249 @@ #include #include #include -#include #include #include +#include #include #include #include -#include +#include #include "zfs_namecheck.h" -typedef struct zfsctl_node { - gfs_dir_t zc_gfs_private; - uint64_t zc_id; - timestruc_t zc_cmtime; /* ctime and mtime, always the same */ -} zfsctl_node_t; - -typedef struct zfsctl_snapdir { - zfsctl_node_t sd_node; - kmutex_t sd_lock; - avl_tree_t sd_snaps; -} zfsctl_snapdir_t; +/* + * "Synthetic" filesystem implementation. + */ -typedef struct { - char *se_name; - vnode_t *se_root; - avl_node_t se_node; -} zfs_snapentry_t; - -static int -snapentry_compare(const void *a, const void *b) -{ - const zfs_snapentry_t *sa = a; - const zfs_snapentry_t *sb = b; - int ret = strcmp(sa->se_name, sb->se_name); - - if (ret < 0) - return (-1); - else if (ret > 0) - return (1); - else - return (0); -} - -#ifdef illumos -vnodeops_t *zfsctl_ops_root; -vnodeops_t *zfsctl_ops_snapdir; -vnodeops_t *zfsctl_ops_snapshot; -vnodeops_t *zfsctl_ops_shares; -vnodeops_t *zfsctl_ops_shares_dir; - -static const fs_operation_def_t zfsctl_tops_root[]; -static const fs_operation_def_t zfsctl_tops_snapdir[]; -static const fs_operation_def_t zfsctl_tops_snapshot[]; -static const fs_operation_def_t zfsctl_tops_shares[]; -#else -static struct vop_vector zfsctl_ops_root; -static struct vop_vector zfsctl_ops_snapdir; -static struct vop_vector zfsctl_ops_snapshot; -static struct vop_vector zfsctl_ops_shares; -static struct vop_vector zfsctl_ops_shares_dir; -#endif +/* + * Assert that A implies B. + */ +#define KASSERT_IMPLY(A, B, msg) KASSERT(!(A) || (B), (msg)); -static vnode_t *zfsctl_mknode_snapdir(vnode_t *); -static vnode_t *zfsctl_mknode_shares(vnode_t *); -static vnode_t *zfsctl_snapshot_mknode(vnode_t *, uint64_t objset); -static int zfsctl_unmount_snap(zfs_snapentry_t *, int, cred_t *); - -#ifdef illumos -static gfs_opsvec_t zfsctl_opsvec[] = { - { ".zfs", zfsctl_tops_root, &zfsctl_ops_root }, - { ".zfs/snapshot", zfsctl_tops_snapdir, &zfsctl_ops_snapdir }, - { ".zfs/snapshot/vnode", zfsctl_tops_snapshot, &zfsctl_ops_snapshot }, - { ".zfs/shares", zfsctl_tops_shares, &zfsctl_ops_shares_dir }, - { ".zfs/shares/vnode", zfsctl_tops_shares, &zfsctl_ops_shares }, - { NULL } -}; -#endif +static MALLOC_DEFINE(M_SFSNODES, "sfs_nodes", "synthetic-fs nodes"); + +typedef struct sfs_node { + char sn_name[ZFS_MAX_DATASET_NAME_LEN]; + uint64_t sn_parent_id; + uint64_t sn_id; +} sfs_node_t; /* - * Root directory elements. We only have two entries - * snapshot and shares. + * Check the parent's ID as well as the node's to account for a chance + * that IDs originating from different domains (snapshot IDs, artifical + * IDs, znode IDs) may clash. */ -static gfs_dirent_t zfsctl_root_entries[] = { - { "snapshot", zfsctl_mknode_snapdir, GFS_CACHE_VNODE }, - { "shares", zfsctl_mknode_shares, GFS_CACHE_VNODE }, - { NULL } -}; +static int +sfs_compare_ids(struct vnode *vp, void *arg) +{ + sfs_node_t *n1 = vp->v_data; + sfs_node_t *n2 = arg; + bool equal; + + equal = n1->sn_id == n2->sn_id && + n1->sn_parent_id == n2->sn_parent_id; + + /* Zero means equality. */ + return (!equal); +} + +static int +sfs_vnode_get(const struct mount *mp, int flags, uint64_t parent_id, + uint64_t id, struct vnode **vpp) +{ + sfs_node_t search; + int err; + + search.sn_id = id; + search.sn_parent_id = parent_id; + err = vfs_hash_get(mp, (u_int)id, flags, curthread, vpp, + sfs_compare_ids, &search); + return (err); +} + +static int +sfs_vnode_insert(struct vnode *vp, int flags, uint64_t parent_id, + uint64_t id, struct vnode **vpp) +{ + int err; + + KASSERT(vp->v_data != NULL, ("sfs_vnode_insert with NULL v_data")); + err = vfs_hash_insert(vp, (u_int)id, flags, curthread, vpp, + sfs_compare_ids, vp->v_data); + return (err); +} + +static void +sfs_vnode_remove(struct vnode *vp) +{ + vfs_hash_remove(vp); +} + +typedef void sfs_vnode_setup_fn(vnode_t *vp, void *arg); + +static int +sfs_vgetx(struct mount *mp, int flags, uint64_t parent_id, uint64_t id, + const char *tag, struct vop_vector *vops, + sfs_vnode_setup_fn setup, void *arg, + struct vnode **vpp) +{ + struct vnode *vp; + int error; + + error = sfs_vnode_get(mp, flags, parent_id, id, vpp); + if (error != 0 || *vpp != NULL) { + KASSERT_IMPLY(error == 0, (*vpp)->v_data != NULL, + "sfs vnode with no data"); + return (error); + } + + /* Allocate a new vnode/inode. */ + error = getnewvnode(tag, mp, vops, &vp); + if (error != 0) { + *vpp = NULL; + return (error); + } + + /* + * Exclusively lock the vnode vnode while it's being constructed. + */ + lockmgr(vp->v_vnlock, LK_EXCLUSIVE, NULL); + error = insmntque(vp, mp); + if (error != 0) { + *vpp = NULL; + return (error); + } + + setup(vp, arg); + + error = sfs_vnode_insert(vp, flags, parent_id, id, vpp); + if (error != 0 || *vpp != NULL) { + KASSERT_IMPLY(error == 0, (*vpp)->v_data != NULL, + "sfs vnode with no data"); + return (error); + } + + *vpp = vp; + return (0); +} + +static void +sfs_print_node(sfs_node_t *node) +{ + printf("\tname = %s\n", node->sn_name); + printf("\tparent_id = %ju\n", (uintmax_t)node->sn_parent_id); + printf("\tid = %ju\n", (uintmax_t)node->sn_id); +} + +static sfs_node_t * +sfs_alloc_node(size_t size, const char *name, uint64_t parent_id, uint64_t id) +{ + struct sfs_node *node; + + KASSERT(strlen(name) < sizeof(node->sn_name), + ("sfs node name is too long")); + KASSERT(size >= sizeof(*node), ("sfs node size is too small")); + node = malloc(size, M_SFSNODES, M_WAITOK | M_ZERO); + strlcpy(node->sn_name, name, sizeof(node->sn_name)); + node->sn_parent_id = parent_id; + node->sn_id = id; + + return (node); +} + +static void +sfs_destroy_node(sfs_node_t *node) +{ + free(node, M_SFSNODES); +} + +static void * +sfs_reclaim_vnode(vnode_t *vp) +{ + sfs_node_t *node; + void *data; + + sfs_vnode_remove(vp); + data = vp->v_data; + vp->v_data = NULL; + return (data); +} + +static int +sfs_readdir_common(uint64_t parent_id, uint64_t id, struct vop_readdir_args *ap, + uio_t *uio, off_t *offp) +{ + struct dirent entry; + int error; + + /* Reset ncookies for subsequent use of vfs_read_dirent. */ + if (ap->a_ncookies != NULL) + *ap->a_ncookies = 0; + + if (uio->uio_resid < sizeof(entry)) + return (SET_ERROR(EINVAL)); + + if (uio->uio_offset < 0) + return (SET_ERROR(EINVAL)); + if (uio->uio_offset == 0) { + entry.d_fileno = id; + entry.d_type = DT_DIR; + entry.d_name[0] = '.'; + entry.d_name[1] = '\0'; + entry.d_namlen = 1; + entry.d_reclen = sizeof(entry); + error = vfs_read_dirent(ap, &entry, uio->uio_offset); + if (error != 0) + return (SET_ERROR(error)); + } + + if (uio->uio_offset < sizeof(entry)) + return (SET_ERROR(EINVAL)); + if (uio->uio_offset == sizeof(entry)) { + entry.d_fileno = parent_id; + entry.d_type = DT_DIR; + entry.d_name[0] = '.'; + entry.d_name[1] = '.'; + entry.d_name[2] = '\0'; + entry.d_namlen = 2; + entry.d_reclen = sizeof(entry); + error = vfs_read_dirent(ap, &entry, uio->uio_offset); + if (error != 0) + return (SET_ERROR(error)); + } -/* include . and .. in the calculation */ -#define NROOT_ENTRIES ((sizeof (zfsctl_root_entries) / \ - sizeof (gfs_dirent_t)) + 1) + if (offp != NULL) + *offp = 2 * sizeof(entry); + return (0); +} /* - * Initialize the various GFS pieces we'll need to create and manipulate .zfs - * directories. This is called from the ZFS init routine, and initializes the - * vnode ops vectors that we'll be using. + * .zfs inode namespace + * + * We need to generate unique inode numbers for all files and directories + * within the .zfs pseudo-filesystem. We use the following scheme: + * + * ENTRY ZFSCTL_INODE + * .zfs 1 + * .zfs/snapshot 2 + * .zfs/snapshot/ objectid(snap) */ +#define ZFSCTL_INO_SNAP(id) (id) + +static struct vop_vector zfsctl_ops_root; +static struct vop_vector zfsctl_ops_snapdir; +static struct vop_vector zfsctl_ops_snapshot; +static struct vop_vector zfsctl_ops_shares_dir; + void zfsctl_init(void) { -#ifdef illumos - VERIFY(gfs_make_opsvec(zfsctl_opsvec) == 0); -#endif } void zfsctl_fini(void) { -#ifdef illumos - /* - * Remove vfsctl vnode ops - */ - if (zfsctl_ops_root) - vn_freevnodeops(zfsctl_ops_root); - if (zfsctl_ops_snapdir) - vn_freevnodeops(zfsctl_ops_snapdir); - if (zfsctl_ops_snapshot) - vn_freevnodeops(zfsctl_ops_snapshot); - if (zfsctl_ops_shares) - vn_freevnodeops(zfsctl_ops_shares); - if (zfsctl_ops_shares_dir) - vn_freevnodeops(zfsctl_ops_shares_dir); - - zfsctl_ops_root = NULL; - zfsctl_ops_snapdir = NULL; - zfsctl_ops_snapshot = NULL; - zfsctl_ops_shares = NULL; - zfsctl_ops_shares_dir = NULL; -#endif /* illumos */ } boolean_t @@ -208,106 +321,114 @@ zfsctl_is_node(vnode_t *vp) return (vn_matchops(vp, zfsctl_ops_root) || vn_matchops(vp, zfsctl_ops_snapdir) || vn_matchops(vp, zfsctl_ops_snapshot) || - vn_matchops(vp, zfsctl_ops_shares) || vn_matchops(vp, zfsctl_ops_shares_dir)); } -/* - * Return the inode number associated with the 'snapshot' or - * 'shares' directory. - */ -/* ARGSUSED */ -static ino64_t -zfsctl_root_inode_cb(vnode_t *vp, int index) -{ - zfsvfs_t *zfsvfs = vp->v_vfsp->vfs_data; - - ASSERT(index < 2); - - if (index == 0) - return (ZFSCTL_INO_SNAPDIR); +typedef struct zfsctl_root { + sfs_node_t node; + sfs_node_t *snapdir; + timestruc_t cmtime; +} zfsctl_root_t; - return (zfsvfs->z_shares_dir); -} /* - * Create the '.zfs' directory. This directory is cached as part of the VFS - * structure. This results in a hold on the vfs_t. The code in zfs_umount() - * therefore checks against a vfs_count of 2 instead of 1. This reference - * is removed when the ctldir is destroyed in the unmount. + * Create the '.zfs' directory. */ void zfsctl_create(zfsvfs_t *zfsvfs) { - vnode_t *vp, *rvp; - zfsctl_node_t *zcp; + zfsctl_root_t *dot_zfs; + sfs_node_t *snapdir; + vnode_t *rvp; uint64_t crtime[2]; ASSERT(zfsvfs->z_ctldir == NULL); - vp = gfs_root_create(sizeof (zfsctl_node_t), zfsvfs->z_vfs, - &zfsctl_ops_root, ZFSCTL_INO_ROOT, zfsctl_root_entries, - zfsctl_root_inode_cb, MAXNAMELEN, NULL, NULL); - zcp = vp->v_data; - zcp->zc_id = ZFSCTL_INO_ROOT; + snapdir = sfs_alloc_node(sizeof(*snapdir), "snapshot", ZFSCTL_INO_ROOT, + ZFSCTL_INO_SNAPDIR); + dot_zfs = (zfsctl_root_t *)sfs_alloc_node(sizeof(*dot_zfs), ".zfs", 0, + ZFSCTL_INO_ROOT); + dot_zfs->snapdir = snapdir; VERIFY(VFS_ROOT(zfsvfs->z_vfs, LK_EXCLUSIVE, &rvp) == 0); VERIFY(0 == sa_lookup(VTOZ(rvp)->z_sa_hdl, SA_ZPL_CRTIME(zfsvfs), - &crtime, sizeof (crtime))); - ZFS_TIME_DECODE(&zcp->zc_cmtime, crtime); - VN_URELE(rvp); - - /* - * We're only faking the fact that we have a root of a filesystem for - * the sake of the GFS interfaces. Undo the flag manipulation it did - * for us. - */ - vp->v_vflag &= ~VV_ROOT; + &crtime, sizeof(crtime))); + ZFS_TIME_DECODE(&dot_zfs->cmtime, crtime); + vput(rvp); - zfsvfs->z_ctldir = vp; - - VOP_UNLOCK(vp, 0); + zfsvfs->z_ctldir = dot_zfs; } /* * Destroy the '.zfs' directory. Only called when the filesystem is unmounted. - * There might still be more references if we were force unmounted, but only - * new zfs_inactive() calls can occur and they don't reference .zfs + * The nodes must not have any associated vnodes by now as they should be + * vflush-ed. */ void zfsctl_destroy(zfsvfs_t *zfsvfs) { - VN_RELE(zfsvfs->z_ctldir); + sfs_destroy_node(zfsvfs->z_ctldir->snapdir); + sfs_destroy_node((sfs_node_t *)zfsvfs->z_ctldir); zfsvfs->z_ctldir = NULL; } -/* - * Given a root znode, retrieve the associated .zfs directory. - * Add a hold to the vnode and return it. - */ -vnode_t * -zfsctl_root(znode_t *zp) +static int +zfsctl_fs_root_vnode(struct mount *mp, void *arg __unused, int flags, + struct vnode **vpp) +{ + return (VFS_ROOT(mp, flags, vpp)); +} + +static void +zfsctl_common_vnode_setup(vnode_t *vp, void *arg) { - ASSERT(zfs_has_ctldir(zp)); - VN_HOLD(zp->z_zfsvfs->z_ctldir); - return (zp->z_zfsvfs->z_ctldir); + ASSERT_VOP_ELOCKED(vp, __func__); + + /* We support shared locking. */ + VN_LOCK_ASHARE(vp); + vp->v_type = VDIR; + vp->v_data = arg; } static int -zfsctl_common_print(ap) - struct vop_print_args /* { - struct vnode *a_vp; - } */ *ap; +zfsctl_root_vnode(struct mount *mp, void *arg __unused, int flags, + struct vnode **vpp) { - vnode_t *vp = ap->a_vp; - gfs_file_t *fp = vp->v_data; + void *node; + int err; - printf(" parent = %p\n", fp->gfs_parent); - printf(" type = %d\n", fp->gfs_type); - printf(" index = %d\n", fp->gfs_index); - printf(" ino = %ju\n", (uintmax_t)fp->gfs_ino); - return (0); + node = ((zfsvfs_t*)mp->mnt_data)->z_ctldir; + err = sfs_vgetx(mp, flags, 0, ZFSCTL_INO_ROOT, "zfs", &zfsctl_ops_root, + zfsctl_common_vnode_setup, node, vpp); + return (err); +} + +static int +zfsctl_snapdir_vnode(struct mount *mp, void *arg __unused, int flags, + struct vnode **vpp) +{ + void *node; + int err; + + node = ((zfsvfs_t*)mp->mnt_data)->z_ctldir->snapdir; + err = sfs_vgetx(mp, flags, ZFSCTL_INO_ROOT, ZFSCTL_INO_SNAPDIR, "zfs", + &zfsctl_ops_snapdir, zfsctl_common_vnode_setup, node, vpp); + return (err); +} + +/* + * Given a root znode, retrieve the associated .zfs directory. + * Add a hold to the vnode and return it. + */ +int +zfsctl_root(zfsvfs_t *zfsvfs, int flags, vnode_t **vpp) +{ + vnode_t *vp; + int error; + + error = zfsctl_root_vnode(zfsvfs->z_vfs, NULL, flags, vpp); + return (error); } /* @@ -350,18 +471,8 @@ zfsctl_common_access(ap) { accmode_t accmode = ap->a_accmode; -#ifdef TODO - if (flags & V_ACE_MASK) { - if (accmode & ACE_ALL_WRITE_PERMS) - return (SET_ERROR(EACCES)); - } else { -#endif - if (accmode & VWRITE) - return (SET_ERROR(EACCES)); -#ifdef TODO - } -#endif - + if (accmode & VWRITE) + return (SET_ERROR(EACCES)); return (0); } @@ -372,6 +483,9 @@ static void zfsctl_common_getattr(vnode_t *vp, vattr_t *vap) { timestruc_t now; + sfs_node_t *node; + + node = vp->v_data; vap->va_uid = 0; vap->va_gid = 0; @@ -394,6 +508,11 @@ zfsctl_common_getattr(vnode_t *vp, vattr vap->va_atime = now; /* FreeBSD: Reset chflags(2) flags. */ vap->va_flags = 0; + + vap->va_nodeid = node->sn_id; + + /* At least '.' and '..'. */ + vap->va_nlink = 2; } /*ARGSUSED*/ @@ -406,81 +525,46 @@ zfsctl_common_fid(ap) { vnode_t *vp = ap->a_vp; fid_t *fidp = (void *)ap->a_fid; - zfsvfs_t *zfsvfs = vp->v_vfsp->vfs_data; - zfsctl_node_t *zcp = vp->v_data; - uint64_t object = zcp->zc_id; + sfs_node_t *node = vp->v_data; + uint64_t object = node->sn_id; zfid_short_t *zfid; int i; - ZFS_ENTER(zfsvfs); - -#ifdef illumos - if (fidp->fid_len < SHORT_FID_LEN) { - fidp->fid_len = SHORT_FID_LEN; - ZFS_EXIT(zfsvfs); - return (SET_ERROR(ENOSPC)); - } -#endif - zfid = (zfid_short_t *)fidp; - zfid->zf_len = SHORT_FID_LEN; - for (i = 0; i < sizeof (zfid->zf_object); i++) + for (i = 0; i < sizeof(zfid->zf_object); i++) zfid->zf_object[i] = (uint8_t)(object >> (8 * i)); - /* .zfs znodes always have a generation number of 0 */ - for (i = 0; i < sizeof (zfid->zf_gen); i++) + /* .zfs nodes always have a generation number of 0 */ + for (i = 0; i < sizeof(zfid->zf_gen); i++) zfid->zf_gen[i] = 0; - ZFS_EXIT(zfsvfs); return (0); } - -/*ARGSUSED*/ static int -zfsctl_shares_fid(ap) - struct vop_fid_args /* { +zfsctl_common_reclaim(ap) + struct vop_reclaim_args /* { struct vnode *a_vp; - struct fid *a_fid; + struct thread *a_td; } */ *ap; { - vnode_t *vp = ap->a_vp; - fid_t *fidp = (void *)ap->a_fid; - zfsvfs_t *zfsvfs = vp->v_vfsp->vfs_data; - znode_t *dzp; - int error; - - ZFS_ENTER(zfsvfs); - - if (zfsvfs->z_shares_dir == 0) { - ZFS_EXIT(zfsvfs); - return (SET_ERROR(ENOTSUP)); - } - - if ((error = zfs_zget(zfsvfs, zfsvfs->z_shares_dir, &dzp)) == 0) { - error = VOP_FID(ZTOV(dzp), fidp); - VN_RELE(ZTOV(dzp)); - } + vnode_t *vp = ap->a_vp; - ZFS_EXIT(zfsvfs); - return (error); + (void) sfs_reclaim_vnode(vp); + return (0); } -/* - * .zfs inode namespace - * - * We need to generate unique inode numbers for all files and directories - * within the .zfs pseudo-filesystem. We use the following scheme: - * - * ENTRY ZFSCTL_INODE - * .zfs 1 - * .zfs/snapshot 2 - * .zfs/snapshot/ objectid(snap) - */ - -#define ZFSCTL_INO_SNAP(id) (id) +static int +zfsctl_common_print(ap) + struct vop_print_args /* { + struct vnode *a_vp; + } */ *ap; +{ + sfs_print_node(ap->a_vp->v_data); + return (0); +} /* * Get root directory attributes. @@ -496,156 +580,132 @@ zfsctl_root_getattr(ap) { struct vnode *vp = ap->a_vp; struct vattr *vap = ap->a_vap; - zfsvfs_t *zfsvfs = vp->v_vfsp->vfs_data; - zfsctl_node_t *zcp = vp->v_data; - - ZFS_ENTER(zfsvfs); - vap->va_nodeid = ZFSCTL_INO_ROOT; - vap->va_nlink = vap->va_size = NROOT_ENTRIES; - vap->va_mtime = vap->va_ctime = zcp->zc_cmtime; - vap->va_birthtime = vap->va_ctime; + zfsctl_root_t *node = vp->v_data; zfsctl_common_getattr(vp, vap); - ZFS_EXIT(zfsvfs); - + vap->va_ctime = node->cmtime; + vap->va_mtime = vap->va_ctime; + vap->va_birthtime = vap->va_ctime; + vap->va_nlink += 1; /* snapdir */ + vap->va_size = vap->va_nlink; return (0); } /* - * Special case the handling of "..". + * When we lookup "." we still can be asked to lock it + * differently, can't we? */ -/* ARGSUSED */ int -zfsctl_root_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, pathname_t *pnp, - int flags, vnode_t *rdir, cred_t *cr, caller_context_t *ct, - int *direntflags, pathname_t *realpnp) +zfsctl_relock_dot(vnode_t *dvp, int ltype) { - zfsvfs_t *zfsvfs = dvp->v_vfsp->vfs_data; - int err; - - /* - * No extended attributes allowed under .zfs - */ - if (flags & LOOKUP_XATTR) - return (SET_ERROR(EINVAL)); - - ZFS_ENTER(zfsvfs); - - if (strcmp(nm, "..") == 0) { -#ifdef illumos - err = VFS_ROOT(dvp->v_vfsp, LK_EXCLUSIVE, vpp); -#else - /* - * NB: can not use VFS_ROOT here as it would acquire - * the vnode lock of the parent (root) vnode while - * holding the child's (.zfs) lock. - */ - znode_t *rootzp; - - err = zfs_zget(zfsvfs, zfsvfs->z_root, &rootzp); - if (err == 0) - *vpp = ZTOV(rootzp); -#endif - } else { - err = gfs_vop_lookup(dvp, nm, vpp, pnp, flags, rdir, - cr, ct, direntflags, realpnp); + vref(dvp); + if (ltype != VOP_ISLOCKED(dvp)) { + if (ltype == LK_EXCLUSIVE) + vn_lock(dvp, LK_UPGRADE | LK_RETRY); + else /* if (ltype == LK_SHARED) */ + vn_lock(dvp, LK_DOWNGRADE | LK_RETRY); + + /* Relock for the "." case may left us with reclaimed vnode. */ + if ((dvp->v_iflag & VI_DOOMED) != 0) { + vrele(dvp); + return (SET_ERROR(ENOENT)); + } } - - ZFS_EXIT(zfsvfs); - - return (err); + return (0); } -static int -zfsctl_freebsd_root_lookup(ap) +/* + * Special case the handling of "..". + */ +int +zfsctl_root_lookup(ap) struct vop_lookup_args /* { struct vnode *a_dvp; struct vnode **a_vpp; struct componentname *a_cnp; } */ *ap; { + struct componentname *cnp = ap->a_cnp; vnode_t *dvp = ap->a_dvp; vnode_t **vpp = ap->a_vpp; cred_t *cr = ap->a_cnp->cn_cred; int flags = ap->a_cnp->cn_flags; int lkflags = ap->a_cnp->cn_lkflags; int nameiop = ap->a_cnp->cn_nameiop; - char nm[NAME_MAX + 1]; int err; + int ltype; - if ((flags & ISLASTCN) && (nameiop == RENAME || nameiop == CREATE)) - return (EOPNOTSUPP); + ASSERT(dvp->v_type == VDIR); - ASSERT(ap->a_cnp->cn_namelen < sizeof(nm)); - strlcpy(nm, ap->a_cnp->cn_nameptr, ap->a_cnp->cn_namelen + 1); -relookup: - err = zfsctl_root_lookup(dvp, nm, vpp, NULL, 0, NULL, cr, NULL, NULL, NULL); - if (err == 0 && (nm[0] != '.' || nm[1] != '\0')) { - if (flags & ISDOTDOT) { - VOP_UNLOCK(dvp, 0); - err = vn_lock(*vpp, lkflags); - if (err != 0) { - vrele(*vpp); - *vpp = NULL; - } - vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY); - } else { - err = vn_lock(*vpp, LK_EXCLUSIVE); - if (err != 0) { - VERIFY3S(err, ==, ENOENT); - goto relookup; - } - } - } - return (err); -} + if ((flags & ISLASTCN) != 0 && nameiop != LOOKUP) + return (SET_ERROR(ENOTSUP)); -static int -zfsctl_root_print(ap) - struct vop_print_args /* { + if (cnp->cn_namelen == 1 && *cnp->cn_nameptr == '.') { + err = zfsctl_relock_dot(dvp, lkflags & LK_TYPE_MASK); + if (err == 0) + *vpp = dvp; + } else if ((flags & ISDOTDOT) != 0) { + err = vn_vget_ino_gen(dvp, zfsctl_fs_root_vnode, NULL, + lkflags, vpp); + } else if (strncmp(cnp->cn_nameptr, "snapshot", cnp->cn_namelen) == 0) { + err = zfsctl_snapdir_vnode(dvp->v_mount, NULL, lkflags, vpp); + } else { + err = SET_ERROR(ENOENT); + } + if (err != 0) + *vpp = NULL; + return (err); +} + +static int +zfsctl_root_readdir(ap) + struct vop_readdir_args /* { struct vnode *a_vp; + struct uio *a_uio; + struct ucred *a_cred; + int *a_eofflag; + int *ncookies; + u_long **a_cookies; } */ *ap; { - printf(" .zfs node\n"); - zfsctl_common_print(ap); + struct dirent entry; + vnode_t *vp = ap->a_vp; + zfsvfs_t *zfsvfs = vp->v_vfsp->vfs_data; + zfsctl_root_t *node = vp->v_data; + uio_t *uio = ap->a_uio; + int *eofp = ap->a_eofflag; + off_t dots_offset; + int error; + + ASSERT(vp->v_type == VDIR); + + error = sfs_readdir_common(zfsvfs->z_root, ZFSCTL_INO_ROOT, ap, uio, *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-10@freebsd.org Thu Mar 23 08:19:53 2017 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 365C6D19DC0; Thu, 23 Mar 2017 08:19:53 +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 031AD1EA1; Thu, 23 Mar 2017 08:19:52 +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 v2N8JqBM094877; Thu, 23 Mar 2017 08:19:52 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N8JqS4094876; Thu, 23 Mar 2017 08:19:52 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201703230819.v2N8JqS4094876@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 23 Mar 2017 08:19: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: r315847 - stable/10 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.23 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, 23 Mar 2017 08:19:53 -0000 Author: avg Date: Thu Mar 23 08:19:51 2017 New Revision: 315847 URL: https://svnweb.freebsd.org/changeset/base/315847 Log: add UPDATING entry for r315844, MFC of re-worked .zfs code Modified: stable/10/UPDATING Modified: stable/10/UPDATING ============================================================================== --- stable/10/UPDATING Thu Mar 23 08:19:31 2017 (r315846) +++ stable/10/UPDATING Thu Mar 23 08:19:51 2017 (r315847) @@ -16,6 +16,12 @@ from older versions of FreeBSD, try WITH stable/10, and then rebuild without this option. The bootstrap process from older version of current is a bit fragile. +20170323: + The code that provides support for ZFS .zfs/ directory functionality + has been reimplemented. It's not possible now to create a snapshot + by mkdir under .zfs/snapshot/. That should be the only user visible + change. + 20160124: The NONE and HPN patches has been removed from OpenSSH. They are still available in the security/openssh-portable port. From owner-svn-src-stable-10@freebsd.org Thu Mar 23 08:22:12 2017 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 8445ED19FE7; Thu, 23 Mar 2017 08:22:12 +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 5359F2CC; Thu, 23 Mar 2017 08:22:12 +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 v2N8MBIo096451; Thu, 23 Mar 2017 08:22:11 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N8MBsF096450; Thu, 23 Mar 2017 08:22:11 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201703230822.v2N8MBsF096450@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 23 Mar 2017 08:22: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: r315848 - 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.23 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, 23 Mar 2017 08:22:12 -0000 Author: avg Date: Thu Mar 23 08:22:11 2017 New Revision: 315848 URL: https://svnweb.freebsd.org/changeset/base/315848 Log: MFC r315076: zfs: provide a special vptocnp method for the .zfs vnode 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 Thu Mar 23 08:19:51 2017 (r315847) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c Thu Mar 23 08:22:11 2017 (r315848) @@ -706,6 +706,28 @@ zfsctl_root_readdir(ap) return (0); } +static int +zfsctl_root_vptocnp(struct vop_vptocnp_args *ap) +{ + static const char dotzfs_name[4] = ".zfs"; + vnode_t *dvp; + int error; + + if (*ap->a_buflen < sizeof (dotzfs_name)) + return (SET_ERROR(ENOMEM)); + + error = vn_vget_ino_gen(ap->a_vp, zfsctl_fs_root_vnode, NULL, + LK_SHARED, &dvp); + if (error != 0) + return (SET_ERROR(error)); + + VOP_UNLOCK(dvp, 0); + *ap->a_vpp = dvp; + *ap->a_buflen -= sizeof (dotzfs_name); + bcopy(dotzfs_name, ap->a_buf + *ap->a_buflen, sizeof (dotzfs_name)); + return (0); +} + static struct vop_vector zfsctl_ops_root = { .vop_default = &default_vnodeops, .vop_open = zfsctl_common_open, @@ -719,6 +741,7 @@ static struct vop_vector zfsctl_ops_root .vop_reclaim = zfsctl_common_reclaim, .vop_fid = zfsctl_common_fid, .vop_print = zfsctl_common_print, + .vop_vptocnp = zfsctl_root_vptocnp, }; static int From owner-svn-src-stable-10@freebsd.org Thu Mar 23 10:22:08 2017 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 12D65D19A0C; Thu, 23 Mar 2017 10:22:08 +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 D63A7100C; Thu, 23 Mar 2017 10:22:07 +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 v2NAM61M048125; Thu, 23 Mar 2017 10:22:06 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2NAM6wG048124; Thu, 23 Mar 2017 10:22:06 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201703231022.v2NAM6wG048124@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 23 Mar 2017 10:22:06 +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: r315854 - stable/10/sys/dev/aacraid 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.23 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, 23 Mar 2017 10:22:08 -0000 Author: avg Date: Thu Mar 23 10:22:06 2017 New Revision: 315854 URL: https://svnweb.freebsd.org/changeset/base/315854 Log: revert r315841, MFC of r315083: not applicable to this branch And it broke the build too. Reported by: lwhsu Modified: stable/10/sys/dev/aacraid/aacraid_cam.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/aacraid/aacraid_cam.c ============================================================================== --- stable/10/sys/dev/aacraid/aacraid_cam.c Thu Mar 23 09:13:21 2017 (r315853) +++ stable/10/sys/dev/aacraid/aacraid_cam.c Thu Mar 23 10:22:06 2017 (r315854) @@ -244,7 +244,6 @@ aac_cam_probe(device_t dev) { struct aac_softc *sc; struct aac_cam *camsc; - struct aac_softc *sc; camsc = (struct aac_cam *)device_get_softc(dev); if (!camsc->inf) @@ -1138,7 +1137,6 @@ aac_container_complete(struct aac_comman { struct aac_softc *sc; union ccb *ccb; - struct aac_softc *sc; u_int32_t status; sc = cm->cm_sc; @@ -1148,7 +1146,7 @@ aac_container_complete(struct aac_comman if (cm->cm_flags & AAC_CMD_RESET) { ccb->ccb_h.status = CAM_SCSI_BUS_RESET; - } else if (status == ST_OK) { + } else if (status == ST_OK) { ccb->ccb_h.status = CAM_REQ_CMP; } else if (status == ST_NOT_READY) { ccb->ccb_h.status = CAM_BUSY; From owner-svn-src-stable-10@freebsd.org Thu Mar 23 20:23:01 2017 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 E71E6CA179B; Thu, 23 Mar 2017 20:23:01 +0000 (UTC) (envelope-from np@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 C1B9316DE; Thu, 23 Mar 2017 20:23:01 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2NKN03t093434; Thu, 23 Mar 2017 20:23:00 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2NKN0WL093433; Thu, 23 Mar 2017 20:23:00 GMT (envelope-from np@FreeBSD.org) Message-Id: <201703232023.v2NKN0WL093433@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Thu, 23 Mar 2017 20:23:00 +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: r315868 - stable/10/sys/dev/cxgbe/iw_cxgbe 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.23 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, 23 Mar 2017 20:23:02 -0000 Author: np Date: Thu Mar 23 20:23:00 2017 New Revision: 315868 URL: https://svnweb.freebsd.org/changeset/base/315868 Log: MFC r314814 and r315325. r314814: cxgbe/iw_cxgbe: Abort connection if there is an error during c4iw_modify_qp. r315325: cxgbe/iw_cxgbe: Use the socket and not the toepcb to reach for the inpcb. t4_tom detaches the inpcb from the toepcb as soon as the hardware is done with the connection (in final_cpl_received) but the socket is around as long as the cm_id and the rest of iWARP state is. This fixes an intermittent NULL dereference during abort. Modified: stable/10/sys/dev/cxgbe/iw_cxgbe/qp.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/cxgbe/iw_cxgbe/qp.c ============================================================================== --- stable/10/sys/dev/cxgbe/iw_cxgbe/qp.c Thu Mar 23 19:54:41 2017 (r315867) +++ stable/10/sys/dev/cxgbe/iw_cxgbe/qp.c Thu Mar 23 20:23:00 2017 (r315868) @@ -63,7 +63,7 @@ struct rss_header; #include "iw_cxgbe.h" #include "user.h" -static void creds(struct toepcb *toep, size_t wrsize); +static int creds(struct toepcb *toep, struct inpcb *inp, size_t wrsize); static void set_state(struct c4iw_qp *qhp, enum c4iw_qp_state state) @@ -960,6 +960,7 @@ static inline void build_term_codes(stru static void post_terminate(struct c4iw_qp *qhp, struct t4_cqe *err_cqe, gfp_t gfp) { + int ret; struct fw_ri_wr *wqe; struct terminate_message *term; struct wrqe *wr; @@ -990,7 +991,11 @@ static void post_terminate(struct c4iw_q term->ecode = qhp->attr.ecode; } else build_term_codes(err_cqe, &term->layer_etype, &term->ecode); - creds(toep, sizeof(*wqe)); + ret = creds(toep, inp, sizeof(*wqe)); + if (ret) { + free_wrqe(wr); + return; + } t4_wrq_tx(qhp->rhp->rdev.adap, wr); } @@ -1093,7 +1098,11 @@ rdma_fini(struct c4iw_dev *rhp, struct c c4iw_init_wr_wait(&ep->com.wr_wait); - creds(toep, sizeof(*wqe)); + ret = creds(toep, inp, sizeof(*wqe)); + if (ret) { + free_wrqe(wr); + return ret; + } t4_wrq_tx(sc, wr); ret = c4iw_wait_for_reply(rdev, &ep->com.wr_wait, ep->hwtid, @@ -1126,13 +1135,17 @@ static void build_rtr_msg(u8 p2p_type, s } } -static void -creds(struct toepcb *toep, size_t wrsize) +static int +creds(struct toepcb *toep, struct inpcb *inp, size_t wrsize) { struct ofld_tx_sdesc *txsd; CTR3(KTR_IW_CXGBE, "%s:creB %p %u", __func__, toep , wrsize); - INP_WLOCK(toep->inp); + INP_WLOCK(inp); + if ((inp->inp_flags & (INP_DROPPED | INP_TIMEWAIT)) != 0) { + INP_WUNLOCK(inp); + return (EINVAL); + } txsd = &toep->txsd[toep->txsd_pidx]; txsd->tx_credits = howmany(wrsize, 16); txsd->plen = 0; @@ -1142,9 +1155,10 @@ creds(struct toepcb *toep, size_t wrsize if (__predict_false(++toep->txsd_pidx == toep->txsd_total)) toep->txsd_pidx = 0; toep->txsd_avail--; - INP_WUNLOCK(toep->inp); + INP_WUNLOCK(inp); CTR5(KTR_IW_CXGBE, "%s:creE %p %u %u %u", __func__, toep , txsd->tx_credits, toep->tx_credits, toep->txsd_pidx); + return (0); } static int rdma_init(struct c4iw_dev *rhp, struct c4iw_qp *qhp) @@ -1215,7 +1229,11 @@ static int rdma_init(struct c4iw_dev *rh c4iw_init_wr_wait(&ep->com.wr_wait); - creds(toep, sizeof(*wqe)); + ret = creds(toep, inp, sizeof(*wqe)); + if (ret) { + free_wrqe(wr); + return ret; + } t4_wrq_tx(sc, wr); ret = c4iw_wait_for_reply(rdev, &ep->com.wr_wait, ep->hwtid, @@ -1426,6 +1444,7 @@ err: qhp->ep = NULL; set_state(qhp, C4IW_QP_STATE_ERROR); free = 1; + abort = 1; BUG_ON(!ep); flush_qp(qhp); wake_up(&qhp->wait); From owner-svn-src-stable-10@freebsd.org Fri Mar 24 03:11:13 2017 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 726D4D17784; Fri, 24 Mar 2017 03:11:13 +0000 (UTC) (envelope-from davidcs@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 36ECB1B63; Fri, 24 Mar 2017 03:11:13 +0000 (UTC) (envelope-from davidcs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2O3BCJF060881; Fri, 24 Mar 2017 03:11:12 GMT (envelope-from davidcs@FreeBSD.org) Received: (from davidcs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2O3BB39060876; Fri, 24 Mar 2017 03:11:11 GMT (envelope-from davidcs@FreeBSD.org) Message-Id: <201703240311.v2O3BB39060876@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: davidcs set sender to davidcs@FreeBSD.org using -f From: David C Somayajulu Date: Fri, 24 Mar 2017 03:11: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: r315882 - stable/10/sys/dev/bxe 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.23 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, 24 Mar 2017 03:11:13 -0000 Author: davidcs Date: Fri Mar 24 03:11:11 2017 New Revision: 315882 URL: https://svnweb.freebsd.org/changeset/base/315882 Log: MFC r314365 1. state checks in bxe_tx_mq_start_locked() and bxe_tx_mq_start() to sync threads during interface down or detach. 2. add sysctl to set pause frame parameters 3. increase max segs for TSO packets to BXE_TSO_MAX_SEGMENTS (32) 4. add debug messages for PHY 5. HW LRO support restricted to FreeBSD versions 8.x and above. Submitted by: Vaishali.Kulkarni@cavium.com Modified: stable/10/sys/dev/bxe/bxe.c stable/10/sys/dev/bxe/bxe.h stable/10/sys/dev/bxe/bxe_elink.c stable/10/sys/dev/bxe/bxe_stats.c stable/10/sys/dev/bxe/bxe_stats.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/bxe/bxe.c ============================================================================== --- stable/10/sys/dev/bxe/bxe.c Fri Mar 24 02:58:20 2017 (r315881) +++ stable/10/sys/dev/bxe/bxe.c Fri Mar 24 03:11:11 2017 (r315882) @@ -27,7 +27,7 @@ #include __FBSDID("$FreeBSD$"); -#define BXE_DRIVER_VERSION "1.78.89" +#define BXE_DRIVER_VERSION "1.78.90" #include "bxe.h" #include "ecore_sp.h" @@ -501,12 +501,19 @@ static const struct { 4, STATS_FLAGS_FUNC, "mbuf_alloc_tpa"}, { STATS_OFFSET32(tx_queue_full_return), 4, STATS_FLAGS_FUNC, "tx_queue_full_return"}, + { STATS_OFFSET32(bxe_tx_mq_sc_state_failures), + 4, STATS_FLAGS_FUNC, "bxe_tx_mq_sc_state_failures"}, { STATS_OFFSET32(tx_request_link_down_failures), 4, STATS_FLAGS_FUNC, "tx_request_link_down_failures"}, { STATS_OFFSET32(bd_avail_too_less_failures), 4, STATS_FLAGS_FUNC, "bd_avail_too_less_failures"}, { STATS_OFFSET32(tx_mq_not_empty), - 4, STATS_FLAGS_FUNC, "tx_mq_not_empty"} + 4, STATS_FLAGS_FUNC, "tx_mq_not_empty"}, + { STATS_OFFSET32(nsegs_path1_errors), + 4, STATS_FLAGS_FUNC, "nsegs_path1_errors"}, + { STATS_OFFSET32(nsegs_path2_errors), + 4, STATS_FLAGS_FUNC, "nsegs_path2_errors"} + }; @@ -621,12 +628,19 @@ static const struct { 4, "mbuf_alloc_tpa"}, { Q_STATS_OFFSET32(tx_queue_full_return), 4, "tx_queue_full_return"}, + { Q_STATS_OFFSET32(bxe_tx_mq_sc_state_failures), + 4, "bxe_tx_mq_sc_state_failures"}, { Q_STATS_OFFSET32(tx_request_link_down_failures), 4, "tx_request_link_down_failures"}, { Q_STATS_OFFSET32(bd_avail_too_less_failures), 4, "bd_avail_too_less_failures"}, { Q_STATS_OFFSET32(tx_mq_not_empty), - 4, "tx_mq_not_empty"} + 4, "tx_mq_not_empty"}, + { Q_STATS_OFFSET32(nsegs_path1_errors), + 4, "nsegs_path1_errors"}, + { Q_STATS_OFFSET32(nsegs_path2_errors), + 4, "nsegs_path2_errors"} + }; @@ -697,6 +711,7 @@ static void bxe_handle_fp_tq(void *conte static int bxe_add_cdev(struct bxe_softc *sc); static void bxe_del_cdev(struct bxe_softc *sc); +int bxe_grc_dump(struct bxe_softc *sc); static int bxe_alloc_buf_rings(struct bxe_softc *sc); static void bxe_free_buf_rings(struct bxe_softc *sc); @@ -4684,7 +4699,7 @@ bxe_ioctl(struct ifnet *ifp, break; } - if (reinit && (sc->ifnet->if_drv_flags & IFF_DRV_RUNNING)) { + if (reinit && (ifp->if_drv_flags & IFF_DRV_RUNNING)) { BLOGD(sc, DBG_LOAD | DBG_IOCTL, "Re-initializing hardware from IOCTL change\n"); bxe_periodic_stop(sc); @@ -5238,12 +5253,24 @@ bxe_tx_encap(struct bxe_fastpath *fp, st fp->eth_q_stats.tx_dma_mapping_failure++; /* No sense in trying to defrag/copy chain, drop it. :( */ rc = error; - } - else { - /* if the chain is still too long then drop it */ - if (__predict_false(nsegs > BXE_MAX_SEGMENTS)) { - bus_dmamap_unload(fp->tx_mbuf_tag, tx_buf->m_map); - rc = ENODEV; + } else { + /* if the chain is still too long then drop it */ + if(m0->m_pkthdr.csum_flags & CSUM_TSO) { + /* + * in case TSO is enabled nsegs should be checked against + * BXE_TSO_MAX_SEGMENTS + */ + if (__predict_false(nsegs > BXE_TSO_MAX_SEGMENTS)) { + bus_dmamap_unload(fp->tx_mbuf_tag, tx_buf->m_map); + fp->eth_q_stats.nsegs_path1_errors++; + rc = ENODEV; + } + } else { + if (__predict_false(nsegs > BXE_MAX_SEGMENTS)) { + bus_dmamap_unload(fp->tx_mbuf_tag, tx_buf->m_map); + fp->eth_q_stats.nsegs_path2_errors++; + rc = ENODEV; + } } } } @@ -5643,6 +5670,11 @@ bxe_tx_mq_start_locked(struct bxe_softc BXE_FP_TX_LOCK_ASSERT(fp); + if (sc->state != BXE_STATE_OPEN) { + fp->eth_q_stats.bxe_tx_mq_sc_state_failures++; + return ENETDOWN; + } + if (!tx_br) { BLOGE(sc, "Multiqueue TX and no buf_ring!\n"); return (EINVAL); @@ -5764,6 +5796,11 @@ bxe_tx_mq_start(struct ifnet *ifp, fp = &sc->fp[fp_index]; + if (sc->state != BXE_STATE_OPEN) { + fp->eth_q_stats.bxe_tx_mq_sc_state_failures++; + return ENETDOWN; + } + if (BXE_FP_TX_TRYLOCK(fp)) { rc = bxe_tx_mq_start_locked(sc, ifp, fp, m); BXE_FP_TX_UNLOCK(fp); @@ -5786,7 +5823,7 @@ bxe_mq_flush(struct ifnet *ifp) for (i = 0; i < sc->num_queues; i++) { fp = &sc->fp[i]; - if (fp->state != BXE_FP_STATE_OPEN) { + if (fp->state != BXE_FP_STATE_IRQ) { BLOGD(sc, DBG_LOAD, "Not clearing fp[%02d] buf_ring (state=%d)\n", fp->index, fp->state); continue; @@ -6003,6 +6040,7 @@ bxe_free_mem(struct bxe_softc *sc) static int bxe_alloc_mem(struct bxe_softc *sc) { + int context_size; int allocated; int i; @@ -6997,7 +7035,7 @@ bxe_link_attn(struct bxe_softc *sc) /* Make sure that we are synced with the current statistics */ bxe_stats_handle(sc, STATS_EVENT_STOP); - + BLOGI(sc, "link_vars phy_flags : %x\n", sc->link_vars.phy_flags); elink_link_update(&sc->link_params, &sc->link_vars); if (sc->link_vars.link_up) { @@ -11202,7 +11240,9 @@ bxe_get_q_flags(struct bxe_softc *sc, if (sc->ifnet->if_capenable & IFCAP_LRO) { bxe_set_bit(ECORE_Q_FLG_TPA, &flags); +#if __FreeBSD_version >= 800000 bxe_set_bit(ECORE_Q_FLG_TPA_IPV6, &flags); +#endif } if (leading) { @@ -11639,13 +11679,13 @@ static void bxe_calc_fc_adv(struct bxe_softc *sc) { uint8_t cfg_idx = bxe_get_link_cfg_idx(sc); + + + sc->port.advertising[cfg_idx] &= ~(ADVERTISED_Asym_Pause | + ADVERTISED_Pause); + switch (sc->link_vars.ieee_fc & MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_MASK) { - case MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_NONE: - default: - sc->port.advertising[cfg_idx] &= ~(ADVERTISED_Asym_Pause | - ADVERTISED_Pause); - break; case MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH: sc->port.advertising[cfg_idx] |= (ADVERTISED_Asym_Pause | @@ -11655,6 +11695,10 @@ bxe_calc_fc_adv(struct bxe_softc *sc) case MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC: sc->port.advertising[cfg_idx] |= ADVERTISED_Asym_Pause; break; + + default: + break; + } } @@ -11736,15 +11780,17 @@ bxe_link_report_locked(struct bxe_softc return; } + ELINK_DEBUG_P2(sc, "Change in link status : cur_data = %x, last_reported_link = %x\n", + cur_data.link_report_flags, sc->last_reported_link.link_report_flags); sc->link_cnt++; + ELINK_DEBUG_P1(sc, "link status change count = %x\n", sc->link_cnt); /* report new link params and remember the state for the next time */ memcpy(&sc->last_reported_link, &cur_data, sizeof(cur_data)); if (bxe_test_bit(BXE_LINK_REPORT_LINK_DOWN, &cur_data.link_report_flags)) { if_link_state_change(sc->ifnet, LINK_STATE_DOWN); - BLOGI(sc, "NIC Link is Down\n"); } else { const char *duplex; const char *flow; @@ -11752,8 +11798,10 @@ bxe_link_report_locked(struct bxe_softc if (bxe_test_and_clear_bit(BXE_LINK_REPORT_FULL_DUPLEX, &cur_data.link_report_flags)) { duplex = "full"; + ELINK_DEBUG_P0(sc, "link set to full duplex\n"); } else { duplex = "half"; + ELINK_DEBUG_P0(sc, "link set to half duplex\n"); } /* @@ -12677,6 +12725,7 @@ bxe_init_ifnet(struct bxe_softc *sc) ifmedia_set(&sc->ifmedia, (IFM_ETHER | IFM_AUTO)); sc->ifmedia.ifm_media = sc->ifmedia.ifm_cur->ifm_media; /* XXX ? */ + BLOGI(sc, "IFMEDIA flags : %x\n", sc->ifmedia.ifm_media); /* allocate the ifnet structure */ if ((ifp = if_alloc(IFT_ETHER)) == NULL) { @@ -14027,6 +14076,8 @@ bxe_link_settings_supported(struct bxe_s BLOGD(sc, DBG_LOAD, "PHY supported 0=0x%08x 1=0x%08x\n", sc->port.supported[0], sc->port.supported[1]); + ELINK_DEBUG_P2(sc, "PHY supported 0=0x%08x 1=0x%08x\n", + sc->port.supported[0], sc->port.supported[1]); } static void @@ -14091,6 +14142,8 @@ bxe_link_settings_requested(struct bxe_s sc->link_params.req_duplex[idx] = DUPLEX_HALF; sc->port.advertising[idx] |= (ADVERTISED_10baseT_Half | ADVERTISED_TP); + ELINK_DEBUG_P1(sc, "driver requesting DUPLEX_HALF req_duplex = %x!\n", + sc->link_params.req_duplex[idx]); } else { BLOGE(sc, "Invalid NVRAM config link_config=0x%08x " "speed_cap_mask=0x%08x\n", @@ -14195,6 +14248,11 @@ bxe_link_settings_requested(struct bxe_s sc->link_params.req_duplex[idx], sc->link_params.req_flow_ctrl[idx], sc->port.advertising[idx]); + ELINK_DEBUG_P3(sc, "req_line_speed=%d req_duplex=%d " + "advertising=0x%x\n", + sc->link_params.req_line_speed[idx], + sc->link_params.req_duplex[idx], + sc->port.advertising[idx]); } } @@ -14207,11 +14265,12 @@ bxe_get_phy_info(struct bxe_softc *sc) /* shmem data already read in bxe_get_shmem_info() */ - BLOGD(sc, DBG_LOAD, "lane_config=0x%08x speed_cap_mask0=0x%08x " + ELINK_DEBUG_P3(sc, "lane_config=0x%08x speed_cap_mask0=0x%08x " "link_config0=0x%08x\n", sc->link_params.lane_config, sc->link_params.speed_cap_mask[0], sc->port.link_config[0]); + bxe_link_settings_supported(sc, sc->link_params.switch_cfg); bxe_link_settings_requested(sc); @@ -14242,6 +14301,7 @@ bxe_get_phy_info(struct bxe_softc *sc) /* get the media type */ bxe_media_detect(sc); + ELINK_DEBUG_P1(sc, "detected media type\n", sc->media); } static void @@ -15597,6 +15657,86 @@ bxe_sysctl_eth_q_stat(SYSCTL_HANDLER_ARG return (sysctl_handle_64(oidp, &value, 0, req)); } +static void bxe_force_link_reset(struct bxe_softc *sc) +{ + + bxe_acquire_phy_lock(sc); + elink_link_reset(&sc->link_params, &sc->link_vars, 1); + bxe_release_phy_lock(sc); +} + +static int +bxe_sysctl_pauseparam(SYSCTL_HANDLER_ARGS) +{ + struct bxe_softc *sc = (struct bxe_softc *)arg1;; + uint32_t cfg_idx = bxe_get_link_cfg_idx(sc); + int rc = 0; + int error; + int result; + + + error = sysctl_handle_int(oidp, &sc->bxe_pause_param, 0, req); + + if (error || !req->newptr) { + return (error); + } + if ((sc->bxe_pause_param < 0) || (sc->bxe_pause_param > 8)) { + BLOGW(sc, "invalid pause param (%d) - use intergers between 1 & 8\n",sc->bxe_pause_param); + sc->bxe_pause_param = 8; + } + + result = (sc->bxe_pause_param << PORT_FEATURE_FLOW_CONTROL_SHIFT); + + + if((result & 0x400) && !(sc->port.supported[cfg_idx] & ELINK_SUPPORTED_Autoneg)) { + BLOGW(sc, "Does not support Autoneg pause_param %d\n", sc->bxe_pause_param); + return -EINVAL; + } + + if(IS_MF(sc)) + return 0; + sc->link_params.req_flow_ctrl[cfg_idx] = ELINK_FLOW_CTRL_AUTO; + if(result & ELINK_FLOW_CTRL_RX) + sc->link_params.req_flow_ctrl[cfg_idx] |= ELINK_FLOW_CTRL_RX; + + if(result & ELINK_FLOW_CTRL_TX) + sc->link_params.req_flow_ctrl[cfg_idx] |= ELINK_FLOW_CTRL_TX; + if(sc->link_params.req_flow_ctrl[cfg_idx] == ELINK_FLOW_CTRL_AUTO) + sc->link_params.req_flow_ctrl[cfg_idx] = ELINK_FLOW_CTRL_NONE; + + if(result & 0x400) { + if (sc->link_params.req_line_speed[cfg_idx] == ELINK_SPEED_AUTO_NEG) { + sc->link_params.req_flow_ctrl[cfg_idx] = + ELINK_FLOW_CTRL_AUTO; + } + sc->link_params.req_fc_auto_adv = 0; + if (result & ELINK_FLOW_CTRL_RX) + sc->link_params.req_fc_auto_adv |= ELINK_FLOW_CTRL_RX; + + if (result & ELINK_FLOW_CTRL_TX) + sc->link_params.req_fc_auto_adv |= ELINK_FLOW_CTRL_TX; + if (!sc->link_params.req_fc_auto_adv) + sc->link_params.req_fc_auto_adv |= ELINK_FLOW_CTRL_NONE; + } + if (IS_PF(sc)) { + if (sc->link_vars.link_up) { + bxe_stats_handle(sc, STATS_EVENT_STOP); + } + if (sc->ifnet->if_drv_flags & IFF_DRV_RUNNING) { + bxe_force_link_reset(sc); + bxe_acquire_phy_lock(sc); + + rc = elink_phy_init(&sc->link_params, &sc->link_vars); + + bxe_release_phy_lock(sc); + + bxe_calc_fc_adv(sc); + } + } + return rc; +} + + static void bxe_add_sysctls(struct bxe_softc *sc) { @@ -15697,6 +15837,12 @@ bxe_add_sysctls(struct bxe_softc *sc) CTLFLAG_RW, &sc->rx_budget, 0, "rx processing budget"); + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "pause_param", + CTLTYPE_UINT | CTLFLAG_RW, sc, 0, + bxe_sysctl_pauseparam, "IU", + "need pause frames- DEF:0/TX:1/RX:2/BOTH:3/AUTO:4/AUTOTX:5/AUTORX:6/AUTORXTX:7/NONE:8"); + + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "state", CTLTYPE_UINT | CTLFLAG_RW, sc, 0, bxe_sysctl_state, "IU", "dump driver state"); @@ -18031,6 +18177,7 @@ bxe_reset_port(struct bxe_softc *sc) int port = SC_PORT(sc); uint32_t val; + ELINK_DEBUG_P0(sc, "bxe_reset_port called\n"); /* reset physical Link */ bxe_link_reset(sc); @@ -18533,8 +18680,6 @@ bxe_grc_dump(struct bxe_softc *sc) uint32_t reg_val; uint32_t reg_addr; uint32_t cmd_offset; - int context_size; - int allocated; struct ecore_ilt *ilt = SC_ILT(sc); struct bxe_fastpath *fp; struct ilt_client_info *ilt_cli; @@ -18629,67 +18774,80 @@ bxe_grc_dump(struct bxe_softc *sc) bxe_pretend_func(sc, SC_ABS_FUNC(sc)); - context_size = (sizeof(union cdu_context) * BXE_L2_CID_COUNT(sc)); - for (i = 0, allocated = 0; allocated < context_size; i++) { - - BLOGI(sc, "cdu_context i %d paddr %#jx vaddr %p size 0x%zx\n", i, - (uintmax_t)sc->context[i].vcxt_dma.paddr, - sc->context[i].vcxt_dma.vaddr, - sc->context[i].size); - allocated += sc->context[i].size; - } - BLOGI(sc, "fw stats start_paddr %#jx end_paddr %#jx vaddr %p size 0x%x\n", - (uintmax_t)sc->fw_stats_req_mapping, - (uintmax_t)sc->fw_stats_data_mapping, - sc->fw_stats_req, (sc->fw_stats_req_size + sc->fw_stats_data_size)); - BLOGI(sc, "def_status_block paddr %p vaddr %p size 0x%zx\n", - (void *)sc->def_sb_dma.paddr, sc->def_sb, - sizeof(struct host_sp_status_block)); - BLOGI(sc, "event_queue paddr %#jx vaddr %p size 0x%x\n", - (uintmax_t)sc->eq_dma.paddr, sc->eq_dma.vaddr, BCM_PAGE_SIZE); - BLOGI(sc, "slow path paddr %#jx vaddr %p size 0x%zx\n", - (uintmax_t)sc->sp_dma.paddr, sc->sp_dma.vaddr, - sizeof(struct bxe_slowpath)); - BLOGI(sc, "slow path queue paddr %#jx vaddr %p size 0x%x\n", - (uintmax_t)sc->spq_dma.paddr, sc->spq_dma.vaddr, BCM_PAGE_SIZE); - BLOGI(sc, "fw_buf paddr %#jx vaddr %p size 0x%x\n", - (uintmax_t)sc->gz_buf_dma.paddr, sc->gz_buf_dma.vaddr, - FW_BUF_SIZE); - for (i = 0; i < sc->num_queues; i++) { - fp = &sc->fp[i]; - BLOGI(sc, "FP status block fp %d paddr %#jx vaddr %p size 0x%zx\n", i, - (uintmax_t)fp->sb_dma.paddr, fp->sb_dma.vaddr, - sizeof(union bxe_host_hc_status_block)); - BLOGI(sc, "TX BD CHAIN fp %d paddr %#jx vaddr %p size 0x%x\n", i, - (uintmax_t)fp->tx_dma.paddr, fp->tx_dma.vaddr, - (BCM_PAGE_SIZE * TX_BD_NUM_PAGES)); - BLOGI(sc, "RX BD CHAIN fp %d paddr %#jx vaddr %p size 0x%x\n", i, - (uintmax_t)fp->rx_dma.paddr, fp->rx_dma.vaddr, - (BCM_PAGE_SIZE * RX_BD_NUM_PAGES)); - BLOGI(sc, "RX RCQ CHAIN fp %d paddr %#jx vaddr %p size 0x%zx\n", i, - (uintmax_t)fp->rcq_dma.paddr, fp->rcq_dma.vaddr, - (BCM_PAGE_SIZE * RCQ_NUM_PAGES)); - BLOGI(sc, "RX SGE CHAIN fp %d paddr %#jx vaddr %p size 0x%x\n", i, - (uintmax_t)fp->rx_sge_dma.paddr, fp->rx_sge_dma.vaddr, - (BCM_PAGE_SIZE * RX_SGE_NUM_PAGES)); - } - - ilt_cli = &ilt->clients[1]; - for (i = ilt_cli->start; i <= ilt_cli->end; i++) { - BLOGI(sc, "ECORE_ILT paddr %#jx vaddr %p size 0x%x\n", - (uintmax_t)(((struct bxe_dma *)((&ilt->lines[i])->page))->paddr), - ((struct bxe_dma *)((&ilt->lines[i])->page))->vaddr, BCM_PAGE_SIZE); - } - - - cmd_offset = DMAE_REG_CMD_MEM; - for (i = 0; i < 224; i++) { - reg_addr = (cmd_offset +(i * 4)); - reg_val = REG_RD(sc, reg_addr); - BLOGI(sc, "DMAE_REG_CMD_MEM i=%d reg_addr 0x%x reg_val 0x%08x\n",i, - reg_addr, reg_val); - } + if(sc->state == BXE_STATE_OPEN) { + if(sc->fw_stats_req != NULL) { + BLOGI(sc, "fw stats start_paddr %#jx end_paddr %#jx vaddr %p size 0x%x\n", + (uintmax_t)sc->fw_stats_req_mapping, + (uintmax_t)sc->fw_stats_data_mapping, + sc->fw_stats_req, (sc->fw_stats_req_size + sc->fw_stats_data_size)); + } + if(sc->def_sb != NULL) { + BLOGI(sc, "def_status_block paddr %p vaddr %p size 0x%zx\n", + (void *)sc->def_sb_dma.paddr, sc->def_sb, + sizeof(struct host_sp_status_block)); + } + if(sc->eq_dma.vaddr != NULL) { + BLOGI(sc, "event_queue paddr %#jx vaddr %p size 0x%x\n", + (uintmax_t)sc->eq_dma.paddr, sc->eq_dma.vaddr, BCM_PAGE_SIZE); + } + if(sc->sp_dma.vaddr != NULL) { + BLOGI(sc, "slow path paddr %#jx vaddr %p size 0x%zx\n", + (uintmax_t)sc->sp_dma.paddr, sc->sp_dma.vaddr, + sizeof(struct bxe_slowpath)); + } + if(sc->spq_dma.vaddr != NULL) { + BLOGI(sc, "slow path queue paddr %#jx vaddr %p size 0x%x\n", + (uintmax_t)sc->spq_dma.paddr, sc->spq_dma.vaddr, BCM_PAGE_SIZE); + } + if(sc->gz_buf_dma.vaddr != NULL) { + BLOGI(sc, "fw_buf paddr %#jx vaddr %p size 0x%x\n", + (uintmax_t)sc->gz_buf_dma.paddr, sc->gz_buf_dma.vaddr, + FW_BUF_SIZE); + } + for (i = 0; i < sc->num_queues; i++) { + fp = &sc->fp[i]; + if(fp->sb_dma.vaddr != NULL && fp->tx_dma.vaddr != NULL && + fp->rx_dma.vaddr != NULL && fp->rcq_dma.vaddr != NULL && + fp->rx_sge_dma.vaddr != NULL) { + + BLOGI(sc, "FP status block fp %d paddr %#jx vaddr %p size 0x%zx\n", i, + (uintmax_t)fp->sb_dma.paddr, fp->sb_dma.vaddr, + sizeof(union bxe_host_hc_status_block)); + BLOGI(sc, "TX BD CHAIN fp %d paddr %#jx vaddr %p size 0x%x\n", i, + (uintmax_t)fp->tx_dma.paddr, fp->tx_dma.vaddr, + (BCM_PAGE_SIZE * TX_BD_NUM_PAGES)); + BLOGI(sc, "RX BD CHAIN fp %d paddr %#jx vaddr %p size 0x%x\n", i, + (uintmax_t)fp->rx_dma.paddr, fp->rx_dma.vaddr, + (BCM_PAGE_SIZE * RX_BD_NUM_PAGES)); + BLOGI(sc, "RX RCQ CHAIN fp %d paddr %#jx vaddr %p size 0x%zx\n", i, + (uintmax_t)fp->rcq_dma.paddr, fp->rcq_dma.vaddr, + (BCM_PAGE_SIZE * RCQ_NUM_PAGES)); + BLOGI(sc, "RX SGE CHAIN fp %d paddr %#jx vaddr %p size 0x%x\n", i, + (uintmax_t)fp->rx_sge_dma.paddr, fp->rx_sge_dma.vaddr, + (BCM_PAGE_SIZE * RX_SGE_NUM_PAGES)); + } + } + if(ilt != NULL ) { + ilt_cli = &ilt->clients[1]; + if(ilt->lines != NULL) { + for (i = ilt_cli->start; i <= ilt_cli->end; i++) { + BLOGI(sc, "ECORE_ILT paddr %#jx vaddr %p size 0x%x\n", + (uintmax_t)(((struct bxe_dma *)((&ilt->lines[i])->page))->paddr), + ((struct bxe_dma *)((&ilt->lines[i])->page))->vaddr, BCM_PAGE_SIZE); + } + } + } + + + cmd_offset = DMAE_REG_CMD_MEM; + for (i = 0; i < 224; i++) { + reg_addr = (cmd_offset +(i * 4)); + reg_val = REG_RD(sc, reg_addr); + BLOGI(sc, "DMAE_REG_CMD_MEM i=%d reg_addr 0x%x reg_val 0x%08x\n",i, + reg_addr, reg_val); + } + } BLOGI(sc, "Collection of grcdump done\n"); sc->grcdump_done = 1; Modified: stable/10/sys/dev/bxe/bxe.h ============================================================================== --- stable/10/sys/dev/bxe/bxe.h Fri Mar 24 02:58:20 2017 (r315881) +++ stable/10/sys/dev/bxe/bxe.h Fri Mar 24 03:11:11 2017 (r315882) @@ -1335,7 +1335,7 @@ struct bxe_softc { struct ifmedia ifmedia; /* network interface media structure */ int media; - int state; /* device state */ + volatile int state; /* device state */ #define BXE_STATE_CLOSED 0x0000 #define BXE_STATE_OPENING_WAITING_LOAD 0x1000 #define BXE_STATE_OPENING_WAITING_PORT 0x2000 @@ -1794,7 +1794,7 @@ struct bxe_softc { unsigned int trigger_grcdump; unsigned int grcdump_done; unsigned int grcdump_started; - + int bxe_pause_param; void *eeprom; }; /* struct bxe_softc */ @@ -2300,7 +2300,6 @@ void bxe_dump_mem(struct bxe_softc *sc, uint8_t *mem, uint32_t len); void bxe_dump_mbuf_data(struct bxe_softc *sc, char *pTag, struct mbuf *m, uint8_t contents); -extern int bxe_grc_dump(struct bxe_softc *sc); #if __FreeBSD_version >= 800000 #if (__FreeBSD_version >= 1001513 && __FreeBSD_version < 1100000) ||\ Modified: stable/10/sys/dev/bxe/bxe_elink.c ============================================================================== --- stable/10/sys/dev/bxe/bxe_elink.c Fri Mar 24 02:58:20 2017 (r315881) +++ stable/10/sys/dev/bxe/bxe_elink.c Fri Mar 24 03:11:11 2017 (r315882) @@ -4333,6 +4333,7 @@ static void elink_pause_resolve(struct e * although we advertised both, need to enable * RX only. */ + if (params->req_fc_auto_adv == ELINK_FLOW_CTRL_BOTH) { ELINK_DEBUG_P0(sc, "Flow Control: RX & TX\n"); vars->flow_ctrl = ELINK_FLOW_CTRL_BOTH; @@ -5538,6 +5539,7 @@ static void elink_sync_link(struct elink vars->link_up = (vars->link_status & LINK_STATUS_LINK_UP); if (vars->link_up) { ELINK_DEBUG_P0(sc, "phy link up\n"); + ELINK_DEBUG_P1(sc, "link status = %x\n", vars->link_status); vars->phy_link_up = 1; vars->duplex = DUPLEX_FULL; @@ -6443,6 +6445,8 @@ static elink_status_t elink_get_link_spe vars->flow_ctrl = ELINK_FLOW_CTRL_NONE; vars->mac_type = ELINK_MAC_TYPE_NONE; } + ELINK_DEBUG_P2(sc, " in elink_get_link_speed_duplex vars->link_status = %x, vars->duplex = %x\n", + vars->link_status, vars->duplex); ELINK_DEBUG_P2(sc, " phy_link_up %x line_speed %d\n", vars->phy_link_up, vars->line_speed); return ELINK_STATUS_OK; @@ -6462,8 +6466,16 @@ static elink_status_t elink_link_setting MDIO_REG_BANK_GP_STATUS, MDIO_GP_STATUS_TOP_AN_STATUS1, &gp_status); - if (gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_DUPLEX_STATUS) + if (gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_DUPLEX_STATUS) { duplex = DUPLEX_FULL; + ELINK_DEBUG_P1(sc, "duplex status read from phy is = %x\n", + duplex); + } else { + ELINK_DEBUG_P1(sc, "phy status does not allow interface to be FULL_DUPLEX : %x\n", + gp_status); + } + + if (gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_LINK_STATUS) link_up = 1; speed_mask = gp_status & ELINK_GP_STATUS_SPEED_MASK; @@ -6539,6 +6551,8 @@ static elink_status_t elink_warpcore_rea elink_cl45_read(sc, phy, MDIO_WC_DEVAD, MDIO_WC_REG_DIGITAL5_LINK_STATUS, &link_up); link_up &= 0x1; + ELINK_DEBUG_P1(sc, "params->loopback_mode link_up read = %x\n", + link_up); } else if ((phy->req_line_speed > ELINK_SPEED_10000) && (phy->supported & ELINK_SUPPORTED_20000baseMLD2_Full)) { uint16_t temp_link_up; @@ -6568,6 +6582,8 @@ static elink_status_t elink_warpcore_rea elink_cl45_read(sc, phy, MDIO_AN_DEVAD, MDIO_AN_REG_STATUS, &an_link); link_up |= (an_link & (1<<2)); + ELINK_DEBUG_P2(sc,"an_link = %x, link_up = %x\n", an_link, + link_up); } if (link_up && ELINK_SINGLE_MEDIA_DIRECT(params)) { uint16_t pd, gp_status4; @@ -6587,12 +6603,17 @@ static elink_status_t elink_warpcore_rea if (pd & (1<<15)) vars->link_status |= LINK_STATUS_PARALLEL_DETECTION_USED; + ELINK_DEBUG_P2(sc, "pd = %x, link_status = %x\n", + pd, vars->link_status); } elink_ext_phy_resolve_fc(phy, params, vars); vars->duplex = duplex; + ELINK_DEBUG_P3(sc, " ELINK_SINGLE_MEDIA_DIRECT duplex %x flow_ctrl 0x%x link_status 0x%x\n", + vars->duplex, vars->flow_ctrl, vars->link_status); } } - + ELINK_DEBUG_P3(sc, "duplex %x flow_ctrl 0x%x link_status 0x%x\n", + vars->duplex, vars->flow_ctrl, vars->link_status); if ((vars->link_status & LINK_STATUS_AUTO_NEGOTIATE_COMPLETE) && ELINK_SINGLE_MEDIA_DIRECT(params)) { uint16_t val; @@ -6607,7 +6628,8 @@ static elink_status_t elink_warpcore_rea MDIO_CL73_IEEEB1_AN_ADV2_ADVR_10G_KR)) vars->link_status |= LINK_STATUS_LINK_PARTNER_10GXFD_CAPABLE; - + ELINK_DEBUG_P2(sc, "val = %x, link_status = %x\n", + val, vars->link_status); elink_cl45_read(sc, phy, MDIO_WC_DEVAD, MDIO_WC_REG_DIGITAL3_LP_UP1, &val); @@ -6617,6 +6639,8 @@ static elink_status_t elink_warpcore_rea if (val & (MDIO_OVER_1G_UP1_10G | MDIO_OVER_1G_UP1_10GH)) vars->link_status |= LINK_STATUS_LINK_PARTNER_10GXFD_CAPABLE; + ELINK_DEBUG_P2(sc, "val = %x, link_status = %x\n", + val, vars->link_status); } @@ -7808,6 +7832,19 @@ elink_status_t elink_link_update(struct ELINK_DEBUG_P1(sc, "Active external phy selected: %x\n", active_external_phy); } + + ELINK_DEBUG_P3(sc, "vars : phy_flags = %x, mac_type = %x, phy_link_up = %x\n", + vars->phy_flags, vars->mac_type, vars->phy_link_up); + ELINK_DEBUG_P3(sc, "vars : link_up = %x, line_speed = %x, duplex = %x\n", + vars->link_up, vars->line_speed, vars->duplex); + ELINK_DEBUG_P3(sc, "vars : flow_ctrl = %x, ieee_fc = %x, link_status = %x\n", + vars->flow_ctrl, vars->ieee_fc, vars->link_status); + ELINK_DEBUG_P3(sc, "vars : eee_status = %x, fault_detected = %x, check_kr2_recovery_cnt = %x\n", + vars->eee_status, vars->fault_detected, vars->check_kr2_recovery_cnt); + ELINK_DEBUG_P3(sc, "vars : periodic_flags = %x, aeu_int_mask = %x, rx_tx_asic_rst = %x\n", + vars->periodic_flags, vars->aeu_int_mask, vars->rx_tx_asic_rst); + ELINK_DEBUG_P2(sc, "vars : turn_to_run_wc_rt = %x, rsrv2 = %x\n", + vars->turn_to_run_wc_rt, vars->rsrv2); for (phy_index = ELINK_EXT_PHY1; phy_index < params->num_phys; phy_index++) { @@ -7835,6 +7872,7 @@ elink_status_t elink_link_update(struct " link speed %d\n", vars->line_speed, ext_phy_line_speed); vars->phy_link_up = 0; + ELINK_DEBUG_P0(sc, "phy_link_up set to 0\n"); } else if (prev_line_speed != vars->line_speed) { REG_WR(sc, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0); @@ -7883,6 +7921,12 @@ elink_status_t elink_link_update(struct ELINK_SINGLE_MEDIA_DIRECT(params)) && (phy_vars[active_external_phy].fault_detected == 0)); + if(vars->link_up) { + ELINK_DEBUG_P0(sc, "local phy and external phy are up\n"); + } else { + ELINK_DEBUG_P0(sc, "either local phy or external phy or both are down\n"); + } + /* Update the PFC configuration in case it was changed */ if (params->feature_config_flags & ELINK_FEATURE_CONFIG_PFC_ENABLED) vars->link_status |= LINK_STATUS_PFC_ENABLED; @@ -12943,6 +12987,8 @@ static void elink_populate_preemphasis(s phy->tx_preemphasis[i << 1] = ((tx>>16) & 0xffff); phy->tx_preemphasis[(i << 1) + 1] = (tx & 0xffff); + ELINK_DEBUG_P2(sc,"phy->rx_preemphasis = %x, phy->tx_preemphasis = %x\n", + phy->rx_preemphasis[i << 1], phy->tx_preemphasis[i << 1]); } } @@ -13070,6 +13116,8 @@ static elink_status_t elink_populate_int phy->flags |= ELINK_FLAGS_MDC_MDIO_WA; else phy->flags |= ELINK_FLAGS_MDC_MDIO_WA_B0; + ELINK_DEBUG_P3(sc, "media_type = %x, flags = %x, supported = %x\n", + phy->media_type, phy->flags, phy->supported); } else { switch (switch_cfg) { @@ -13300,6 +13348,9 @@ static void elink_phy_def_cfg(struct eli break; } + ELINK_DEBUG_P2(sc, "Default config phy idx %x, req_duplex config %x\n", + phy_index, phy->req_duplex); + switch (link_config & PORT_FEATURE_FLOW_CONTROL_MASK) { case PORT_FEATURE_FLOW_CONTROL_AUTO: phy->req_flow_ctrl = ELINK_FLOW_CTRL_AUTO; @@ -13317,6 +13368,8 @@ static void elink_phy_def_cfg(struct eli phy->req_flow_ctrl = ELINK_FLOW_CTRL_NONE; break; } + ELINK_DEBUG_P3(sc, "Requested Duplex = %x, line_speed = %x, flow_ctrl = %x\n", + phy->req_duplex, phy->req_line_speed, phy->req_flow_ctrl); } uint32_t elink_phy_selection(struct elink_params *params) @@ -13924,6 +13977,18 @@ elink_status_t elink_phy_init(struct eli /* Check if link flap can be avoided */ lfa_status = elink_check_lfa(params); + ELINK_DEBUG_P3(sc, " params : port = %x, loopback_mode = %x req_duplex = %x\n", + params->port, params->loopback_mode, params->req_duplex[0]); + ELINK_DEBUG_P3(sc, " params : switch_cfg = %x, lane_config = %x req_duplex[1] = %x\n", + params->switch_cfg, params->lane_config, params->req_duplex[1]); + ELINK_DEBUG_P3(sc, " params : chip_id = %x, feature_config_flags = %x, num_phys = %x\n", + params->chip_id, params->feature_config_flags, params->num_phys); + ELINK_DEBUG_P3(sc, " params : rsrv = %x, eee_mode = %x, hw_led_mode = x\n", + params->rsrv, params->eee_mode, params->hw_led_mode); + ELINK_DEBUG_P3(sc, " params : multi_phy = %x, req_fc_auto_adv = %x, link_flags = %x\n", + params->multi_phy_config, params->req_fc_auto_adv, params->link_flags); + ELINK_DEBUG_P2(sc, " params : lfa_base = %x, link_attr = %x\n", + params->lfa_base, params->link_attr_sync); if (lfa_status == 0) { ELINK_DEBUG_P0(sc, "Link Flap Avoidance in progress\n"); return elink_avoid_link_flap(params, vars); Modified: stable/10/sys/dev/bxe/bxe_stats.c ============================================================================== --- stable/10/sys/dev/bxe/bxe_stats.c Fri Mar 24 02:58:20 2017 (r315881) +++ stable/10/sys/dev/bxe/bxe_stats.c Fri Mar 24 03:11:11 2017 (r315882) @@ -36,6 +36,8 @@ __FBSDID("$FreeBSD$"); #define BITS_PER_LONG 64 #endif +extern int bxe_grc_dump(struct bxe_softc *sc); + static inline long bxe_hilo(uint32_t *hiref) { Modified: stable/10/sys/dev/bxe/bxe_stats.h ============================================================================== --- stable/10/sys/dev/bxe/bxe_stats.h Fri Mar 24 02:58:20 2017 (r315881) +++ stable/10/sys/dev/bxe/bxe_stats.h Fri Mar 24 03:11:11 2017 (r315882) @@ -267,9 +267,13 @@ struct bxe_eth_stats { /* num. of times tx queue full occured */ uint32_t tx_queue_full_return; /* debug stats */ + uint32_t bxe_tx_mq_sc_state_failures; uint32_t tx_request_link_down_failures; uint32_t bd_avail_too_less_failures; uint32_t tx_mq_not_empty; + uint32_t nsegs_path1_errors; + uint32_t nsegs_path2_errors; + }; @@ -378,9 +382,13 @@ struct bxe_eth_q_stats { uint32_t tx_queue_full_return; /* debug stats */ + uint32_t bxe_tx_mq_sc_state_failures; uint32_t tx_request_link_down_failures; uint32_t bd_avail_too_less_failures; uint32_t tx_mq_not_empty; + uint32_t nsegs_path1_errors; + uint32_t nsegs_path2_errors; + }; struct bxe_eth_stats_old { From owner-svn-src-stable-10@freebsd.org Fri Mar 24 07:00:17 2017 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 EF256D1B88C; Fri, 24 Mar 2017 07:00:17 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C9E561996; Fri, 24 Mar 2017 07:00:17 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2O70GEa053449; Fri, 24 Mar 2017 07:00:16 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2O70Gwj053448; Fri, 24 Mar 2017 07:00:16 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703240700.v2O70Gwj053448@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 24 Mar 2017 07:00:16 +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: r315887 - stable/10/sys/cam/ctl 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.23 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, 24 Mar 2017 07:00:18 -0000 Author: mav Date: Fri Mar 24 07:00:16 2017 New Revision: 315887 URL: https://svnweb.freebsd.org/changeset/base/315887 Log: MFC r315025: Switch work_queue from TAILQ to STAILQ. It is mostly FIFO and we don't need random removal there. Modified: stable/10/sys/cam/ctl/scsi_ctl.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/ctl/scsi_ctl.c ============================================================================== --- stable/10/sys/cam/ctl/scsi_ctl.c Fri Mar 24 06:59:40 2017 (r315886) +++ stable/10/sys/cam/ctl/scsi_ctl.c Fri Mar 24 07:00:16 2017 (r315887) @@ -105,7 +105,7 @@ struct ctlfe_lun_softc { int atios_alloced; /* Number of ATIOs not freed */ int inots_alloced; /* Number of INOTs not freed */ struct task refdrain_task; - TAILQ_HEAD(, ccb_hdr) work_queue; + STAILQ_HEAD(, ccb_hdr) work_queue; STAILQ_ENTRY(ctlfe_lun_softc) links; }; @@ -449,7 +449,7 @@ ctlferegister(struct cam_periph *periph, softc = (struct ctlfe_lun_softc *)arg; bus_softc = softc->parent_softc; - TAILQ_INIT(&softc->work_queue); + STAILQ_INIT(&softc->work_queue); softc->periph = periph; periph->softc = softc; @@ -738,14 +738,13 @@ ctlfestart(struct cam_periph *periph, un softc = (struct ctlfe_lun_softc *)periph->softc; next: - ccb_h = TAILQ_FIRST(&softc->work_queue); + /* Take the ATIO off the work queue */ + ccb_h = STAILQ_FIRST(&softc->work_queue); if (ccb_h == NULL) { xpt_release_ccb(start_ccb); return; } - - /* Take the ATIO off the work queue */ - TAILQ_REMOVE(&softc->work_queue, ccb_h, periph_links.tqe); + STAILQ_REMOVE_HEAD(&softc->work_queue, periph_links.stqe); atio = (struct ccb_accept_tio *)ccb_h; io = (union ctl_io *)ccb_h->io_ptr; csio = &start_ccb->csio; @@ -870,7 +869,7 @@ next: /* * If we still have work to do, ask for another CCB. */ - if (!TAILQ_EMPTY(&softc->work_queue)) + if (!STAILQ_EMPTY(&softc->work_queue)) xpt_schedule(periph, CAM_PRIORITY_NORMAL); } @@ -1196,8 +1195,8 @@ ctlfedone(struct cam_periph *periph, uni io->scsiio.io_hdr.status = CTL_STATUS_NONE; io->io_hdr.flags |= CTL_FLAG_DMA_QUEUED; xpt_release_ccb(done_ccb); - TAILQ_INSERT_HEAD(&softc->work_queue, &atio->ccb_h, - periph_links.tqe); + STAILQ_INSERT_HEAD(&softc->work_queue, &atio->ccb_h, + periph_links.stqe); xpt_schedule(periph, CAM_PRIORITY_NORMAL); break; } @@ -1811,7 +1810,7 @@ ctlfe_dump_queue(struct ctlfe_lun_softc periph = softc->periph; num_items = 0; - TAILQ_FOREACH(hdr, &softc->work_queue, periph_links.tqe) { + STAILQ_FOREACH(hdr, &softc->work_queue, periph_links.stqe) { union ctl_io *io = hdr->io_ptr; num_items++; @@ -1866,8 +1865,8 @@ ctlfe_datamove(union ctl_io *io) io->io_hdr.flags |= CTL_FLAG_DMA_QUEUED; if ((io->io_hdr.status & CTL_STATUS_MASK) != CTL_STATUS_NONE) io->io_hdr.flags |= CTL_FLAG_STATUS_QUEUED; - TAILQ_INSERT_TAIL(&softc->work_queue, &ccb->ccb_h, - periph_links.tqe); + STAILQ_INSERT_TAIL(&softc->work_queue, &ccb->ccb_h, + periph_links.stqe); xpt_schedule(periph, CAM_PRIORITY_NORMAL); cam_periph_unlock(periph); } @@ -1919,8 +1918,8 @@ ctlfe_done(union ctl_io *io) return; } else { io->io_hdr.flags |= CTL_FLAG_STATUS_QUEUED; - TAILQ_INSERT_TAIL(&softc->work_queue, &ccb->ccb_h, - periph_links.tqe); + STAILQ_INSERT_TAIL(&softc->work_queue, &ccb->ccb_h, + periph_links.stqe); xpt_schedule(periph, CAM_PRIORITY_NORMAL); } From owner-svn-src-stable-10@freebsd.org Fri Mar 24 07:02:04 2017 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 7EDFED1BA89; Fri, 24 Mar 2017 07:02:04 +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 3EA111EF2; Fri, 24 Mar 2017 07:02:04 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2O7233d054303; Fri, 24 Mar 2017 07:02:03 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2O7234P054302; Fri, 24 Mar 2017 07:02:03 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703240702.v2O7234P054302@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 24 Mar 2017 07:02:03 +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: r315889 - stable/10/sys/cam/ctl 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.23 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, 24 Mar 2017 07:02:04 -0000 Author: mav Date: Fri Mar 24 07:02:03 2017 New Revision: 315889 URL: https://svnweb.freebsd.org/changeset/base/315889 Log: MFC r315030: Abort all ATIOs and INOTs queued to SIM on LUN disable. Some SIMs may not abort them implicitly, that either fail the LUN disable request or just make us wait for those CCBs forever. With this change I can successfully disable LUNs on mpt(4). For isp(4), which aborts them implicitly, this change should be irrelevant. Modified: stable/10/sys/cam/ctl/scsi_ctl.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/ctl/scsi_ctl.c ============================================================================== --- stable/10/sys/cam/ctl/scsi_ctl.c Fri Mar 24 07:01:31 2017 (r315888) +++ stable/10/sys/cam/ctl/scsi_ctl.c Fri Mar 24 07:02:03 2017 (r315889) @@ -106,6 +106,8 @@ struct ctlfe_lun_softc { int inots_alloced; /* Number of INOTs not freed */ struct task refdrain_task; STAILQ_HEAD(, ccb_hdr) work_queue; + LIST_HEAD(, ccb_hdr) atio_list; /* List of ATIOs queued to SIM. */ + LIST_HEAD(, ccb_hdr) inot_list; /* List of INOTs queued to SIM. */ STAILQ_ENTRY(ctlfe_lun_softc) links; }; @@ -442,7 +444,7 @@ ctlferegister(struct cam_periph *periph, { struct ctlfe_softc *bus_softc; struct ctlfe_lun_softc *softc; - union ccb en_lun_ccb; + union ccb ccb; cam_status status; int i; @@ -450,19 +452,21 @@ ctlferegister(struct cam_periph *periph, bus_softc = softc->parent_softc; STAILQ_INIT(&softc->work_queue); + LIST_INIT(&softc->atio_list); + LIST_INIT(&softc->inot_list); softc->periph = periph; periph->softc = softc; - xpt_setup_ccb(&en_lun_ccb.ccb_h, periph->path, CAM_PRIORITY_NONE); - en_lun_ccb.ccb_h.func_code = XPT_EN_LUN; - en_lun_ccb.cel.grp6_len = 0; - en_lun_ccb.cel.grp7_len = 0; - en_lun_ccb.cel.enable = 1; - xpt_action(&en_lun_ccb); - status = (en_lun_ccb.ccb_h.status & CAM_STATUS_MASK); + xpt_setup_ccb(&ccb.ccb_h, periph->path, CAM_PRIORITY_NONE); + ccb.ccb_h.func_code = XPT_EN_LUN; + ccb.cel.grp6_len = 0; + ccb.cel.grp7_len = 0; + ccb.cel.enable = 1; + xpt_action(&ccb); + status = (ccb.ccb_h.status & CAM_STATUS_MASK); if (status != CAM_REQ_CMP) { xpt_print(periph->path, "%s: Enable LUN failed, status 0x%x\n", - __func__, en_lun_ccb.ccb_h.status); + __func__, ccb.ccb_h.status); return (status); } @@ -496,6 +500,7 @@ ctlferegister(struct cam_periph *periph, PRIV_INFO(new_io) = cmd_info; softc->atios_alloced++; new_ccb->ccb_h.io_ptr = new_io; + LIST_INSERT_HEAD(&softc->atio_list, &new_ccb->ccb_h, periph_links.le); xpt_setup_ccb(&new_ccb->ccb_h, periph->path, /*priority*/ 1); new_ccb->ccb_h.func_code = XPT_ACCEPT_TARGET_IO; @@ -542,6 +547,7 @@ ctlferegister(struct cam_periph *periph, } softc->inots_alloced++; new_ccb->ccb_h.io_ptr = new_io; + LIST_INSERT_HEAD(&softc->inot_list, &new_ccb->ccb_h, periph_links.le); xpt_setup_ccb(&new_ccb->ccb_h, periph->path, /*priority*/ 1); new_ccb->ccb_h.func_code = XPT_IMMEDIATE_NOTIFY; @@ -578,23 +584,34 @@ ctlferegister(struct cam_periph *periph, static void ctlfeoninvalidate(struct cam_periph *periph) { - union ccb en_lun_ccb; - cam_status status; + struct ctlfe_lun_softc *softc = (struct ctlfe_lun_softc *)periph->softc; struct ctlfe_softc *bus_softc; - struct ctlfe_lun_softc *softc; - - softc = (struct ctlfe_lun_softc *)periph->softc; + union ccb ccb; + struct ccb_hdr *hdr; + cam_status status; - xpt_setup_ccb(&en_lun_ccb.ccb_h, periph->path, CAM_PRIORITY_NONE); - en_lun_ccb.ccb_h.func_code = XPT_EN_LUN; - en_lun_ccb.cel.grp6_len = 0; - en_lun_ccb.cel.grp7_len = 0; - en_lun_ccb.cel.enable = 0; - xpt_action(&en_lun_ccb); - status = (en_lun_ccb.ccb_h.status & CAM_STATUS_MASK); + /* Abort all ATIOs and INOTs queued to SIM. */ + xpt_setup_ccb(&ccb.ccb_h, periph->path, CAM_PRIORITY_NONE); + ccb.ccb_h.func_code = XPT_ABORT; + LIST_FOREACH(hdr, &softc->atio_list, periph_links.le) { + ccb.cab.abort_ccb = (union ccb *)hdr; + xpt_action(&ccb); + } + LIST_FOREACH(hdr, &softc->inot_list, periph_links.le) { + ccb.cab.abort_ccb = (union ccb *)hdr; + xpt_action(&ccb); + } + + /* Disable the LUN in SIM. */ + ccb.ccb_h.func_code = XPT_EN_LUN; + ccb.cel.grp6_len = 0; + ccb.cel.grp7_len = 0; + ccb.cel.enable = 0; + xpt_action(&ccb); + status = (ccb.ccb_h.status & CAM_STATUS_MASK); if (status != CAM_REQ_CMP) { xpt_print(periph->path, "%s: Disable LUN failed, status 0x%x\n", - __func__, en_lun_ccb.ccb_h.status); + __func__, ccb.ccb_h.status); /* * XXX KDM what do we do now? */ @@ -952,6 +969,11 @@ ctlfe_requeue_ccb(struct cam_periph *per mtx_unlock(mtx); return; } + softc = (struct ctlfe_lun_softc *)periph->softc; + if (ccb->ccb_h.func_code == XPT_ACCEPT_TARGET_IO) + LIST_INSERT_HEAD(&softc->atio_list, &ccb->ccb_h, periph_links.le); + else + LIST_INSERT_HEAD(&softc->inot_list, &ccb->ccb_h, periph_links.le); if (unlock) cam_periph_unlock(periph); @@ -960,7 +982,6 @@ ctlfe_requeue_ccb(struct cam_periph *per * target/lun. Reset the target and LUN fields back to the wildcard * values before we send them back down to the SIM. */ - softc = (struct ctlfe_lun_softc *)periph->softc; if (softc->flags & CTLFE_LUN_WILDCARD) { ccb->ccb_h.target_id = CAM_TARGET_WILDCARD; ccb->ccb_h.target_lun = CAM_LUN_WILDCARD; @@ -1075,6 +1096,7 @@ ctlfedone(struct cam_periph *periph, uni switch (done_ccb->ccb_h.func_code) { case XPT_ACCEPT_TARGET_IO: { + LIST_REMOVE(&done_ccb->ccb_h, periph_links.le); atio = &done_ccb->atio; status = atio->ccb_h.status & CAM_STATUS_MASK; if (status != CAM_CDB_RECVD) { @@ -1364,6 +1386,7 @@ ctlfedone(struct cam_periph *periph, uni struct ccb_immediate_notify *inot; int send_ctl_io; + LIST_REMOVE(&done_ccb->ccb_h, periph_links.le); inot = &done_ccb->cin1; io = done_ccb->ccb_h.io_ptr; ctl_zero_io(io); From owner-svn-src-stable-10@freebsd.org Fri Mar 24 07:03:27 2017 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 C450ED1BC2B; Fri, 24 Mar 2017 07:03:27 +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 8556912C5; Fri, 24 Mar 2017 07:03:27 +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 v2O73QMR057286; Fri, 24 Mar 2017 07:03:26 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2O73Ql0057285; Fri, 24 Mar 2017 07:03:26 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703240703.v2O73Ql0057285@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 24 Mar 2017 07:03: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: r315891 - stable/10/sys/cam/ctl 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.23 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, 24 Mar 2017 07:03:27 -0000 Author: mav Date: Fri Mar 24 07:03:26 2017 New Revision: 315891 URL: https://svnweb.freebsd.org/changeset/base/315891 Log: MFC r315022: Request change of SIM target role only when it is different. Separate WWNs change into separate request to know what actually failed. Modified: stable/10/sys/cam/ctl/scsi_ctl.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/ctl/scsi_ctl.c ============================================================================== --- stable/10/sys/cam/ctl/scsi_ctl.c Fri Mar 24 07:02:51 2017 (r315890) +++ stable/10/sys/cam/ctl/scsi_ctl.c Fri Mar 24 07:03:26 2017 (r315891) @@ -1502,18 +1502,14 @@ out: static void ctlfe_onoffline(void *arg, int online) { - struct ctlfe_softc *bus_softc; + struct ctlfe_softc *bus_softc = arg; union ccb *ccb; cam_status status; struct cam_path *path; - int set_wwnn; - - bus_softc = (struct ctlfe_softc *)arg; - - set_wwnn = 0; + int set_wwnn = 0; status = xpt_create_path(&path, /*periph*/ NULL, bus_softc->path_id, - CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD); + CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD); if (status != CAM_REQ_CMP) { printf("%s: unable to create path!\n", __func__); return; @@ -1523,21 +1519,9 @@ ctlfe_onoffline(void *arg, int online) ccb->ccb_h.func_code = XPT_GET_SIM_KNOB; xpt_action(ccb); - /* - * Copan WWN format: - * - * Bits 63-60: 0x5 NAA, IEEE registered name - * Bits 59-36: 0x000ED5 IEEE Company name assigned to Copan - * Bits 35-12: Copan SSN (Sequential Serial Number) - * Bits 11-8: Type of port: - * 1 == N-Port - * 2 == F-Port - * 3 == NL-Port - * Bits 7-0: 0 == Node Name, >0 == Port Number - */ + /* Check whether we should change WWNs. */ if (online != 0) { if ((ccb->knob.xport_specific.valid & KNOB_VALID_ADDRESS) != 0){ - printf("%s: %s current WWNN %#jx\n", __func__, bus_softc->port_name, ccb->knob.xport_specific.fc.wwnn); @@ -1570,43 +1554,59 @@ ctlfe_onoffline(void *arg, int online) false, 0, true, ccb->knob.xport_specific.fc.wwpn); } - - - if (set_wwnn != 0) { - printf("%s: %s new WWNN %#jx\n", __func__, - bus_softc->port_name, - ccb->knob.xport_specific.fc.wwnn); - printf("%s: %s new WWPN %#jx\n", __func__, - bus_softc->port_name, - ccb->knob.xport_specific.fc.wwpn); - } } else { printf("%s: %s has no valid WWNN/WWPN\n", __func__, bus_softc->port_name); + if (bus_softc->port.wwnn != 0) { + ccb->knob.xport_specific.fc.wwnn = + bus_softc->port.wwnn; + set_wwnn = 1; + } + if (bus_softc->port.wwpn != 0) { + ccb->knob.xport_specific.fc.wwpn = + bus_softc->port.wwpn; + set_wwnn = 1; + } + } + } + if (set_wwnn) { + ccb->ccb_h.func_code = XPT_SET_SIM_KNOB; + ccb->knob.xport_specific.valid = KNOB_VALID_ADDRESS; + xpt_action(ccb); + if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { + printf("%s: %s (path id %d) failed set WWNs: %#x\n", + __func__, bus_softc->port_name, bus_softc->path_id, + ccb->ccb_h.status); + } else { + printf("%s: %s new WWNN %#jx\n", __func__, + bus_softc->port_name, + ccb->knob.xport_specific.fc.wwnn); + printf("%s: %s new WWPN %#jx\n", __func__, + bus_softc->port_name, + ccb->knob.xport_specific.fc.wwpn); } } - ccb->ccb_h.func_code = XPT_SET_SIM_KNOB; - ccb->knob.xport_specific.valid = KNOB_VALID_ROLE; - if (set_wwnn != 0) - ccb->knob.xport_specific.valid |= KNOB_VALID_ADDRESS; - - if (online != 0) - ccb->knob.xport_specific.fc.role |= KNOB_ROLE_TARGET; - else - ccb->knob.xport_specific.fc.role &= ~KNOB_ROLE_TARGET; - - xpt_action(ccb); - if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { - printf("%s: SIM %s (path id %d) target %s failed with " - "status %#x\n", - __func__, bus_softc->port_name, bus_softc->path_id, - (online != 0) ? "enable" : "disable", - ccb->ccb_h.status); - } else { - printf("%s: SIM %s (path id %d) target %s succeeded\n", - __func__, bus_softc->port_name, bus_softc->path_id, - (online != 0) ? "enable" : "disable"); + /* Check whether we should change role. */ + if ((ccb->knob.xport_specific.valid & KNOB_VALID_ROLE) == 0 || + ((online != 0) ^ + ((ccb->knob.xport_specific.fc.role & KNOB_ROLE_TARGET) != 0)) != 0) { + ccb->ccb_h.func_code = XPT_SET_SIM_KNOB; + ccb->knob.xport_specific.valid = KNOB_VALID_ROLE; + if (online) + ccb->knob.xport_specific.fc.role |= KNOB_ROLE_TARGET; + else + ccb->knob.xport_specific.fc.role &= ~KNOB_ROLE_TARGET; + xpt_action(ccb); + if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { + printf("%s: %s (path id %d) failed %s target role: %#x\n", + __func__, bus_softc->port_name, bus_softc->path_id, + online ? "enable" : "disable", ccb->ccb_h.status); + } else { + printf("%s: %s (path id %d) target role %s succeeded\n", + __func__, bus_softc->port_name, bus_softc->path_id, + online ? "enable" : "disable"); + } } xpt_free_path(path); From owner-svn-src-stable-10@freebsd.org Fri Mar 24 07:22:34 2017 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 3D72DD1B15E; Fri, 24 Mar 2017 07:22:34 +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 0722B1E85; Fri, 24 Mar 2017 07:22:33 +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 v2O7MXCA065474; Fri, 24 Mar 2017 07:22:33 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2O7MXO5065473; Fri, 24 Mar 2017 07:22:33 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201703240722.v2O7MXO5065473@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 24 Mar 2017 07:22: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: r315894 - 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.23 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, 24 Mar 2017 07:22:34 -0000 Author: kib Date: Fri Mar 24 07:22:32 2017 New Revision: 315894 URL: https://svnweb.freebsd.org/changeset/base/315894 Log: MFC r315453: When clearing altsigstack settings on exec, do it to the right thread. Modified: stable/10/sys/kern/kern_sig.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/kern_sig.c ============================================================================== --- stable/10/sys/kern/kern_sig.c Fri Mar 24 07:14:46 2017 (r315893) +++ stable/10/sys/kern/kern_sig.c Fri Mar 24 07:22:32 2017 (r315894) @@ -964,7 +964,6 @@ execsigs(struct proc *p) * and are now ignored by default). */ PROC_LOCK_ASSERT(p, MA_OWNED); - td = FIRST_THREAD_IN_PROC(p); ps = p->p_sigacts; mtx_lock(&ps->ps_mtx); while (SIGNOTEMPTY(ps->ps_sigcatch)) { @@ -977,6 +976,8 @@ execsigs(struct proc *p) * Reset stack state to the user stack. * Clear set of signals caught on the signal stack. */ + td = curthread; + MPASS(td->td_proc == p); td->td_sigstk.ss_flags = SS_DISABLE; td->td_sigstk.ss_size = 0; td->td_sigstk.ss_sp = 0; From owner-svn-src-stable-10@freebsd.org Fri Mar 24 14:26:02 2017 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 E8250D1B977; Fri, 24 Mar 2017 14:26:02 +0000 (UTC) (envelope-from des@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 A04AF8B; Fri, 24 Mar 2017 14:26:02 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2OEQ1os035830; Fri, 24 Mar 2017 14:26:01 GMT (envelope-from des@FreeBSD.org) Received: (from des@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2OEQ1Qc035824; Fri, 24 Mar 2017 14:26:01 GMT (envelope-from des@FreeBSD.org) Message-Id: <201703241426.v2OEQ1Qc035824@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: des set sender to des@FreeBSD.org using -f From: =?UTF-8?Q?Dag-Erling_Sm=c3=b8rgrav?= Date: Fri, 24 Mar 2017 14:26:01 +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: r315904 - stable/10/lib/libfetch 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.23 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, 24 Mar 2017 14:26:03 -0000 Author: des Date: Fri Mar 24 14:26:01 2017 New Revision: 315904 URL: https://svnweb.freebsd.org/changeset/base/315904 Log: MFH (r313974,r314596): open .netrc early in case we want to drop privs MFH (r314396,r315143): fix a crash caused by an incorrect format string MFH (r314701): fix handling of 416 errors when requesting a range MFH (r315455): fix parsing of IP literals (square brackets) PR: 212065, 217723 Modified: stable/10/lib/libfetch/common.c stable/10/lib/libfetch/common.h stable/10/lib/libfetch/fetch.c stable/10/lib/libfetch/fetch.h stable/10/lib/libfetch/http.c Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libfetch/common.c ============================================================================== --- stable/10/lib/libfetch/common.c Fri Mar 24 14:25:56 2017 (r315903) +++ stable/10/lib/libfetch/common.c Fri Mar 24 14:26:01 2017 (r315904) @@ -153,7 +153,7 @@ fetch_syserr(void) case EHOSTDOWN: fetchLastErrCode = FETCH_DOWN; break; -default: + default: fetchLastErrCode = FETCH_UNKNOWN; } snprintf(fetchLastErrString, MAXERRSTRING, "%s", strerror(errno)); @@ -248,37 +248,51 @@ fetch_resolve(const char *addr, int port { char hbuf[256], sbuf[8]; struct addrinfo hints, *res; - const char *sep, *host, *service; + const char *hb, *he, *sep; + const char *host, *service; int err, len; - /* split address if necessary */ - err = EAI_SYSTEM; - if ((sep = strchr(addr, ':')) != NULL) { + /* first, check for a bracketed IPv6 address */ + if (*addr == '[') { + hb = addr + 1; + if ((sep = strchr(hb, ']')) == NULL) { + errno = EINVAL; + goto syserr; + } + he = sep++; + } else { + hb = addr; + sep = strchrnul(hb, ':'); + he = sep; + } + + /* see if we need to copy the host name */ + if (*he != '\0') { len = snprintf(hbuf, sizeof(hbuf), - "%.*s", (int)(sep - addr), addr); + "%.*s", (int)(he - hb), hb); if (len < 0) - return (NULL); + goto syserr; if (len >= (int)sizeof(hbuf)) { errno = ENAMETOOLONG; - fetch_syserr(); - return (NULL); + goto syserr; } host = hbuf; - service = sep + 1; - } else if (port != 0) { + } else { + host = hb; + } + + /* was it followed by a service name? */ + if (*sep == '\0' && port != 0) { if (port < 1 || port > 65535) { errno = EINVAL; - fetch_syserr(); - return (NULL); - } - if (snprintf(sbuf, sizeof(sbuf), "%d", port) < 0) { - fetch_syserr(); - return (NULL); + goto syserr; } - host = addr; + if (snprintf(sbuf, sizeof(sbuf), "%d", port) < 0) + goto syserr; service = sbuf; + } else if (*sep != '\0') { + service = sep; } else { - host = addr; service = NULL; } @@ -292,6 +306,9 @@ fetch_resolve(const char *addr, int port return (NULL); } return (res); +syserr: + fetch_syserr(); + return (NULL); } @@ -371,7 +388,7 @@ fetch_connect(const char *host, int port } if (err != 0) { if (verbose) - fetch_info("failed to connect to %s:%s", host, port); + fetch_info("failed to connect to %s:%d", host, port); goto syserr; } @@ -1339,16 +1356,11 @@ fetch_read_word(FILE *f) return (word); } -/* - * Get authentication data for a URL from .netrc - */ -int -fetch_netrc_auth(struct url *url) +static int +fetch_netrc_open(void) { + const char *p; char fn[PATH_MAX]; - const char *word; - char *p; - FILE *f; if ((p = getenv("NETRC")) != NULL) { if (snprintf(fn, sizeof(fn), "%s", p) >= (int)sizeof(fn)) { @@ -1368,8 +1380,25 @@ fetch_netrc_auth(struct url *url) return (-1); } - if ((f = fopen(fn, "r")) == NULL) + return (open(fn, O_RDONLY)); +} + +/* + * Get authentication data for a URL from .netrc + */ +int +fetch_netrc_auth(struct url *url) +{ + const char *word; + FILE *f; + + if (url->netrcfd == -2) + url->netrcfd = fetch_netrc_open(); + if (url->netrcfd < 0) + return (-1); + if ((f = fdopen(url->netrcfd, "r")) == NULL) return (-1); + rewind(f); while ((word = fetch_read_word(f)) != NULL) { if (strcmp(word, "default") == 0) { DEBUG(fetch_info("Using default .netrc settings")); Modified: stable/10/lib/libfetch/common.h ============================================================================== --- stable/10/lib/libfetch/common.h Fri Mar 24 14:25:56 2017 (r315903) +++ stable/10/lib/libfetch/common.h Fri Mar 24 14:26:01 2017 (r315904) @@ -73,7 +73,7 @@ struct iovec; void fetch_seterr(struct fetcherr *, int); void fetch_syserr(void); -void fetch_info(const char *, ...); +void fetch_info(const char *, ...) __printflike(1, 2); int fetch_default_port(const char *); int fetch_default_proxy_port(const char *); struct addrinfo *fetch_resolve(const char *, int, int); Modified: stable/10/lib/libfetch/fetch.c ============================================================================== --- stable/10/lib/libfetch/fetch.c Fri Mar 24 14:25:56 2017 (r315903) +++ stable/10/lib/libfetch/fetch.c Fri Mar 24 14:26:01 2017 (r315904) @@ -284,6 +284,7 @@ fetchMakeURL(const char *scheme, const c seturl(pwd); #undef seturl u->port = port; + u->netrcfd = -2; return (u); } @@ -349,6 +350,7 @@ fetchParseURL(const char *URL) fetch_syserr(); return (NULL); } + u->netrcfd = -2; /* scheme name */ if ((p = strstr(URL, ":/"))) { @@ -384,18 +386,17 @@ fetchParseURL(const char *URL) } /* hostname */ -#ifdef INET6 if (*p == '[' && (q = strchr(p + 1, ']')) != NULL && (*++q == '\0' || *q == '/' || *q == ':')) { - if ((i = q - p - 2) > MAXHOSTNAMELEN) + if ((i = q - p) > MAXHOSTNAMELEN) i = MAXHOSTNAMELEN; - strncpy(u->host, ++p, i); + strncpy(u->host, p, i); p = q; - } else -#endif + } else { for (i = 0; *p && (*p != '/') && (*p != ':'); p++) if (i < MAXHOSTNAMELEN) u->host[i++] = *p; + } /* port */ if (*p == ':') { @@ -442,12 +443,12 @@ nohost: } DEBUG(fprintf(stderr, - "scheme: [%s]\n" - "user: [%s]\n" - "password: [%s]\n" - "host: [%s]\n" - "port: [%d]\n" - "document: [%s]\n", + "scheme: \"%s\"\n" + "user: \"%s\"\n" + "password: \"%s\"\n" + "host: \"%s\"\n" + "port: \"%d\"\n" + "document: \"%s\"\n", u->scheme, u->user, u->pwd, u->host, u->port, u->doc)); Modified: stable/10/lib/libfetch/fetch.h ============================================================================== --- stable/10/lib/libfetch/fetch.h Fri Mar 24 14:25:56 2017 (r315903) +++ stable/10/lib/libfetch/fetch.h Fri Mar 24 14:26:01 2017 (r315904) @@ -47,6 +47,7 @@ struct url { off_t offset; size_t length; time_t ims_time; + int netrcfd; }; struct url_stat { Modified: stable/10/lib/libfetch/http.c ============================================================================== --- stable/10/lib/libfetch/http.c Fri Mar 24 14:25:56 2017 (r315903) +++ stable/10/lib/libfetch/http.c Fri Mar 24 14:26:01 2017 (r315904) @@ -118,7 +118,7 @@ __FBSDID("$FreeBSD$"); || (xyz) == HTTP_USE_PROXY \ || (xyz) == HTTP_SEE_OTHER) -#define HTTP_ERROR(xyz) ((xyz) > 400 && (xyz) < 599) +#define HTTP_ERROR(xyz) ((xyz) >= 400 && (xyz) <= 599) /***************************************************************************** @@ -1604,20 +1604,11 @@ http_request_body(struct url *URL, const if ((conn = http_connect(url, purl, flags)) == NULL) goto ouch; + /* append port number only if necessary */ host = url->host; -#ifdef INET6 - if (strchr(url->host, ':')) { - snprintf(hbuf, sizeof(hbuf), "[%s]", url->host); - host = hbuf; - } -#endif if (url->port != fetch_default_port(url->scheme)) { - if (host != hbuf) { - strcpy(hbuf, host); - host = hbuf; - } - snprintf(hbuf + strlen(hbuf), - sizeof(hbuf) - strlen(hbuf), ":%d", url->port); + snprintf(hbuf, sizeof(hbuf), "%s:%d", host, url->port); + host = hbuf; } /* send request */ @@ -1925,7 +1916,7 @@ http_request_body(struct url *URL, const /* requested range not satisfiable */ if (conn->err == HTTP_BAD_RANGE) { - if (url->offset == size && url->length == 0) { + if (url->offset > 0 && url->length == 0) { /* asked for 0 bytes; fake it */ offset = url->offset; clength = -1; From owner-svn-src-stable-10@freebsd.org Fri Mar 24 14:40:54 2017 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 A713BD1BFCD; Fri, 24 Mar 2017 14:40:54 +0000 (UTC) (envelope-from des@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 59906F63; Fri, 24 Mar 2017 14:40:54 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2OEeras042386; Fri, 24 Mar 2017 14:40:53 GMT (envelope-from des@FreeBSD.org) Received: (from des@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2OEerrk042384; Fri, 24 Mar 2017 14:40:53 GMT (envelope-from des@FreeBSD.org) Message-Id: <201703241440.v2OEerrk042384@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: des set sender to des@FreeBSD.org using -f From: =?UTF-8?Q?Dag-Erling_Sm=c3=b8rgrav?= Date: Fri, 24 Mar 2017 14:40: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: r315907 - stable/10/contrib/openpam/lib/libpam 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.23 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, 24 Mar 2017 14:40:54 -0000 Author: des Date: Fri Mar 24 14:40:53 2017 New Revision: 315907 URL: https://svnweb.freebsd.org/changeset/base/315907 Log: Subset of upstream r902 which fixes custom prompts. PR: 216172 Modified: stable/10/contrib/openpam/lib/libpam/pam_get_authtok.c stable/10/contrib/openpam/lib/libpam/pam_get_user.c Modified: stable/10/contrib/openpam/lib/libpam/pam_get_authtok.c ============================================================================== --- stable/10/contrib/openpam/lib/libpam/pam_get_authtok.c Fri Mar 24 14:39:00 2017 (r315906) +++ stable/10/contrib/openpam/lib/libpam/pam_get_authtok.c Fri Mar 24 14:40:53 2017 (r315907) @@ -122,9 +122,11 @@ pam_get_authtok(pam_handle_t *pamh, if ((promptp = openpam_get_option(pamh, prompt_option)) != NULL) prompt = promptp; /* no prompt provided, see if there is one tucked away somewhere */ - if (prompt == NULL) - if (pam_get_item(pamh, pitem, &promptp) && promptp != NULL) + if (prompt == NULL) { + r = pam_get_item(pamh, pitem, &promptp); + if (r == PAM_SUCCESS && promptp != NULL) prompt = promptp; + } /* fall back to hardcoded default */ if (prompt == NULL) prompt = default_prompt; Modified: stable/10/contrib/openpam/lib/libpam/pam_get_user.c ============================================================================== --- stable/10/contrib/openpam/lib/libpam/pam_get_user.c Fri Mar 24 14:39:00 2017 (r315906) +++ stable/10/contrib/openpam/lib/libpam/pam_get_user.c Fri Mar 24 14:40:53 2017 (r315907) @@ -78,10 +78,11 @@ pam_get_user(pam_handle_t *pamh, if ((promptp = openpam_get_option(pamh, "user_prompt")) != NULL) prompt = promptp; /* no prompt provided, see if there is one tucked away somewhere */ - if (prompt == NULL) - if (pam_get_item(pamh, PAM_USER_PROMPT, &promptp) && - promptp != NULL) + if (prompt == NULL) { + r = pam_get_item(pamh, PAM_USER_PROMPT, &promptp); + if (r == PAM_SUCCESS && promptp != NULL) prompt = promptp; + } /* fall back to hardcoded default */ if (prompt == NULL) prompt = user_prompt; From owner-svn-src-stable-10@freebsd.org Fri Mar 24 18:28:15 2017 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 481F9D1B5F9; Fri, 24 Mar 2017 18:28:15 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 22D8F1289; Fri, 24 Mar 2017 18:28:15 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2OISEmc035761; Fri, 24 Mar 2017 18:28:14 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2OISE3o035760; Fri, 24 Mar 2017 18:28:14 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201703241828.v2OISE3o035760@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Fri, 24 Mar 2017 18:28:14 +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: r315915 - in stable: 10/contrib/libc++/include 9/contrib/libc++/include 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.23 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, 24 Mar 2017 18:28:15 -0000 Author: dim Date: Fri Mar 24 18:28:13 2017 New Revision: 315915 URL: https://svnweb.freebsd.org/changeset/base/315915 Log: Pull in r283944 from upstream libc++ trunk (by Eric Fiselier): Fix std::pair on FreeBSD Summary: FreeBSD ships an old ABI for std::pair which requires that it have non-trivial copy/move constructors. Currently the non-trivial copy/move is achieved by providing explicit definitions of the constructors. This is problematic because it means the constructors don't SFINAE properly. In order to SFINAE copy/move constructors they have to be explicitly defaulted and hense non-trivial. This patch attempts to provide SFINAE'ing copy/move constructors for std::pair while still making them non-trivial. It does this by adding a base class with a non-trivial copy constructor and then allowing pair's constructors to be generated by the compiler. This also allows the constructors to be constexpr. Reviewers: emaste, theraven, rsmith, dim Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25389 This should fix building www/chromium 57.0.2987.110 on stable/10 and stable/9 without having to use -D_LIBCPP_TRIVIAL_PAIR_COPY_CTOR=1 (which changes the ABI). Direct commit to stable/10 and stable/9, since head already has libc++ 4.0, which includes this fix. Modified: stable/10/contrib/libc++/include/utility Changes in other areas also in this revision: Modified: stable/9/contrib/libc++/include/utility Modified: stable/10/contrib/libc++/include/utility ============================================================================== --- stable/10/contrib/libc++/include/utility Fri Mar 24 17:34:55 2017 (r315914) +++ stable/10/contrib/libc++/include/utility Fri Mar 24 18:28:13 2017 (r315915) @@ -244,8 +244,20 @@ extern const piecewise_construct_t piece constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t(); #endif +#if !_LIBCPP_TRIVIAL_PAIR_COPY_CTOR +struct __non_trivially_copyable_base { + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + __non_trivially_copyable_base() _NOEXCEPT {} + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + __non_trivially_copyable_base(__non_trivially_copyable_base const&) _NOEXCEPT {} +}; +#endif + template struct _LIBCPP_TYPE_VIS_ONLY pair +#if !_LIBCPP_TRIVIAL_PAIR_COPY_CTOR +: private __non_trivially_copyable_base +#endif { typedef _T1 first_type; typedef _T2 second_type; @@ -253,9 +265,6 @@ struct _LIBCPP_TYPE_VIS_ONLY pair _T1 first; _T2 second; - // pair(const pair&) = default; - // pair(pair&&) = default; - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR pair() : first(), second() {} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 @@ -272,18 +281,11 @@ struct _LIBCPP_TYPE_VIS_ONLY pair ) : first(__p.first), second(__p.second) {} -#if !defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && _LIBCPP_TRIVIAL_PAIR_COPY_CTOR - _LIBCPP_INLINE_VISIBILITY - pair(const pair& __p) = default; -#elif !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) || !_LIBCPP_TRIVIAL_PAIR_COPY_CTOR - _LIBCPP_INLINE_VISIBILITY - pair(const pair& __p) - _NOEXCEPT_(is_nothrow_copy_constructible::value && - is_nothrow_copy_constructible::value) - : first(__p.first), - second(__p.second) - { - } +#if !defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) + pair(pair const&) = default; + pair(pair&&) = default; +#else + // Use the implicitly declared copy constructor in C++03 #endif _LIBCPP_INLINE_VISIBILITY @@ -315,19 +317,6 @@ struct _LIBCPP_TYPE_VIS_ONLY pair : first(_VSTD::forward<_U1>(__p.first)), second(_VSTD::forward<_U2>(__p.second)) {} -#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS - _LIBCPP_INLINE_VISIBILITY - pair(pair&& __p) = default; -#else - _LIBCPP_INLINE_VISIBILITY - pair(pair&& __p) _NOEXCEPT_(is_nothrow_move_constructible::value && - is_nothrow_move_constructible::value) - : first(_VSTD::forward(__p.first)), - second(_VSTD::forward(__p.second)) - { - } -#endif - _LIBCPP_INLINE_VISIBILITY pair& operator=(pair&& __p) _NOEXCEPT_(is_nothrow_move_assignable::value && From owner-svn-src-stable-10@freebsd.org Fri Mar 24 18:28:49 2017 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 8F888D1B6C7; Fri, 24 Mar 2017 18:28:49 +0000 (UTC) (envelope-from erj@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 5C2BC1561; Fri, 24 Mar 2017 18:28:49 +0000 (UTC) (envelope-from erj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2OISmRL035823; Fri, 24 Mar 2017 18:28:48 GMT (envelope-from erj@FreeBSD.org) Received: (from erj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2OISmMo035822; Fri, 24 Mar 2017 18:28:48 GMT (envelope-from erj@FreeBSD.org) Message-Id: <201703241828.v2OISmMo035822@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: erj set sender to erj@FreeBSD.org using -f From: Eric Joyner Date: Fri, 24 Mar 2017 18:28: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: r315916 - stable/10/sys/dev/ixgbe 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.23 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, 24 Mar 2017 18:28:49 -0000 Author: erj Date: Fri Mar 24 18:28:48 2017 New Revision: 315916 URL: https://svnweb.freebsd.org/changeset/base/315916 Log: ixgbe(4): Re-add mutex lock call that was dropped in a previous commit. PR: 218062 Reported by: Terry Kennedy Sponsored by: Intel Corporation Modified: stable/10/sys/dev/ixgbe/if_ix.c Modified: stable/10/sys/dev/ixgbe/if_ix.c ============================================================================== --- stable/10/sys/dev/ixgbe/if_ix.c Fri Mar 24 18:28:13 2017 (r315915) +++ stable/10/sys/dev/ixgbe/if_ix.c Fri Mar 24 18:28:48 2017 (r315916) @@ -3929,6 +3929,7 @@ ixgbe_handle_msf(void *context, int pend u32 autoneg; bool negotiate; + IXGBE_CORE_LOCK(adapter); /* get_supported_phy_layer will call hw->phy.ops.identify_sfp() */ adapter->phy_layer = ixgbe_get_supported_physical_layer(hw); From owner-svn-src-stable-10@freebsd.org Sat Mar 25 05:09:04 2017 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 DD8D0D1D508; Sat, 25 Mar 2017 05:09:04 +0000 (UTC) (envelope-from grehan@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 87D761998; Sat, 25 Mar 2017 05:09:04 +0000 (UTC) (envelope-from grehan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2P593xK099232; Sat, 25 Mar 2017 05:09:03 GMT (envelope-from grehan@FreeBSD.org) Received: (from grehan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2P593tK099229; Sat, 25 Mar 2017 05:09:03 GMT (envelope-from grehan@FreeBSD.org) Message-Id: <201703250509.v2P593tK099229@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: grehan set sender to grehan@FreeBSD.org using -f From: Peter Grehan Date: Sat, 25 Mar 2017 05:09:03 +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: r315928 - in stable/10/sys: amd64/vmm x86/include x86/x86 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.23 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, 25 Mar 2017 05:09:05 -0000 Author: grehan Date: Sat Mar 25 05:09:03 2017 New Revision: 315928 URL: https://svnweb.freebsd.org/changeset/base/315928 Log: MFC r315361 and r315364: Hide MONITORX/MWAITX from guests. r315361 Add the AMD MONITORX/MWAITX feature definition introduced in Bulldozer/Ryzen CPUs. r315364 Hide the AMD MONITORX/MWAITX capability. Otherwise, recent Linux guests will use these instructions, resulting in #UD exceptions since bhyve doesn't implement MONITOR/MWAIT exits. This fixes boot-time hangs in recent Linux guests on Ryzen CPUs (and probably Bulldozer aka AMD FX as well). Modified: stable/10/sys/amd64/vmm/x86.c stable/10/sys/x86/include/specialreg.h stable/10/sys/x86/x86/identcpu.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/amd64/vmm/x86.c ============================================================================== --- stable/10/sys/amd64/vmm/x86.c Sat Mar 25 05:05:12 2017 (r315927) +++ stable/10/sys/amd64/vmm/x86.c Sat Mar 25 05:09:03 2017 (r315928) @@ -176,6 +176,9 @@ x86_emulate_cpuid(struct vm *vm, int vcp /* Don't advertise the OS visible workaround feature */ regs[2] &= ~AMDID2_OSVW; + /* Hide mwaitx/monitorx capability from the guest */ + regs[2] &= ~AMDID2_MWAITX; + /* * Hide rdtscp/ia32_tsc_aux until we know how * to deal with them. Modified: stable/10/sys/x86/include/specialreg.h ============================================================================== --- stable/10/sys/x86/include/specialreg.h Sat Mar 25 05:05:12 2017 (r315927) +++ stable/10/sys/x86/include/specialreg.h Sat Mar 25 05:09:03 2017 (r315928) @@ -226,6 +226,7 @@ #define AMDID2_DBE 0x04000000 #define AMDID2_PTSC 0x08000000 #define AMDID2_PTSCEL2I 0x10000000 +#define AMDID2_MWAITX 0x20000000 /* * CPUID instruction 1 eax info Modified: stable/10/sys/x86/x86/identcpu.c ============================================================================== --- stable/10/sys/x86/x86/identcpu.c Sat Mar 25 05:05:12 2017 (r315927) +++ stable/10/sys/x86/x86/identcpu.c Sat Mar 25 05:09:03 2017 (r315928) @@ -875,7 +875,7 @@ printcpuinfo(void) "\033DBE" /* Data Breakpoint extension */ "\034PTSC" /* Performance TSC */ "\035PL2I" /* L2I perf count */ - "\036" + "\036MWAITX" /* MONITORX/MWAITX instructions */ "\037" "\040" ); From owner-svn-src-stable-10@freebsd.org Sat Mar 25 11:36:07 2017 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 C41C6D1B956; Sat, 25 Mar 2017 11:36:07 +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 79B881A20; Sat, 25 Mar 2017 11:36:07 +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 v2PBa60H055328; Sat, 25 Mar 2017 11:36:06 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2PBa66V055327; Sat, 25 Mar 2017 11:36:06 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703251136.v2PBa66V055327@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sat, 25 Mar 2017 11:36:06 +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: r315937 - stable/10/sys/cam 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.23 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, 25 Mar 2017 11:36:07 -0000 Author: mav Date: Sat Mar 25 11:36:06 2017 New Revision: 315937 URL: https://svnweb.freebsd.org/changeset/base/315937 Log: MFC r315082: Allow XPT_GDEV_STATS for UNCONFIGURED devices. Queue statistics has nothing to do with presence or absence of INQUIRY data, etc. Target mode devices are never configured, but have queues. Modified: stable/10/sys/cam/cam_xpt.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/cam_xpt.c ============================================================================== --- stable/10/sys/cam/cam_xpt.c Sat Mar 25 11:35:31 2017 (r315936) +++ stable/10/sys/cam/cam_xpt.c Sat Mar 25 11:36:06 2017 (r315937) @@ -2674,36 +2674,25 @@ call_sim: } case XPT_GDEV_STATS: { - struct cam_ed *dev; + struct ccb_getdevstats *cgds = &start_ccb->cgds; + struct cam_ed *dev = path->device; + struct cam_eb *bus = path->bus; + struct cam_et *tar = path->target; + struct cam_devq *devq = bus->sim->devq; - dev = path->device; - if ((dev->flags & CAM_DEV_UNCONFIGURED) != 0) { - start_ccb->ccb_h.status = CAM_DEV_NOT_THERE; - } else { - struct ccb_getdevstats *cgds; - struct cam_eb *bus; - struct cam_et *tar; - struct cam_devq *devq; - - cgds = &start_ccb->cgds; - bus = path->bus; - tar = path->target; - devq = bus->sim->devq; - mtx_lock(&devq->send_mtx); - cgds->dev_openings = dev->ccbq.dev_openings; - cgds->dev_active = dev->ccbq.dev_active; - cgds->allocated = dev->ccbq.allocated; - cgds->queued = cam_ccbq_pending_ccb_count(&dev->ccbq); - cgds->held = cgds->allocated - cgds->dev_active - - cgds->queued; - cgds->last_reset = tar->last_reset; - cgds->maxtags = dev->maxtags; - cgds->mintags = dev->mintags; - if (timevalcmp(&tar->last_reset, &bus->last_reset, <)) - cgds->last_reset = bus->last_reset; - mtx_unlock(&devq->send_mtx); - cgds->ccb_h.status = CAM_REQ_CMP; - } + mtx_lock(&devq->send_mtx); + cgds->dev_openings = dev->ccbq.dev_openings; + cgds->dev_active = dev->ccbq.dev_active; + cgds->allocated = dev->ccbq.allocated; + cgds->queued = cam_ccbq_pending_ccb_count(&dev->ccbq); + cgds->held = cgds->allocated - cgds->dev_active - cgds->queued; + cgds->last_reset = tar->last_reset; + cgds->maxtags = dev->maxtags; + cgds->mintags = dev->mintags; + if (timevalcmp(&tar->last_reset, &bus->last_reset, <)) + cgds->last_reset = bus->last_reset; + mtx_unlock(&devq->send_mtx); + cgds->ccb_h.status = CAM_REQ_CMP; break; } case XPT_GDEVLIST: From owner-svn-src-stable-10@freebsd.org Sat Mar 25 11:45:20 2017 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 5C717D1BC94; Sat, 25 Mar 2017 11:45:20 +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 1EB07106B; Sat, 25 Mar 2017 11:45:20 +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 v2PBjJFT059558; Sat, 25 Mar 2017 11:45:19 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2PBjJSd059557; Sat, 25 Mar 2017 11:45:19 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703251145.v2PBjJSd059557@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sat, 25 Mar 2017 11:45: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: r315939 - stable/10/sys/cam/ctl 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.23 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, 25 Mar 2017 11:45:20 -0000 Author: mav Date: Sat Mar 25 11:45:19 2017 New Revision: 315939 URL: https://svnweb.freebsd.org/changeset/base/315939 Log: MFC r315084: Increase device openings to tagged maximum. Some SIMs report much less untagged device openings then tagged ones. Target mode devices are not handled by regular probing routines, and so there is nothing to increase queue size for them to the SIM's maximum. To fix that resize the queue explicitly on ctl periph registration. This radically improves performance of mpt(4) in target mode. Also fetch and report device queue statistics in `ctladm dumpstructs`, since regular way of `camcontrol tags` is not usable in target mode. Modified: stable/10/sys/cam/ctl/scsi_ctl.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/ctl/scsi_ctl.c ============================================================================== --- stable/10/sys/cam/ctl/scsi_ctl.c Sat Mar 25 11:44:34 2017 (r315938) +++ stable/10/sys/cam/ctl/scsi_ctl.c Sat Mar 25 11:45:19 2017 (r315939) @@ -457,6 +457,16 @@ ctlferegister(struct cam_periph *periph, softc->periph = periph; periph->softc = softc; + /* Increase device openings to maximum for the SIM. */ + if (bus_softc->sim->max_tagged_dev_openings > + bus_softc->sim->max_dev_openings) { + cam_release_devq(periph->path, + /*relsim_flags*/RELSIM_ADJUST_OPENINGS, + /*openings*/bus_softc->sim->max_tagged_dev_openings, + /*timeout*/0, + /*getcount_only*/1); + } + xpt_setup_ccb(&ccb.ccb_h, periph->path, CAM_PRIORITY_NONE); ccb.ccb_h.func_code = XPT_EN_LUN; ccb.cel.grp6_len = 0; @@ -1815,9 +1825,9 @@ static void ctlfe_dump_sim(struct cam_sim *sim) { - printf("%s%d: max tagged openings: %d, max dev openings: %d\n", - sim->sim_name, sim->unit_number, - sim->max_tagged_dev_openings, sim->max_dev_openings); + printf("%s%d: max dev openings: %d, max tagged dev openings: %d\n", + sim->sim_name, sim->unit_number, sim->max_dev_openings, + sim->max_tagged_dev_openings); } /* @@ -1826,11 +1836,21 @@ ctlfe_dump_sim(struct cam_sim *sim) static void ctlfe_dump_queue(struct ctlfe_lun_softc *softc) { + struct cam_periph *periph = softc->periph; struct ccb_hdr *hdr; - struct cam_periph *periph; + struct ccb_getdevstats cgds; int num_items; - periph = softc->periph; + xpt_setup_ccb(&cgds.ccb_h, periph->path, CAM_PRIORITY_NORMAL); + cgds.ccb_h.func_code = XPT_GDEV_STATS; + xpt_action((union ccb *)&cgds); + if ((cgds.ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) { + xpt_print(periph->path, "devq: openings %d, active %d, " + "allocated %d, queued %d, held %d\n", + cgds.dev_openings, cgds.dev_active, cgds.allocated, + cgds.queued, cgds.held); + } + num_items = 0; STAILQ_FOREACH(hdr, &softc->work_queue, periph_links.stqe) { From owner-svn-src-stable-10@freebsd.org Sat Mar 25 11:48:13 2017 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 A23C3D1BE2B; Sat, 25 Mar 2017 11:48:13 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7CADB13D0; Sat, 25 Mar 2017 11:48:13 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2PBmCYJ059754; Sat, 25 Mar 2017 11:48:12 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2PBmCGc059753; Sat, 25 Mar 2017 11:48:12 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703251148.v2PBmCGc059753@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sat, 25 Mar 2017 11:48: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: r315941 - 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.23 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, 25 Mar 2017 11:48:13 -0000 Author: mav Date: Sat Mar 25 11:48:12 2017 New Revision: 315941 URL: https://svnweb.freebsd.org/changeset/base/315941 Log: MFC r315087, r315146: Improve ctl(4) description, including frontends and backends. Modified: stable/10/share/man/man4/ctl.4 Directory Properties: stable/10/ (props changed) Modified: stable/10/share/man/man4/ctl.4 ============================================================================== --- stable/10/share/man/man4/ctl.4 Sat Mar 25 11:47:23 2017 (r315940) +++ stable/10/share/man/man4/ctl.4 Sat Mar 25 11:48:12 2017 (r315941) @@ -1,5 +1,5 @@ .\" Copyright (c) 2013 Edward Tomasz Napierala -.\" Copyright (c) 2015 Alexander Motin +.\" Copyright (c) 2015-2017 Alexander Motin .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -24,12 +24,12 @@ .\" SUCH DAMAGE. .\" .\" $FreeBSD$ -.Dd September 27, 2015 +.Dd March 11, 2017 .Dt CTL 4 .Os .Sh NAME .Nm ctl -.Nd CAM Target Layer / iSCSI target +.Nd CAM Target Layer / SCSI target subsystem .Sh SYNOPSIS To compile this driver into the kernel, place the following line in your @@ -48,12 +48,12 @@ ctl_load="YES" .Sh DESCRIPTION The .Nm -subsystem provides SCSI disk and processor emulation. +subsystem provides SCSI target devices emulation. It supports features such as: .Pp .Bl -bullet -compact .It -Disk, processor and cdrom device emulation +Disk, CD-ROM and processor device emulation .It Tagged queueing .It @@ -61,32 +61,73 @@ SCSI task attribute support (ordered, he .It SCSI implicit command ordering support .It -Full task management support (abort, LUN reset, target reset, etc.) +Full task management support (abort, query, reset, etc.) .It -Support for multiple ports +Support for multiple ports, initiators, targets and backing stores .It -Support for multiple simultaneous initiators -.It -Support for multiple simultaneous backing stores -.It -Support for VMWare VAAI: COMPARE AND WRITE, XCOPY, WRITE SAME, -and UNMAP commands -.It -Support for Microsoft ODX: POPULATE TOKEN/WRITE USING TOKEN, -WRITE SAME, and UNMAP commands +Support for VMWare VAAI and Microsoft ODX offload (COMPARE AND WRITE, +XCOPY, POPULATE TOKEN/WRITE USING TOKEN, WRITE SAME and UNMAP) .It Persistent reservation support .It -Mode sense/select support +Extensive VPD/mode/log pages support .It -Error injection support +Featured error reporting, error injection and basic SMART support .It High Availability clustering support with ALUA .It All I/O handled in-kernel, no userland context switch overhead .El .Pp -It also serves as a kernel component of the native iSCSI target. +The +.Nm +subsystem includes multiple frontends to provide access using different +transport protocols and implementations: +.Bl -tag -width cfumass +.It camsim +Provides access for local system via virtual initiator mode +.Xr CAM 4 +SIM. +.It camtgt +Provides access for remote systems via target mode +.Xr CAM 4 +SIMs, such as Fibre Channel +.Xr isp 4 +and +.Xr mpt 4 . +.It cfumass +Provides access for remote systems via USB Mass Storage Class +Bulk Only (BBB) Transport. +.It ha +Internal frontend used to receive requests from other node ports in +High Availability cluster. +.It ioctl +Provides access for local user-level applications via +.Xr ioctl 2 +based API. +.It iscsi +Combined with +.Xr iscsi 4 +and +.Xr ctld 8 , +provides access for remote systems via iSCSI protocol. +.It tpc +Internal frontend used to receive requests from Third Party Copy engine, +implementing copy offload operations. +.El +.Pp +The +.Nm +subsystem includes two backends to create logical units using different +kinds of backing stores: +.Bl -tag -width ramdisk +.It block +Stores data in ZFS ZVOLs, files or raw block devices. +.It ramdisk +Stores data in RAM, that makes it mostly useful for performance testing. +Depending on configured capacity can work as black hole, thin or thick +provisioned disk. +.El .Sh SYSCTL VARIABLES The following variables are available as both .Xr sysctl 8 @@ -146,7 +187,7 @@ primary; .It 1 secondary. .El -This role can be overriden on per-LUN basis using "ha_role" LUN option, +This role can be overridden on per-LUN basis using "ha_role" LUN option, so that for one LUN one node is primary, while for another -- another. Role change from primary to secondary for HA modes 0 and 2 closes backends, the opposite change -- opens. From owner-svn-src-stable-10@freebsd.org Sat Mar 25 12:29:16 2017 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 E441ED1B1CA; Sat, 25 Mar 2017 12:29:16 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B327E1B29; Sat, 25 Mar 2017 12:29:16 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2PCTFDG075798; Sat, 25 Mar 2017 12:29:15 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2PCTFsM075797; Sat, 25 Mar 2017 12:29:15 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201703251229.v2PCTFsM075797@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Sat, 25 Mar 2017 12:29: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: r315943 - in stable: 10/contrib/libcxxrt 11/contrib/libcxxrt 9/contrib/libcxxrt 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.23 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, 25 Mar 2017 12:29:17 -0000 Author: dim Date: Sat Mar 25 12:29:15 2017 New Revision: 315943 URL: https://svnweb.freebsd.org/changeset/base/315943 Log: MFC r315745: Cherry-pick libcxxrt commit 8a853717e61d5d55cbdf74d9d0a7545da5d5ff92: Author: David Chisnall Date: Wed Mar 22 12:27:08 2017 +0000 Simplify some code. realloc() with a null pointer is equivalent to malloc, so we don't need to handle the two cases independently. Fixes #46 This should help with lang/beignet and other programs, which expect __cxa_demangle(name, NULL, NULL, &status) to return zero in status. PR: 213732 Modified: stable/10/contrib/libcxxrt/typeinfo.cc Directory Properties: stable/10/ (props changed) Changes in other areas also in this revision: Modified: stable/11/contrib/libcxxrt/typeinfo.cc stable/9/contrib/libcxxrt/typeinfo.cc Directory Properties: stable/11/ (props changed) stable/9/ (props changed) stable/9/contrib/ (props changed) stable/9/contrib/libcxxrt/ (props changed) Modified: stable/10/contrib/libcxxrt/typeinfo.cc ============================================================================== --- stable/10/contrib/libcxxrt/typeinfo.cc Sat Mar 25 12:21:20 2017 (r315942) +++ stable/10/contrib/libcxxrt/typeinfo.cc Sat Mar 25 12:29:15 2017 (r315943) @@ -86,15 +86,7 @@ extern "C" char* __cxa_demangle(const ch if (NULL != demangled) { size_t len = strlen(demangled); - if (buf == NULL) - { - if (n) - { - *n = len; - } - return demangled; - } - if (*n < len+1) + if (!buf || (*n < len+1)) { buf = static_cast(realloc(buf, len+1)); } From owner-svn-src-stable-10@freebsd.org Sat Mar 25 13:33:26 2017 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 F068ED1CB4D; Sat, 25 Mar 2017 13:33:26 +0000 (UTC) (envelope-from badger@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 8CF591579; Sat, 25 Mar 2017 13:33:26 +0000 (UTC) (envelope-from badger@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2PDXPkH004390; Sat, 25 Mar 2017 13:33:25 GMT (envelope-from badger@FreeBSD.org) Received: (from badger@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2PDXPGc004383; Sat, 25 Mar 2017 13:33:25 GMT (envelope-from badger@FreeBSD.org) Message-Id: <201703251333.v2PDXPGc004383@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: badger set sender to badger@FreeBSD.org using -f From: Eric Badger Date: Sat, 25 Mar 2017 13:33:25 +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: r315949 - in stable: 10/sys/kern 10/sys/sys 10/tests/sys/kern 11/sys/kern 11/sys/sys 11/tests/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.23 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, 25 Mar 2017 13:33:27 -0000 Author: badger Date: Sat Mar 25 13:33:23 2017 New Revision: 315949 URL: https://svnweb.freebsd.org/changeset/base/315949 Log: MFC r313992, r314075, r314118, r315484: r315484: ptrace_test: eliminate assumption about thread scheduling A couple of the ptrace tests make assumptions about which thread in a multithreaded process will run after a halt. This makes the tests less portable across branches, and susceptible to future breakage. Instead, twiddle thread scheduling and priorities to match the tests' expectation. r314118: Actually fix buildworlds other than i386/amd64/sparc64 after r313992 Disable offending test for platforms without a userspace visible breakpoint(). r314075: Fix world build for archs where __builtin_debugtrap() does not work. The offending code was introduced in r313992. r313992: Defer ptracestop() signals that cannot be delivered immediately When a thread is stopped in ptracestop(), the ptrace(2) user may request a signal be delivered upon resumption of the thread. Heretofore, those signals were discarded unless ptracestop()'s caller was issignal(). Fix this by modifying ptracestop() to queue up signals requested by the ptrace user that will be delivered when possible. Take special care when the signal is SIGKILL (usually generated from a PT_KILL request); no new stop events should be triggered after a PT_KILL. Add a number of tests for the new functionality. Several tests were authored by jhb. PR: 212607 Sponsored by: Dell EMC Modified: stable/10/sys/kern/kern_fork.c stable/10/sys/kern/kern_sig.c stable/10/sys/kern/kern_thr.c stable/10/sys/kern/subr_syscall.c stable/10/sys/kern/sys_process.c stable/10/sys/sys/signalvar.h stable/10/tests/sys/kern/Makefile stable/10/tests/sys/kern/ptrace_test.c Directory Properties: stable/10/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/kern/kern_fork.c stable/11/sys/kern/kern_sig.c stable/11/sys/kern/kern_thr.c stable/11/sys/kern/subr_syscall.c stable/11/sys/kern/sys_process.c stable/11/sys/sys/signalvar.h stable/11/tests/sys/kern/Makefile stable/11/tests/sys/kern/ptrace_test.c Directory Properties: stable/11/ (props changed) Modified: stable/10/sys/kern/kern_fork.c ============================================================================== --- stable/10/sys/kern/kern_fork.c Sat Mar 25 13:32:28 2017 (r315948) +++ stable/10/sys/kern/kern_fork.c Sat Mar 25 13:33:23 2017 (r315949) @@ -1072,7 +1072,7 @@ fork_return(struct thread *td, struct tr proc_reparent(p, dbg); sx_xunlock(&proctree_lock); td->td_dbgflags |= TDB_CHILD | TDB_SCX | TDB_FSTP; - ptracestop(td, SIGSTOP); + ptracestop(td, SIGSTOP, NULL); td->td_dbgflags &= ~(TDB_CHILD | TDB_SCX); } else { /* @@ -1093,7 +1093,7 @@ fork_return(struct thread *td, struct tr _STOPEVENT(p, S_SCX, td->td_dbg_sc_code); if ((p->p_ptevents & PTRACE_SCX) != 0 || (td->td_dbgflags & TDB_BORN) != 0) - ptracestop(td, SIGTRAP); + ptracestop(td, SIGTRAP, NULL); td->td_dbgflags &= ~(TDB_SCX | TDB_BORN); PROC_UNLOCK(p); } Modified: stable/10/sys/kern/kern_sig.c ============================================================================== --- stable/10/sys/kern/kern_sig.c Sat Mar 25 13:32:28 2017 (r315948) +++ stable/10/sys/kern/kern_sig.c Sat Mar 25 13:33:23 2017 (r315949) @@ -277,6 +277,7 @@ sigqueue_init(sigqueue_t *list, struct p { SIGEMPTYSET(list->sq_signals); SIGEMPTYSET(list->sq_kill); + SIGEMPTYSET(list->sq_ptrace); TAILQ_INIT(&list->sq_list); list->sq_proc = p; list->sq_flags = SQ_INIT; @@ -300,9 +301,15 @@ sigqueue_get(sigqueue_t *sq, int signo, if (!SIGISMEMBER(sq->sq_signals, signo)) return (0); + if (SIGISMEMBER(sq->sq_ptrace, signo)) { + count++; + SIGDELSET(sq->sq_ptrace, signo); + si->ksi_flags |= KSI_PTRACE; + } if (SIGISMEMBER(sq->sq_kill, signo)) { count++; - SIGDELSET(sq->sq_kill, signo); + if (count == 1) + SIGDELSET(sq->sq_kill, signo); } TAILQ_FOREACH_SAFE(ksi, &sq->sq_list, ksi_link, next) { @@ -346,7 +353,8 @@ sigqueue_take(ksiginfo_t *ksi) if (kp->ksi_signo == ksi->ksi_signo) break; } - if (kp == NULL && !SIGISMEMBER(sq->sq_kill, ksi->ksi_signo)) + if (kp == NULL && !SIGISMEMBER(sq->sq_kill, ksi->ksi_signo) && + !SIGISMEMBER(sq->sq_ptrace, ksi->ksi_signo)) SIGDELSET(sq->sq_signals, ksi->ksi_signo); } @@ -359,6 +367,10 @@ sigqueue_add(sigqueue_t *sq, int signo, KASSERT(sq->sq_flags & SQ_INIT, ("sigqueue not inited")); + /* + * SIGKILL/SIGSTOP cannot be caught or masked, so take the fast path + * for these signals. + */ if (signo == SIGKILL || signo == SIGSTOP || si == NULL) { SIGADDSET(sq->sq_kill, signo); goto out_set_bit; @@ -397,16 +409,19 @@ sigqueue_add(sigqueue_t *sq, int signo, ksi->ksi_sigq = sq; } - if ((si->ksi_flags & KSI_TRAP) != 0 || - (si->ksi_flags & KSI_SIGQ) == 0) { - if (ret != 0) + if (ret != 0) { + if ((si->ksi_flags & KSI_PTRACE) != 0) { + SIGADDSET(sq->sq_ptrace, signo); + ret = 0; + goto out_set_bit; + } else if ((si->ksi_flags & KSI_TRAP) != 0 || + (si->ksi_flags & KSI_SIGQ) == 0) { SIGADDSET(sq->sq_kill, signo); - ret = 0; - goto out_set_bit; - } - - if (ret != 0) + ret = 0; + goto out_set_bit; + } return (ret); + } out_set_bit: SIGADDSET(sq->sq_signals, signo); @@ -433,6 +448,7 @@ sigqueue_flush(sigqueue_t *sq) SIGEMPTYSET(sq->sq_signals); SIGEMPTYSET(sq->sq_kill); + SIGEMPTYSET(sq->sq_ptrace); } static void @@ -465,6 +481,11 @@ sigqueue_move_set(sigqueue_t *src, sigqu SIGSETOR(dst->sq_kill, tmp); SIGSETNAND(src->sq_kill, tmp); + tmp = src->sq_ptrace; + SIGSETAND(tmp, *set); + SIGSETOR(dst->sq_ptrace, tmp); + SIGSETNAND(src->sq_ptrace, tmp); + tmp = src->sq_signals; SIGSETAND(tmp, *set); SIGSETOR(dst->sq_signals, tmp); @@ -501,6 +522,7 @@ sigqueue_delete_set(sigqueue_t *sq, cons } } SIGSETNAND(sq->sq_kill, *set); + SIGSETNAND(sq->sq_ptrace, *set); SIGSETNAND(sq->sq_signals, *set); } @@ -2474,69 +2496,116 @@ sig_suspend_threads(struct thread *td, s } } +/* + * Stop the process for an event deemed interesting to the debugger. If si is + * non-NULL, this is a signal exchange; the new signal requested by the + * debugger will be returned for handling. If si is NULL, this is some other + * type of interesting event. The debugger may request a signal be delivered in + * that case as well, however it will be deferred until it can be handled. + */ int -ptracestop(struct thread *td, int sig) +ptracestop(struct thread *td, int sig, ksiginfo_t *si) { struct proc *p = td->td_proc; + struct thread *td2; + ksiginfo_t ksi; + int prop; PROC_LOCK_ASSERT(p, MA_OWNED); KASSERT(!(p->p_flag & P_WEXIT), ("Stopping exiting process")); WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, &p->p_mtx.lock_object, "Stopping for traced signal"); - td->td_dbgflags |= TDB_XSIG; td->td_xsig = sig; - CTR4(KTR_PTRACE, "ptracestop: tid %d (pid %d) flags %#x sig %d", - td->td_tid, p->p_pid, td->td_dbgflags, sig); - PROC_SLOCK(p); - while ((p->p_flag & P_TRACED) && (td->td_dbgflags & TDB_XSIG)) { - if (p->p_flag & P_SINGLE_EXIT && - !(td->td_dbgflags & TDB_EXIT)) { + + if (si == NULL || (si->ksi_flags & KSI_PTRACE) == 0) { + td->td_dbgflags |= TDB_XSIG; + CTR4(KTR_PTRACE, "ptracestop: tid %d (pid %d) flags %#x sig %d", + td->td_tid, p->p_pid, td->td_dbgflags, sig); + PROC_SLOCK(p); + while ((p->p_flag & P_TRACED) && (td->td_dbgflags & TDB_XSIG)) { + if (P_KILLED(p)) { + /* + * Ensure that, if we've been PT_KILLed, the + * exit status reflects that. Another thread + * may also be in ptracestop(), having just + * received the SIGKILL, but this thread was + * unsuspended first. + */ + td->td_dbgflags &= ~TDB_XSIG; + td->td_xsig = SIGKILL; + p->p_ptevents = 0; + break; + } + if (p->p_flag & P_SINGLE_EXIT && + !(td->td_dbgflags & TDB_EXIT)) { + /* + * Ignore ptrace stops except for thread exit + * events when the process exits. + */ + td->td_dbgflags &= ~TDB_XSIG; + PROC_SUNLOCK(p); + return (0); + } + /* - * Ignore ptrace stops except for thread exit - * events when the process exits. + * Make wait(2) work. Ensure that right after the + * attach, the thread which was decided to become the + * leader of attach gets reported to the waiter. + * Otherwise, just avoid overwriting another thread's + * assignment to p_xthread. If another thread has + * already set p_xthread, the current thread will get + * a chance to report itself upon the next iteration. */ - td->td_dbgflags &= ~TDB_XSIG; - PROC_SUNLOCK(p); - return (sig); - } - - /* - * Make wait(2) work. Ensure that right after the - * attach, the thread which was decided to become the - * leader of attach gets reported to the waiter. - * Otherwise, just avoid overwriting another thread's - * assignment to p_xthread. If another thread has - * already set p_xthread, the current thread will get - * a chance to report itself upon the next iteration. - */ - if ((td->td_dbgflags & TDB_FSTP) != 0 || - ((p->p_flag2 & P2_PTRACE_FSTP) == 0 && - p->p_xthread == NULL)) { - p->p_xstat = sig; - p->p_xthread = td; - td->td_dbgflags &= ~TDB_FSTP; - p->p_flag2 &= ~P2_PTRACE_FSTP; - p->p_flag |= P_STOPPED_SIG | P_STOPPED_TRACE; - sig_suspend_threads(td, p, 0); - } - if ((td->td_dbgflags & TDB_STOPATFORK) != 0) { - td->td_dbgflags &= ~TDB_STOPATFORK; - cv_broadcast(&p->p_dbgwait); - } + if ((td->td_dbgflags & TDB_FSTP) != 0 || + ((p->p_flag2 & P2_PTRACE_FSTP) == 0 && + p->p_xthread == NULL)) { + p->p_xstat = sig; + p->p_xthread = td; + td->td_dbgflags &= ~TDB_FSTP; + p->p_flag2 &= ~P2_PTRACE_FSTP; + p->p_flag |= P_STOPPED_SIG | P_STOPPED_TRACE; + sig_suspend_threads(td, p, 0); + } + if ((td->td_dbgflags & TDB_STOPATFORK) != 0) { + td->td_dbgflags &= ~TDB_STOPATFORK; + cv_broadcast(&p->p_dbgwait); + } stopme: - thread_suspend_switch(td, p); - if (p->p_xthread == td) - p->p_xthread = NULL; - if (!(p->p_flag & P_TRACED)) - break; - if (td->td_dbgflags & TDB_SUSPEND) { - if (p->p_flag & P_SINGLE_EXIT) + thread_suspend_switch(td, p); + if (p->p_xthread == td) + p->p_xthread = NULL; + if (!(p->p_flag & P_TRACED)) break; - goto stopme; + if (td->td_dbgflags & TDB_SUSPEND) { + if (p->p_flag & P_SINGLE_EXIT) + break; + goto stopme; + } } + PROC_SUNLOCK(p); } - PROC_SUNLOCK(p); + + if (si != NULL && sig == td->td_xsig) { + /* Parent wants us to take the original signal unchanged. */ + si->ksi_flags |= KSI_HEAD; + if (sigqueue_add(&td->td_sigqueue, sig, si) != 0) + si->ksi_signo = 0; + } else if (td->td_xsig != 0) { + /* + * If parent wants us to take a new signal, then it will leave + * it in td->td_xsig; otherwise we just look for signals again. + */ + ksiginfo_init(&ksi); + ksi.ksi_signo = td->td_xsig; + ksi.ksi_flags |= KSI_PTRACE; + prop = sigprop(td->td_xsig); + td2 = sigtd(p, td->td_xsig, prop); + tdsendsignal(p, td2, td->td_xsig, &ksi); + if (td != td2) + return (0); + } + return (td->td_xsig); } @@ -2653,7 +2722,7 @@ issignal(struct thread *td) struct sigacts *ps; struct sigqueue *queue; sigset_t sigpending; - int sig, prop, newsig; + int sig, prop; p = td->td_proc; ps = p->p_sigacts; @@ -2715,47 +2784,18 @@ issignal(struct thread *td) } mtx_unlock(&ps->ps_mtx); - newsig = ptracestop(td, sig); + sig = ptracestop(td, sig, &td->td_dbgksi); mtx_lock(&ps->ps_mtx); - if (sig != newsig) { - - /* - * If parent wants us to take the signal, - * then it will leave it in p->p_xstat; - * otherwise we just look for signals again. - */ - if (newsig == 0) - continue; - sig = newsig; - - /* - * Put the new signal into td_sigqueue. If the - * signal is being masked, look for other - * signals. - */ - sigqueue_add(queue, sig, NULL); - if (SIGISMEMBER(td->td_sigmask, sig)) - continue; - signotify(td); - } else { - if (td->td_dbgksi.ksi_signo != 0) { - td->td_dbgksi.ksi_flags |= KSI_HEAD; - if (sigqueue_add(&td->td_sigqueue, sig, - &td->td_dbgksi) != 0) - td->td_dbgksi.ksi_signo = 0; - } - if (td->td_dbgksi.ksi_signo == 0) - sigqueue_add(&td->td_sigqueue, sig, - NULL); - } - - /* + /* + * Keep looking if the debugger discarded the signal + * or replaced it with a masked signal. + * * If the traced bit got turned off, go back up * to the top to rescan signals. This ensures * that p_sig* and p_sigact are consistent. */ - if ((p->p_flag & P_TRACED) == 0) + if (sig == 0 || (p->p_flag & P_TRACED) == 0) continue; } Modified: stable/10/sys/kern/kern_thr.c ============================================================================== --- stable/10/sys/kern/kern_thr.c Sat Mar 25 13:32:28 2017 (r315948) +++ stable/10/sys/kern/kern_thr.c Sat Mar 25 13:33:23 2017 (r315949) @@ -346,7 +346,7 @@ kern_thr_exit(struct thread *td) p->p_pendingexits++; td->td_dbgflags |= TDB_EXIT; if (p->p_ptevents & PTRACE_LWP) - ptracestop(td, SIGTRAP); + ptracestop(td, SIGTRAP, NULL); PROC_UNLOCK(p); tidhash_remove(td); PROC_LOCK(p); Modified: stable/10/sys/kern/subr_syscall.c ============================================================================== --- stable/10/sys/kern/subr_syscall.c Sat Mar 25 13:32:28 2017 (r315948) +++ stable/10/sys/kern/subr_syscall.c Sat Mar 25 13:33:23 2017 (r315949) @@ -89,7 +89,7 @@ syscallenter(struct thread *td, struct s td->td_dbg_sc_code = sa->code; td->td_dbg_sc_narg = sa->narg; if (p->p_ptevents & PTRACE_SCE) - ptracestop((td), SIGTRAP); + ptracestop((td), SIGTRAP, NULL); PROC_UNLOCK(p); } if (td->td_dbgflags & TDB_USERWR) { @@ -216,7 +216,7 @@ syscallret(struct thread *td, int error, if (traced && ((td->td_dbgflags & (TDB_FORK | TDB_EXEC)) != 0 || (p->p_ptevents & PTRACE_SCX) != 0)) - ptracestop(td, SIGTRAP); + ptracestop(td, SIGTRAP, NULL); td->td_dbgflags &= ~(TDB_SCX | TDB_EXEC | TDB_FORK); PROC_UNLOCK(p); } @@ -253,7 +253,7 @@ again: if (td->td_dbgflags & TDB_VFORK) { PROC_LOCK(p); if (p->p_ptevents & PTRACE_VFORK) - ptracestop(td, SIGTRAP); + ptracestop(td, SIGTRAP, NULL); td->td_dbgflags &= ~TDB_VFORK; PROC_UNLOCK(p); } Modified: stable/10/sys/kern/sys_process.c ============================================================================== --- stable/10/sys/kern/sys_process.c Sat Mar 25 13:32:28 2017 (r315948) +++ stable/10/sys/kern/sys_process.c Sat Mar 25 13:33:23 2017 (r315949) @@ -1082,6 +1082,16 @@ kern_ptrace(struct thread *td, int req, td2->td_dbgflags &= ~TDB_XSIG; td2->td_xsig = data; + /* + * P_WKILLED is insurance that a PT_KILL/SIGKILL always + * works immediately, even if another thread is + * unsuspended first and attempts to handle a different + * signal or if the POSIX.1b style signal queue cannot + * accommodate any new signals. + */ + if (data == SIGKILL) + p->p_flag |= P_WKILLED; + if (req == PT_DETACH) { FOREACH_THREAD_IN_PROC(p, td3) td3->td_dbgflags &= ~TDB_SUSPEND; Modified: stable/10/sys/sys/signalvar.h ============================================================================== --- stable/10/sys/sys/signalvar.h Sat Mar 25 13:32:28 2017 (r315948) +++ stable/10/sys/sys/signalvar.h Sat Mar 25 13:33:23 2017 (r315949) @@ -235,13 +235,15 @@ typedef struct ksiginfo { #define KSI_INS 0x04 /* Directly insert ksi, not the copy */ #define KSI_SIGQ 0x08 /* Generated by sigqueue, might ret EAGAIN. */ #define KSI_HEAD 0x10 /* Insert into head, not tail. */ -#define KSI_COPYMASK (KSI_TRAP|KSI_SIGQ) +#define KSI_PTRACE 0x20 /* Generated by ptrace. */ +#define KSI_COPYMASK (KSI_TRAP | KSI_SIGQ | KSI_PTRACE) #define KSI_ONQ(ksi) ((ksi)->ksi_sigq != NULL) typedef struct sigqueue { sigset_t sq_signals; /* All pending signals. */ sigset_t sq_kill; /* Legacy depth 1 queue. */ + sigset_t sq_ptrace; /* Depth 1 queue for ptrace(2). */ TAILQ_HEAD(, ksiginfo) sq_list;/* Queued signal info. */ struct proc *sq_proc; int sq_flags; @@ -336,7 +338,7 @@ void pgsigio(struct sigio **sigiop, int void pgsignal(struct pgrp *pgrp, int sig, int checkctty, ksiginfo_t *ksi); int postsig(int sig); void kern_psignal(struct proc *p, int sig); -int ptracestop(struct thread *td, int sig); +int ptracestop(struct thread *td, int sig, ksiginfo_t *si); void sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *retmask); struct sigacts *sigacts_alloc(void); void sigacts_copy(struct sigacts *dest, struct sigacts *src); Modified: stable/10/tests/sys/kern/Makefile ============================================================================== --- stable/10/tests/sys/kern/Makefile Sat Mar 25 13:32:28 2017 (r315948) +++ stable/10/tests/sys/kern/Makefile Sat Mar 25 13:33:23 2017 (r315949) @@ -8,6 +8,7 @@ TESTSDIR= ${TESTSBASE}/sys/kern ATF_TESTS_C+= kern_descrip_test ATF_TESTS_C+= ptrace_test +TEST_METADATA.ptrace_test+= timeout="15" ATF_TESTS_C+= reaper ATF_TESTS_C+= unix_seqpacket_test ATF_TESTS_C+= unix_passfd_test Modified: stable/10/tests/sys/kern/ptrace_test.c ============================================================================== --- stable/10/tests/sys/kern/ptrace_test.c Sat Mar 25 13:32:28 2017 (r315948) +++ stable/10/tests/sys/kern/ptrace_test.c Sat Mar 25 13:33:23 2017 (r315949) @@ -27,14 +27,22 @@ #include __FBSDID("$FreeBSD$"); -#include +#include +#include +#include +#include #include +#include +#include #include #include #include #include #include +#include #include +#include +#include #include #include #include @@ -1587,6 +1595,1143 @@ ATF_TC_BODY(ptrace__ptrace_vfork_follow, ATF_REQUIRE(errno == ECHILD); } +/* + * XXX: There's nothing inherently platform specific about this test, however a + * userspace visible breakpoint() is a prerequisite. + */ + #if defined(__amd64__) || defined(__i386__) || defined(__sparc64__) +/* + * Verify that no more events are reported after PT_KILL except for the + * process exit when stopped due to a breakpoint trap. + */ +ATF_TC_WITHOUT_HEAD(ptrace__PT_KILL_breakpoint); +ATF_TC_BODY(ptrace__PT_KILL_breakpoint, tc) +{ + pid_t fpid, wpid; + int status; + + ATF_REQUIRE((fpid = fork()) != -1); + if (fpid == 0) { + trace_me(); + breakpoint(); + exit(1); + } + + /* The first wait() should report the stop from SIGSTOP. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP); + + /* Continue the child ignoring the SIGSTOP. */ + ATF_REQUIRE(ptrace(PT_CONTINUE, fpid, (caddr_t)1, 0) == 0); + + /* The second wait() should report hitting the breakpoint. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGTRAP); + + /* Kill the child process. */ + ATF_REQUIRE(ptrace(PT_KILL, fpid, 0, 0) == 0); + + /* The last wait() should report the SIGKILL. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSIGNALED(status)); + ATF_REQUIRE(WTERMSIG(status) == SIGKILL); + + wpid = wait(&status); + ATF_REQUIRE(wpid == -1); + ATF_REQUIRE(errno == ECHILD); +} +#endif /* defined(__amd64__) || defined(__i386__) || defined(__sparc64__) */ + +/* + * Verify that no more events are reported after PT_KILL except for the + * process exit when stopped inside of a system call. + */ +ATF_TC_WITHOUT_HEAD(ptrace__PT_KILL_system_call); +ATF_TC_BODY(ptrace__PT_KILL_system_call, tc) +{ + struct ptrace_lwpinfo pl; + pid_t fpid, wpid; + int status; + + ATF_REQUIRE((fpid = fork()) != -1); + if (fpid == 0) { + trace_me(); + getpid(); + exit(1); + } + + /* The first wait() should report the stop from SIGSTOP. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP); + + /* Continue the child ignoring the SIGSTOP and tracing system calls. */ + ATF_REQUIRE(ptrace(PT_SYSCALL, fpid, (caddr_t)1, 0) == 0); + + /* The second wait() should report a system call entry for getpid(). */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGTRAP); + + ATF_REQUIRE(ptrace(PT_LWPINFO, wpid, (caddr_t)&pl, sizeof(pl)) != -1); + ATF_REQUIRE(pl.pl_flags & PL_FLAG_SCE); + + /* Kill the child process. */ + ATF_REQUIRE(ptrace(PT_KILL, fpid, 0, 0) == 0); + + /* The last wait() should report the SIGKILL. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSIGNALED(status)); + ATF_REQUIRE(WTERMSIG(status) == SIGKILL); + + wpid = wait(&status); + ATF_REQUIRE(wpid == -1); + ATF_REQUIRE(errno == ECHILD); +} + +/* + * Verify that no more events are reported after PT_KILL except for the + * process exit when killing a multithreaded process. + */ +ATF_TC_WITHOUT_HEAD(ptrace__PT_KILL_threads); +ATF_TC_BODY(ptrace__PT_KILL_threads, tc) +{ + struct ptrace_lwpinfo pl; + pid_t fpid, wpid; + lwpid_t main_lwp; + int status; + + ATF_REQUIRE((fpid = fork()) != -1); + if (fpid == 0) { + trace_me(); + simple_thread_main(); + } + + /* The first wait() should report the stop from SIGSTOP. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP); + + ATF_REQUIRE(ptrace(PT_LWPINFO, wpid, (caddr_t)&pl, + sizeof(pl)) != -1); + main_lwp = pl.pl_lwpid; + + ATF_REQUIRE(ptrace(PT_LWP_EVENTS, wpid, NULL, 1) == 0); + + /* Continue the child ignoring the SIGSTOP. */ + ATF_REQUIRE(ptrace(PT_CONTINUE, fpid, (caddr_t)1, 0) == 0); + + /* The first event should be for the child thread's birth. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGTRAP); + + ATF_REQUIRE(ptrace(PT_LWPINFO, wpid, (caddr_t)&pl, sizeof(pl)) != -1); + ATF_REQUIRE((pl.pl_flags & (PL_FLAG_BORN | PL_FLAG_SCX)) == + (PL_FLAG_BORN | PL_FLAG_SCX)); + ATF_REQUIRE(pl.pl_lwpid != main_lwp); + + /* Kill the child process. */ + ATF_REQUIRE(ptrace(PT_KILL, fpid, 0, 0) == 0); + + /* The last wait() should report the SIGKILL. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSIGNALED(status)); + ATF_REQUIRE(WTERMSIG(status) == SIGKILL); + + wpid = wait(&status); + ATF_REQUIRE(wpid == -1); + ATF_REQUIRE(errno == ECHILD); +} + +static void * +mask_usr1_thread(void *arg) +{ + pthread_barrier_t *pbarrier; + sigset_t sigmask; + + pbarrier = (pthread_barrier_t*)arg; + + sigemptyset(&sigmask); + sigaddset(&sigmask, SIGUSR1); + CHILD_REQUIRE(pthread_sigmask(SIG_BLOCK, &sigmask, NULL) == 0); + + /* Sync up with other thread after sigmask updated. */ + pthread_barrier_wait(pbarrier); + + for (;;) + sleep(60); + + return (NULL); +} + +/* + * Verify that the SIGKILL from PT_KILL takes priority over other signals + * and prevents spurious stops due to those other signals. + */ +ATF_TC_WITHOUT_HEAD(ptrace__PT_KILL_competing_signal); +ATF_TC_BODY(ptrace__PT_KILL_competing_signal, tc) +{ + pid_t fpid, wpid; + int status; + cpuset_t setmask; + pthread_t t; + pthread_barrier_t barrier; + struct sched_param sched_param; + + ATF_REQUIRE((fpid = fork()) != -1); + if (fpid == 0) { + /* Bind to one CPU so only one thread at a time will run. */ + CPU_ZERO(&setmask); + CPU_SET(0, &setmask); + cpusetid_t setid; + CHILD_REQUIRE(cpuset(&setid) == 0); + CHILD_REQUIRE(cpuset_setaffinity(CPU_LEVEL_CPUSET, + CPU_WHICH_CPUSET, setid, sizeof(setmask), &setmask) == 0); + + CHILD_REQUIRE(pthread_barrier_init(&barrier, NULL, 2) == 0); + + CHILD_REQUIRE(pthread_create(&t, NULL, mask_usr1_thread, + (void*)&barrier) == 0); + + /* + * Give the main thread higher priority. The test always + * assumes that, if both threads are able to run, the main + * thread runs first. + */ + sched_param.sched_priority = + (sched_get_priority_max(SCHED_FIFO) + + sched_get_priority_min(SCHED_FIFO)) / 2; + CHILD_REQUIRE(pthread_setschedparam(pthread_self(), + SCHED_FIFO, &sched_param) == 0); + sched_param.sched_priority -= RQ_PPQ; + CHILD_REQUIRE(pthread_setschedparam(t, SCHED_FIFO, + &sched_param) == 0); + + sigset_t sigmask; + sigemptyset(&sigmask); + sigaddset(&sigmask, SIGUSR2); + CHILD_REQUIRE(pthread_sigmask(SIG_BLOCK, &sigmask, NULL) == 0); + + /* Sync up with other thread after sigmask updated. */ + pthread_barrier_wait(&barrier); + + trace_me(); + + for (;;) + sleep(60); + + exit(1); + } + + /* The first wait() should report the stop from SIGSTOP. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP); + + /* Continue the child ignoring the SIGSTOP. */ + ATF_REQUIRE(ptrace(PT_CONTINUE, fpid, (caddr_t)1, 0) == 0); + + /* Send a signal that only the second thread can handle. */ + ATF_REQUIRE(kill(fpid, SIGUSR2) == 0); + + /* The second wait() should report the SIGUSR2. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGUSR2); + + /* Send a signal that only the first thread can handle. */ + ATF_REQUIRE(kill(fpid, SIGUSR1) == 0); + + /* Replace the SIGUSR2 with a kill. */ + ATF_REQUIRE(ptrace(PT_KILL, fpid, 0, 0) == 0); + + /* The last wait() should report the SIGKILL (not the SIGUSR signal). */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSIGNALED(status)); + ATF_REQUIRE(WTERMSIG(status) == SIGKILL); + + wpid = wait(&status); + ATF_REQUIRE(wpid == -1); + ATF_REQUIRE(errno == ECHILD); +} + +/* + * Verify that the SIGKILL from PT_KILL takes priority over other stop events + * and prevents spurious stops caused by those events. + */ +ATF_TC_WITHOUT_HEAD(ptrace__PT_KILL_competing_stop); +ATF_TC_BODY(ptrace__PT_KILL_competing_stop, tc) +{ + pid_t fpid, wpid; + int status; + cpuset_t setmask; + pthread_t t; + pthread_barrier_t barrier; + lwpid_t main_lwp; + struct ptrace_lwpinfo pl; + struct sched_param sched_param; + + ATF_REQUIRE((fpid = fork()) != -1); + if (fpid == 0) { + trace_me(); + + /* Bind to one CPU so only one thread at a time will run. */ + CPU_ZERO(&setmask); + CPU_SET(0, &setmask); + cpusetid_t setid; + CHILD_REQUIRE(cpuset(&setid) == 0); + CHILD_REQUIRE(cpuset_setaffinity(CPU_LEVEL_CPUSET, + CPU_WHICH_CPUSET, setid, sizeof(setmask), &setmask) == 0); + + CHILD_REQUIRE(pthread_barrier_init(&barrier, NULL, 2) == 0); + + CHILD_REQUIRE(pthread_create(&t, NULL, mask_usr1_thread, + (void*)&barrier) == 0); + + /* + * Give the main thread higher priority. The test always + * assumes that, if both threads are able to run, the main + * thread runs first. + */ + sched_param.sched_priority = + (sched_get_priority_max(SCHED_FIFO) + + sched_get_priority_min(SCHED_FIFO)) / 2; + CHILD_REQUIRE(pthread_setschedparam(pthread_self(), + SCHED_FIFO, &sched_param) == 0); + sched_param.sched_priority -= RQ_PPQ; + CHILD_REQUIRE(pthread_setschedparam(t, SCHED_FIFO, + &sched_param) == 0); + + sigset_t sigmask; + sigemptyset(&sigmask); + sigaddset(&sigmask, SIGUSR2); + CHILD_REQUIRE(pthread_sigmask(SIG_BLOCK, &sigmask, NULL) == 0); + + /* Sync up with other thread after sigmask updated. */ + pthread_barrier_wait(&barrier); + + /* Sync up with the test before doing the getpid(). */ + raise(SIGSTOP); + + getpid(); + exit(1); + } + + /* The first wait() should report the stop from SIGSTOP. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP); + + ATF_REQUIRE(ptrace(PT_LWPINFO, wpid, (caddr_t)&pl, sizeof(pl)) != -1); + main_lwp = pl.pl_lwpid; + + /* Continue the child ignoring the SIGSTOP and tracing system calls. */ + ATF_REQUIRE(ptrace(PT_SYSCALL, fpid, (caddr_t)1, 0) == 0); + + /* + * Continue until child is done with setup, which is indicated with + * SIGSTOP. Ignore system calls in the meantime. + */ + for (;;) { + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + if (WSTOPSIG(status) == SIGTRAP) { + ATF_REQUIRE(ptrace(PT_LWPINFO, wpid, (caddr_t)&pl, + sizeof(pl)) != -1); + ATF_REQUIRE(pl.pl_flags & (PL_FLAG_SCE | PL_FLAG_SCX)); + } else { + ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP); + break; + } + ATF_REQUIRE(ptrace(PT_SYSCALL, fpid, (caddr_t)1, 0) == 0); + } + + /* Proceed, allowing main thread to hit syscall entry for getpid(). */ + ATF_REQUIRE(ptrace(PT_SYSCALL, fpid, (caddr_t)1, 0) == 0); + + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGTRAP); + + ATF_REQUIRE(ptrace(PT_LWPINFO, wpid, (caddr_t)&pl, + sizeof(pl)) != -1); + ATF_REQUIRE(pl.pl_lwpid == main_lwp); + ATF_REQUIRE(pl.pl_flags & PL_FLAG_SCE); + /* Prevent the main thread from hitting its syscall exit for now. */ + ATF_REQUIRE(ptrace(PT_SUSPEND, main_lwp, 0, 0) == 0); + + /* + * Proceed, allowing second thread to hit syscall exit for + * pthread_barrier_wait(). + */ + ATF_REQUIRE(ptrace(PT_SYSCALL, fpid, (caddr_t)1, 0) == 0); + + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGTRAP); + + ATF_REQUIRE(ptrace(PT_LWPINFO, wpid, (caddr_t)&pl, + sizeof(pl)) != -1); + ATF_REQUIRE(pl.pl_lwpid != main_lwp); + ATF_REQUIRE(pl.pl_flags & PL_FLAG_SCX); + + /* Send a signal that only the second thread can handle. */ + ATF_REQUIRE(kill(fpid, SIGUSR2) == 0); + + ATF_REQUIRE(ptrace(PT_SYSCALL, fpid, (caddr_t)1, 0) == 0); + + /* The next wait() should report the SIGUSR2. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGUSR2); + + /* Allow the main thread to try to finish its system call. */ + ATF_REQUIRE(ptrace(PT_RESUME, main_lwp, 0, 0) == 0); + + /* + * At this point, the main thread is in the middle of a system call and + * has been resumed. The second thread has taken a SIGUSR2 which will + * be replaced with a SIGKILL below. The main thread will get to run + * first. It should notice the kill request (even though the signal + * replacement occurred in the other thread) and exit accordingly. It + * should not stop for the system call exit event. + */ + + /* Replace the SIGUSR2 with a kill. */ + ATF_REQUIRE(ptrace(PT_KILL, fpid, 0, 0) == 0); + + /* The last wait() should report the SIGKILL (not a syscall exit). */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSIGNALED(status)); + ATF_REQUIRE(WTERMSIG(status) == SIGKILL); + + wpid = wait(&status); + ATF_REQUIRE(wpid == -1); + ATF_REQUIRE(errno == ECHILD); +} + +static void +sigusr1_handler(int sig) +{ + + CHILD_REQUIRE(sig == SIGUSR1); + _exit(2); +} + +/* + * Verify that even if the signal queue is full for a child process, + * a PT_KILL will kill the process. + */ +ATF_TC_WITHOUT_HEAD(ptrace__PT_KILL_with_signal_full_sigqueue); +ATF_TC_BODY(ptrace__PT_KILL_with_signal_full_sigqueue, tc) +{ + pid_t fpid, wpid; + int status; + int max_pending_per_proc; + size_t len; + int i; + + ATF_REQUIRE(signal(SIGUSR1, sigusr1_handler) != SIG_ERR); + + ATF_REQUIRE((fpid = fork()) != -1); + if (fpid == 0) { + trace_me(); + exit(1); + } + + /* The first wait() should report the stop from SIGSTOP. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP); + + len = sizeof(max_pending_per_proc); + ATF_REQUIRE(sysctlbyname("kern.sigqueue.max_pending_per_proc", + &max_pending_per_proc, &len, NULL, 0) == 0); + + /* Fill the signal queue. */ + for (i = 0; i < max_pending_per_proc; ++i) + ATF_REQUIRE(kill(fpid, SIGUSR1) == 0); + + /* Kill the child process. */ + ATF_REQUIRE(ptrace(PT_KILL, fpid, 0, 0) == 0); + + /* The last wait() should report the SIGKILL. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSIGNALED(status)); + ATF_REQUIRE(WTERMSIG(status) == SIGKILL); + + wpid = wait(&status); + ATF_REQUIRE(wpid == -1); + ATF_REQUIRE(errno == ECHILD); +} + +/* + * Verify that when stopped at a system call entry, a signal can be + * requested with PT_CONTINUE which will be delivered once the system + * call is complete. + */ +ATF_TC_WITHOUT_HEAD(ptrace__PT_CONTINUE_with_signal_system_call_entry); +ATF_TC_BODY(ptrace__PT_CONTINUE_with_signal_system_call_entry, tc) +{ + struct ptrace_lwpinfo pl; + pid_t fpid, wpid; + int status; + + ATF_REQUIRE(signal(SIGUSR1, sigusr1_handler) != SIG_ERR); + + ATF_REQUIRE((fpid = fork()) != -1); + if (fpid == 0) { + trace_me(); + getpid(); + exit(1); + } + + /* The first wait() should report the stop from SIGSTOP. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP); + + /* Continue the child ignoring the SIGSTOP and tracing system calls. */ + ATF_REQUIRE(ptrace(PT_SYSCALL, fpid, (caddr_t)1, 0) == 0); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-10@freebsd.org Sat Mar 25 20:14:10 2017 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 005E5D1D84A; Sat, 25 Mar 2017 20:14:10 +0000 (UTC) (envelope-from badger@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 B5DBC1E4F; Sat, 25 Mar 2017 20:14:09 +0000 (UTC) (envelope-from badger@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2PKE8Nn065225; Sat, 25 Mar 2017 20:14:08 GMT (envelope-from badger@FreeBSD.org) Received: (from badger@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2PKE8Cl065223; Sat, 25 Mar 2017 20:14:08 GMT (envelope-from badger@FreeBSD.org) Message-Id: <201703252014.v2PKE8Cl065223@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: badger set sender to badger@FreeBSD.org using -f From: Eric Badger Date: Sat, 25 Mar 2017 20:14: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: r315963 - in stable: 10/sys/kern 10/tests/sys/kern 11/sys/kern 11/tests/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.23 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, 25 Mar 2017 20:14:10 -0000 Author: badger Date: Sat Mar 25 20:14:08 2017 New Revision: 315963 URL: https://svnweb.freebsd.org/changeset/base/315963 Log: MFC r315412, r314852: r315412: Don't clear p_ptevents on normal SIGKILL delivery The ptrace() user has the option of discarding the signal. In such a case, p_ptevents should not be modified. If the ptrace() user decides to send a SIGKILL, ptevents will be cleared in ptracestop(). procfs events do not have the capability to discard the signal, so continue to clear the mask in that case. r314852: don't stop in issignal() if P_SINGLE_EXIT is set Suppose a traced process is stopped in ptracestop() due to receipt of a SIGSTOP signal, and is awaiting orders from the tracing process on how to handle the signal. Before sending any such orders, the tracing process exits. This should kill the traced process. But suppose a second thread handles the SIGKILL and proceeds to exit1(), calling thread_single(). The first thread will now awaken and will have a chance to check once more if it should go to sleep due to the SIGSTOP. It must not sleep after P_SINGLE_EXIT has been set; this would prevent the SIGKILL from taking effect, leaving a stopped orphan behind after the tracing process dies. Also add new tests for this condition. Sponsored by: Dell EMC Modified: stable/10/sys/kern/kern_sig.c stable/10/tests/sys/kern/ptrace_test.c Directory Properties: stable/10/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/kern/kern_sig.c stable/11/tests/sys/kern/ptrace_test.c Directory Properties: stable/11/ (props changed) Modified: stable/10/sys/kern/kern_sig.c ============================================================================== --- stable/10/sys/kern/kern_sig.c Sat Mar 25 19:46:53 2017 (r315962) +++ stable/10/sys/kern/kern_sig.c Sat Mar 25 20:14:08 2017 (r315963) @@ -2197,11 +2197,9 @@ tdsendsignal(struct proc *p, struct thre if (action == SIG_HOLD && !((prop & SA_CONT) && (p->p_flag & P_STOPPED_SIG))) return (ret); - /* - * SIGKILL: Remove procfs STOPEVENTs and ptrace events. - */ + + /* SIGKILL: Remove procfs STOPEVENTs. */ if (sig == SIGKILL) { - p->p_ptevents = 0; /* from procfs_ioctl.c: PIOCBIC */ p->p_stops = 0; /* from procfs_ioctl.c: PIOCCONT */ @@ -2824,14 +2822,15 @@ issignal(struct thread *td) break; /* == ignore */ } /* - * If there is a pending stop signal to process - * with default action, stop here, - * then clear the signal. However, - * if process is member of an orphaned - * process group, ignore tty stop signals. + * If there is a pending stop signal to process with + * default action, stop here, then clear the signal. + * Traced or exiting processes should ignore stops. + * Additionally, a member of an orphaned process group + * should ignore tty stops. */ if (prop & SA_STOP) { - if (p->p_flag & (P_TRACED|P_WEXIT) || + if (p->p_flag & + (P_TRACED | P_WEXIT | P_SINGLE_EXIT) || (p->p_pgrp->pg_jobc == 0 && prop & SA_TTYSTOP)) break; /* == ignore */ Modified: stable/10/tests/sys/kern/ptrace_test.c ============================================================================== --- stable/10/tests/sys/kern/ptrace_test.c Sat Mar 25 19:46:53 2017 (r315962) +++ stable/10/tests/sys/kern/ptrace_test.c Sat Mar 25 20:14:08 2017 (r315963) @@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -2732,6 +2733,212 @@ ATF_TC_BODY(ptrace__PT_CONTINUE_with_sig ATF_REQUIRE(errno == ECHILD); } +static void * +raise_sigstop_thread(void *arg __unused) +{ + + raise(SIGSTOP); + return NULL; +} + +static void * +sleep_thread(void *arg __unused) +{ + + sleep(60); + return NULL; +} + +static void +terminate_with_pending_sigstop(bool sigstop_from_main_thread) +{ + pid_t fpid, wpid; + int status, i; + cpuset_t setmask; + cpusetid_t setid; + pthread_t t; + + /* + * Become the reaper for this process tree. We need to be able to check + * that both child and grandchild have died. + */ + ATF_REQUIRE(procctl(P_PID, getpid(), PROC_REAP_ACQUIRE, NULL) == 0); + + fpid = fork(); + ATF_REQUIRE(fpid >= 0); + if (fpid == 0) { + fpid = fork(); + CHILD_REQUIRE(fpid >= 0); + if (fpid == 0) { + trace_me(); + + /* Pin to CPU 0 to serialize thread execution. */ + CPU_ZERO(&setmask); + CPU_SET(0, &setmask); + CHILD_REQUIRE(cpuset(&setid) == 0); + CHILD_REQUIRE(cpuset_setaffinity(CPU_LEVEL_CPUSET, + CPU_WHICH_CPUSET, setid, + sizeof(setmask), &setmask) == 0); + + if (sigstop_from_main_thread) { + /* + * We expect the SIGKILL sent when our parent + * dies to be delivered to the new thread. + * Raise the SIGSTOP in this thread so the + * threads compete. + */ + CHILD_REQUIRE(pthread_create(&t, NULL, + sleep_thread, NULL) == 0); + raise(SIGSTOP); + } else { + /* + * We expect the SIGKILL to be delivered to + * this thread. After creating the new thread, + * just get off the CPU so the other thread can + * raise the SIGSTOP. + */ + CHILD_REQUIRE(pthread_create(&t, NULL, + raise_sigstop_thread, NULL) == 0); + sleep(60); + } + + exit(0); + } + /* First stop is trace_me() immediately after fork. */ + wpid = waitpid(fpid, &status, 0); + CHILD_REQUIRE(wpid == fpid); + CHILD_REQUIRE(WIFSTOPPED(status)); + CHILD_REQUIRE(WSTOPSIG(status) == SIGSTOP); + + CHILD_REQUIRE(ptrace(PT_CONTINUE, fpid, (caddr_t)1, 0) == 0); + + /* Second stop is from the raise(SIGSTOP). */ + wpid = waitpid(fpid, &status, 0); + CHILD_REQUIRE(wpid == fpid); + CHILD_REQUIRE(WIFSTOPPED(status)); + CHILD_REQUIRE(WSTOPSIG(status) == SIGSTOP); + + /* + * Terminate tracing process without detaching. Our child + * should be killed. + */ + exit(0); + } + + /* + * We should get a normal exit from our immediate child and a SIGKILL + * exit from our grandchild. The latter case is the interesting one. + * Our grandchild should not have stopped due to the SIGSTOP that was + * left dangling when its parent died. + */ + for (i = 0; i < 2; ++i) { + wpid = wait(&status); + if (wpid == fpid) + ATF_REQUIRE(WIFEXITED(status) && + WEXITSTATUS(status) == 0); + else + ATF_REQUIRE(WIFSIGNALED(status) && + WTERMSIG(status) == SIGKILL); + } +} + +/* + * These two tests ensure that if the tracing process exits without detaching + * just after the child received a SIGSTOP, the child is cleanly killed and + * doesn't go to sleep due to the SIGSTOP. The parent's death will send a + * SIGKILL to the child. If the SIGKILL and the SIGSTOP are handled by + * different threads, the SIGKILL must win. There are two variants of this + * test, designed to catch the case where the SIGKILL is delivered to the + * younger thread (the first test) and the case where the SIGKILL is delivered + * to the older thread (the second test). This behavior has changed in the + * past, so make no assumption. + */ +ATF_TC_WITHOUT_HEAD(ptrace__parent_terminate_with_pending_sigstop1); +ATF_TC_BODY(ptrace__parent_terminate_with_pending_sigstop1, tc) +{ + + terminate_with_pending_sigstop(true); +} +ATF_TC_WITHOUT_HEAD(ptrace__parent_terminate_with_pending_sigstop2); +ATF_TC_BODY(ptrace__parent_terminate_with_pending_sigstop2, tc) +{ + + terminate_with_pending_sigstop(false); +} + +/* + * Verify that after ptrace() discards a SIGKILL signal, the event mask + * is not modified. + */ +ATF_TC_WITHOUT_HEAD(ptrace__event_mask_sigkill_discard); +ATF_TC_BODY(ptrace__event_mask_sigkill_discard, tc) +{ + struct ptrace_lwpinfo pl; + pid_t fpid, wpid; + int status, event_mask, new_event_mask; + + ATF_REQUIRE((fpid = fork()) != -1); + if (fpid == 0) { + trace_me(); + raise(SIGSTOP); + exit(0); + } + + /* The first wait() should report the stop from trace_me(). */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP); + + /* Set several unobtrusive event bits. */ + event_mask = PTRACE_EXEC | PTRACE_FORK | PTRACE_LWP; + ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, wpid, (caddr_t)&event_mask, + sizeof(event_mask)) == 0); + + /* Send a SIGKILL without using ptrace. */ + ATF_REQUIRE(kill(fpid, SIGKILL) == 0); + + /* Continue the child ignoring the SIGSTOP. */ + ATF_REQUIRE(ptrace(PT_CONTINUE, fpid, (caddr_t)1, 0) == 0); + + /* The next stop should be due to the SIGKILL. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGKILL); + + ATF_REQUIRE(ptrace(PT_LWPINFO, wpid, (caddr_t)&pl, sizeof(pl)) != -1); + ATF_REQUIRE(pl.pl_flags & PL_FLAG_SI); + ATF_REQUIRE(pl.pl_siginfo.si_signo == SIGKILL); + + /* Continue the child ignoring the SIGKILL. */ + ATF_REQUIRE(ptrace(PT_CONTINUE, fpid, (caddr_t)1, 0) == 0); + + /* The next wait() should report the stop from SIGSTOP. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP); + + /* Check the current event mask. It should not have changed. */ + new_event_mask = 0; + ATF_REQUIRE(ptrace(PT_GET_EVENT_MASK, wpid, (caddr_t)&new_event_mask, + sizeof(new_event_mask)) == 0); + ATF_REQUIRE(event_mask == new_event_mask); + + /* Continue the child to let it exit. */ + ATF_REQUIRE(ptrace(PT_CONTINUE, fpid, (caddr_t)1, 0) == 0); + + /* The last event should be for the child process's exit. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(WIFEXITED(status)); + ATF_REQUIRE(WEXITSTATUS(status) == 0); + + wpid = wait(&status); + ATF_REQUIRE(wpid == -1); + ATF_REQUIRE(errno == ECHILD); +} + ATF_TP_ADD_TCS(tp) { @@ -2775,6 +2982,9 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, ptrace__PT_CONTINUE_with_signal_mix); ATF_TP_ADD_TC(tp, ptrace__PT_CONTINUE_with_signal_kqueue); ATF_TP_ADD_TC(tp, ptrace__PT_CONTINUE_with_signal_thread_sigmask); + ATF_TP_ADD_TC(tp, ptrace__parent_terminate_with_pending_sigstop1); + ATF_TP_ADD_TC(tp, ptrace__parent_terminate_with_pending_sigstop2); + ATF_TP_ADD_TC(tp, ptrace__event_mask_sigkill_discard); return (atf_no_error()); } From owner-svn-src-stable-10@freebsd.org Sat Mar 25 21:46:04 2017 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 423B8D1D91D; Sat, 25 Mar 2017 21:46:04 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 198F317CE; Sat, 25 Mar 2017 21:46:04 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2PLk3GC002420; Sat, 25 Mar 2017 21:46:03 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2PLk2RL002413; Sat, 25 Mar 2017 21:46:02 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201703252146.v2PLk2RL002413@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Sat, 25 Mar 2017 21:46: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: r315965 - in stable/10: contrib/libcxxrt lib/libcxxrt 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.23 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, 25 Mar 2017 21:46:04 -0000 Author: dim Date: Sat Mar 25 21:46:02 2017 New Revision: 315965 URL: https://svnweb.freebsd.org/changeset/base/315965 Log: Synchronize libcxxrt in stable/10 with stable/11. MFC r284553 (by emaste): Update libcxxrt upgrade instructions The typeinfo file no longer exists upstream. MFC r297299: Compile libcxxrt as C++11, since it is only really used in combination with libc++, which is also C++11. Also change one _Static_assert (which is really C11) back into static_assert, like upstream. This should help when compiling libcxxrt with newer versions of gcc, which refuse to recognize any form of static assertions, if not compiling for C++11 or higher. While here, add -nostdinc++ to CFLAGS, to prevent picking up any C++ headers outside the source tree. MFC r299144: Import libcxxrt master 516a65c109eb0a01e5e95fbef455eb3215135cef. Interesting fixes: 3adaa2e Fix _Unwind_Exception cleanup functions 286776c Check exception cleanup function ptr before calling edda626 Correct exception specifications on new and delete operators MFC r303157 (by emaste): libcxxrt: add padding in __cxa_allocate_* to fix alignment The addition of the referenceCount to __cxa_allocate_exception put the unwindHeader at offset 0x58 in __cxa_exception, but it requires 16-byte alignment. In order to avoid changing the current __cxa_exception ABI (and thus breaking its consumers), add explicit padding in the allocation routines (and account for it when freeing). This is intended as a lower-risk change for FreeBSD 11. A "more correct" fix should be prepared for upstream and -CURRENT. Reviewed by: dim Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D7271 MFC r305396: Add _US_ACTION_MASK to libcxxrt's arm-specific unwind header. This value is used in newer versions of compiler-rt. Modified: stable/10/contrib/libcxxrt/FREEBSD-upgrade stable/10/contrib/libcxxrt/exception.cc stable/10/contrib/libcxxrt/guard.cc stable/10/contrib/libcxxrt/memory.cc stable/10/contrib/libcxxrt/unwind-arm.h stable/10/lib/libcxxrt/Makefile stable/10/lib/libcxxrt/Version.map Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/libcxxrt/FREEBSD-upgrade ============================================================================== --- stable/10/contrib/libcxxrt/FREEBSD-upgrade Sat Mar 25 21:33:48 2017 (r315964) +++ stable/10/contrib/libcxxrt/FREEBSD-upgrade Sat Mar 25 21:46:02 2017 (r315965) @@ -3,4 +3,4 @@ $FreeBSD$ This is the FreeBSD copy of libcxxrt. It contains the src directory from the upstream repository. -When updating, copy *.{c,cc,h} and typeinfo from the upstream src/. +When updating, copy *.{c,cc,h} from the upstream src/. Modified: stable/10/contrib/libcxxrt/exception.cc ============================================================================== --- stable/10/contrib/libcxxrt/exception.cc Sat Mar 25 21:33:48 2017 (r315964) +++ stable/10/contrib/libcxxrt/exception.cc Sat Mar 25 21:46:02 2017 (r315965) @@ -304,13 +304,17 @@ static pthread_key_t eh_key; static void exception_cleanup(_Unwind_Reason_Code reason, struct _Unwind_Exception *ex) { - __cxa_free_exception(static_cast(ex)); + // Exception layout: + // [__cxa_exception [_Unwind_Exception]] [exception object] + // + // __cxa_free_exception expects a pointer to the exception object + __cxa_free_exception(static_cast(ex + 1)); } static void dependent_exception_cleanup(_Unwind_Reason_Code reason, struct _Unwind_Exception *ex) { - __cxa_free_dependent_exception(static_cast(ex)); + __cxa_free_dependent_exception(static_cast(ex + 1)); } /** @@ -340,7 +344,8 @@ static void thread_cleanup(void* thread_ if (info->foreign_exception_state != __cxa_thread_info::none) { _Unwind_Exception *e = reinterpret_cast<_Unwind_Exception*>(info->globals.caughtExceptions); - e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e); + if (e->exception_cleanup) + e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e); } else { @@ -567,6 +572,19 @@ static void free_exception(char *e) } } +#ifdef __LP64__ +/** + * There's an ABI bug in __cxa_exception: unwindHeader requires 16-byte + * alignment but it was broken by the addition of the referenceCount. + * The unwindHeader is at offset 0x58 in __cxa_exception. In order to keep + * compatibility with consumers of the broken __cxa_exception, explicitly add + * padding on allocation (and account for it on free). + */ +static const int exception_alignment_padding = 8; +#else +static const int exception_alignment_padding = 0; +#endif + /** * Allocates an exception structure. Returns a pointer to the space that can * be used to store an object of thrown_size bytes. This function will use an @@ -575,16 +593,19 @@ static void free_exception(char *e) */ extern "C" void *__cxa_allocate_exception(size_t thrown_size) { - size_t size = thrown_size + sizeof(__cxa_exception); + size_t size = exception_alignment_padding + sizeof(__cxa_exception) + + thrown_size; char *buffer = alloc_or_die(size); - return buffer+sizeof(__cxa_exception); + return buffer + exception_alignment_padding + sizeof(__cxa_exception); } extern "C" void *__cxa_allocate_dependent_exception(void) { - size_t size = sizeof(__cxa_dependent_exception); + size_t size = exception_alignment_padding + + sizeof(__cxa_dependent_exception); char *buffer = alloc_or_die(size); - return buffer+sizeof(__cxa_dependent_exception); + return buffer + exception_alignment_padding + + sizeof(__cxa_dependent_exception); } /** @@ -612,7 +633,8 @@ extern "C" void __cxa_free_exception(voi } } - free_exception(reinterpret_cast(ex)); + free_exception(reinterpret_cast(ex) - + exception_alignment_padding); } static void releaseException(__cxa_exception *exception) @@ -639,7 +661,8 @@ void __cxa_free_dependent_exception(void { releaseException(realExceptionFromException(reinterpret_cast<__cxa_exception*>(ex))); } - free_exception(reinterpret_cast(ex)); + free_exception(reinterpret_cast(ex) - + exception_alignment_padding); } /** @@ -1282,12 +1305,13 @@ extern "C" void __cxa_end_catch() if (ti->foreign_exception_state != __cxa_thread_info::none) { - globals->caughtExceptions = 0; if (ti->foreign_exception_state != __cxa_thread_info::rethrown) { _Unwind_Exception *e = reinterpret_cast<_Unwind_Exception*>(ti->globals.caughtExceptions); - e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e); + if (e->exception_cleanup) + e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e); } + globals->caughtExceptions = 0; ti->foreign_exception_state = __cxa_thread_info::none; return; } @@ -1474,6 +1498,15 @@ namespace std return info->globals.uncaughtExceptions != 0; } /** + * Returns the number of exceptions currently being thrown that have not + * been caught. This can occur inside a nested catch statement. + */ + int uncaught_exceptions() throw() + { + __cxa_thread_info *info = thread_info(); + return info->globals.uncaughtExceptions; + } + /** * Returns the current unexpected handler. */ unexpected_handler get_unexpected() throw() Modified: stable/10/contrib/libcxxrt/guard.cc ============================================================================== --- stable/10/contrib/libcxxrt/guard.cc Sat Mar 25 21:33:48 2017 (r315964) +++ stable/10/contrib/libcxxrt/guard.cc Sat Mar 25 21:46:02 2017 (r315965) @@ -101,7 +101,7 @@ typedef struct { uint32_t init_half; uint32_t lock_half; } guard_t; -_Static_assert(sizeof(guard_t) == sizeof(uint64_t), ""); +static_assert(sizeof(guard_t) == sizeof(uint64_t), ""); static const uint32_t LOCKED = 1; static const uint32_t INITIALISED = static_cast(1) << 24; # endif Modified: stable/10/contrib/libcxxrt/memory.cc ============================================================================== --- stable/10/contrib/libcxxrt/memory.cc Sat Mar 25 21:33:48 2017 (r315964) +++ stable/10/contrib/libcxxrt/memory.cc Sat Mar 25 21:46:02 2017 (r315965) @@ -71,8 +71,17 @@ namespace std } +#if __cplusplus < 201103L +#define NOEXCEPT throw() +#define BADALLOC throw(std::bad_alloc) +#else +#define NOEXCEPT noexcept +#define BADALLOC +#endif + + __attribute__((weak)) -void* operator new(size_t size) +void* operator new(size_t size) BADALLOC { if (0 == size) { @@ -97,7 +106,7 @@ void* operator new(size_t size) } __attribute__((weak)) -void* operator new(size_t size, const std::nothrow_t &) throw() +void* operator new(size_t size, const std::nothrow_t &) NOEXCEPT { try { return :: operator new(size); @@ -110,27 +119,21 @@ void* operator new(size_t size, const st __attribute__((weak)) -void operator delete(void * ptr) -#if __cplusplus < 201000L -throw() -#endif +void operator delete(void * ptr) NOEXCEPT { free(ptr); } __attribute__((weak)) -void * operator new[](size_t size) -#if __cplusplus < 201000L -throw(std::bad_alloc) -#endif +void * operator new[](size_t size) BADALLOC { return ::operator new(size); } __attribute__((weak)) -void * operator new[](size_t size, const std::nothrow_t &) throw() +void * operator new[](size_t size, const std::nothrow_t &) NOEXCEPT { try { return ::operator new[](size); @@ -143,10 +146,7 @@ void * operator new[](size_t size, const __attribute__((weak)) -void operator delete[](void * ptr) -#if __cplusplus < 201000L -throw() -#endif +void operator delete[](void * ptr) NOEXCEPT { ::operator delete(ptr); } Modified: stable/10/contrib/libcxxrt/unwind-arm.h ============================================================================== --- stable/10/contrib/libcxxrt/unwind-arm.h Sat Mar 25 21:33:48 2017 (r315964) +++ stable/10/contrib/libcxxrt/unwind-arm.h Sat Mar 25 21:46:02 2017 (r315965) @@ -28,7 +28,7 @@ { _URC_OK = 0, /* operation completed successfully */ _URC_FOREIGN_EXCEPTION_CAUGHT = 1, - _URC_END_OF_STACK = 5, + _URC_END_OF_STACK = 5, _URC_HANDLER_FOUND = 6, _URC_INSTALL_CONTEXT = 7, _URC_CONTINUE_UNWIND = 8, @@ -43,10 +43,12 @@ typedef uint32_t _Unwind_State; static const _Unwind_State _US_VIRTUAL_UNWIND_FRAME = 0; static const _Unwind_State _US_UNWIND_FRAME_STARTING = 1; static const _Unwind_State _US_UNWIND_FRAME_RESUME = 2; +static const _Unwind_State _US_ACTION_MASK = 3; #else // GCC fails at knowing what a constant expression is # define _US_VIRTUAL_UNWIND_FRAME 0 # define _US_UNWIND_FRAME_STARTING 1 -# define _US_UNWIND_FRAME_RESUME 2 +# define _US_UNWIND_FRAME_RESUME 2 +# define _US_ACTION_MASK 3 #endif typedef struct _Unwind_Context _Unwind_Context; Modified: stable/10/lib/libcxxrt/Makefile ============================================================================== --- stable/10/lib/libcxxrt/Makefile Sat Mar 25 21:33:48 2017 (r315964) +++ stable/10/lib/libcxxrt/Makefile Sat Mar 25 21:46:02 2017 (r315965) @@ -20,7 +20,10 @@ SRCS+= libelftc_dem_gnu3.c\ guard.cc WARNS= 0 -CFLAGS+= -I${SRCDIR} +CFLAGS+= -I${SRCDIR} -nostdinc++ +.if empty(CXXFLAGS:M-std=*) +CXXFLAGS+= -std=c++11 +.endif VERSION_MAP= ${.CURDIR}/Version.map .include Modified: stable/10/lib/libcxxrt/Version.map ============================================================================== --- stable/10/lib/libcxxrt/Version.map Sat Mar 25 21:33:48 2017 (r315964) +++ stable/10/lib/libcxxrt/Version.map Sat Mar 25 21:46:02 2017 (r315965) @@ -377,3 +377,9 @@ GLIBCXX_3.4.9 { }; } GLIBCXX_3.4; +GLIBCXX_3.4.22 { + extern "C++" { + "std::uncaught_exceptions()"; + }; +} GLIBCXX_3.4.9; +