From owner-svn-src-stable-11@freebsd.org Sun Oct 15 10:59:33 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0F998E4028C; Sun, 15 Oct 2017 10:59:33 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DB33772903; Sun, 15 Oct 2017 10:59:32 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9FAxW3C060993; Sun, 15 Oct 2017 10:59:32 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9FAxWqo060992; Sun, 15 Oct 2017 10:59:32 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201710151059.v9FAxWqo060992@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 15 Oct 2017 10:59:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324624 - stable/11/sys/dev/smbus X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/dev/smbus X-SVN-Commit-Revision: 324624 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Oct 2017 10:59:33 -0000 Author: kib Date: Sun Oct 15 10:59:31 2017 New Revision: 324624 URL: https://svnweb.freebsd.org/changeset/base/324624 Log: MFC r324156: Improve smb(4) devfs interactions. Modified: stable/11/sys/dev/smbus/smb.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/smbus/smb.c ============================================================================== --- stable/11/sys/dev/smbus/smb.c Sun Oct 15 08:03:14 2017 (r324623) +++ stable/11/sys/dev/smbus/smb.c Sun Oct 15 10:59:31 2017 (r324624) @@ -47,9 +47,7 @@ struct smb_softc { device_t sc_dev; - int sc_count; /* >0 if device opened */ struct cdev *sc_devnode; - struct mtx sc_lock; }; static void smb_identify(driver_t *driver, device_t parent); @@ -78,15 +76,11 @@ static driver_t smb_driver = { sizeof(struct smb_softc), }; -static d_open_t smbopen; -static d_close_t smbclose; static d_ioctl_t smbioctl; static struct cdevsw smb_cdevsw = { .d_version = D_VERSION, .d_flags = D_TRACKCLOSE, - .d_open = smbopen, - .d_close = smbclose, .d_ioctl = smbioctl, .d_name = "smb", }; @@ -112,59 +106,31 @@ smb_probe(device_t dev) static int smb_attach(device_t dev) { - struct smb_softc *sc = device_get_softc(dev); - int unit; - - unit = device_get_unit(dev); + struct smb_softc *sc; + struct make_dev_args mda; + int error; + + sc = device_get_softc(dev); sc->sc_dev = dev; - sc->sc_devnode = make_dev(&smb_cdevsw, unit, UID_ROOT, GID_WHEEL, - 0600, "smb%d", unit); - sc->sc_devnode->si_drv1 = sc; - mtx_init(&sc->sc_lock, device_get_nameunit(dev), NULL, MTX_DEF); - - return (0); + make_dev_args_init(&mda); + mda.mda_devsw = &smb_cdevsw; + mda.mda_unit = device_get_unit(dev); + mda.mda_uid = UID_ROOT; + mda.mda_gid = GID_WHEEL; + mda.mda_mode = 0600; + mda.mda_si_drv1 = sc; + error = make_dev_s(&mda, &sc->sc_devnode, "smb%d", mda.mda_unit); + return (error); } static int smb_detach(device_t dev) { - struct smb_softc *sc = (struct smb_softc *)device_get_softc(dev); + struct smb_softc *sc; - if (sc->sc_devnode) - destroy_dev(sc->sc_devnode); - mtx_destroy(&sc->sc_lock); - - return (0); -} - -static int -smbopen(struct cdev *dev, int flags, int fmt, struct thread *td) -{ - struct smb_softc *sc = dev->si_drv1; - - mtx_lock(&sc->sc_lock); - if (sc->sc_count != 0) { - mtx_unlock(&sc->sc_lock); - return (EBUSY); - } - - sc->sc_count++; - mtx_unlock(&sc->sc_lock); - - return (0); -} - -static int -smbclose(struct cdev *dev, int flags, int fmt, struct thread *td) -{ - struct smb_softc *sc = dev->si_drv1; - - mtx_lock(&sc->sc_lock); - KASSERT(sc->sc_count == 1, ("device not busy")); - sc->sc_count--; - mtx_unlock(&sc->sc_lock); - + sc = device_get_softc(dev); + destroy_dev(sc->sc_devnode); return (0); } From owner-svn-src-stable-11@freebsd.org Sun Oct 15 14:03:55 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8EF7FE43E3F; Sun, 15 Oct 2017 14:03:55 +0000 (UTC) (envelope-from fsu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 67F6777711; Sun, 15 Oct 2017 14:03:55 +0000 (UTC) (envelope-from fsu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9FE3sOJ040113; Sun, 15 Oct 2017 14:03:54 GMT (envelope-from fsu@FreeBSD.org) Received: (from fsu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9FE3san040109; Sun, 15 Oct 2017 14:03:54 GMT (envelope-from fsu@FreeBSD.org) Message-Id: <201710151403.v9FE3san040109@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: fsu set sender to fsu@FreeBSD.org using -f From: Fedor Uporov Date: Sun, 15 Oct 2017 14:03:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324627 - stable/11/sys/fs/ext2fs X-SVN-Group: stable-11 X-SVN-Commit-Author: fsu X-SVN-Commit-Paths: stable/11/sys/fs/ext2fs X-SVN-Commit-Revision: 324627 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Oct 2017 14:03:55 -0000 Author: fsu Date: Sun Oct 15 14:03:53 2017 New Revision: 324627 URL: https://svnweb.freebsd.org/changeset/base/324627 Log: MFC r324064: Add check to avoid raw inode iblocks fields overflow in case of huge_file feature. Use the Linux logic for now. Approved by: pfg (mentor) Differential Revision: https://reviews.freebsd.org/D12131 Modified: stable/11/sys/fs/ext2fs/ext2_alloc.c stable/11/sys/fs/ext2fs/ext2_extern.h stable/11/sys/fs/ext2fs/ext2_inode.c stable/11/sys/fs/ext2fs/ext2_inode_cnv.c Modified: stable/11/sys/fs/ext2fs/ext2_alloc.c ============================================================================== --- stable/11/sys/fs/ext2fs/ext2_alloc.c Sun Oct 15 11:46:11 2017 (r324626) +++ stable/11/sys/fs/ext2fs/ext2_alloc.c Sun Oct 15 14:03:53 2017 (r324627) @@ -56,7 +56,6 @@ static daddr_t ext2_alloccg(struct inode *, int, daddr_t, int); static daddr_t ext2_clusteralloc(struct inode *, int, daddr_t, int); static u_long ext2_dirpref(struct inode *); -static void ext2_fserr(struct m_ext2fs *, uid_t, char *); static u_long ext2_hashalloc(struct inode *, int, long, int, daddr_t (*)(struct inode *, int, daddr_t, int)); @@ -1303,7 +1302,7 @@ ext2_mapsearch(struct m_ext2fs *fs, char *bbp, daddr_t * The form of the error message is: * fs: error message */ -static void +void ext2_fserr(struct m_ext2fs *fs, uid_t uid, char *cp) { Modified: stable/11/sys/fs/ext2fs/ext2_extern.h ============================================================================== --- stable/11/sys/fs/ext2fs/ext2_extern.h Sun Oct 15 11:46:11 2017 (r324626) +++ stable/11/sys/fs/ext2fs/ext2_extern.h Sun Oct 15 14:03:53 2017 (r324627) @@ -62,9 +62,10 @@ int ext2_bmap(struct vop_bmap_args *); int ext2_bmaparray(struct vnode *, daddr_t, daddr_t *, int *, int *); void ext2_clusteracct(struct m_ext2fs *, char *, int, daddr_t, int); void ext2_dirbad(struct inode *ip, doff_t offset, char *how); +void ext2_fserr(struct m_ext2fs *, uid_t, char *); void ext2_ei2i(struct ext2fs_dinode *, struct inode *); int ext2_getlbns(struct vnode *, daddr_t, struct indir *, int *); -void ext2_i2ei(struct inode *, struct ext2fs_dinode *); +int ext2_i2ei(struct inode *, struct ext2fs_dinode *); void ext2_itimes(struct vnode *vp); int ext2_reallocblks(struct vop_reallocblks_args *); int ext2_reclaim(struct vop_reclaim_args *); Modified: stable/11/sys/fs/ext2fs/ext2_inode.c ============================================================================== --- stable/11/sys/fs/ext2fs/ext2_inode.c Sun Oct 15 11:46:11 2017 (r324626) +++ stable/11/sys/fs/ext2fs/ext2_inode.c Sun Oct 15 14:03:53 2017 (r324627) @@ -90,8 +90,12 @@ ext2_update(struct vnode *vp, int waitfor) brelse(bp); return (error); } - ext2_i2ei(ip, (struct ext2fs_dinode *)((char *)bp->b_data + + error = ext2_i2ei(ip, (struct ext2fs_dinode *)((char *)bp->b_data + EXT2_INODE_SIZE(fs) * ino_to_fsbo(fs, ip->i_number))); + if (error) { + brelse(bp); + return (error); + } if (waitfor && !DOINGASYNC(vp)) return (bwrite(bp)); else { Modified: stable/11/sys/fs/ext2fs/ext2_inode_cnv.c ============================================================================== --- stable/11/sys/fs/ext2fs/ext2_inode_cnv.c Sun Oct 15 11:46:11 2017 (r324626) +++ stable/11/sys/fs/ext2fs/ext2_inode_cnv.c Sun Oct 15 14:03:53 2017 (r324627) @@ -136,11 +136,13 @@ ext2_ei2i(struct ext2fs_dinode *ei, struct inode *ip) /* * inode to raw ext2 inode */ -void +int ext2_i2ei(struct inode *ip, struct ext2fs_dinode *ei) { + struct m_ext2fs *fs; int i; + fs = ip->i_e2fs; ei->e2di_mode = ip->i_mode; ei->e2di_nlink = ip->i_nlink; /* @@ -167,8 +169,19 @@ ext2_i2ei(struct inode *ip, struct ext2fs_dinode *ei) ei->e2di_flags |= (ip->i_flags & UF_NODUMP) ? EXT2_NODUMP : 0; ei->e2di_flags |= (ip->i_flag & IN_E3INDEX) ? EXT3_INDEX : 0; ei->e2di_flags |= (ip->i_flag & IN_E4EXTENTS) ? EXT4_EXTENTS : 0; - ei->e2di_nblock = ip->i_blocks & 0xffffffff; - ei->e2di_nblock_high = ip->i_blocks >> 32 & 0xffff; + if (ip->i_blocks > ~0U && + !EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_HUGE_FILE)) { + ext2_fserr(fs, ip->i_uid, "i_blocks value is out of range"); + return (EIO); + } + if (ip->i_blocks <= 0xffffffffffffULL) { + ei->e2di_nblock = ip->i_blocks & 0xffffffff; + ei->e2di_nblock_high = ip->i_blocks >> 32 & 0xffff; + } else { + ei->e2di_flags |= EXT4_HUGE_FILE; + ei->e2di_nblock = dbtofsb(fs, ip->i_blocks); + ei->e2di_nblock_high = dbtofsb(fs, ip->i_blocks) >> 32 & 0xffff; + } ei->e2di_facl = ip->i_facl & 0xffffffff; ei->e2di_facl_high = ip->i_facl >> 32 & 0xffff; ei->e2di_gen = ip->i_gen; @@ -181,4 +194,6 @@ ext2_i2ei(struct inode *ip, struct ext2fs_dinode *ei) ei->e2di_blocks[i] = ip->i_db[i]; for (i = 0; i < NIADDR; i++) ei->e2di_blocks[EXT2_NDIR_BLOCKS + i] = ip->i_ib[i]; + + return (0); } From owner-svn-src-stable-11@freebsd.org Sun Oct 15 22:34:13 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6FAE8E4C803; Sun, 15 Oct 2017 22:34:13 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3C31F636EF; Sun, 15 Oct 2017 22:34:13 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9FMYCoC055511; Sun, 15 Oct 2017 22:34:12 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9FMYCwR055510; Sun, 15 Oct 2017 22:34:12 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201710152234.v9FMYCwR055510@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Sun, 15 Oct 2017 22:34:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324640 - stable/11/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: stable/11/sys/kern X-SVN-Commit-Revision: 324640 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Oct 2017 22:34:13 -0000 Author: brooks Date: Sun Oct 15 22:34:12 2017 New Revision: 324640 URL: https://svnweb.freebsd.org/changeset/base/324640 Log: MFC r320999: Add 32-bit compat for kinfo_proc's ki_tdaddr. This appears to have been an oversight in r213536. Reviewed by: markj Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D11521 Modified: stable/11/sys/kern/kern_proc.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/kern_proc.c ============================================================================== --- stable/11/sys/kern/kern_proc.c Sun Oct 15 22:22:27 2017 (r324639) +++ stable/11/sys/kern/kern_proc.c Sun Oct 15 22:34:12 2017 (r324640) @@ -1311,6 +1311,7 @@ freebsd32_kinfo_proc_out(const struct kinfo_proc *ki, PTRTRIM_CP(*ki, *ki32, ki_pcb); PTRTRIM_CP(*ki, *ki32, ki_kstack); PTRTRIM_CP(*ki, *ki32, ki_udata); + PTRTRIM_CP(*ki, *ki32, ki_tdaddr); CP(*ki, *ki32, ki_sflag); CP(*ki, *ki32, ki_tdflags); } From owner-svn-src-stable-11@freebsd.org Sun Oct 15 22:43:57 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E2BF6E4CBAB; Sun, 15 Oct 2017 22:43:57 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B02DC63D49; Sun, 15 Oct 2017 22:43:57 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9FMhu5b059616; Sun, 15 Oct 2017 22:43:56 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9FMhu0F059614; Sun, 15 Oct 2017 22:43:56 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201710152243.v9FMhu0F059614@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Sun, 15 Oct 2017 22:43:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324642 - stable/11/sys/conf X-SVN-Group: stable-11 X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: stable/11/sys/conf X-SVN-Commit-Revision: 324642 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Oct 2017 22:43:58 -0000 Author: brooks Date: Sun Oct 15 22:43:56 2017 New Revision: 324642 URL: https://svnweb.freebsd.org/changeset/base/324642 Log: MFC r321256: Include ARCH_FLAGS in CFLAGS when building modules. Without this change, modules will match the default compiler configuration which may not be the same as the kernel values. Reviewed by: imp Obtained from: CheriBSD Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D11633 Modified: stable/11/sys/conf/kern.pre.mk stable/11/sys/conf/kmod.mk Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/conf/kern.pre.mk ============================================================================== --- stable/11/sys/conf/kern.pre.mk Sun Oct 15 22:39:31 2017 (r324641) +++ stable/11/sys/conf/kern.pre.mk Sun Oct 15 22:43:56 2017 (r324642) @@ -203,6 +203,7 @@ MKMODULESENV+= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMO MKMODULESENV+= MACHINE_CPUARCH=${MACHINE_CPUARCH} MKMODULESENV+= MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE_ARCH} MKMODULESENV+= MODULES_EXTRA="${MODULES_EXTRA}" WITHOUT_MODULES="${WITHOUT_MODULES}" +MKMODULESENV+= ARCH_FLAGS="${ARCH_FLAGS}" .if (${KERN_IDENT} == LINT) MKMODULESENV+= ALL_MODULES=LINT .endif Modified: stable/11/sys/conf/kmod.mk ============================================================================== --- stable/11/sys/conf/kmod.mk Sun Oct 15 22:39:31 2017 (r324641) +++ stable/11/sys/conf/kmod.mk Sun Oct 15 22:43:56 2017 (r324642) @@ -357,7 +357,7 @@ ${_src}: .endif # Respect configuration-specific C flags. -CFLAGS+= ${CONF_CFLAGS} +CFLAGS+= ${ARCH_FLAGS} ${CONF_CFLAGS} .if !empty(SRCS:Mvnode_if.c) CLEANFILES+= vnode_if.c From owner-svn-src-stable-11@freebsd.org Mon Oct 16 21:53:31 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 05516E46428; Mon, 16 Oct 2017 21:53:31 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C69DE6ECEC; Mon, 16 Oct 2017 21:53:30 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9GLrTVJ041017; Mon, 16 Oct 2017 21:53:29 GMT (envelope-from mckusick@FreeBSD.org) Received: (from mckusick@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9GLrTbc041016; Mon, 16 Oct 2017 21:53:29 GMT (envelope-from mckusick@FreeBSD.org) Message-Id: <201710162153.v9GLrTbc041016@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mckusick set sender to mckusick@FreeBSD.org using -f From: Kirk McKusick Date: Mon, 16 Oct 2017 21:53:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324674 - stable/11/sbin/fsck_ffs X-SVN-Group: stable-11 X-SVN-Commit-Author: mckusick X-SVN-Commit-Paths: stable/11/sbin/fsck_ffs X-SVN-Commit-Revision: 324674 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Oct 2017 21:53:31 -0000 Author: mckusick Date: Mon Oct 16 21:53:29 2017 New Revision: 324674 URL: https://svnweb.freebsd.org/changeset/base/324674 Log: MFC of 324456. Do not report filesystem as modified if only timestamp updated in superblock. Modified: stable/11/sbin/fsck_ffs/main.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/fsck_ffs/main.c ============================================================================== --- stable/11/sbin/fsck_ffs/main.c Mon Oct 16 21:46:11 2017 (r324673) +++ stable/11/sbin/fsck_ffs/main.c Mon Oct 16 21:53:29 2017 (r324674) @@ -231,6 +231,7 @@ checkfilesys(char *filesys) struct group *grp; struct iovec *iov; char errmsg[255]; + int ofsmodified; int iovlen; int cylno; intmax_t blks, files; @@ -425,10 +426,15 @@ checkfilesys(char *filesys) } /* * Write the superblock so we don't try to recover the - * journal on another pass. + * journal on another pass. If this is the only change + * to the filesystem, we do not want it to be called + * out as modified. */ sblock.fs_mtime = time(NULL); sbdirty(); + ofsmodified = fsmodified; + flush(fswritefd, &sblk); + fsmodified = ofsmodified; } /* From owner-svn-src-stable-11@freebsd.org Tue Oct 17 00:25:45 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B23EAE498CF; Tue, 17 Oct 2017 00:25:45 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 748037399C; Tue, 17 Oct 2017 00:25:45 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9H0Pi43025914; Tue, 17 Oct 2017 00:25:44 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9H0Pixl025913; Tue, 17 Oct 2017 00:25:44 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201710170025.v9H0Pixl025913@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Tue, 17 Oct 2017 00:25:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324679 - stable/11/share/man/man9 X-SVN-Group: stable-11 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/11/share/man/man9 X-SVN-Commit-Revision: 324679 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Oct 2017 00:25:45 -0000 Author: emaste Date: Tue Oct 17 00:25:44 2017 New Revision: 324679 URL: https://svnweb.freebsd.org/changeset/base/324679 Log: MFC r324509: sysctl.9: document CTLFLAG_CAPRD and CTLFLAG_CAPWR Reported by: Shawn Webb Sponsored by: The FreeBSD Foundation Modified: stable/11/share/man/man9/sysctl.9 Directory Properties: stable/11/ (props changed) Modified: stable/11/share/man/man9/sysctl.9 ============================================================================== --- stable/11/share/man/man9/sysctl.9 Mon Oct 16 23:43:18 2017 (r324678) +++ stable/11/share/man/man9/sysctl.9 Tue Oct 17 00:25:44 2017 (r324679) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 23, 2015 +.Dd October 16, 2017 .Dt SYSCTL 9 .Os .Sh NAME @@ -637,6 +637,10 @@ Additionally, any of the following optional flags may .Bl -tag -width ".Dv CTLFLAG_ANYBODY" .It Dv CTLFLAG_ANYBODY Any user or process can write to this sysctl. +.It Dv CTLFLAG_CAPRD +A process in capability mode can read from this sysctl. +.It Dv CTLFLAG_CAPWR +A process in capability mode can write to this sysctl. .It Dv CTLFLAG_SECURE This sysctl can be written to only if the effective securelevel of the process is \[<=] 0. From owner-svn-src-stable-11@freebsd.org Tue Oct 17 12:42:18 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D0288E3976D; Tue, 17 Oct 2017 12:42:18 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9D9306B44D; Tue, 17 Oct 2017 12:42:18 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9HCgHRc030708; Tue, 17 Oct 2017 12:42:17 GMT (envelope-from tuexen@FreeBSD.org) Received: (from tuexen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9HCgHG4030707; Tue, 17 Oct 2017 12:42:17 GMT (envelope-from tuexen@FreeBSD.org) Message-Id: <201710171242.v9HCgHG4030707@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tuexen set sender to tuexen@FreeBSD.org using -f From: Michael Tuexen Date: Tue, 17 Oct 2017 12:42:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324686 - stable/11/sys/netinet X-SVN-Group: stable-11 X-SVN-Commit-Author: tuexen X-SVN-Commit-Paths: stable/11/sys/netinet X-SVN-Commit-Revision: 324686 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Oct 2017 12:42:18 -0000 Author: tuexen Date: Tue Oct 17 12:42:17 2017 New Revision: 324686 URL: https://svnweb.freebsd.org/changeset/base/324686 Log: MFC r322648: Ensure inp_vflag is consistently set for TCP endpoints. Make sure that the flags INP_IPV4 and INP_IPV6 are consistently set for inpcbs used for TCP sockets, no matter if the setting is derived from the net.inet6.ip6.v6only sysctl or the IPV6_V6ONLY socket option. For UDP this was already done right. PR: 221385 Modified: stable/11/sys/netinet/tcp_usrreq.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netinet/tcp_usrreq.c ============================================================================== --- stable/11/sys/netinet/tcp_usrreq.c Tue Oct 17 11:20:32 2017 (r324685) +++ stable/11/sys/netinet/tcp_usrreq.c Tue Oct 17 12:42:17 2017 (r324686) @@ -1899,6 +1899,8 @@ tcp_attach(struct socket *so) #ifdef INET6 if (inp->inp_vflag & INP_IPV6PROTO) { inp->inp_vflag |= INP_IPV6; + if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0) + inp->inp_vflag |= INP_IPV4; inp->in6p_hops = -1; /* use kernel default */ } else From owner-svn-src-stable-11@freebsd.org Tue Oct 17 12:45:53 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AE2ACE39853; Tue, 17 Oct 2017 12:45:53 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 882706B680; Tue, 17 Oct 2017 12:45:53 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9HCjqon031673; Tue, 17 Oct 2017 12:45:52 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9HCjp7p031663; Tue, 17 Oct 2017 12:45:51 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201710171245.v9HCjp7p031663@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Tue, 17 Oct 2017 12:45:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324687 - in stable/11/sys: arm/include arm64/include kern mips/include powerpc/include riscv/include sparc64/include sys x86/include X-SVN-Group: stable-11 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable/11/sys: arm/include arm64/include kern mips/include powerpc/include riscv/include sparc64/include sys x86/include X-SVN-Commit-Revision: 324687 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Oct 2017 12:45:53 -0000 Author: jhb Date: Tue Oct 17 12:45:51 2017 New Revision: 324687 URL: https://svnweb.freebsd.org/changeset/base/324687 Log: MFC 323579,323585: Add AT_HWCAP and AT_EHDRFLAGS on all platforms. To preserve KBI on stable/11, a new SV_HWCAP flag is added which indicates if the sv_hwcap field is present and valid to avoid examining the field in old modules. Only sysentvec's which wish to use sv_hwcap need to set the flag in stable/11. 323579: Add AT_HWCAP and AT_EHDRFLAGS on all platforms. A new 'u_long *sv_hwcap' field is added to 'struct sysentvec'. A process ABI can set this field to point to a value holding a mask of architecture-specific CPU feature flags. If an ABI does not wish to supply AT_HWCAP to processes the field can be left as NULL. The support code for AT_EHDRFLAGS was already present on all systems, just the #define was not present. This is a step towards unifying the AT_* constants across platforms. 323585: Add AT_EHDRFLAGS and AT_HWCAP on amd64. x86 has two separate (but identical) list of AT_* constants and the earlier commit to add AT_HWCAP only updated the i386 list. Modified: stable/11/sys/arm/include/elf.h stable/11/sys/arm64/include/elf.h stable/11/sys/kern/imgact_elf.c stable/11/sys/mips/include/elf.h stable/11/sys/powerpc/include/elf.h stable/11/sys/riscv/include/elf.h stable/11/sys/sparc64/include/elf.h stable/11/sys/sys/sysent.h stable/11/sys/x86/include/elf.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm/include/elf.h ============================================================================== --- stable/11/sys/arm/include/elf.h Tue Oct 17 12:42:17 2017 (r324686) +++ stable/11/sys/arm/include/elf.h Tue Oct 17 12:45:51 2017 (r324687) @@ -85,8 +85,9 @@ __ElfType(Auxinfo); #define AT_TIMEKEEP 22 /* Pointer to timehands. */ #define AT_STACKPROT 23 /* Initial stack protection. */ #define AT_EHDRFLAGS 24 /* e_flags field from elf hdr */ +#define AT_HWCAP 25 /* CPU feature flags. */ -#define AT_COUNT 25 /* Count of defined aux entry types. */ +#define AT_COUNT 26 /* Count of defined aux entry types. */ #define R_ARM_COUNT 33 /* Count of defined relocation types. */ Modified: stable/11/sys/arm64/include/elf.h ============================================================================== --- stable/11/sys/arm64/include/elf.h Tue Oct 17 12:42:17 2017 (r324686) +++ stable/11/sys/arm64/include/elf.h Tue Oct 17 12:45:51 2017 (r324687) @@ -90,8 +90,10 @@ __ElfType(Auxinfo); #define AT_PAGESIZESLEN 21 /* Number of pagesizes. */ #define AT_TIMEKEEP 22 /* Pointer to timehands. */ #define AT_STACKPROT 23 /* Initial stack protection. */ +#define AT_EHDRFLAGS 24 /* e_flags field from elf hdr */ +#define AT_HWCAP 25 /* CPU feature flags. */ -#define AT_COUNT 24 /* Count of defined aux entry types. */ +#define AT_COUNT 26 /* Count of defined aux entry types. */ /* Define "machine" characteristics */ #define ELF_TARG_CLASS ELFCLASS64 Modified: stable/11/sys/kern/imgact_elf.c ============================================================================== --- stable/11/sys/kern/imgact_elf.c Tue Oct 17 12:42:17 2017 (r324686) +++ stable/11/sys/kern/imgact_elf.c Tue Oct 17 12:45:51 2017 (r324687) @@ -1110,9 +1110,7 @@ __elfN(freebsd_fixup)(register_t **stack_base, struct AUXARGS_ENTRY(pos, AT_FLAGS, args->flags); AUXARGS_ENTRY(pos, AT_ENTRY, args->entry); AUXARGS_ENTRY(pos, AT_BASE, args->base); -#ifdef AT_EHDRFLAGS AUXARGS_ENTRY(pos, AT_EHDRFLAGS, args->hdr_eflags); -#endif if (imgp->execpathp != 0) AUXARGS_ENTRY(pos, AT_EXECPATH, imgp->execpathp); AUXARGS_ENTRY(pos, AT_OSRELDATE, @@ -1133,6 +1131,9 @@ __elfN(freebsd_fixup)(register_t **stack_base, struct AUXARGS_ENTRY(pos, AT_STACKPROT, imgp->sysent->sv_shared_page_obj != NULL && imgp->stack_prot != 0 ? imgp->stack_prot : imgp->sysent->sv_stackprot); + if ((imgp->sysent->sv_flags & SV_HWCAP) != 0 && + imgp->sysent->sv_hwcap != NULL) + AUXARGS_ENTRY(pos, AT_HWCAP, *imgp->sysent->sv_hwcap); AUXARGS_ENTRY(pos, AT_NULL, 0); free(imgp->auxargs, M_TEMP); Modified: stable/11/sys/mips/include/elf.h ============================================================================== --- stable/11/sys/mips/include/elf.h Tue Oct 17 12:42:17 2017 (r324686) +++ stable/11/sys/mips/include/elf.h Tue Oct 17 12:45:51 2017 (r324687) @@ -144,8 +144,10 @@ __ElfType(Auxinfo); #define AT_PAGESIZESLEN 21 /* Number of pagesizes. */ #define AT_TIMEKEEP 22 /* Pointer to timehands. */ #define AT_STACKPROT 23 /* Initial stack protection. */ +#define AT_EHDRFLAGS 24 /* e_flags field from elf hdr */ +#define AT_HWCAP 25 /* CPU feature flags. */ -#define AT_COUNT 24 /* Count of defined aux entry types. */ +#define AT_COUNT 26 /* Count of defined aux entry types. */ #define ET_DYN_LOAD_ADDR 0x0120000 Modified: stable/11/sys/powerpc/include/elf.h ============================================================================== --- stable/11/sys/powerpc/include/elf.h Tue Oct 17 12:42:17 2017 (r324686) +++ stable/11/sys/powerpc/include/elf.h Tue Oct 17 12:45:51 2017 (r324687) @@ -107,8 +107,10 @@ __ElfType(Auxinfo); #define AT_PAGESIZESLEN 19 /* Number of pagesizes. */ #define AT_STACKPROT 21 /* Initial stack protection. */ #define AT_TIMEKEEP 22 /* Pointer to timehands. */ +#define AT_EHDRFLAGS 24 /* e_flags field from elf hdr */ +#define AT_HWCAP 25 /* CPU feature flags. */ -#define AT_COUNT 23 /* Count of defined aux entry types. */ +#define AT_COUNT 26 /* Count of defined aux entry types. */ /* * Relocation types. Modified: stable/11/sys/riscv/include/elf.h ============================================================================== --- stable/11/sys/riscv/include/elf.h Tue Oct 17 12:42:17 2017 (r324686) +++ stable/11/sys/riscv/include/elf.h Tue Oct 17 12:45:51 2017 (r324687) @@ -90,8 +90,10 @@ __ElfType(Auxinfo); #define AT_PAGESIZESLEN 21 /* Number of pagesizes. */ #define AT_TIMEKEEP 22 /* Pointer to timehands. */ #define AT_STACKPROT 23 /* Initial stack protection. */ +#define AT_EHDRFLAGS 24 /* e_flags field from elf hdr */ +#define AT_HWCAP 25 /* CPU feature flags. */ -#define AT_COUNT 24 /* Count of defined aux entry types. */ +#define AT_COUNT 26 /* Count of defined aux entry types. */ /* Define "machine" characteristics */ #define ELF_TARG_CLASS ELFCLASS64 Modified: stable/11/sys/sparc64/include/elf.h ============================================================================== --- stable/11/sys/sparc64/include/elf.h Tue Oct 17 12:42:17 2017 (r324686) +++ stable/11/sys/sparc64/include/elf.h Tue Oct 17 12:45:51 2017 (r324687) @@ -92,8 +92,10 @@ __ElfType(Auxinfo); #define AT_PAGESIZESLEN 21 /* Number of pagesizes. */ #define AT_TIMEKEEP 22 /* Pointer to timehands. */ #define AT_STACKPROT 23 /* Initial stack protection. */ +#define AT_EHDRFLAGS 24 /* e_flags field from elf hdr */ +#define AT_HWCAP 25 /* CPU feature flags. */ -#define AT_COUNT 24 /* Count of defined aux entry types. */ +#define AT_COUNT 26 /* Count of defined aux entry types. */ /* Define "machine" characteristics */ #if __ELF_WORD_SIZE == 32 Modified: stable/11/sys/sys/sysent.h ============================================================================== --- stable/11/sys/sys/sysent.h Tue Oct 17 12:42:17 2017 (r324686) +++ stable/11/sys/sys/sysent.h Tue Oct 17 12:45:51 2017 (r324687) @@ -129,6 +129,7 @@ struct sysentvec { void (*sv_schedtail)(struct thread *); void (*sv_thread_detach)(struct thread *); int (*sv_trap)(struct thread *); + u_long *sv_hwcap; /* Value passed in AT_HWCAP. */ }; #define SV_ILP32 0x000100 /* 32-bit executable. */ @@ -138,6 +139,7 @@ struct sysentvec { #define SV_SHP 0x010000 /* Shared page. */ #define SV_CAPSICUM 0x020000 /* Force cap_enter() on startup. */ #define SV_TIMEKEEP 0x040000 /* Shared page timehands. */ +#define SV_HWCAP 0x080000 /* sv_hwcap field is valid. */ #define SV_ABI_MASK 0xff #define SV_ABI_ERRNO(p, e) ((p)->p_sysent->sv_errsize <= 0 ? e : \ Modified: stable/11/sys/x86/include/elf.h ============================================================================== --- stable/11/sys/x86/include/elf.h Tue Oct 17 12:42:17 2017 (r324686) +++ stable/11/sys/x86/include/elf.h Tue Oct 17 12:45:51 2017 (r324687) @@ -100,8 +100,10 @@ __ElfType(Auxinfo); #define AT_PAGESIZESLEN 21 /* Number of pagesizes. */ #define AT_TIMEKEEP 22 /* Pointer to timehands. */ #define AT_STACKPROT 23 /* Initial stack protection. */ +#define AT_EHDRFLAGS 24 /* e_flags field from elf hdr */ +#define AT_HWCAP 25 /* CPU feature flags. */ -#define AT_COUNT 24 /* Count of defined aux entry types. */ +#define AT_COUNT 26 /* Count of defined aux entry types. */ /* * Relocation types. @@ -185,8 +187,10 @@ __ElfType(Auxinfo); #define AT_PAGESIZESLEN 21 /* Number of pagesizes. */ #define AT_TIMEKEEP 22 /* Pointer to timehands. */ #define AT_STACKPROT 23 /* Initial stack protection. */ +#define AT_EHDRFLAGS 24 /* e_flags field from elf hdr */ +#define AT_HWCAP 25 /* CPU feature flags. */ -#define AT_COUNT 24 /* Count of defined aux entry types. */ +#define AT_COUNT 26 /* Count of defined aux entry types. */ /* * Relocation types. From owner-svn-src-stable-11@freebsd.org Tue Oct 17 15:52:07 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 662E2E3DF79; Tue, 17 Oct 2017 15:52:07 +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 CD25D71CB0; Tue, 17 Oct 2017 15:52:03 +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 v9HFq2WR010246; Tue, 17 Oct 2017 15:52:02 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9HFq2ET010244; Tue, 17 Oct 2017 15:52:02 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201710171552.v9HFq2ET010244@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Tue, 17 Oct 2017 15:52:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324691 - in stable/11: sbin/growfs/tests tests/sys/geom/class/eli X-SVN-Group: stable-11 X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: in stable/11: sbin/growfs/tests tests/sys/geom/class/eli X-SVN-Commit-Revision: 324691 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Oct 2017 15:52:07 -0000 Author: ngie Date: Tue Oct 17 15:52:02 2017 New Revision: 324691 URL: https://svnweb.freebsd.org/changeset/base/324691 Log: MFC r324478: Check the exit code from fsck_ffs instead of relying on MODIFIED being in the output ^/head@r323923 changed when MODIFIED is printed at exit. It's better to follow the documented way of determining whether or not a filesystem is clean per fsck_ffs, i.e., ensure that the exit code is either 0 or 7. The pass/fail determination is brittle prior to this commit, and ^/head@r323923 made the issue apparent -- thus this needs to be fixed independent of ^/head@r323923. PR: 222780 MFC with: r323923 Modified: stable/11/sbin/growfs/tests/legacy_test.pl stable/11/tests/sys/geom/class/eli/resize_test.sh Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/growfs/tests/legacy_test.pl ============================================================================== --- stable/11/sbin/growfs/tests/legacy_test.pl Tue Oct 17 15:49:36 2017 (r324690) +++ stable/11/sbin/growfs/tests/legacy_test.pl Tue Oct 17 15:52:02 2017 (r324691) @@ -2,6 +2,7 @@ use strict; use warnings; +use POSIX; use Test::More tests => 19; use Fcntl qw(:DEFAULT :seek); @@ -11,6 +12,22 @@ use constant BLKS_PER_MB => 2048; my $unit; END { system "mdconfig -du$unit" if defined $unit }; +sub fsck_md { + my ($is_clean, $md); + + $md = shift; + + chomp(my @fsck_output = `fsck_ffs -Ffy ${md}a`); + $is_clean = WIFEXITED($?) && + (WEXITSTATUS($?) == 0 || WEXITSTATUS($?) == 7); + ok($is_clean, "checking ${md}a's filesystem"); + if ($is_clean) { + diag "filesystem reported clean"; + } else { + diag "filesystem not reported clean: " . join("\n", @fsck_output); + } +} + sub setsize { my ($partszMB, $unitszMB) = @_; @@ -46,9 +63,8 @@ SKIP: { ok(setsize(10, 40), "Sized ${md}a to 10m"); system "newfs -O $type -U ${md}a >/dev/null"; is($?, 0, "Initialised the filesystem on ${md}a as UFS$type"); - chomp(my @out = `fsck -tufs -y ${md}a`); - ok(!grep(/MODIFIED/, @out), "fsck says ${md}a is clean, " . - scalar(@out) . " lines of output"); + + fsck_md($md); } extend20_zeroed: { @@ -62,9 +78,7 @@ SKIP: { fill(30 * BLKS_PER_MB - $unallocated, $unallocated, chr(0)) if $unallocated; - chomp(my @out = `fsck -tufs -y ${md}a`); - ok(!grep(/MODIFIED/, @out), "fsck says ${md}a is clean, " . - scalar(@out) . " lines of output"); + fsck_md($md); } extend30_garbaged: { @@ -78,9 +92,7 @@ SKIP: { fill(30 * BLKS_PER_MB - $unallocated, $unallocated, chr(0)) if $unallocated; - chomp(my @out = `fsck -tufs -y ${md}a`); - ok(!grep(/MODIFIED/, @out), "fsck says ${md}a is clean, " . - scalar(@out) . " lines of output"); + fsck_md($md); } } Modified: stable/11/tests/sys/geom/class/eli/resize_test.sh ============================================================================== --- stable/11/tests/sys/geom/class/eli/resize_test.sh Tue Oct 17 15:49:36 2017 (r324690) +++ stable/11/tests/sys/geom/class/eli/resize_test.sh Tue Oct 17 15:52:02 2017 (r324691) @@ -12,6 +12,19 @@ md=$(mdconfig -s40m) || exit 1 unit=${md#md} i=1 +fsck_md() +{ + local is_clean + + out=$(fsck_ffs -Ffy ${md}a.eli) + if [ $? -eq 0 -o $? -eq 7 ]; then + echo "ok $i - fsck says ${md}a.eli is clean" + else + echo "not ok $i - fsck says ${md}a.eli is dirty" + fi + i=$((i + 1)) +} + setsize() { partszMB=$1 unitszMB=$2 @@ -38,13 +51,8 @@ i=$((i + 1)) newfs -U ${md}a.eli >/dev/null || echo -n "not " echo ok $i - "Initialised the filesystem on ${md}a.eli" i=$((i + 1)) -out=$(fsck -tufs -y ${md}a.eli) -echo "$out" | fgrep -q MODIFIED && echo -n "not " -echo ok $i - "fsck says ${md}a.eli is clean," $(echo $(echo "$out" | wc -l)) \ - "lines of output" -i=$((i + 1)) +fsck_md - # Doing a backup, resize & restore must be forced (with -f) as geli # verifies that the provider size in the metadata matches the consumer. @@ -78,13 +86,8 @@ growfs -y ${md}a.eli >/dev/null || echo -n "not " echo ok $i - "Extended the filesystem on ${md}a.eli" i=$((i + 1)) -out=$(fsck -tufs -y ${md}a.eli) -echo "$out" | fgrep -q MODIFIED && echo -n "not " -echo ok $i - "fsck says ${md}a.eli is clean," $(echo $(echo "$out" | wc -l)) \ - "lines of output" -i=$((i + 1)) +fsck_md - # Now do the resize properly geli detach ${md}a.eli || echo -n "not " @@ -110,11 +113,7 @@ growfs -y ${md}a.eli >/dev/null || echo -n "not " echo ok $i - "Extended the filesystem on ${md}a.eli" i=$((i + 1)) -out=$(fsck -tufs -y ${md}a.eli) -echo "$out" | fgrep -q MODIFIED && echo -n "not " -echo ok $i - "fsck says ${md}a.eli is clean," $(echo $(echo "$out" | wc -l)) \ - "lines of output" -i=$((i + 1)) +fsck_md geli detach ${md}a.eli gpart destroy -F $md >/dev/null From owner-svn-src-stable-11@freebsd.org Tue Oct 17 15:53:24 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4D3BAE3E1C5; Tue, 17 Oct 2017 15:53: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 2561A720B1; Tue, 17 Oct 2017 15:53: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 v9HFrMCg010431; Tue, 17 Oct 2017 15:53:22 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9HFrM2l010430; Tue, 17 Oct 2017 15:53:22 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201710171553.v9HFrM2l010430@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Tue, 17 Oct 2017 15:53:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324693 - stable/11/usr.bin/su X-SVN-Group: stable-11 X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: stable/11/usr.bin/su X-SVN-Commit-Revision: 324693 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Oct 2017 15:53:24 -0000 Author: ngie Date: Tue Oct 17 15:53:22 2017 New Revision: 324693 URL: https://svnweb.freebsd.org/changeset/base/324693 Log: MFC r324497: Mute gcc warning about p not being possibly initialized I'm running into this warning on a tinderbox run with gcc 4.2.1 with mips and powerpc. Modified: stable/11/usr.bin/su/su.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/su/su.c ============================================================================== --- stable/11/usr.bin/su/su.c Tue Oct 17 15:53:19 2017 (r324692) +++ stable/11/usr.bin/su/su.c Tue Oct 17 15:53:22 2017 (r324693) @@ -172,7 +172,7 @@ main(int argc, char *argv[]) au_id_t auid; #endif - shell = class = cleanenv = NULL; + p = shell = class = cleanenv = NULL; asme = asthem = fastlogin = statusp = 0; user = "root"; iscsh = UNSET; From owner-svn-src-stable-11@freebsd.org Tue Oct 17 17:30:21 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7C8F5E40EDD; Tue, 17 Oct 2017 17:30:21 +0000 (UTC) (envelope-from gordon@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1C1D27638F; Tue, 17 Oct 2017 17:30:21 +0000 (UTC) (envelope-from gordon@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9HHUK1C048341; Tue, 17 Oct 2017 17:30:20 GMT (envelope-from gordon@FreeBSD.org) Received: (from gordon@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9HHUJk2048328; Tue, 17 Oct 2017 17:30:19 GMT (envelope-from gordon@FreeBSD.org) Message-Id: <201710171730.v9HHUJk2048328@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gordon set sender to gordon@FreeBSD.org using -f From: Gordon Tetlow Date: Tue, 17 Oct 2017 17:30:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324697 - in stable/11/contrib/wpa: src/ap src/common src/rsn_supp wpa_supplicant X-SVN-Group: stable-11 X-SVN-Commit-Author: gordon X-SVN-Commit-Paths: in stable/11/contrib/wpa: src/ap src/common src/rsn_supp wpa_supplicant X-SVN-Commit-Revision: 324697 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Oct 2017 17:30:21 -0000 Author: gordon Date: Tue Oct 17 17:30:18 2017 New Revision: 324697 URL: https://svnweb.freebsd.org/changeset/base/324697 Log: MFC r324696: Update wpa_supplicant/hostapd for 2017-01 vulnerability release. hostapd: Avoid key reinstallation in FT handshake Prevent reinstallation of an already in-use group key Extend protection of GTK/IGTK reinstallation of WNM-Sleep Mode cases Fix TK configuration to the driver in EAPOL-Key 3/4 retry case Prevent installation of an all-zero TK Fix PTK rekeying to generate a new ANonce TDLS: Reject TPK-TK reconfiguration WNM: Ignore Key Data in WNM Sleep Mode Response frame if no PMF in use WNM: Ignore WNM-Sleep Mode Response if WNM-Sleep Mode has not been used WNM: Ignore WNM-Sleep Mode Response without pending request FT: Do not allow multiple Reassociation Response frames TDLS: Ignore incoming TDLS Setup Response retries Submitted by: jhb Obtained from: https://w1.fi/security/2017-01/ (against later version) Security: FreeBSD-SA-17:07 Security: CERT VU#228519 Security: CVE-2017-13077 Security: CVE-2017-13078 Security: CVE-2017-13079 Security: CVE-2017-13080 Security: CVE-2017-13081 Security: CVE-2017-13082 Security: CVE-2017-13086 Security: CVE-2017-13087 Security: CVE-2017-13088 Modified: stable/11/contrib/wpa/src/ap/wpa_auth.c stable/11/contrib/wpa/src/ap/wpa_auth.h stable/11/contrib/wpa/src/ap/wpa_auth_ft.c stable/11/contrib/wpa/src/ap/wpa_auth_i.h stable/11/contrib/wpa/src/common/wpa_common.h stable/11/contrib/wpa/src/rsn_supp/tdls.c stable/11/contrib/wpa/src/rsn_supp/wpa.c stable/11/contrib/wpa/src/rsn_supp/wpa_ft.c stable/11/contrib/wpa/src/rsn_supp/wpa_i.h stable/11/contrib/wpa/wpa_supplicant/ctrl_iface.c stable/11/contrib/wpa/wpa_supplicant/events.c stable/11/contrib/wpa/wpa_supplicant/wnm_sta.c stable/11/contrib/wpa/wpa_supplicant/wpa_supplicant_i.h Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/wpa/src/ap/wpa_auth.c ============================================================================== --- stable/11/contrib/wpa/src/ap/wpa_auth.c Tue Oct 17 17:22:36 2017 (r324696) +++ stable/11/contrib/wpa/src/ap/wpa_auth.c Tue Oct 17 17:30:18 2017 (r324697) @@ -1893,6 +1893,21 @@ SM_STATE(WPA_PTK, AUTHENTICATION2) } +static int wpa_auth_sm_ptk_update(struct wpa_state_machine *sm) +{ + if (random_get_bytes(sm->ANonce, WPA_NONCE_LEN)) { + wpa_printf(MSG_ERROR, + "WPA: Failed to get random data for ANonce"); + sm->Disconnect = TRUE; + return -1; + } + wpa_hexdump(MSG_DEBUG, "WPA: Assign new ANonce", sm->ANonce, + WPA_NONCE_LEN); + sm->TimeoutCtr = 0; + return 0; +} + + SM_STATE(WPA_PTK, INITPMK) { u8 msk[2 * PMK_LEN]; @@ -2414,9 +2429,12 @@ SM_STEP(WPA_PTK) SM_ENTER(WPA_PTK, AUTHENTICATION); else if (sm->ReAuthenticationRequest) SM_ENTER(WPA_PTK, AUTHENTICATION2); - else if (sm->PTKRequest) - SM_ENTER(WPA_PTK, PTKSTART); - else switch (sm->wpa_ptk_state) { + else if (sm->PTKRequest) { + if (wpa_auth_sm_ptk_update(sm) < 0) + SM_ENTER(WPA_PTK, DISCONNECTED); + else + SM_ENTER(WPA_PTK, PTKSTART); + } else switch (sm->wpa_ptk_state) { case WPA_PTK_INITIALIZE: break; case WPA_PTK_DISCONNECT: @@ -3206,6 +3224,14 @@ int wpa_auth_sta_wpa_version(struct wpa_state_machine if (sm == NULL) return 0; return sm->wpa; +} + + +int wpa_auth_sta_ft_tk_already_set(struct wpa_state_machine *sm) +{ + if (!sm || !wpa_key_mgmt_ft(sm->wpa_key_mgmt)) + return 0; + return sm->tk_already_set; } Modified: stable/11/contrib/wpa/src/ap/wpa_auth.h ============================================================================== --- stable/11/contrib/wpa/src/ap/wpa_auth.h Tue Oct 17 17:22:36 2017 (r324696) +++ stable/11/contrib/wpa/src/ap/wpa_auth.h Tue Oct 17 17:30:18 2017 (r324697) @@ -271,6 +271,7 @@ int wpa_auth_pairwise_set(struct wpa_state_machine *sm int wpa_auth_get_pairwise(struct wpa_state_machine *sm); int wpa_auth_sta_key_mgmt(struct wpa_state_machine *sm); int wpa_auth_sta_wpa_version(struct wpa_state_machine *sm); +int wpa_auth_sta_ft_tk_already_set(struct wpa_state_machine *sm); int wpa_auth_sta_clear_pmksa(struct wpa_state_machine *sm, struct rsn_pmksa_cache_entry *entry); struct rsn_pmksa_cache_entry * Modified: stable/11/contrib/wpa/src/ap/wpa_auth_ft.c ============================================================================== --- stable/11/contrib/wpa/src/ap/wpa_auth_ft.c Tue Oct 17 17:22:36 2017 (r324696) +++ stable/11/contrib/wpa/src/ap/wpa_auth_ft.c Tue Oct 17 17:30:18 2017 (r324697) @@ -780,6 +780,14 @@ void wpa_ft_install_ptk(struct wpa_state_machine *sm) return; } + if (sm->tk_already_set) { + /* Must avoid TK reconfiguration to prevent clearing of TX/RX + * PN in the driver */ + wpa_printf(MSG_DEBUG, + "FT: Do not re-install same PTK to the driver"); + return; + } + /* FIX: add STA entry to kernel/driver here? The set_key will fail * most likely without this.. At the moment, STA entry is added only * after association has been completed. This function will be called @@ -792,6 +800,7 @@ void wpa_ft_install_ptk(struct wpa_state_machine *sm) /* FIX: MLME-SetProtection.Request(TA, Tx_Rx) */ sm->pairwise_set = TRUE; + sm->tk_already_set = TRUE; } @@ -898,6 +907,7 @@ static int wpa_ft_process_auth_req(struct wpa_state_ma sm->pairwise = pairwise; sm->PTK_valid = TRUE; + sm->tk_already_set = FALSE; wpa_ft_install_ptk(sm); buflen = 2 + sizeof(struct rsn_mdie) + 2 + sizeof(struct rsn_ftie) + Modified: stable/11/contrib/wpa/src/ap/wpa_auth_i.h ============================================================================== --- stable/11/contrib/wpa/src/ap/wpa_auth_i.h Tue Oct 17 17:22:36 2017 (r324696) +++ stable/11/contrib/wpa/src/ap/wpa_auth_i.h Tue Oct 17 17:30:18 2017 (r324697) @@ -64,6 +64,7 @@ struct wpa_state_machine { struct wpa_ptk PTK; Boolean PTK_valid; Boolean pairwise_set; + Boolean tk_already_set; int keycount; Boolean Pair; struct wpa_key_replay_counter { Modified: stable/11/contrib/wpa/src/common/wpa_common.h ============================================================================== --- stable/11/contrib/wpa/src/common/wpa_common.h Tue Oct 17 17:22:36 2017 (r324696) +++ stable/11/contrib/wpa/src/common/wpa_common.h Tue Oct 17 17:30:18 2017 (r324697) @@ -213,8 +213,20 @@ struct wpa_ptk { size_t kck_len; size_t kek_len; size_t tk_len; + int installed; /* 1 if key has already been installed to driver */ }; +struct wpa_gtk { + u8 gtk[WPA_GTK_MAX_LEN]; + size_t gtk_len; +}; + +#ifdef CONFIG_IEEE80211W +struct wpa_igtk { + u8 igtk[WPA_IGTK_MAX_LEN]; + size_t igtk_len; +}; +#endif /* CONFIG_IEEE80211W */ /* WPA IE version 1 * 00-50-f2:1 (OUI:OUI type) Modified: stable/11/contrib/wpa/src/rsn_supp/tdls.c ============================================================================== --- stable/11/contrib/wpa/src/rsn_supp/tdls.c Tue Oct 17 17:22:36 2017 (r324696) +++ stable/11/contrib/wpa/src/rsn_supp/tdls.c Tue Oct 17 17:30:18 2017 (r324697) @@ -112,6 +112,7 @@ struct wpa_tdls_peer { u8 tk[16]; /* TPK-TK; assuming only CCMP will be used */ } tpk; int tpk_set; + int tk_set; /* TPK-TK configured to the driver */ int tpk_success; int tpk_in_progress; @@ -192,6 +193,20 @@ static int wpa_tdls_set_key(struct wpa_sm *sm, struct u8 rsc[6]; enum wpa_alg alg; + if (peer->tk_set) { + /* + * This same TPK-TK has already been configured to the driver + * and this new configuration attempt (likely due to an + * unexpected retransmitted frame) would result in clearing + * the TX/RX sequence number which can break security, so must + * not allow that to happen. + */ + wpa_printf(MSG_INFO, "TDLS: TPK-TK for the peer " MACSTR + " has already been configured to the driver - do not reconfigure", + MAC2STR(peer->addr)); + return -1; + } + os_memset(rsc, 0, 6); switch (peer->cipher) { @@ -209,12 +224,15 @@ static int wpa_tdls_set_key(struct wpa_sm *sm, struct return -1; } + wpa_printf(MSG_DEBUG, "TDLS: Configure pairwise key for peer " MACSTR, + MAC2STR(peer->addr)); if (wpa_sm_set_key(sm, alg, peer->addr, -1, 1, rsc, sizeof(rsc), peer->tpk.tk, key_len) < 0) { wpa_printf(MSG_WARNING, "TDLS: Failed to set TPK to the " "driver"); return -1; } + peer->tk_set = 1; return 0; } @@ -690,7 +708,7 @@ static void wpa_tdls_peer_clear(struct wpa_sm *sm, str peer->cipher = 0; peer->qos_info = 0; peer->wmm_capable = 0; - peer->tpk_set = peer->tpk_success = 0; + peer->tk_set = peer->tpk_set = peer->tpk_success = 0; peer->chan_switch_enabled = 0; os_memset(&peer->tpk, 0, sizeof(peer->tpk)); os_memset(peer->inonce, 0, WPA_NONCE_LEN); @@ -1153,6 +1171,7 @@ skip_rsnie: wpa_tdls_peer_free(sm, peer); return -1; } + peer->tk_set = 0; /* A new nonce results in a new TK */ wpa_hexdump(MSG_DEBUG, "TDLS: Initiator Nonce for TPK handshake", peer->inonce, WPA_NONCE_LEN); os_memcpy(ftie->Snonce, peer->inonce, WPA_NONCE_LEN); @@ -1745,6 +1764,19 @@ static int wpa_tdls_addset_peer(struct wpa_sm *sm, str } +static int tdls_nonce_set(const u8 *nonce) +{ + int i; + + for (i = 0; i < WPA_NONCE_LEN; i++) { + if (nonce[i]) + return 1; + } + + return 0; +} + + static int wpa_tdls_process_tpk_m1(struct wpa_sm *sm, const u8 *src_addr, const u8 *buf, size_t len) { @@ -1998,7 +2030,8 @@ skip_rsn: peer->rsnie_i_len = kde.rsn_ie_len; peer->cipher = cipher; - if (os_memcmp(peer->inonce, ftie->Snonce, WPA_NONCE_LEN) != 0) { + if (os_memcmp(peer->inonce, ftie->Snonce, WPA_NONCE_LEN) != 0 || + !tdls_nonce_set(peer->inonce)) { /* * There is no point in updating the RNonce for every obtained * TPK M1 frame (e.g., retransmission due to timeout) with the @@ -2014,6 +2047,7 @@ skip_rsn: "TDLS: Failed to get random data for responder nonce"); goto error; } + peer->tk_set = 0; /* A new nonce results in a new TK */ } #if 0 @@ -2170,6 +2204,14 @@ static int wpa_tdls_process_tpk_m2(struct wpa_sm *sm, "ignore TPK M2 from " MACSTR, MAC2STR(src_addr)); return -1; } + + if (peer->tpk_success) { + wpa_printf(MSG_INFO, "TDLS: Ignore incoming TPK M2 retry, from " + MACSTR " as TPK M3 was already sent", + MAC2STR(src_addr)); + return 0; + } + wpa_tdls_tpk_retry_timeout_cancel(sm, peer, WLAN_TDLS_SETUP_REQUEST); if (len < 3 + 2 + 1) { Modified: stable/11/contrib/wpa/src/rsn_supp/wpa.c ============================================================================== --- stable/11/contrib/wpa/src/rsn_supp/wpa.c Tue Oct 17 17:22:36 2017 (r324696) +++ stable/11/contrib/wpa/src/rsn_supp/wpa.c Tue Oct 17 17:30:18 2017 (r324697) @@ -605,6 +605,12 @@ static int wpa_supplicant_install_ptk(struct wpa_sm *s const u8 *key_rsc; u8 null_rsc[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + if (sm->ptk.installed) { + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "WPA: Do not re-install same PTK to the driver"); + return 0; + } + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "WPA: Installing PTK to the driver"); @@ -643,6 +649,7 @@ static int wpa_supplicant_install_ptk(struct wpa_sm *s /* TK is not needed anymore in supplicant */ os_memset(sm->ptk.tk, 0, WPA_TK_MAX_LEN); + sm->ptk.installed = 1; if (sm->wpa_ptk_rekey) { eloop_cancel_timeout(wpa_sm_rekey_ptk, sm, NULL); @@ -692,11 +699,23 @@ struct wpa_gtk_data { static int wpa_supplicant_install_gtk(struct wpa_sm *sm, const struct wpa_gtk_data *gd, - const u8 *key_rsc) + const u8 *key_rsc, int wnm_sleep) { const u8 *_gtk = gd->gtk; u8 gtk_buf[32]; + /* Detect possible key reinstallation */ + if ((sm->gtk.gtk_len == (size_t) gd->gtk_len && + os_memcmp(sm->gtk.gtk, gd->gtk, sm->gtk.gtk_len) == 0) || + (sm->gtk_wnm_sleep.gtk_len == (size_t) gd->gtk_len && + os_memcmp(sm->gtk_wnm_sleep.gtk, gd->gtk, + sm->gtk_wnm_sleep.gtk_len) == 0)) { + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "WPA: Not reinstalling already in-use GTK to the driver (keyidx=%d tx=%d len=%d)", + gd->keyidx, gd->tx, gd->gtk_len); + return 0; + } + wpa_hexdump_key(MSG_DEBUG, "WPA: Group Key", gd->gtk, gd->gtk_len); wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "WPA: Installing GTK to the driver (keyidx=%d tx=%d len=%d)", @@ -731,6 +750,15 @@ static int wpa_supplicant_install_gtk(struct wpa_sm *s } os_memset(gtk_buf, 0, sizeof(gtk_buf)); + if (wnm_sleep) { + sm->gtk_wnm_sleep.gtk_len = gd->gtk_len; + os_memcpy(sm->gtk_wnm_sleep.gtk, gd->gtk, + sm->gtk_wnm_sleep.gtk_len); + } else { + sm->gtk.gtk_len = gd->gtk_len; + os_memcpy(sm->gtk.gtk, gd->gtk, sm->gtk.gtk_len); + } + return 0; } @@ -788,7 +816,7 @@ static int wpa_supplicant_pairwise_gtk(struct wpa_sm * (wpa_supplicant_check_group_cipher(sm, sm->group_cipher, gtk_len, gtk_len, &gd.key_rsc_len, &gd.alg) || - wpa_supplicant_install_gtk(sm, &gd, key->key_rsc))) { + wpa_supplicant_install_gtk(sm, &gd, key->key_rsc, 0))) { wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "RSN: Failed to install GTK"); os_memset(&gd, 0, sizeof(gd)); @@ -802,6 +830,58 @@ static int wpa_supplicant_pairwise_gtk(struct wpa_sm * } +#ifdef CONFIG_IEEE80211W +static int wpa_supplicant_install_igtk(struct wpa_sm *sm, + const struct wpa_igtk_kde *igtk, + int wnm_sleep) +{ + size_t len = wpa_cipher_key_len(sm->mgmt_group_cipher); + u16 keyidx = WPA_GET_LE16(igtk->keyid); + + /* Detect possible key reinstallation */ + if ((sm->igtk.igtk_len == len && + os_memcmp(sm->igtk.igtk, igtk->igtk, sm->igtk.igtk_len) == 0) || + (sm->igtk_wnm_sleep.igtk_len == len && + os_memcmp(sm->igtk_wnm_sleep.igtk, igtk->igtk, + sm->igtk_wnm_sleep.igtk_len) == 0)) { + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "WPA: Not reinstalling already in-use IGTK to the driver (keyidx=%d)", + keyidx); + return 0; + } + + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "WPA: IGTK keyid %d pn %02x%02x%02x%02x%02x%02x", + keyidx, MAC2STR(igtk->pn)); + wpa_hexdump_key(MSG_DEBUG, "WPA: IGTK", igtk->igtk, len); + if (keyidx > 4095) { + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: Invalid IGTK KeyID %d", keyidx); + return -1; + } + if (wpa_sm_set_key(sm, wpa_cipher_to_alg(sm->mgmt_group_cipher), + broadcast_ether_addr, + keyidx, 0, igtk->pn, sizeof(igtk->pn), + igtk->igtk, len) < 0) { + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: Failed to configure IGTK to the driver"); + return -1; + } + + if (wnm_sleep) { + sm->igtk_wnm_sleep.igtk_len = len; + os_memcpy(sm->igtk_wnm_sleep.igtk, igtk->igtk, + sm->igtk_wnm_sleep.igtk_len); + } else { + sm->igtk.igtk_len = len; + os_memcpy(sm->igtk.igtk, igtk->igtk, sm->igtk.igtk_len); + } + + return 0; +} +#endif /* CONFIG_IEEE80211W */ + + static int ieee80211w_set_keys(struct wpa_sm *sm, struct wpa_eapol_ie_parse *ie) { @@ -812,30 +892,14 @@ static int ieee80211w_set_keys(struct wpa_sm *sm, if (ie->igtk) { size_t len; const struct wpa_igtk_kde *igtk; - u16 keyidx; + len = wpa_cipher_key_len(sm->mgmt_group_cipher); if (ie->igtk_len != WPA_IGTK_KDE_PREFIX_LEN + len) return -1; + igtk = (const struct wpa_igtk_kde *) ie->igtk; - keyidx = WPA_GET_LE16(igtk->keyid); - wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "WPA: IGTK keyid %d " - "pn %02x%02x%02x%02x%02x%02x", - keyidx, MAC2STR(igtk->pn)); - wpa_hexdump_key(MSG_DEBUG, "WPA: IGTK", - igtk->igtk, len); - if (keyidx > 4095) { - wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, - "WPA: Invalid IGTK KeyID %d", keyidx); + if (wpa_supplicant_install_igtk(sm, igtk, 0) < 0) return -1; - } - if (wpa_sm_set_key(sm, wpa_cipher_to_alg(sm->mgmt_group_cipher), - broadcast_ether_addr, - keyidx, 0, igtk->pn, sizeof(igtk->pn), - igtk->igtk, len) < 0) { - wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, - "WPA: Failed to configure IGTK to the driver"); - return -1; - } } return 0; @@ -1483,7 +1547,7 @@ static void wpa_supplicant_process_1_of_2(struct wpa_s if (ret) goto failed; - if (wpa_supplicant_install_gtk(sm, &gd, key->key_rsc) || + if (wpa_supplicant_install_gtk(sm, &gd, key->key_rsc, 0) || wpa_supplicant_send_2_of_2(sm, key, ver, key_info)) goto failed; os_memset(&gd, 0, sizeof(gd)); @@ -2251,7 +2315,7 @@ void wpa_sm_deinit(struct wpa_sm *sm) */ void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid) { - int clear_ptk = 1; + int clear_keys = 1; if (sm == NULL) return; @@ -2277,11 +2341,11 @@ void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 * /* Prepare for the next transition */ wpa_ft_prepare_auth_request(sm, NULL); - clear_ptk = 0; + clear_keys = 0; } #endif /* CONFIG_IEEE80211R */ - if (clear_ptk) { + if (clear_keys) { /* * IEEE 802.11, 8.4.10: Delete PTK SA on (re)association if * this is not part of a Fast BSS Transition. @@ -2291,6 +2355,12 @@ void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 * os_memset(&sm->ptk, 0, sizeof(sm->ptk)); sm->tptk_set = 0; os_memset(&sm->tptk, 0, sizeof(sm->tptk)); + os_memset(&sm->gtk, 0, sizeof(sm->gtk)); + os_memset(&sm->gtk_wnm_sleep, 0, sizeof(sm->gtk_wnm_sleep)); +#ifdef CONFIG_IEEE80211W + os_memset(&sm->igtk, 0, sizeof(sm->igtk)); + os_memset(&sm->igtk_wnm_sleep, 0, sizeof(sm->igtk_wnm_sleep)); +#endif /* CONFIG_IEEE80211W */ } #ifdef CONFIG_TDLS @@ -2322,6 +2392,9 @@ void wpa_sm_notify_disassoc(struct wpa_sm *sm) #ifdef CONFIG_TDLS wpa_tdls_disassoc(sm); #endif /* CONFIG_TDLS */ +#ifdef CONFIG_IEEE80211R + sm->ft_reassoc_completed = 0; +#endif /* CONFIG_IEEE80211R */ /* Keys are not needed in the WPA state machine anymore */ wpa_sm_drop_sa(sm); @@ -2807,6 +2880,12 @@ void wpa_sm_drop_sa(struct wpa_sm *sm) os_memset(sm->pmk, 0, sizeof(sm->pmk)); os_memset(&sm->ptk, 0, sizeof(sm->ptk)); os_memset(&sm->tptk, 0, sizeof(sm->tptk)); + os_memset(&sm->gtk, 0, sizeof(sm->gtk)); + os_memset(&sm->gtk_wnm_sleep, 0, sizeof(sm->gtk_wnm_sleep)); +#ifdef CONFIG_IEEE80211W + os_memset(&sm->igtk, 0, sizeof(sm->igtk)); + os_memset(&sm->igtk_wnm_sleep, 0, sizeof(sm->igtk_wnm_sleep)); +#endif /* CONFIG_IEEE80211W */ #ifdef CONFIG_IEEE80211R os_memset(sm->xxkey, 0, sizeof(sm->xxkey)); os_memset(sm->pmk_r0, 0, sizeof(sm->pmk_r0)); @@ -2870,7 +2949,7 @@ int wpa_wnmsleep_install_key(struct wpa_sm *sm, u8 sub wpa_hexdump_key(MSG_DEBUG, "Install GTK (WNM SLEEP)", gd.gtk, gd.gtk_len); - if (wpa_supplicant_install_gtk(sm, &gd, key_rsc)) { + if (wpa_supplicant_install_gtk(sm, &gd, key_rsc, 1)) { os_memset(&gd, 0, sizeof(gd)); wpa_printf(MSG_DEBUG, "Failed to install the GTK in " "WNM mode"); @@ -2879,29 +2958,11 @@ int wpa_wnmsleep_install_key(struct wpa_sm *sm, u8 sub os_memset(&gd, 0, sizeof(gd)); #ifdef CONFIG_IEEE80211W } else if (subelem_id == WNM_SLEEP_SUBELEM_IGTK) { - struct wpa_igtk_kde igd; - u16 keyidx; + const struct wpa_igtk_kde *igtk; - os_memset(&igd, 0, sizeof(igd)); - keylen = wpa_cipher_key_len(sm->mgmt_group_cipher); - os_memcpy(igd.keyid, buf + 2, 2); - os_memcpy(igd.pn, buf + 4, 6); - - keyidx = WPA_GET_LE16(igd.keyid); - os_memcpy(igd.igtk, buf + 10, keylen); - - wpa_hexdump_key(MSG_DEBUG, "Install IGTK (WNM SLEEP)", - igd.igtk, keylen); - if (wpa_sm_set_key(sm, wpa_cipher_to_alg(sm->mgmt_group_cipher), - broadcast_ether_addr, - keyidx, 0, igd.pn, sizeof(igd.pn), - igd.igtk, keylen) < 0) { - wpa_printf(MSG_DEBUG, "Failed to install the IGTK in " - "WNM mode"); - os_memset(&igd, 0, sizeof(igd)); + igtk = (const struct wpa_igtk_kde *) (buf + 2); + if (wpa_supplicant_install_igtk(sm, igtk, 1) < 0) return -1; - } - os_memset(&igd, 0, sizeof(igd)); #endif /* CONFIG_IEEE80211W */ } else { wpa_printf(MSG_DEBUG, "Unknown element id"); Modified: stable/11/contrib/wpa/src/rsn_supp/wpa_ft.c ============================================================================== --- stable/11/contrib/wpa/src/rsn_supp/wpa_ft.c Tue Oct 17 17:22:36 2017 (r324696) +++ stable/11/contrib/wpa/src/rsn_supp/wpa_ft.c Tue Oct 17 17:30:18 2017 (r324697) @@ -153,6 +153,7 @@ static u8 * wpa_ft_gen_req_ies(struct wpa_sm *sm, size u16 capab; sm->ft_completed = 0; + sm->ft_reassoc_completed = 0; buf_len = 2 + sizeof(struct rsn_mdie) + 2 + sizeof(struct rsn_ftie) + 2 + sm->r0kh_id_len + ric_ies_len + 100; @@ -681,6 +682,11 @@ int wpa_ft_validate_reassoc_resp(struct wpa_sm *sm, co return -1; } + if (sm->ft_reassoc_completed) { + wpa_printf(MSG_DEBUG, "FT: Reassociation has already been completed for this FT protocol instance - ignore unexpected retransmission"); + return 0; + } + if (wpa_ft_parse_ies(ies, ies_len, &parse) < 0) { wpa_printf(MSG_DEBUG, "FT: Failed to parse IEs"); return -1; @@ -780,6 +786,8 @@ int wpa_ft_validate_reassoc_resp(struct wpa_sm *sm, co wpa_hexdump(MSG_MSGDUMP, "FT: Calculated MIC", mic, 16); return -1; } + + sm->ft_reassoc_completed = 1; if (wpa_ft_process_gtk_subelem(sm, parse.gtk, parse.gtk_len) < 0) return -1; Modified: stable/11/contrib/wpa/src/rsn_supp/wpa_i.h ============================================================================== --- stable/11/contrib/wpa/src/rsn_supp/wpa_i.h Tue Oct 17 17:22:36 2017 (r324696) +++ stable/11/contrib/wpa/src/rsn_supp/wpa_i.h Tue Oct 17 17:30:18 2017 (r324697) @@ -30,6 +30,12 @@ struct wpa_sm { u8 rx_replay_counter[WPA_REPLAY_COUNTER_LEN]; int rx_replay_counter_set; u8 request_counter[WPA_REPLAY_COUNTER_LEN]; + struct wpa_gtk gtk; + struct wpa_gtk gtk_wnm_sleep; +#ifdef CONFIG_IEEE80211W + struct wpa_igtk igtk; + struct wpa_igtk igtk_wnm_sleep; +#endif /* CONFIG_IEEE80211W */ struct eapol_sm *eapol; /* EAPOL state machine from upper level code */ @@ -121,6 +127,7 @@ struct wpa_sm { size_t r0kh_id_len; u8 r1kh_id[FT_R1KH_ID_LEN]; int ft_completed; + int ft_reassoc_completed; int over_the_ds_in_progress; u8 target_ap[ETH_ALEN]; /* over-the-DS target AP */ int set_ptk_after_assoc; Modified: stable/11/contrib/wpa/wpa_supplicant/ctrl_iface.c ============================================================================== --- stable/11/contrib/wpa/wpa_supplicant/ctrl_iface.c Tue Oct 17 17:22:36 2017 (r324696) +++ stable/11/contrib/wpa/wpa_supplicant/ctrl_iface.c Tue Oct 17 17:30:18 2017 (r324697) @@ -6891,6 +6891,7 @@ static void wpa_supplicant_ctrl_iface_flush(struct wpa } eloop_cancel_timeout(wpas_network_reenabled, wpa_s, NULL); + wpa_s->wnmsleep_used = 0; } Modified: stable/11/contrib/wpa/wpa_supplicant/events.c ============================================================================== --- stable/11/contrib/wpa/wpa_supplicant/events.c Tue Oct 17 17:22:36 2017 (r324696) +++ stable/11/contrib/wpa/wpa_supplicant/events.c Tue Oct 17 17:30:18 2017 (r324697) @@ -303,6 +303,7 @@ void wpa_supplicant_mark_disassoc(struct wpa_supplican wpa_s->key_mgmt = 0; wpas_rrm_reset(wpa_s); + wpa_s->wnmsleep_used = 0; } Modified: stable/11/contrib/wpa/wpa_supplicant/wnm_sta.c ============================================================================== --- stable/11/contrib/wpa/wpa_supplicant/wnm_sta.c Tue Oct 17 17:22:36 2017 (r324696) +++ stable/11/contrib/wpa/wpa_supplicant/wnm_sta.c Tue Oct 17 17:30:18 2017 (r324697) @@ -137,6 +137,8 @@ int ieee802_11_send_wnmsleep_req(struct wpa_supplicant if (res < 0) wpa_printf(MSG_DEBUG, "Failed to send WNM-Sleep Request " "(action=%d, intval=%d)", action, intval); + else + wpa_s->wnmsleep_used = 1; os_free(wnmsleep_ie); os_free(wnmtfs_ie); @@ -187,6 +189,12 @@ static void wnm_sleep_mode_exit_success(struct wpa_sup end = ptr + key_len_total; wpa_hexdump_key(MSG_DEBUG, "WNM: Key Data", ptr, key_len_total); + if (key_len_total && !wpa_sm_pmf_enabled(wpa_s->wpa)) { + wpa_msg(wpa_s, MSG_INFO, + "WNM: Ignore Key Data in WNM-Sleep Mode Response - PMF not enabled"); + return; + } + while (ptr + 1 < end) { if (ptr + 2 + ptr[1] > end) { wpa_printf(MSG_DEBUG, "WNM: Invalid Key Data element " @@ -247,6 +255,12 @@ static void ieee802_11_rx_wnmsleep_resp(struct wpa_sup u8 *tfsresp_ie_end = NULL; size_t left; + if (!wpa_s->wnmsleep_used) { + wpa_printf(MSG_DEBUG, + "WNM: Ignore WNM-Sleep Mode Response frame since WNM-Sleep Mode operation has not been requested"); + return; + } + if (len < 3) return; key_len_total = WPA_GET_LE16(frm + 1); @@ -281,6 +295,8 @@ static void ieee802_11_rx_wnmsleep_resp(struct wpa_sup wpa_printf(MSG_DEBUG, "No WNM-Sleep IE found"); return; } + + wpa_s->wnmsleep_used = 0; if (wnmsleep_ie->status == WNM_STATUS_SLEEP_ACCEPT || wnmsleep_ie->status == WNM_STATUS_SLEEP_EXIT_ACCEPT_GTK_UPDATE) { Modified: stable/11/contrib/wpa/wpa_supplicant/wpa_supplicant_i.h ============================================================================== --- stable/11/contrib/wpa/wpa_supplicant/wpa_supplicant_i.h Tue Oct 17 17:22:36 2017 (r324696) +++ stable/11/contrib/wpa/wpa_supplicant/wpa_supplicant_i.h Tue Oct 17 17:30:18 2017 (r324697) @@ -658,6 +658,7 @@ struct wpa_supplicant { unsigned int reattach:1; /* reassociation to the same BSS requested */ unsigned int mac_addr_changed:1; unsigned int added_vif:1; + unsigned int wnmsleep_used:1; struct os_reltime last_mac_addr_change; int last_mac_addr_style; From owner-svn-src-stable-11@freebsd.org Wed Oct 18 08:05:48 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1D4D0E2FACB; Wed, 18 Oct 2017 08:05:48 +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 DD6E66F872; Wed, 18 Oct 2017 08:05:47 +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 v9I85lRE018339; Wed, 18 Oct 2017 08:05:47 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9I85lKP018338; Wed, 18 Oct 2017 08:05:47 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201710180805.v9I85lKP018338@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 18 Oct 2017 08:05:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324718 - stable/11/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/kern X-SVN-Commit-Revision: 324718 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Oct 2017 08:05:48 -0000 Author: kib Date: Wed Oct 18 08:05:46 2017 New Revision: 324718 URL: https://svnweb.freebsd.org/changeset/base/324718 Log: MFC r324528: In tc_windup(), do not re-calculate bintime. Modified: stable/11/sys/kern/kern_tc.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/kern_tc.c ============================================================================== --- stable/11/sys/kern/kern_tc.c Wed Oct 18 07:39:21 2017 (r324717) +++ stable/11/sys/kern/kern_tc.c Wed Oct 18 08:05:46 2017 (r324718) @@ -1417,10 +1417,8 @@ tc_windup(struct bintime *new_boottimebin) if (bt.sec != t) th->th_boottime.sec += bt.sec - t; } - th->th_bintime = th->th_offset; - bintime_add(&th->th_bintime, &th->th_boottime); /* Update the UTC timestamps used by the get*() functions. */ - /* XXX shouldn't do this here. Should force non-`get' versions. */ + th->th_bintime = bt; bintime2timeval(&bt, &th->th_microtime); bintime2timespec(&bt, &th->th_nanotime); From owner-svn-src-stable-11@freebsd.org Wed Oct 18 08:18:02 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 89289E2FE84; Wed, 18 Oct 2017 08:18:02 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 56CAA6FF73; Wed, 18 Oct 2017 08:18:02 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9I8I1uG022688; Wed, 18 Oct 2017 08:18:01 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9I8I1Be022687; Wed, 18 Oct 2017 08:18:01 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201710180818.v9I8I1Be022687@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Wed, 18 Oct 2017 08:18:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324720 - stable/11/usr.sbin/ctld X-SVN-Group: stable-11 X-SVN-Commit-Author: bapt X-SVN-Commit-Paths: stable/11/usr.sbin/ctld X-SVN-Commit-Revision: 324720 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Oct 2017 08:18:02 -0000 Author: bapt Date: Wed Oct 18 08:18:01 2017 New Revision: 324720 URL: https://svnweb.freebsd.org/changeset/base/324720 Log: MFC r324623: Fix ctld segfaulting when using ucl conf file format and having duplicated lun or target Submitted by: Nikita Kozlov Sponsored by: blade Differential Revision: https://reviews.freebsd.org/D12646 Modified: stable/11/usr.sbin/ctld/uclparse.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/ctld/uclparse.c ============================================================================== --- stable/11/usr.sbin/ctld/uclparse.c Wed Oct 18 08:06:05 2017 (r324719) +++ stable/11/usr.sbin/ctld/uclparse.c Wed Oct 18 08:18:01 2017 (r324720) @@ -619,6 +619,8 @@ uclparse_target(const char *name, const ucl_object_t * const char *key; target = target_new(conf, name); + if (target == NULL) + return (1); while ((obj = ucl_iterate_object(top, &it, true))) { key = ucl_object_key(obj); @@ -807,6 +809,8 @@ uclparse_lun(const char *name, const ucl_object_t *top const char *key; lun = lun_new(conf, name); + if (lun == NULL) + return (1); while ((obj = ucl_iterate_object(top, &it, true))) { key = ucl_object_key(obj); From owner-svn-src-stable-11@freebsd.org Thu Oct 19 07:21:25 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 56215E312B9; Thu, 19 Oct 2017 07:21:25 +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 22AA682456; Thu, 19 Oct 2017 07:21:25 +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 v9J7LOpF004158; Thu, 19 Oct 2017 07:21:24 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9J7LOr9004157; Thu, 19 Oct 2017 07:21:24 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201710190721.v9J7LOr9004157@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 19 Oct 2017 07:21:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324744 - stable/11/sys/cddl/compat/opensolaris/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/11/sys/cddl/compat/opensolaris/kern X-SVN-Commit-Revision: 324744 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Oct 2017 07:21:25 -0000 Author: avg Date: Thu Oct 19 07:21:23 2017 New Revision: 324744 URL: https://svnweb.freebsd.org/changeset/base/324744 Log: MFC r324309: remove heuristic error detection from ddi_strto*() Modified: stable/11/sys/cddl/compat/opensolaris/kern/opensolaris_sunddi.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/compat/opensolaris/kern/opensolaris_sunddi.c ============================================================================== --- stable/11/sys/cddl/compat/opensolaris/kern/opensolaris_sunddi.c Thu Oct 19 04:13:47 2017 (r324743) +++ stable/11/sys/cddl/compat/opensolaris/kern/opensolaris_sunddi.c Thu Oct 19 07:21:23 2017 (r324744) @@ -41,10 +41,6 @@ ddi_strtol(const char *str, char **nptr, int base, lon { *result = strtol(str, nptr, base); - if (*result == 0) - return (EINVAL); - else if (*result == LONG_MIN || *result == LONG_MAX) - return (ERANGE); return (0); } @@ -58,10 +54,6 @@ ddi_strtoul(const char *str, char **nptr, int base, un } *result = strtoul(str, nptr, base); - if (*result == 0) - return (EINVAL); - else if (*result == ULONG_MAX) - return (ERANGE); return (0); } @@ -70,10 +62,6 @@ ddi_strtoull(const char *str, char **nptr, int base, u { *result = (unsigned long long)strtouq(str, nptr, base); - if (*result == 0) - return (EINVAL); - else if (*result == ULLONG_MAX) - return (ERANGE); return (0); } From owner-svn-src-stable-11@freebsd.org Thu Oct 19 07:23:27 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ED4DDE313F9; Thu, 19 Oct 2017 07:23:27 +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 C6F86828B8; Thu, 19 Oct 2017 07:23:27 +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 v9J7NQuf004365; Thu, 19 Oct 2017 07:23:26 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9J7NQ4Q004364; Thu, 19 Oct 2017 07:23:26 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201710190723.v9J7NQ4Q004364@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 19 Oct 2017 07:23:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324746 - stable/11/etc/devd X-SVN-Group: stable-11 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/11/etc/devd X-SVN-Commit-Revision: 324746 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Oct 2017 07:23:28 -0000 Author: avg Date: Thu Oct 19 07:23:26 2017 New Revision: 324746 URL: https://svnweb.freebsd.org/changeset/base/324746 Log: MFC r324312: fix the misleading log facility used in devd/zfs.conf Modified: stable/11/etc/devd/zfs.conf Directory Properties: stable/11/ (props changed) Modified: stable/11/etc/devd/zfs.conf ============================================================================== --- stable/11/etc/devd/zfs.conf Thu Oct 19 07:21:45 2017 (r324745) +++ stable/11/etc/devd/zfs.conf Thu Oct 19 07:23:26 2017 (r324746) @@ -5,73 +5,73 @@ notify 10 { match "system" "ZFS"; match "type" "fs.zfs.checksum"; - action "logger -p kern.warn -t ZFS 'checksum mismatch, zpool=$pool path=$vdev_path offset=$zio_offset size=$zio_size'"; + action "logger -p local7.warn -t ZFS 'checksum mismatch, zpool=$pool path=$vdev_path offset=$zio_offset size=$zio_size'"; }; notify 10 { match "system" "ZFS"; match "type" "fs.zfs.io"; - action "logger -p kern.warn -t ZFS 'vdev I/O failure, zpool=$pool path=$vdev_path offset=$zio_offset size=$zio_size error=$zio_err'"; + action "logger -p local7.warn -t ZFS 'vdev I/O failure, zpool=$pool path=$vdev_path offset=$zio_offset size=$zio_size error=$zio_err'"; }; notify 10 { match "system" "ZFS"; match "type" "fs.zfs.data"; - action "logger -p kern.warn -t ZFS 'pool I/O failure, zpool=$pool error=$zio_err'"; + action "logger -p local7.warn -t ZFS 'pool I/O failure, zpool=$pool error=$zio_err'"; }; notify 10 { match "system" "ZFS"; match "type" "fs.zfs.zpool"; - action "logger -p kern.err -t ZFS 'failed to load zpool $pool'"; + action "logger -p local7.err -t ZFS 'failed to load zpool $pool'"; }; notify 10 { match "system" "ZFS"; match "type" "fs.zfs.vdev\..*"; - action "logger -p kern.err -t ZFS 'vdev problem, zpool=$pool path=$vdev_path type=$type'"; + action "logger -p local7.err -t ZFS 'vdev problem, zpool=$pool path=$vdev_path type=$type'"; }; notify 10 { match "system" "ZFS"; match "type" "fs.zfs.io_failure"; - action "logger -p kern.alert -t ZFS 'catastrophic pool I/O failure, zpool=$pool'"; + action "logger -p local7.alert -t ZFS 'catastrophic pool I/O failure, zpool=$pool'"; }; notify 10 { match "system" "ZFS"; match "type" "fs.zfs.probe_failure"; - action "logger -p kern.err -t ZFS 'vdev probe failure, zpool=$pool path=$vdev_path'"; + action "logger -p local7.err -t ZFS 'vdev probe failure, zpool=$pool path=$vdev_path'"; }; notify 10 { match "system" "ZFS"; match "type" "fs.zfs.log_replay"; - action "logger -p kern.err -t ZFS 'pool log replay failure, zpool=$pool'"; + action "logger -p local7.err -t ZFS 'pool log replay failure, zpool=$pool'"; }; notify 10 { match "system" "ZFS"; match "type" "fs.zfs.config_cache_write"; - action "logger -p kern.warn -t ZFS 'failed to write zpool.cache, zpool=$pool'"; + action "logger -p local7.warn -t ZFS 'failed to write zpool.cache, zpool=$pool'"; }; notify 10 { match "system" "ZFS"; match "type" "resource.fs.zfs.removed"; - action "logger -p kern.notice -t ZFS 'vdev is removed, pool_guid=$pool_guid vdev_guid=$vdev_guid'"; + action "logger -p local7.notice -t ZFS 'vdev is removed, pool_guid=$pool_guid vdev_guid=$vdev_guid'"; }; notify 10 { match "system" "ZFS"; match "type" "resource.fs.zfs.autoreplace"; - action "logger -p kern.info -t ZFS 'autoreplace is configured for vdev, pool_guid=$pool_guid vdev_guid=$vdev_guid'"; + action "logger -p local7.info -t ZFS 'autoreplace is configured for vdev, pool_guid=$pool_guid vdev_guid=$vdev_guid'"; }; notify 10 { match "system" "ZFS"; match "type" "resource.fs.zfs.statechange"; - action "logger -p kern.notice -t ZFS 'vdev state changed, pool_guid=$pool_guid vdev_guid=$vdev_guid'"; + action "logger -p local7.notice -t ZFS 'vdev state changed, pool_guid=$pool_guid vdev_guid=$vdev_guid'"; }; From owner-svn-src-stable-11@freebsd.org Thu Oct 19 07:54:05 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 60EF4E32131; Thu, 19 Oct 2017 07:54:05 +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 3A9678376A; Thu, 19 Oct 2017 07:54:05 +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 v9J7s40H017307; Thu, 19 Oct 2017 07:54:04 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9J7s4IA017304; Thu, 19 Oct 2017 07:54:04 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201710190754.v9J7s4IA017304@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 19 Oct 2017 07:54:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324748 - in stable/11/sys: kern sys X-SVN-Group: stable-11 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: in stable/11/sys: kern sys X-SVN-Commit-Revision: 324748 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Oct 2017 07:54:05 -0000 Author: avg Date: Thu Oct 19 07:54:04 2017 New Revision: 324748 URL: https://svnweb.freebsd.org/changeset/base/324748 Log: MFC r324311: sysctl-s in a module should be accessible only when the module is initialized Sponsored by: Panzura Modified: stable/11/sys/kern/kern_linker.c stable/11/sys/kern/kern_sysctl.c stable/11/sys/sys/sysctl.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/kern_linker.c ============================================================================== --- stable/11/sys/kern/kern_linker.c Thu Oct 19 07:23:47 2017 (r324747) +++ stable/11/sys/kern/kern_linker.c Thu Oct 19 07:54:04 2017 (r324748) @@ -288,7 +288,7 @@ linker_file_sysuninit(linker_file_t lf) } static void -linker_file_register_sysctls(linker_file_t lf) +linker_file_register_sysctls(linker_file_t lf, bool enable) { struct sysctl_oid **start, **stop, **oidp; @@ -303,8 +303,34 @@ linker_file_register_sysctls(linker_file_t lf) sx_xunlock(&kld_sx); sysctl_wlock(); + for (oidp = start; oidp < stop; oidp++) { + if (enable) + sysctl_register_oid(*oidp); + else + sysctl_register_disabled_oid(*oidp); + } + sysctl_wunlock(); + sx_xlock(&kld_sx); +} + +static void +linker_file_enable_sysctls(linker_file_t lf) +{ + struct sysctl_oid **start, **stop, **oidp; + + KLD_DPF(FILE, + ("linker_file_enable_sysctls: enable SYSCTLs for %s\n", + lf->filename)); + + sx_assert(&kld_sx, SA_XLOCKED); + + if (linker_file_lookup_set(lf, "sysctl_set", &start, &stop, NULL) != 0) + return; + + sx_xunlock(&kld_sx); + sysctl_wlock(); for (oidp = start; oidp < stop; oidp++) - sysctl_register_oid(*oidp); + sysctl_enable_oid(*oidp); sysctl_wunlock(); sx_xlock(&kld_sx); } @@ -430,7 +456,7 @@ linker_load_file(const char *filename, linker_file_t * return (error); } modules = !TAILQ_EMPTY(&lf->modules); - linker_file_register_sysctls(lf); + linker_file_register_sysctls(lf, false); linker_file_sysinit(lf); lf->flags |= LINKER_FILE_LINKED; @@ -443,6 +469,7 @@ linker_load_file(const char *filename, linker_file_t * linker_file_unload(lf, LINKER_UNLOAD_FORCE); return (ENOEXEC); } + linker_file_enable_sysctls(lf); EVENTHANDLER_INVOKE(kld_load, lf); *result = lf; return (0); @@ -691,8 +718,8 @@ linker_file_unload(linker_file_t file, int flags) */ if (file->flags & LINKER_FILE_LINKED) { file->flags &= ~LINKER_FILE_LINKED; - linker_file_sysuninit(file); linker_file_unregister_sysctls(file); + linker_file_sysuninit(file); } TAILQ_REMOVE(&linker_files, file, link); @@ -1640,7 +1667,7 @@ restart: if (linker_file_lookup_set(lf, "sysinit_set", &si_start, &si_stop, NULL) == 0) sysinit_add(si_start, si_stop); - linker_file_register_sysctls(lf); + linker_file_register_sysctls(lf, true); lf->flags |= LINKER_FILE_LINKED; continue; fail: Modified: stable/11/sys/kern/kern_sysctl.c ============================================================================== --- stable/11/sys/kern/kern_sysctl.c Thu Oct 19 07:23:47 2017 (r324747) +++ stable/11/sys/kern/kern_sysctl.c Thu Oct 19 07:54:04 2017 (r324748) @@ -425,6 +425,37 @@ retry: } void +sysctl_register_disabled_oid(struct sysctl_oid *oidp) +{ + + /* + * Mark the leaf as dormant if it's not to be immediately enabled. + * We do not disable nodes as they can be shared between modules + * and it is always safe to access a node. + */ + KASSERT((oidp->oid_kind & CTLFLAG_DORMANT) == 0, + ("internal flag is set in oid_kind")); + if ((oidp->oid_kind & CTLTYPE) != CTLTYPE_NODE) + oidp->oid_kind |= CTLFLAG_DORMANT; + sysctl_register_oid(oidp); +} + +void +sysctl_enable_oid(struct sysctl_oid *oidp) +{ + + SYSCTL_ASSERT_WLOCKED(); + if ((oidp->oid_kind & CTLTYPE) == CTLTYPE_NODE) { + KASSERT((oidp->oid_kind & CTLFLAG_DORMANT) == 0, + ("sysctl node is marked as dormant")); + return; + } + KASSERT((oidp->oid_kind & CTLFLAG_DORMANT) != 0, + ("enabling already enabled sysctl oid")); + oidp->oid_kind &= ~CTLFLAG_DORMANT; +} + +void sysctl_unregister_oid(struct sysctl_oid *oidp) { struct sysctl_oid *p; @@ -965,7 +996,7 @@ sysctl_sysctl_next_ls(struct sysctl_oid_list *lsp, int *next = oidp->oid_number; *oidpp = oidp; - if (oidp->oid_kind & CTLFLAG_SKIP) + if ((oidp->oid_kind & (CTLFLAG_SKIP | CTLFLAG_DORMANT)) != 0) continue; if (!namelen) { @@ -1761,6 +1792,8 @@ sysctl_find_oid(int *name, u_int namelen, struct sysct } lsp = SYSCTL_CHILDREN(oid); } else if (indx == namelen) { + if ((oid->oid_kind & CTLFLAG_DORMANT) != 0) + return (ENOENT); *noid = oid; if (nindx != NULL) *nindx = indx; Modified: stable/11/sys/sys/sysctl.h ============================================================================== --- stable/11/sys/sys/sysctl.h Thu Oct 19 07:23:47 2017 (r324747) +++ stable/11/sys/sys/sysctl.h Thu Oct 19 07:54:04 2017 (r324748) @@ -83,6 +83,7 @@ struct ctlname { #define CTLFLAG_RD 0x80000000 /* Allow reads of variable */ #define CTLFLAG_WR 0x40000000 /* Allow writes to the variable */ #define CTLFLAG_RW (CTLFLAG_RD|CTLFLAG_WR) +#define CTLFLAG_DORMANT 0x20000000 /* This sysctl is not active yet */ #define CTLFLAG_ANYBODY 0x10000000 /* All users can set this var */ #define CTLFLAG_SECURE 0x08000000 /* Permit set only if securelevel<=0 */ #define CTLFLAG_PRISON 0x04000000 /* Prisoned roots can fiddle */ @@ -218,6 +219,8 @@ int sysctl_dpcpu_quad(SYSCTL_HANDLER_ARGS); * These functions are used to add/remove an oid from the mib. */ void sysctl_register_oid(struct sysctl_oid *oidp); +void sysctl_register_disabled_oid(struct sysctl_oid *oidp); +void sysctl_enable_oid(struct sysctl_oid *oidp); void sysctl_unregister_oid(struct sysctl_oid *oidp); /* Declare a static oid to allow child oids to be added to it. */ From owner-svn-src-stable-11@freebsd.org Thu Oct 19 08:15:42 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 992F6E32D5C; Thu, 19 Oct 2017 08:15:42 +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 6C64920F; Thu, 19 Oct 2017 08:15:42 +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 v9J8FffR026596; Thu, 19 Oct 2017 08:15:41 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9J8FfpW026595; Thu, 19 Oct 2017 08:15:41 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201710190815.v9J8FfpW026595@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 19 Oct 2017 08:15:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324750 - stable/11/usr.sbin/i2c X-SVN-Group: stable-11 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/11/usr.sbin/i2c X-SVN-Commit-Revision: 324750 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Oct 2017 08:15:42 -0000 Author: avg Date: Thu Oct 19 08:15:41 2017 New Revision: 324750 URL: https://svnweb.freebsd.org/changeset/base/324750 Log: Really MFC r309357,r309409: Speling fixes and fix line endings for err_msg output Note: somehow these revisions were in mergeinfo but the actual changes were not merged. Modified: stable/11/usr.sbin/i2c/i2c.c Modified: stable/11/usr.sbin/i2c/i2c.c ============================================================================== --- stable/11/usr.sbin/i2c/i2c.c Thu Oct 19 08:00:34 2017 (r324749) +++ stable/11/usr.sbin/i2c/i2c.c Thu Oct 19 08:15:41 2017 (r324750) @@ -350,7 +350,7 @@ i2c_write(char *dev, struct options i2c_opt, char *i2c error = ioctl(fd, I2CWRITE, &cmd); free(buf); if (error == -1) { - err_msg = "ioctl: error when write offset"; + err_msg = "ioctl: error writing offset"; goto err1; } } @@ -375,7 +375,7 @@ i2c_write(char *dev, struct options i2c_opt, char *i2c cmd.last = 0; error = ioctl(fd, I2CWRITE, &cmd); if (error == -1) { - err_msg = "ioctl: error when write"; + err_msg = "ioctl: error writing"; goto err1; } break; @@ -390,7 +390,7 @@ i2c_write(char *dev, struct options i2c_opt, char *i2c error = ioctl(fd, I2CWRITE, &cmd); free(buf); if (error == -1) { - err_msg = "ioctl: error when write offset"; + err_msg = "ioctl: error writing offset"; goto err1; } } @@ -411,7 +411,7 @@ i2c_write(char *dev, struct options i2c_opt, char *i2c cmd.last = 0; error = ioctl(fd, I2CWRITE, &cmd); if (error == -1) { - err_msg = "ioctl: error when write"; + err_msg = "ioctl: error writing"; goto err1; } break; @@ -434,7 +434,7 @@ i2c_write(char *dev, struct options i2c_opt, char *i2c error = ioctl(fd, I2CWRITE, &cmd); free(buf); if (error == -1) { - err_msg = "ioctl: error when write"; + err_msg = "ioctl: error writing"; goto err1; } break; @@ -453,10 +453,10 @@ err1: cmd.slave = i2c_opt.addr; error = ioctl(fd, I2CSTOP, &cmd); if (error == -1) - fprintf(stderr, "error sending stop condtion\n"); + fprintf(stderr, "error sending stop condition\n"); err2: if (err_msg) - fprintf(stderr, "%s", err_msg); + fprintf(stderr, "%s\n", err_msg); close(fd); return (1); @@ -498,7 +498,7 @@ i2c_read(char *dev, struct options i2c_opt, char *i2c_ error = ioctl(fd, I2CWRITE, &cmd); free(buf); if (error == -1) { - err_msg = "ioctl: error when write offset"; + err_msg = "ioctl: error writing offset"; goto err1; } @@ -506,7 +506,7 @@ i2c_read(char *dev, struct options i2c_opt, char *i2c_ cmd.slave = i2c_opt.addr; error = ioctl(fd, I2CSTOP, &cmd); if (error == -1) { - err_msg = "error sending stop condtion\n"; + err_msg = "error sending stop condition"; goto err2; } } @@ -531,7 +531,7 @@ i2c_read(char *dev, struct options i2c_opt, char *i2c_ } error = ioctl(fd, I2CSTOP, &cmd); if (error == -1) { - err_msg = "error sending stop condtion\n"; + err_msg = "error sending stop condition"; goto err2; } @@ -550,10 +550,10 @@ err1: cmd.slave = i2c_opt.addr; error = ioctl(fd, I2CSTOP, &cmd); if (error == -1) - fprintf(stderr, "error sending stop condtion\n"); + fprintf(stderr, "error sending stop condition\n"); err2: if (err_msg) - fprintf(stderr, "%s", err_msg); + fprintf(stderr, "%s\n", err_msg); close(fd); return (1); From owner-svn-src-stable-11@freebsd.org Thu Oct 19 08:17:33 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8E886E32EB1; Thu, 19 Oct 2017 08:17:33 +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 684C9400; Thu, 19 Oct 2017 08:17:33 +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 v9J8HWZ2026730; Thu, 19 Oct 2017 08:17:32 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9J8HWVf026728; Thu, 19 Oct 2017 08:17:32 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201710190817.v9J8HWVf026728@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 19 Oct 2017 08:17:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324751 - stable/11/usr.sbin/i2c X-SVN-Group: stable-11 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/11/usr.sbin/i2c X-SVN-Commit-Revision: 324751 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Oct 2017 08:17:33 -0000 Author: avg Date: Thu Oct 19 08:17:32 2017 New Revision: 324751 URL: https://svnweb.freebsd.org/changeset/base/324751 Log: MFC r324590: i2c(8): clean up and clarify read operation Modified: stable/11/usr.sbin/i2c/i2c.8 stable/11/usr.sbin/i2c/i2c.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/i2c/i2c.8 ============================================================================== --- stable/11/usr.sbin/i2c/i2c.8 Thu Oct 19 08:15:41 2017 (r324750) +++ stable/11/usr.sbin/i2c/i2c.8 Thu Oct 19 08:17:32 2017 (r324751) @@ -83,6 +83,10 @@ using selected addresses 'a:b:c'. This option is avail used. .It Fl o Ar offset offset within the device for data transfer (hex). +The default is zero. +Use +.Dq -w 0 +to disable writing of the offset to the slave. .It Fl r reset the controller. .It Fl s @@ -91,6 +95,12 @@ scan the bus for devices. be verbose. .It Fl w Ar 0|8|16 device addressing width (in bits). +This is used to determine how to pass +.Ar offset +specified with +.Fl o +to the slave. +Zero means that the offset is ignored and not passed to the slave at all. .El .Sh WARNINGS Great care must be taken when manipulating slave I2C devices with the Modified: stable/11/usr.sbin/i2c/i2c.c ============================================================================== --- stable/11/usr.sbin/i2c/i2c.c Thu Oct 19 08:15:41 2017 (r324750) +++ stable/11/usr.sbin/i2c/i2c.c Thu Oct 19 08:17:32 2017 (r324751) @@ -212,15 +212,14 @@ start_over: use_read_xfer = 1; goto start_over; } - cmd.slave = i << 1; - cmd.last = 1; - ioctl(fd, I2CSTOP, &cmd); + ioctl(fd, I2CSTOP); } if (error == 0) { ++num_found; printf("%02x ", i); } } + /* * If we found nothing, maybe START is not supported and returns a * generic error code such as EIO or ENXIO, so try again using reads. @@ -355,7 +354,7 @@ i2c_write(char *dev, struct options i2c_opt, char *i2c } } - error = ioctl(fd, I2CSTOP, &cmd); + error = ioctl(fd, I2CSTOP); if (error == -1) { err_msg = "ioctl: error sending stop condition"; goto err2; @@ -439,8 +438,7 @@ i2c_write(char *dev, struct options i2c_opt, char *i2c } break; } - cmd.slave = i2c_opt.addr; - error = ioctl(fd, I2CSTOP, &cmd); + error = ioctl(fd, I2CSTOP); if (error == -1) { err_msg = "ioctl: error sending stop condition"; goto err2; @@ -450,8 +448,7 @@ i2c_write(char *dev, struct options i2c_opt, char *i2c return (0); err1: - cmd.slave = i2c_opt.addr; - error = ioctl(fd, I2CSTOP, &cmd); + error = ioctl(fd, I2CSTOP); if (error == -1) fprintf(stderr, "error sending stop condition\n"); err2: @@ -466,7 +463,7 @@ static int i2c_read(char *dev, struct options i2c_opt, char *i2c_buf) { struct iiccmd cmd; - int i, fd, error, bufsize; + int fd, error, bufsize; char *err_msg, data = 0, *buf; fd = open(dev, O_RDWR); @@ -503,23 +500,22 @@ i2c_read(char *dev, struct options i2c_opt, char *i2c_ } if (i2c_opt.mode == I2C_MODE_STOP_START) { - cmd.slave = i2c_opt.addr; - error = ioctl(fd, I2CSTOP, &cmd); + error = ioctl(fd, I2CSTOP); if (error == -1) { err_msg = "error sending stop condition"; goto err2; } } } - cmd.slave = i2c_opt.addr; + cmd.slave = i2c_opt.addr | 1; cmd.count = 1; cmd.last = 0; cmd.buf = &data; - if (i2c_opt.mode == I2C_MODE_STOP_START) { + if (i2c_opt.mode == I2C_MODE_STOP_START || i2c_opt.width == 0) { error = ioctl(fd, I2CSTART, &cmd); if (error == -1) { err_msg = "ioctl: error sending start condition"; - goto err1; + goto err2; } } else if (i2c_opt.mode == I2C_MODE_REPEATED_START) { error = ioctl(fd, I2CRPTSTART, &cmd); @@ -529,26 +525,27 @@ i2c_read(char *dev, struct options i2c_opt, char *i2c_ goto err1; } } - error = ioctl(fd, I2CSTOP, &cmd); + + cmd.count = i2c_opt.count; + cmd.buf = i2c_buf; + cmd.last = 1; + error = ioctl(fd, I2CREAD, &cmd); if (error == -1) { - err_msg = "error sending stop condition"; - goto err2; + err_msg = "ioctl: error while reading"; + goto err1; } - for (i = 0; i < i2c_opt.count; i++) { - error = read(fd, &i2c_buf[i], 1); - if (error == -1) { - err_msg = "ioctl: error while reading"; - goto err1; - } + error = ioctl(fd, I2CSTOP); + if (error == -1) { + err_msg = "error sending stop condtion\n"; + goto err2; } close(fd); return (0); err1: - cmd.slave = i2c_opt.addr; - error = ioctl(fd, I2CSTOP, &cmd); + error = ioctl(fd, I2CSTOP); if (error == -1) fprintf(stderr, "error sending stop condition\n"); err2: From owner-svn-src-stable-11@freebsd.org Thu Oct 19 16:07:58 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C03ACE3F50E; Thu, 19 Oct 2017 16:07:58 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 895ED6F1C0; Thu, 19 Oct 2017 16:07:58 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9JG7vmr023076; Thu, 19 Oct 2017 16:07:57 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9JG7vn1023071; Thu, 19 Oct 2017 16:07:57 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201710191607.v9JG7vn1023071@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Thu, 19 Oct 2017 16:07:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324755 - in stable/11/sys: arm/allwinner arm/freescale/imx dev/gpio sys X-SVN-Group: stable-11 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: in stable/11/sys: arm/allwinner arm/freescale/imx dev/gpio sys X-SVN-Commit-Revision: 324755 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Oct 2017 16:07:58 -0000 Author: ian Date: Thu Oct 19 16:07:57 2017 New Revision: 324755 URL: https://svnweb.freebsd.org/changeset/base/324755 Log: MFC r323392: Add gpio methods to read/write/configure up to 32 pins simultaneously. Sometimes it is necessary to combine several gpio pins into an ad-hoc bus and manipulate the pins as a group. In such cases manipulating the pins individualy is not an option, because the value on the "bus" assumes potentially-invalid intermediate values as each pin is changed in turn. Note that the "bus" may be something as simple as a bi-color LED where changing colors requires changing both gpio pins at once, or something as complex as a bitbanged multiplexed address/data bus connected to a microcontroller. In addition to the absolute requirement of simultaneously changing the output values of driven pins, a desirable feature of these new methods is to provide a higher-performance mechanism for reading and writing multiple pins, especially from userland where pin-at-a-time access incurs a noticible syscall time penalty. These new interfaces are NOT intended to abstract away all the ugly details of how gpio is implemented on any given platform. In fact, to use these properly you absolutely must know something about how the gpio hardware is organized. Typically there are "banks" of gpio pins controlled by registers which group several pins together. A bank may be as small as 2 pins or as big as "all the pins on the device, hundreds of them." In the latter case, a driver might support this interface by allowing access to any 32 adjacent pins within the overall collection. Or, more likely, any 32 adjacent pins starting at any multiple of 32. Whatever the hardware restrictions may be, you would need to understand them to use this interface. In additional to defining the interfaces, two example implementations are included here, for imx5/6, and allwinner. These represent the two primary types of gpio hardware drivers. imx6 has multiple gpio devices, each implementing a single bank of 32 pins. Allwinner implements a single large gpio number space from 1-n pins, and the driver internally translates that linear number space to a bank+pin scheme based on how the pins are grouped into control registers. The allwinner implementation imposes the restriction that the first_pin argument to the new functions must always be pin 0 of a bank. Differential Revision: https://reviews.freebsd.org/D11810 Modified: stable/11/sys/arm/allwinner/a10_gpio.c stable/11/sys/arm/freescale/imx/imx_gpio.c stable/11/sys/dev/gpio/gpio_if.m stable/11/sys/dev/gpio/gpioc.c stable/11/sys/sys/gpio.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm/allwinner/a10_gpio.c ============================================================================== --- stable/11/sys/arm/allwinner/a10_gpio.c Thu Oct 19 13:22:52 2017 (r324754) +++ stable/11/sys/arm/allwinner/a10_gpio.c Thu Oct 19 16:07:57 2017 (r324755) @@ -174,6 +174,9 @@ struct a10_gpio_softc { #define A10_GPIO_GP_INT_STA 0x214 #define A10_GPIO_GP_INT_DEB 0x218 +static int a10_gpio_pin_get(device_t dev, uint32_t pin, unsigned int *value); +static int a10_gpio_pin_set(device_t dev, uint32_t pin, unsigned int value); + #define A10_GPIO_WRITE(_sc, _off, _val) \ bus_space_write_4(_sc->sc_bst, _sc->sc_bsh, _off, _val) #define A10_GPIO_READ(_sc, _off) \ @@ -295,29 +298,44 @@ a10_gpio_set_drv(struct a10_gpio_softc *sc, uint32_t p static int a10_gpio_pin_configure(struct a10_gpio_softc *sc, uint32_t pin, uint32_t flags) { + u_int val; int err = 0; /* Must be called with lock held. */ A10_GPIO_LOCK_ASSERT(sc); + if (pin > sc->padconf->npins) + return (EINVAL); + /* Manage input/output. */ - if (flags & (GPIO_PIN_INPUT | GPIO_PIN_OUTPUT)) { - if (flags & GPIO_PIN_OUTPUT) - err = a10_gpio_set_function(sc, pin, A10_GPIO_OUTPUT); - else + if (flags & GPIO_PIN_INPUT) { + err = a10_gpio_set_function(sc, pin, A10_GPIO_INPUT); + } else if (flags & GPIO_PIN_OUTPUT) { + if (flags & GPIO_PIN_PRESET_LOW) { + a10_gpio_pin_set(sc->sc_dev, pin, 0); + } else if (flags & GPIO_PIN_PRESET_HIGH) { + a10_gpio_pin_set(sc->sc_dev, pin, 1); + } else { + /* Read the pin and preset output to current state. */ err = a10_gpio_set_function(sc, pin, A10_GPIO_INPUT); + if (err == 0) { + a10_gpio_pin_get(sc->sc_dev, pin, &val); + a10_gpio_pin_set(sc->sc_dev, pin, val); + } + } + if (err == 0) + err = a10_gpio_set_function(sc, pin, A10_GPIO_OUTPUT); } if (err) return (err); /* Manage Pull-up/pull-down. */ - if (flags & (GPIO_PIN_PULLUP | GPIO_PIN_PULLDOWN)) { - if (flags & GPIO_PIN_PULLUP) - a10_gpio_set_pud(sc, pin, A10_GPIO_PULLUP); - else - a10_gpio_set_pud(sc, pin, A10_GPIO_PULLDOWN); - } else + if (flags & GPIO_PIN_PULLUP) + a10_gpio_set_pud(sc, pin, A10_GPIO_PULLUP); + else if (flags & GPIO_PIN_PULLDOWN) + a10_gpio_set_pud(sc, pin, A10_GPIO_PULLDOWN); + else a10_gpio_set_pud(sc, pin, A10_GPIO_NONE); return (0); @@ -505,6 +523,73 @@ a10_gpio_pin_toggle(device_t dev, uint32_t pin) } static int +a10_gpio_pin_access_32(device_t dev, uint32_t first_pin, uint32_t clear_pins, + uint32_t change_pins, uint32_t *orig_pins) +{ + struct a10_gpio_softc *sc; + uint32_t bank, data, pin; + + sc = device_get_softc(dev); + if (first_pin > sc->padconf->npins) + return (EINVAL); + + /* + * We require that first_pin refers to the first pin in a bank, because + * this API is not about convenience, it's for making a set of pins + * change simultaneously (required) with reasonably high performance + * (desired); we need to do a read-modify-write on a single register. + */ + bank = sc->padconf->pins[first_pin].port; + pin = sc->padconf->pins[first_pin].pin; + if (pin != 0) + return (EINVAL); + + A10_GPIO_LOCK(sc); + data = A10_GPIO_READ(sc, A10_GPIO_GP_DAT(bank)); + if ((clear_pins | change_pins) != 0) + A10_GPIO_WRITE(sc, A10_GPIO_GP_DAT(bank), + (data & ~clear_pins) ^ change_pins); + A10_GPIO_UNLOCK(sc); + + if (orig_pins != NULL) + *orig_pins = data; + + return (0); +} + +static int +a10_gpio_pin_config_32(device_t dev, uint32_t first_pin, uint32_t num_pins, + uint32_t *pin_flags) +{ + struct a10_gpio_softc *sc; + uint32_t bank, pin; + int err; + + sc = device_get_softc(dev); + if (first_pin > sc->padconf->npins) + return (EINVAL); + + bank = sc->padconf->pins[first_pin].port; + if (sc->padconf->pins[first_pin].pin != 0) + return (EINVAL); + + /* + * The configuration for a bank of pins is scattered among several + * registers; we cannot g'tee to simultaneously change the state of all + * the pins in the flags array. So just loop through the array + * configuring each pin for now. If there was a strong need, it might + * be possible to support some limited simultaneous config, such as + * adjacent groups of 8 pins that line up the same as the config regs. + */ + for (err = 0, pin = first_pin; err == 0 && pin < num_pins; ++pin) { + if (pin_flags[pin] & (GPIO_PIN_INPUT | GPIO_PIN_OUTPUT)) + err = a10_gpio_pin_configure(sc, pin, pin_flags[pin]); + } + + return (err); +} + +static int aw_find_pinnum_by_name(struct a10_gpio_softc *sc, const char *pinname) { int i; @@ -743,6 +828,8 @@ static device_method_t a10_gpio_methods[] = { DEVMETHOD(gpio_pin_get, a10_gpio_pin_get), DEVMETHOD(gpio_pin_set, a10_gpio_pin_set), DEVMETHOD(gpio_pin_toggle, a10_gpio_pin_toggle), + DEVMETHOD(gpio_pin_access_32, a10_gpio_pin_access_32), + DEVMETHOD(gpio_pin_config_32, a10_gpio_pin_config_32), DEVMETHOD(gpio_map_gpios, a10_gpio_map_gpios), /* ofw_bus interface */ Modified: stable/11/sys/arm/freescale/imx/imx_gpio.c ============================================================================== --- stable/11/sys/arm/freescale/imx/imx_gpio.c Thu Oct 19 13:22:52 2017 (r324754) +++ stable/11/sys/arm/freescale/imx/imx_gpio.c Thu Oct 19 16:07:57 2017 (r324755) @@ -669,6 +669,72 @@ imx51_gpio_pin_toggle(device_t dev, uint32_t pin) } static int +imx51_gpio_pin_access_32(device_t dev, uint32_t first_pin, uint32_t clear_pins, + uint32_t change_pins, uint32_t *orig_pins) +{ + struct imx51_gpio_softc *sc; + + if (first_pin != 0) + return (EINVAL); + + sc = device_get_softc(dev); + + if (orig_pins != NULL) + *orig_pins = READ4(sc, IMX_GPIO_PSR_REG); + + if ((clear_pins | change_pins) != 0) { + mtx_lock_spin(&sc->sc_mtx); + WRITE4(sc, IMX_GPIO_DR_REG, + (READ4(sc, IMX_GPIO_DR_REG) & ~clear_pins) ^ change_pins); + mtx_unlock_spin(&sc->sc_mtx); + } + + return (0); +} + +static int +imx51_gpio_pin_config_32(device_t dev, uint32_t first_pin, uint32_t num_pins, + uint32_t *pin_flags) +{ + struct imx51_gpio_softc *sc; + u_int i; + uint32_t bit, drclr, drset, flags, oeclr, oeset, pads; + + sc = device_get_softc(dev); + + if (first_pin != 0 || num_pins > sc->gpio_npins) + return (EINVAL); + + drclr = drset = oeclr = oeset = 0; + pads = READ4(sc, IMX_GPIO_PSR_REG); + + for (i = 0; i < num_pins; ++i) { + bit = 1u << i; + flags = pin_flags[i]; + if (flags & GPIO_PIN_INPUT) { + oeclr |= bit; + } else if (flags & GPIO_PIN_OUTPUT) { + oeset |= bit; + if (flags & GPIO_PIN_PRESET_LOW) + drclr |= bit; + else if (flags & GPIO_PIN_PRESET_HIGH) + drset |= bit; + else /* Drive whatever it's now pulled to. */ + drset |= pads & bit; + } + } + + mtx_lock_spin(&sc->sc_mtx); + WRITE4(sc, IMX_GPIO_DR_REG, + (READ4(sc, IMX_GPIO_DR_REG) & ~drclr) | drset); + WRITE4(sc, IMX_GPIO_OE_REG, + (READ4(sc, IMX_GPIO_OE_REG) & ~oeclr) | oeset); + mtx_unlock_spin(&sc->sc_mtx); + + return (0); +} + +static int imx51_gpio_probe(device_t dev) { @@ -791,6 +857,8 @@ static device_method_t imx51_gpio_methods[] = { DEVMETHOD(gpio_pin_get, imx51_gpio_pin_get), DEVMETHOD(gpio_pin_set, imx51_gpio_pin_set), DEVMETHOD(gpio_pin_toggle, imx51_gpio_pin_toggle), + DEVMETHOD(gpio_pin_access_32, imx51_gpio_pin_access_32), + DEVMETHOD(gpio_pin_config_32, imx51_gpio_pin_config_32), {0, 0}, }; Modified: stable/11/sys/dev/gpio/gpio_if.m ============================================================================== --- stable/11/sys/dev/gpio/gpio_if.m Thu Oct 19 13:22:52 2017 (r324754) +++ stable/11/sys/dev/gpio/gpio_if.m Thu Oct 19 16:07:57 2017 (r324755) @@ -40,6 +40,13 @@ CODE { } static int + gpio_default_nosupport(void) + { + + return (EOPNOTSUPP); + } + + static int gpio_default_map_gpios(device_t bus, phandle_t dev, phandle_t gparent, int gcells, pcell_t *gpios, uint32_t *pin, uint32_t *flags) @@ -151,3 +158,31 @@ METHOD int map_gpios { uint32_t *pin; uint32_t *flags; } DEFAULT gpio_default_map_gpios; + +# +# Simultaneously read and/or change up to 32 adjacent pins. +# If the device cannot change the pins simultaneously, returns EOPNOTSUPP. +# +# More details about using this interface can be found in sys/gpio.h +# +METHOD int pin_access_32 { + device_t dev; + uint32_t first_pin; + uint32_t clear_pins; + uint32_t change_pins; + uint32_t *orig_pins; +} DEFAULT gpio_default_nosupport; + +# +# Simultaneously configure up to 32 adjacent pins. +# This is intended to change the configuration of all the pins simultaneously, +# but unlike pin_access_32, this will not fail if the hardware can't do so. +# +# More details about using this interface can be found in sys/gpio.h +# +METHOD int pin_config_32 { + device_t dev; + uint32_t first_pin; + uint32_t num_pins; + uint32_t *pin_flags; +} DEFAULT gpio_default_nosupport; Modified: stable/11/sys/dev/gpio/gpioc.c ============================================================================== --- stable/11/sys/dev/gpio/gpioc.c Thu Oct 19 13:22:52 2017 (r324754) +++ stable/11/sys/dev/gpio/gpioc.c Thu Oct 19 16:07:57 2017 (r324755) @@ -125,6 +125,8 @@ gpioc_ioctl(struct cdev *cdev, u_long cmd, caddr_t arg struct gpioc_softc *sc = cdev->si_drv1; struct gpio_pin pin; struct gpio_req req; + struct gpio_access_32 *a32; + struct gpio_config_32 *c32; uint32_t caps; bus = GPIO_GET_BUS(sc->sc_pdev); @@ -184,6 +186,16 @@ gpioc_ioctl(struct cdev *cdev, u_long cmd, caddr_t arg dprintf("set name on pin %d\n", pin.gp_pin); res = GPIOBUS_PIN_SETNAME(bus, pin.gp_pin, pin.gp_name); + break; + case GPIOACCESS32: + a32 = (struct gpio_access_32 *)arg; + res = GPIO_PIN_ACCESS_32(sc->sc_pdev, a32->first_pin, + a32->clear_pins, a32->orig_pins, &a32->orig_pins); + break; + case GPIOCONFIG32: + c32 = (struct gpio_config_32 *)arg; + res = GPIO_PIN_CONFIG_32(sc->sc_pdev, c32->first_pin, + c32->num_pins, c32->pin_flags); break; default: return (ENOTTY); Modified: stable/11/sys/sys/gpio.h ============================================================================== --- stable/11/sys/sys/gpio.h Thu Oct 19 13:22:52 2017 (r324754) +++ stable/11/sys/sys/gpio.h Thu Oct 19 16:07:57 2017 (r324755) @@ -70,6 +70,8 @@ #define GPIO_PIN_INVIN 0x00000080 /* invert input */ #define GPIO_PIN_INVOUT 0x00000100 /* invert output */ #define GPIO_PIN_PULSATE 0x00000200 /* pulsate in hardware */ +#define GPIO_PIN_PRESET_LOW 0x00000400 /* preset pin to high or */ +#define GPIO_PIN_PRESET_HIGH 0x00000800 /* low before enabling output */ /* GPIO interrupt capabilities */ #define GPIO_INTR_NONE 0x00000000 /* no interrupt support */ #define GPIO_INTR_LEVEL_LOW 0x00010000 /* level trigger, low */ @@ -95,6 +97,71 @@ struct gpio_req { }; /* + * gpio_access_32 / GPIOACCESS32 + * + * Simultaneously read and/or change up to 32 adjacent pins. + * If the device cannot change the pins simultaneously, returns EOPNOTSUPP. + * + * This accesses an adjacent set of up to 32 pins starting at first_pin within + * the device's collection of pins. How the hardware pins are mapped to the 32 + * bits in the arguments is device-specific. It is expected that lower-numbered + * pins in the device's number space map linearly to lower-ordered bits within + * the 32-bit words (i.e., bit 0 is first_pin, bit 1 is first_pin+1, etc). + * Other mappings are possible; know your device. + * + * Some devices may limit the value of first_pin to 0, or to multiples of 16 or + * 32 or some other hardware-specific number; to access pin 2 would require + * first_pin to be zero and then manipulate bit (1 << 2) in the 32-bit word. + * Invalid values in first_pin result in an EINVAL error return. + * + * The starting state of the pins is captured and stored in orig_pins, then the + * pins are set to ((starting_state & ~clear_pins) ^ change_pins). + * + * Clear Change Hardware pin after call + * 0 0 No change + * 0 1 Opposite of current value + * 1 0 Cleared + * 1 1 Set + */ +struct gpio_access_32 { + uint32_t first_pin; /* First pin in group of 32 adjacent */ + uint32_t clear_pins; /* Pins are changed using: */ + uint32_t change_pins; /* ((hwstate & ~clear_pins) ^ change_pins) */ + uint32_t orig_pins; /* Returned hwstate of pins before change. */ +}; + +/* + * gpio_config_32 / GPIOCONFIG32 + * + * Simultaneously configure up to 32 adjacent pins. This is intended to change + * the configuration of all the pins simultaneously, such that pins configured + * for output all begin to drive the configured values simultaneously, but not + * all hardware can do that, so the driver "does the best it can" in this + * regard. Notably unlike pin_access_32(), this does NOT fail if the pins + * cannot be atomically configured; it is expected that callers understand the + * hardware and have decided to live with any such limitations it may have. + * + * The pin_flags argument is an array of GPIO_PIN_xxxx flags. If the array + * contains any GPIO_PIN_OUTPUT flags, the driver will manipulate the hardware + * such that all output pins become driven with the proper initial values + * simultaneously if it can. The elements in the array map to pins in the same + * way that bits are mapped by pin_acces_32(), and the same restrictions may + * apply. For example, to configure pins 2 and 3 it may be necessary to set + * first_pin to zero and only populate pin_flags[2] and pin_flags[3]. If a + * given array entry doesn't contain GPIO_PIN_INPUT or GPIO_PIN_OUTPUT then no + * configuration is done for that pin. + * + * Some devices may limit the value of first_pin to 0, or to multiples of 16 or + * 32 or some other hardware-specific number. Invalid values in first_pin or + * num_pins result in an error return with errno set to EINVAL. + */ +struct gpio_config_32 { + uint32_t first_pin; + uint32_t num_pins; + uint32_t pin_flags[32]; +}; + +/* * ioctls */ #define GPIOMAXPIN _IOR('G', 0, int) @@ -104,5 +171,7 @@ struct gpio_req { #define GPIOSET _IOW('G', 4, struct gpio_req) #define GPIOTOGGLE _IOWR('G', 5, struct gpio_req) #define GPIOSETNAME _IOW('G', 6, struct gpio_pin) +#define GPIOACCESS32 _IOWR('G', 7, struct gpio_access_32) +#define GPIOCONFIG32 _IOW('G', 8, struct gpio_config_32) #endif /* __GPIO_H__ */ From owner-svn-src-stable-11@freebsd.org Thu Oct 19 16:16:28 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 48E41E3F854; Thu, 19 Oct 2017 16:16:28 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 16B8B6F66F; Thu, 19 Oct 2017 16:16:28 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9JGGRpM027046; Thu, 19 Oct 2017 16:16:27 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9JGGR8W027044; Thu, 19 Oct 2017 16:16:27 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201710191616.v9JGGR8W027044@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Thu, 19 Oct 2017 16:16:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324756 - in stable/11/sys/cddl: compat/opensolaris/sys contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-11 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: in stable/11/sys/cddl: compat/opensolaris/sys contrib/opensolaris/uts/common/fs/zfs X-SVN-Commit-Revision: 324756 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Oct 2017 16:16:28 -0000 Author: ian Date: Thu Oct 19 16:16:26 2017 New Revision: 324756 URL: https://svnweb.freebsd.org/changeset/base/324756 Log: MFC r323985: Use nstosbt() instead of multiplying by SBT_1NS to avoid roundoff errors. Differential Revision: https://reviews.freebsd.org/D11779 Modified: stable/11/sys/cddl/compat/opensolaris/sys/kcondvar.h stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/compat/opensolaris/sys/kcondvar.h ============================================================================== --- stable/11/sys/cddl/compat/opensolaris/sys/kcondvar.h Thu Oct 19 16:07:57 2017 (r324755) +++ stable/11/sys/cddl/compat/opensolaris/sys/kcondvar.h Thu Oct 19 16:16:26 2017 (r324756) @@ -63,13 +63,8 @@ static clock_t cv_timedwait_hires(kcondvar_t *cvp, kmutex_t *mp, hrtime_t tim, hrtime_t res, int flag) { - sbintime_t sbt; - sbintime_t pr; - sbt = tim * SBT_1NS; - pr = res * SBT_1NS; - - return (cv_timedwait_sbt(cvp, mp, sbt, pr, 0)); + return (cv_timedwait_sbt(cvp, mp, nstosbt(tim), nstosbt(res), 0)); } #endif /* _KERNEL */ Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c Thu Oct 19 16:07:57 2017 (r324755) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c Thu Oct 19 16:16:26 2017 (r324756) @@ -806,8 +806,8 @@ dmu_tx_delay(dmu_tx_t *tx, uint64_t dirty) continue; mutex_exit(&curthread->t_delay_lock); #else - pause_sbt("dmu_tx_delay", wakeup * SBT_1NS, - zfs_delay_resolution_ns * SBT_1NS, C_ABSOLUTE); + pause_sbt("dmu_tx_delay", nstosbt(wakeup), + nstosbt(zfs_delay_resolution_ns), C_ABSOLUTE); #endif #else hrtime_t delta = wakeup - gethrtime(); From owner-svn-src-stable-11@freebsd.org Thu Oct 19 17:26:28 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2B6B4E41DD7; Thu, 19 Oct 2017 17:26:28 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 02CF9737B5; Thu, 19 Oct 2017 17:26:27 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9JHQRui059319; Thu, 19 Oct 2017 17:26:27 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9JHQRHx059318; Thu, 19 Oct 2017 17:26:27 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201710191726.v9JHQRHx059318@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Thu, 19 Oct 2017 17:26:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324760 - stable/11/contrib/gcc/config/arm X-SVN-Group: stable-11 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: stable/11/contrib/gcc/config/arm X-SVN-Commit-Revision: 324760 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Oct 2017 17:26:28 -0000 Author: ian Date: Thu Oct 19 17:26:26 2017 New Revision: 324760 URL: https://svnweb.freebsd.org/changeset/base/324760 Log: MFC r323997-r323998 r323997: Fix handling of uncaught exceptions in a std::terminate() handler on arm. When raising an exception, the unwinder searches for a catch handler and if none is found it should invoke std::terminate() with the uncaught exception as the "current" exception. Before this change, the terminate handler was invoked with no exception as current (abi::__cxa_current_exception_type() returned NULL), because the return value from the unwinder indicated an internal failure in unwinding. It turns out that was because all errors from get_eit_entry() were translated to _URC_FAILURE. Now the error is returned untranslated, which allows _URC_END_OF_STACK to percolate upwards to throw_exception() in libcxxrt. When it sees that return status it properly calls std::terminate() with the uncaught exception installed as the current exception, allowing custom terminate handlers to work with it. r323998: Fix the return value from _Unwind_Backtrace() on arm. If unwinding stops due to hitting the end of the call chain, the return value is supposed to be _URC_END_OF_STACK; other values indicate internal errors. The return value from get_eit_entry() is now returned without translating it to _URC_FAILURE, so that callers can see _URC_END_OF_STACK when it happens. Modified: stable/11/contrib/gcc/config/arm/unwind-arm.c Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/gcc/config/arm/unwind-arm.c ============================================================================== --- stable/11/contrib/gcc/config/arm/unwind-arm.c Thu Oct 19 16:42:03 2017 (r324759) +++ stable/11/contrib/gcc/config/arm/unwind-arm.c Thu Oct 19 17:26:26 2017 (r324760) @@ -625,8 +625,8 @@ __gnu_Unwind_RaiseException (_Unwind_Control_Block * u do { /* Find the entry for this routine. */ - if (get_eit_entry (ucbp, saved_vrs.core.r[R_PC]) != _URC_OK) - return _URC_FAILURE; + if ((pr_result = get_eit_entry (ucbp, saved_vrs.core.r[R_PC])) != _URC_OK) + return pr_result; /* Call the pr to decide what to do. */ pr_result = ((personality_routine) UCB_PR_ADDR (ucbp)) @@ -773,11 +773,8 @@ __gnu_Unwind_Backtrace(_Unwind_Trace_Fn trace, void * do { /* Find the entry for this routine. */ - if (get_eit_entry (ucbp, saved_vrs.core.r[R_PC]) != _URC_OK) - { - code = _URC_FAILURE; + if ((code = get_eit_entry (ucbp, saved_vrs.core.r[R_PC])) != _URC_OK) break; - } /* The dwarf unwinder assumes the context structure holds things like the function and LSDA pointers. The ARM implementation From owner-svn-src-stable-11@freebsd.org Thu Oct 19 17:28:10 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E3334E41E60; Thu, 19 Oct 2017 17:28:10 +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 B13FA73903; Thu, 19 Oct 2017 17:28:10 +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 v9JHS9Co059433; Thu, 19 Oct 2017 17:28:09 GMT (envelope-from davidcs@FreeBSD.org) Received: (from davidcs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9JHS9vx059431; Thu, 19 Oct 2017 17:28:09 GMT (envelope-from davidcs@FreeBSD.org) Message-Id: <201710191728.v9JHS9vx059431@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: davidcs set sender to davidcs@FreeBSD.org using -f From: David C Somayajulu Date: Thu, 19 Oct 2017 17:28:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324761 - stable/11/sys/dev/qlxgbe X-SVN-Group: stable-11 X-SVN-Commit-Author: davidcs X-SVN-Commit-Paths: stable/11/sys/dev/qlxgbe X-SVN-Commit-Revision: 324761 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Oct 2017 17:28:11 -0000 Author: davidcs Date: Thu Oct 19 17:28:09 2017 New Revision: 324761 URL: https://svnweb.freebsd.org/changeset/base/324761 Log: MFC r324535 Add sanity checks in ql_hw_send() qla_send() to ensure that empty slots in Tx Ring map to empty slot in Tx_buf array before Transmits. If the checks fail further Transmission on that Tx Ring is prevented. Modified: stable/11/sys/dev/qlxgbe/ql_hw.c stable/11/sys/dev/qlxgbe/ql_os.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/qlxgbe/ql_hw.c ============================================================================== --- stable/11/sys/dev/qlxgbe/ql_hw.c Thu Oct 19 17:26:26 2017 (r324760) +++ stable/11/sys/dev/qlxgbe/ql_hw.c Thu Oct 19 17:28:09 2017 (r324761) @@ -2374,6 +2374,20 @@ ql_hw_send(qla_host_t *ha, bus_dma_segment_t *segs, in } } + for (i = 0; i < num_tx_cmds; i++) { + int j; + + j = (tx_idx+i) & (NUM_TX_DESCRIPTORS - 1); + + if (NULL != ha->tx_ring[txr_idx].tx_buf[j].m_head) { + QL_ASSERT(ha, 0, \ + ("%s [%d]: txr_idx = %d tx_idx = %d mbuf = %p\n",\ + __func__, __LINE__, txr_idx, j,\ + ha->tx_ring[txr_idx].tx_buf[j].m_head)); + return (EINVAL); + } + } + tx_cmd = &hw->tx_cntxt[txr_idx].tx_ring_base[tx_idx]; if (!(mp->m_pkthdr.csum_flags & CSUM_TSO)) { Modified: stable/11/sys/dev/qlxgbe/ql_os.c ============================================================================== --- stable/11/sys/dev/qlxgbe/ql_os.c Thu Oct 19 17:26:26 2017 (r324760) +++ stable/11/sys/dev/qlxgbe/ql_os.c Thu Oct 19 17:28:09 2017 (r324761) @@ -1232,6 +1232,17 @@ qla_send(qla_host_t *ha, struct mbuf **m_headp, uint32 QL_DPRINT8(ha, (ha->pci_dev, "%s: enter\n", __func__)); tx_idx = ha->hw.tx_cntxt[txr_idx].txr_next; + + if (NULL != ha->tx_ring[txr_idx].tx_buf[tx_idx].m_head) { + QL_ASSERT(ha, 0, ("%s [%d]: txr_idx = %d tx_idx = %d "\ + "mbuf = %p\n", __func__, __LINE__, txr_idx, tx_idx,\ + ha->tx_ring[txr_idx].tx_buf[tx_idx].m_head)); + if (m_head) + m_freem(m_head); + *m_headp = NULL; + return (ret); + } + map = ha->tx_ring[txr_idx].tx_buf[tx_idx].map; ret = bus_dmamap_load_mbuf_sg(ha->tx_tag, map, m_head, segs, &nsegs, From owner-svn-src-stable-11@freebsd.org Thu Oct 19 17:30:21 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F0F95E41EED; Thu, 19 Oct 2017 17:30:21 +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 BD02773A8D; Thu, 19 Oct 2017 17:30:21 +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 v9JHUKNl059582; Thu, 19 Oct 2017 17:30:20 GMT (envelope-from davidcs@FreeBSD.org) Received: (from davidcs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9JHUKWR059575; Thu, 19 Oct 2017 17:30:20 GMT (envelope-from davidcs@FreeBSD.org) Message-Id: <201710191730.v9JHUKWR059575@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: davidcs set sender to davidcs@FreeBSD.org using -f From: David C Somayajulu Date: Thu, 19 Oct 2017 17:30:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324762 - stable/11/sys/dev/qlxgbe X-SVN-Group: stable-11 X-SVN-Commit-Author: davidcs X-SVN-Commit-Paths: stable/11/sys/dev/qlxgbe X-SVN-Commit-Revision: 324762 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Oct 2017 17:30:22 -0000 Author: davidcs Date: Thu Oct 19 17:30:20 2017 New Revision: 324762 URL: https://svnweb.freebsd.org/changeset/base/324762 Log: MFC r324538 Added support driver state capture/retrieval Modified: stable/11/sys/dev/qlxgbe/ql_def.h stable/11/sys/dev/qlxgbe/ql_glbl.h stable/11/sys/dev/qlxgbe/ql_hw.h stable/11/sys/dev/qlxgbe/ql_ioctl.c stable/11/sys/dev/qlxgbe/ql_ioctl.h stable/11/sys/dev/qlxgbe/ql_os.c stable/11/sys/dev/qlxgbe/ql_ver.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/qlxgbe/ql_def.h ============================================================================== --- stable/11/sys/dev/qlxgbe/ql_def.h Thu Oct 19 17:28:09 2017 (r324761) +++ stable/11/sys/dev/qlxgbe/ql_def.h Thu Oct 19 17:30:20 2017 (r324762) @@ -201,7 +201,6 @@ struct qla_host { qla_rx_buf_t *rxb_free; uint32_t rxb_free_count; - volatile uint32_t posting; /* stats */ uint32_t err_m_getcl; Modified: stable/11/sys/dev/qlxgbe/ql_glbl.h ============================================================================== --- stable/11/sys/dev/qlxgbe/ql_glbl.h Thu Oct 19 17:28:09 2017 (r324761) +++ stable/11/sys/dev/qlxgbe/ql_glbl.h Thu Oct 19 17:30:20 2017 (r324762) @@ -112,4 +112,8 @@ extern unsigned int ql83xx_resetseq_len; extern unsigned char ql83xx_minidump[]; extern unsigned int ql83xx_minidump_len; +extern void ql_alloc_drvr_state_buffer(qla_host_t *ha); +extern void ql_free_drvr_state_buffer(qla_host_t *ha); +extern void ql_capture_drvr_state(qla_host_t *ha); + #endif /* #ifndef_QL_GLBL_H_ */ Modified: stable/11/sys/dev/qlxgbe/ql_hw.h ============================================================================== --- stable/11/sys/dev/qlxgbe/ql_hw.h Thu Oct 19 17:28:09 2017 (r324761) +++ stable/11/sys/dev/qlxgbe/ql_hw.h Thu Oct 19 17:30:20 2017 (r324762) @@ -1703,6 +1703,9 @@ typedef struct _qla_hw { uint32_t mdump_buffer_size; void *mdump_template; uint32_t mdump_template_size; + + /* driver state related */ + void *drvr_state; } qla_hw_t; #define QL_UPDATE_RDS_PRODUCER_INDEX(ha, prod_reg, val) \ Modified: stable/11/sys/dev/qlxgbe/ql_ioctl.c ============================================================================== --- stable/11/sys/dev/qlxgbe/ql_ioctl.c Thu Oct 19 17:28:09 2017 (r324761) +++ stable/11/sys/dev/qlxgbe/ql_ioctl.c Thu Oct 19 17:30:20 2017 (r324762) @@ -39,7 +39,11 @@ __FBSDID("$FreeBSD$"); #include "ql_inline.h" #include "ql_glbl.h" #include "ql_ioctl.h" +#include "ql_ver.h" +#include "ql_dbg.h" +static int ql_drvr_state(qla_host_t *ha, qla_driver_state_t *drvr_state); +static uint32_t ql_drvr_state_size(qla_host_t *ha); static int ql_eioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag, struct thread *td); @@ -279,6 +283,10 @@ ql_eioctl(struct cdev *dev, u_long cmd, caddr_t data, rval = ENXIO; break; + case QLA_RD_DRVR_STATE: + rval = ql_drvr_state(ha, (qla_driver_state_t *)data); + break; + case QLA_RD_PCI_IDS: pci_ids = (qla_rd_pci_ids_t *)data; pci_ids->ven_id = pci_get_vendor(pci_dev); @@ -293,5 +301,225 @@ ql_eioctl(struct cdev *dev, u_long cmd, caddr_t data, } return rval; +} + + +static int +ql_drvr_state(qla_host_t *ha, qla_driver_state_t *state) +{ + int rval = 0; + uint32_t drvr_state_size; + qla_drvr_state_hdr_t *hdr; + + drvr_state_size = ql_drvr_state_size(ha); + + if (state->buffer == NULL) { + state->size = drvr_state_size; + return (0); + } + + if (state->size < drvr_state_size) + return (ENXIO); + + if (ha->hw.drvr_state == NULL) + return (ENOMEM); + + hdr = ha->hw.drvr_state; + + if (!hdr->drvr_version_major) + ql_capture_drvr_state(ha); + + rval = copyout(ha->hw.drvr_state, state->buffer, drvr_state_size); + + bzero(ha->hw.drvr_state, drvr_state_size); + + return (rval); +} + +static uint32_t +ql_drvr_state_size(qla_host_t *ha) +{ + uint32_t drvr_state_size; + uint32_t size; + + size = sizeof (qla_drvr_state_hdr_t); + drvr_state_size = QL_ALIGN(size, 64); + + size = ha->hw.num_tx_rings * (sizeof (qla_drvr_state_tx_t)); + drvr_state_size += QL_ALIGN(size, 64); + + size = ha->hw.num_rds_rings * (sizeof (qla_drvr_state_rx_t)); + drvr_state_size += QL_ALIGN(size, 64); + + size = ha->hw.num_sds_rings * (sizeof (qla_drvr_state_sds_t)); + drvr_state_size += QL_ALIGN(size, 64); + + size = sizeof(q80_tx_cmd_t) * NUM_TX_DESCRIPTORS * ha->hw.num_tx_rings; + drvr_state_size += QL_ALIGN(size, 64); + + size = sizeof(q80_recv_desc_t) * NUM_RX_DESCRIPTORS * ha->hw.num_rds_rings; + drvr_state_size += QL_ALIGN(size, 64); + + size = sizeof(q80_stat_desc_t) * NUM_STATUS_DESCRIPTORS * + ha->hw.num_sds_rings; + drvr_state_size += QL_ALIGN(size, 64); + + return (drvr_state_size); +} + +static void +ql_get_tx_state(qla_host_t *ha, qla_drvr_state_tx_t *tx_state) +{ + int i; + + for (i = 0; i < ha->hw.num_tx_rings; i++) { + tx_state->base_p_addr = ha->hw.tx_cntxt[i].tx_ring_paddr; + tx_state->cons_p_addr = ha->hw.tx_cntxt[i].tx_cons_paddr; + tx_state->tx_prod_reg = ha->hw.tx_cntxt[i].tx_prod_reg; + tx_state->tx_cntxt_id = ha->hw.tx_cntxt[i].tx_cntxt_id; + tx_state->txr_free = ha->hw.tx_cntxt[i].txr_free; + tx_state->txr_next = ha->hw.tx_cntxt[i].txr_next; + tx_state->txr_comp = ha->hw.tx_cntxt[i].txr_comp; + tx_state++; + } + return; +} + +static void +ql_get_rx_state(qla_host_t *ha, qla_drvr_state_rx_t *rx_state) +{ + int i; + + for (i = 0; i < ha->hw.num_rds_rings; i++) { + rx_state->prod_std = ha->hw.rds[i].prod_std; + rx_state->rx_next = ha->hw.rds[i].rx_next; + rx_state++; + } + return; +} + +static void +ql_get_sds_state(qla_host_t *ha, qla_drvr_state_sds_t *sds_state) +{ + int i; + + for (i = 0; i < ha->hw.num_sds_rings; i++) { + sds_state->sdsr_next = ha->hw.sds[i].sdsr_next; + sds_state->sds_consumer = ha->hw.sds[i].sds_consumer; + sds_state++; + } + return; +} + +void +ql_capture_drvr_state(qla_host_t *ha) +{ + uint8_t *state_buffer; + uint8_t *ptr; + uint32_t drvr_state_size; + qla_drvr_state_hdr_t *hdr; + uint32_t size; + int i; + + drvr_state_size = ql_drvr_state_size(ha); + + state_buffer = ha->hw.drvr_state; + + if (state_buffer == NULL) + return; + + bzero(state_buffer, drvr_state_size); + + hdr = (qla_drvr_state_hdr_t *)state_buffer; + + hdr->drvr_version_major = QLA_VERSION_MAJOR; + hdr->drvr_version_minor = QLA_VERSION_MINOR; + hdr->drvr_version_build = QLA_VERSION_BUILD; + + bcopy(ha->hw.mac_addr, hdr->mac_addr, ETHER_ADDR_LEN); + + hdr->link_speed = ha->hw.link_speed; + hdr->cable_length = ha->hw.cable_length; + hdr->cable_oui = ha->hw.cable_oui; + hdr->link_up = ha->hw.link_up; + hdr->module_type = ha->hw.module_type; + hdr->link_faults = ha->hw.link_faults; + hdr->rcv_intr_coalesce = ha->hw.rcv_intr_coalesce; + hdr->xmt_intr_coalesce = ha->hw.xmt_intr_coalesce; + + size = sizeof (qla_drvr_state_hdr_t); + hdr->tx_state_offset = QL_ALIGN(size, 64); + + ptr = state_buffer + hdr->tx_state_offset; + + ql_get_tx_state(ha, (qla_drvr_state_tx_t *)ptr); + + size = ha->hw.num_tx_rings * (sizeof (qla_drvr_state_tx_t)); + hdr->rx_state_offset = hdr->tx_state_offset + QL_ALIGN(size, 64); + ptr = state_buffer + hdr->rx_state_offset; + + ql_get_rx_state(ha, (qla_drvr_state_rx_t *)ptr); + + size = ha->hw.num_rds_rings * (sizeof (qla_drvr_state_rx_t)); + hdr->sds_state_offset = hdr->rx_state_offset + QL_ALIGN(size, 64); + ptr = state_buffer + hdr->sds_state_offset; + + ql_get_sds_state(ha, (qla_drvr_state_sds_t *)ptr); + + size = ha->hw.num_sds_rings * (sizeof (qla_drvr_state_sds_t)); + hdr->txr_offset = hdr->sds_state_offset + QL_ALIGN(size, 64); + ptr = state_buffer + hdr->txr_offset; + + hdr->num_tx_rings = ha->hw.num_tx_rings; + hdr->txr_size = sizeof(q80_tx_cmd_t) * NUM_TX_DESCRIPTORS; + hdr->txr_entries = NUM_TX_DESCRIPTORS; + + size = hdr->num_tx_rings * hdr->txr_size; + bcopy(ha->hw.dma_buf.tx_ring.dma_b, ptr, size); + + hdr->rxr_offset = hdr->txr_offset + QL_ALIGN(size, 64); + ptr = state_buffer + hdr->rxr_offset; + + hdr->rxr_size = sizeof(q80_recv_desc_t) * NUM_RX_DESCRIPTORS; + hdr->rxr_entries = NUM_RX_DESCRIPTORS; + hdr->num_rx_rings = ha->hw.num_rds_rings; + + for (i = 0; i < ha->hw.num_rds_rings; i++) { + bcopy(ha->hw.dma_buf.rds_ring[i].dma_b, ptr, hdr->rxr_size); + ptr += hdr->rxr_size; + } + + size = hdr->rxr_size * hdr->num_rx_rings; + hdr->sds_offset = hdr->rxr_offset + QL_ALIGN(size, 64); + hdr->sds_ring_size = sizeof(q80_stat_desc_t) * NUM_STATUS_DESCRIPTORS; + hdr->sds_entries = NUM_STATUS_DESCRIPTORS; + hdr->num_sds_rings = ha->hw.num_sds_rings; + + ptr = state_buffer + hdr->sds_offset; + for (i = 0; i < ha->hw.num_sds_rings; i++) { + bcopy(ha->hw.dma_buf.sds_ring[i].dma_b, ptr, hdr->sds_ring_size); + ptr += hdr->sds_ring_size; + } + return; +} + +void +ql_alloc_drvr_state_buffer(qla_host_t *ha) +{ + uint32_t drvr_state_size; + + drvr_state_size = ql_drvr_state_size(ha); + + ha->hw.drvr_state = malloc(drvr_state_size, M_QLA83XXBUF, M_NOWAIT); + + return; +} + +void +ql_free_drvr_state_buffer(qla_host_t *ha) +{ + if (ha->hw.drvr_state != NULL) + free(ha->hw.drvr_state, M_QLA83XXBUF); + return; } Modified: stable/11/sys/dev/qlxgbe/ql_ioctl.h ============================================================================== --- stable/11/sys/dev/qlxgbe/ql_ioctl.h Thu Oct 19 17:28:09 2017 (r324761) +++ stable/11/sys/dev/qlxgbe/ql_ioctl.h Thu Oct 19 17:30:20 2017 (r324762) @@ -93,6 +93,72 @@ struct qla_rd_fw_dump { }; typedef struct qla_rd_fw_dump qla_rd_fw_dump_t; +struct qla_drvr_state_tx { + uint64_t base_p_addr; + uint64_t cons_p_addr; + uint32_t tx_prod_reg; + uint32_t tx_cntxt_id; + uint32_t txr_free; + uint32_t txr_next; + uint32_t txr_comp; +}; +typedef struct qla_drvr_state_tx qla_drvr_state_tx_t; + +struct qla_drvr_state_sds { + uint32_t sdsr_next; /* next entry in SDS ring to process */ + uint32_t sds_consumer; +}; +typedef struct qla_drvr_state_sds qla_drvr_state_sds_t; + +struct qla_drvr_state_rx { + uint32_t prod_std; + uint32_t rx_next; /* next standard rcv ring to arm fw */; +}; +typedef struct qla_drvr_state_rx qla_drvr_state_rx_t; + +struct qla_drvr_state_hdr { + uint32_t drvr_version_major; + uint32_t drvr_version_minor; + uint32_t drvr_version_build; + + uint8_t mac_addr[ETHER_ADDR_LEN]; + uint16_t link_speed; + uint16_t cable_length; + uint32_t cable_oui; + uint8_t link_up; + uint8_t module_type; + uint8_t link_faults; + uint32_t rcv_intr_coalesce; + uint32_t xmt_intr_coalesce; + + uint32_t tx_state_offset;/* size = sizeof (qla_drvr_state_tx_t) * num_tx_rings */ + uint32_t rx_state_offset;/* size = sizeof (qla_drvr_state_rx_t) * num_rx_rings */ + uint32_t sds_state_offset;/* size = sizeof (qla_drvr_state_sds_t) * num_sds_rings */ + + uint32_t num_tx_rings; /* number of tx rings */ + uint32_t txr_size; /* size of each tx ring in bytes */ + uint32_t txr_entries; /* number of descriptors in each tx ring */ + uint32_t txr_offset; /* start of tx ring [0 - #rings] content */ + + uint32_t num_rx_rings; /* number of rx rings */ + uint32_t rxr_size; /* size of each rx ring in bytes */ + uint32_t rxr_entries; /* number of descriptors in each rx ring */ + uint32_t rxr_offset; /* start of rx ring [0 - #rings] content */ + + uint32_t num_sds_rings; /* number of sds rings */ + uint32_t sds_ring_size; /* size of each sds ring in bytes */ + uint32_t sds_entries; /* number of descriptors in each sds ring */ + uint32_t sds_offset; /* start of sds ring [0 - #rings] content */ +}; + +typedef struct qla_drvr_state_hdr qla_drvr_state_hdr_t; + +struct qla_driver_state { + uint32_t size; + void *buffer; +}; +typedef struct qla_driver_state qla_driver_state_t; + /* * Read/Write Register */ @@ -132,5 +198,11 @@ typedef struct qla_rd_fw_dump qla_rd_fw_dump_t; * Read Minidump Template */ #define QLA_RD_FW_DUMP _IOWR('q', 8, qla_rd_fw_dump_t) + +/* + * Read Driver State + */ +#define QLA_RD_DRVR_STATE _IOWR('q', 9, qla_driver_state_t) + #endif /* #ifndef _QL_IOCTL_H_ */ Modified: stable/11/sys/dev/qlxgbe/ql_os.c ============================================================================== --- stable/11/sys/dev/qlxgbe/ql_os.c Thu Oct 19 17:28:09 2017 (r324761) +++ stable/11/sys/dev/qlxgbe/ql_os.c Thu Oct 19 17:30:20 2017 (r324762) @@ -492,6 +492,7 @@ qla_pci_attach(device_t dev) device_printf(dev, "%s: ql_minidump_init failed\n", __func__); goto qla_pci_attach_err; } + ql_alloc_drvr_state_buffer(ha); /* create the o.s ethernet interface */ qla_init_ifnet(dev, ha); @@ -645,6 +646,7 @@ qla_release(qla_host_t *ha) if (ha->ifp != NULL) ether_ifdetach(ha->ifp); + ql_free_drvr_state_buffer(ha); ql_free_dma(ha); qla_free_parent_dma_tag(ha); Modified: stable/11/sys/dev/qlxgbe/ql_ver.h ============================================================================== --- stable/11/sys/dev/qlxgbe/ql_ver.h Thu Oct 19 17:28:09 2017 (r324761) +++ stable/11/sys/dev/qlxgbe/ql_ver.h Thu Oct 19 17:30:20 2017 (r324762) @@ -36,6 +36,6 @@ #define QLA_VERSION_MAJOR 3 #define QLA_VERSION_MINOR 10 -#define QLA_VERSION_BUILD 34 +#define QLA_VERSION_BUILD 35 #endif /* #ifndef _QL_VER_H_ */ From owner-svn-src-stable-11@freebsd.org Thu Oct 19 20:16:42 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 14705E4642E; Thu, 19 Oct 2017 20:16:42 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E1EBA7E1BD; Thu, 19 Oct 2017 20:16:41 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9JKGfup031105; Thu, 19 Oct 2017 20:16:41 GMT (envelope-from wulf@FreeBSD.org) Received: (from wulf@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9JKGeTc031095; Thu, 19 Oct 2017 20:16:40 GMT (envelope-from wulf@FreeBSD.org) Message-Id: <201710192016.v9JKGeTc031095@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: wulf set sender to wulf@FreeBSD.org using -f From: Vladimir Kondratyev Date: Thu, 19 Oct 2017 20:16:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324768 - stable/11/sys/dev/evdev X-SVN-Group: stable-11 X-SVN-Commit-Author: wulf X-SVN-Commit-Paths: stable/11/sys/dev/evdev X-SVN-Commit-Revision: 324768 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Oct 2017 20:16:42 -0000 Author: wulf Date: Thu Oct 19 20:16:40 2017 New Revision: 324768 URL: https://svnweb.freebsd.org/changeset/base/324768 Log: MFC r321397-r321399 r321397: evdev: style(9), sort headers alphabetically r321398: evdev: Macroize common locking sequences r321399: Change my email address to wulf@FreeBSD.org in copyright headers. Approved by: gonzo (mentor) Modified: stable/11/sys/dev/evdev/cdev.c stable/11/sys/dev/evdev/evdev.c stable/11/sys/dev/evdev/evdev_mt.c stable/11/sys/dev/evdev/evdev_private.h stable/11/sys/dev/evdev/evdev_utils.c stable/11/sys/dev/evdev/input-event-codes.h stable/11/sys/dev/evdev/input.h stable/11/sys/dev/evdev/uinput.c stable/11/sys/dev/evdev/uinput.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/evdev/cdev.c ============================================================================== --- stable/11/sys/dev/evdev/cdev.c Thu Oct 19 18:04:16 2017 (r324767) +++ stable/11/sys/dev/evdev/cdev.c Thu Oct 19 20:16:40 2017 (r324768) @@ -1,6 +1,6 @@ /*- * Copyright (c) 2014 Jakub Wojciech Klama - * Copyright (c) 2015-2016 Vladimir Kondratyev + * Copyright (c) 2015-2016 Vladimir Kondratyev * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,24 +29,23 @@ #include "opt_evdev.h" -#include -#include -#include #include -#include +#include #include -#include -#include -#include #include #include -#include +#include #include +#include +#include +#include +#include #include +#include -#include #include #include +#include #ifdef EVDEV_DEBUG #define debugf(client, fmt, args...) printf("evdev cdev: "fmt"\n", ##args) Modified: stable/11/sys/dev/evdev/evdev.c ============================================================================== --- stable/11/sys/dev/evdev/evdev.c Thu Oct 19 18:04:16 2017 (r324767) +++ stable/11/sys/dev/evdev/evdev.c Thu Oct 19 20:16:40 2017 (r324768) @@ -1,6 +1,6 @@ /*- * Copyright (c) 2014 Jakub Wojciech Klama - * Copyright (c) 2015-2016 Vladimir Kondratyev + * Copyright (c) 2015-2016 Vladimir Kondratyev * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,19 +29,18 @@ #include "opt_evdev.h" -#include -#include #include -#include -#include +#include #include +#include #include -#include +#include #include +#include -#include #include #include +#include #ifdef EVDEV_DEBUG #define debugf(evdev, fmt, args...) printf("evdev: " fmt "\n", ##args) @@ -758,14 +757,11 @@ evdev_push_event(struct evdev_dev *evdev, uint16_t typ int32_t value) { - if (evdev->ev_lock_type != EV_LOCK_INTERNAL) - EVDEV_LOCK_ASSERT(evdev); - if (evdev_check_event(evdev, type, code, value) != 0) return (EINVAL); - if (evdev->ev_lock_type == EV_LOCK_INTERNAL) - EVDEV_LOCK(evdev); + EVDEV_ENTER(evdev); + evdev_modify_event(evdev, type, code, &value); if (type == EV_SYN && code == SYN_REPORT && bit_test(evdev->ev_flags, EVDEV_FLAG_MT_AUTOREL)) @@ -774,8 +770,8 @@ evdev_push_event(struct evdev_dev *evdev, uint16_t typ bit_test(evdev->ev_flags, EVDEV_FLAG_MT_STCOMPAT)) evdev_send_mt_compat(evdev); evdev_send_event(evdev, type, code, value); - if (evdev->ev_lock_type == EV_LOCK_INTERNAL) - EVDEV_UNLOCK(evdev); + + EVDEV_EXIT(evdev); return (0); } Modified: stable/11/sys/dev/evdev/evdev_mt.c ============================================================================== --- stable/11/sys/dev/evdev/evdev_mt.c Thu Oct 19 18:04:16 2017 (r324767) +++ stable/11/sys/dev/evdev/evdev_mt.c Thu Oct 19 20:16:40 2017 (r324768) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2016 Vladimir Kondratyev + * Copyright (c) 2016 Vladimir Kondratyev * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -27,14 +27,14 @@ */ #include -#include #include +#include #include #include -#include #include #include +#include #ifdef DEBUG #define debugf(fmt, args...) printf("evdev: " fmt "\n", ##args) @@ -224,13 +224,9 @@ void evdev_push_nfingers(struct evdev_dev *evdev, int32_t nfingers) { - if (evdev->ev_lock_type == EV_LOCK_INTERNAL) - EVDEV_LOCK(evdev); - else - EVDEV_LOCK_ASSERT(evdev); + EVDEV_ENTER(evdev); evdev_send_nfingers(evdev, nfingers); - if (evdev->ev_lock_type == EV_LOCK_INTERNAL) - EVDEV_UNLOCK(evdev); + EVDEV_EXIT(evdev); } void @@ -264,13 +260,9 @@ void evdev_push_mt_compat(struct evdev_dev *evdev) { - if (evdev->ev_lock_type == EV_LOCK_INTERNAL) - EVDEV_LOCK(evdev); - else - EVDEV_LOCK_ASSERT(evdev); + EVDEV_ENTER(evdev); evdev_send_mt_compat(evdev); - if (evdev->ev_lock_type == EV_LOCK_INTERNAL) - EVDEV_UNLOCK(evdev); + EVDEV_EXIT(evdev); } void Modified: stable/11/sys/dev/evdev/evdev_private.h ============================================================================== --- stable/11/sys/dev/evdev/evdev_private.h Thu Oct 19 18:04:16 2017 (r324767) +++ stable/11/sys/dev/evdev/evdev_private.h Thu Oct 19 20:16:40 2017 (r324768) @@ -1,6 +1,6 @@ /*- * Copyright (c) 2014 Jakub Wojciech Klama - * Copyright (c) 2015-2016 Vladimir Kondratyev + * Copyright (c) 2015-2016 Vladimir Kondratyev * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,10 +31,11 @@ #define _DEV_EVDEV_EVDEV_PRIVATE_H #include -#include -#include #include +#include +#include #include + #include #include #include @@ -134,6 +135,16 @@ struct evdev_dev #define EVDEV_LOCK(evdev) mtx_lock((evdev)->ev_lock) #define EVDEV_UNLOCK(evdev) mtx_unlock((evdev)->ev_lock) #define EVDEV_LOCK_ASSERT(evdev) mtx_assert((evdev)->ev_lock, MA_OWNED) +#define EVDEV_ENTER(evdev) do { \ + if ((evdev)->ev_lock_type == EV_LOCK_INTERNAL) \ + EVDEV_LOCK(evdev); \ + else \ + EVDEV_LOCK_ASSERT(evdev); \ +} while (0) +#define EVDEV_EXIT(evdev) do { \ + if ((evdev)->ev_lock_type == EV_LOCK_INTERNAL) \ + EVDEV_UNLOCK(evdev); \ +} while (0) struct evdev_client { Modified: stable/11/sys/dev/evdev/evdev_utils.c ============================================================================== --- stable/11/sys/dev/evdev/evdev_utils.c Thu Oct 19 18:04:16 2017 (r324767) +++ stable/11/sys/dev/evdev/evdev_utils.c Thu Oct 19 20:16:40 2017 (r324768) @@ -1,6 +1,6 @@ /*- * Copyright (c) 2014 Jakub Wojciech Klama - * Copyright (c) 2015-2016 Vladimir Kondratyev + * Copyright (c) 2015-2016 Vladimir Kondratyev * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -27,17 +27,16 @@ * $FreeBSD$ */ -#include -#include #include #include -#include #include -#include #include +#include +#include +#include -#include #include +#include #include Modified: stable/11/sys/dev/evdev/input-event-codes.h ============================================================================== --- stable/11/sys/dev/evdev/input-event-codes.h Thu Oct 19 18:04:16 2017 (r324767) +++ stable/11/sys/dev/evdev/input-event-codes.h Thu Oct 19 20:16:40 2017 (r324768) @@ -1,6 +1,6 @@ /*- * Copyright (c) 2016 Oleksandr Tymoshenko - * Copyright (c) 2015-2016 Vladimir Kondratyev + * Copyright (c) 2015-2016 Vladimir Kondratyev * All rights reserved. * * Redistribution and use in source and binary forms, with or without Modified: stable/11/sys/dev/evdev/input.h ============================================================================== --- stable/11/sys/dev/evdev/input.h Thu Oct 19 18:04:16 2017 (r324767) +++ stable/11/sys/dev/evdev/input.h Thu Oct 19 20:16:40 2017 (r324768) @@ -1,6 +1,6 @@ /*- * Copyright (c) 2016 Oleksandr Tymoshenko - * Copyright (c) 2015-2016 Vladimir Kondratyev + * Copyright (c) 2015-2016 Vladimir Kondratyev * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,8 +31,8 @@ #define _EVDEV_INPUT_H #ifndef __KERNEL__ -#include #include +#include #include #endif Modified: stable/11/sys/dev/evdev/uinput.c ============================================================================== --- stable/11/sys/dev/evdev/uinput.c Thu Oct 19 18:04:16 2017 (r324767) +++ stable/11/sys/dev/evdev/uinput.c Thu Oct 19 20:16:40 2017 (r324768) @@ -1,6 +1,6 @@ /*- * Copyright (c) 2014 Jakub Wojciech Klama - * Copyright (c) 2015-2016 Vladimir Kondratyev + * Copyright (c) 2015-2016 Vladimir Kondratyev * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,25 +29,24 @@ #include "opt_evdev.h" -#include -#include #include +#include #include #include +#include +#include #include -#include -#include -#include #include +#include #include -#include -#include +#include #include +#include -#include -#include #include #include +#include +#include #ifdef UINPUT_DEBUG #define debugf(state, fmt, args...) printf("uinput: " fmt "\n", ##args) Modified: stable/11/sys/dev/evdev/uinput.h ============================================================================== --- stable/11/sys/dev/evdev/uinput.h Thu Oct 19 18:04:16 2017 (r324767) +++ stable/11/sys/dev/evdev/uinput.h Thu Oct 19 20:16:40 2017 (r324768) @@ -1,6 +1,6 @@ /*- * Copyright (c) 2016 Oleksandr Tymoshenko - * Copyright (c) 2015-2016 Vladimir Kondratyev + * Copyright (c) 2015-2016 Vladimir Kondratyev * All rights reserved. * * Redistribution and use in source and binary forms, with or without From owner-svn-src-stable-11@freebsd.org Thu Oct 19 20:28:06 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8F2C1E467CC; Thu, 19 Oct 2017 20:28:06 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 49E1A7E78C; Thu, 19 Oct 2017 20:28:06 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9JKS5JN035480; Thu, 19 Oct 2017 20:28:05 GMT (envelope-from wulf@FreeBSD.org) Received: (from wulf@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9JKS4Id035470; Thu, 19 Oct 2017 20:28:04 GMT (envelope-from wulf@FreeBSD.org) Message-Id: <201710192028.v9JKS4Id035470@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: wulf set sender to wulf@FreeBSD.org using -f From: Vladimir Kondratyev Date: Thu, 19 Oct 2017 20:28:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324769 - in stable/11: share/man/man4 sys/conf sys/dev/usb sys/dev/usb/input sys/dev/usb/quirk sys/modules/usb sys/modules/usb/wmt X-SVN-Group: stable-11 X-SVN-Commit-Author: wulf X-SVN-Commit-Paths: in stable/11: share/man/man4 sys/conf sys/dev/usb sys/dev/usb/input sys/dev/usb/quirk sys/modules/usb sys/modules/usb/wmt X-SVN-Commit-Revision: 324769 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Oct 2017 20:28:06 -0000 Author: wulf Date: Thu Oct 19 20:28:04 2017 New Revision: 324769 URL: https://svnweb.freebsd.org/changeset/base/324769 Log: MFC r322695: Add support for generic MS Windows 7/8/10-compatible USB HID touchscreens found in many laptops. Reviewed by: hps, gonzo, bcr (manpages) Approved by: gonzo (mentor) Differential Revision: https://reviews.freebsd.org/D12017 Added: stable/11/share/man/man4/wmt.4 - copied unchanged from r322695, head/share/man/man4/wmt.4 stable/11/sys/dev/usb/input/wmt.c - copied unchanged from r322695, head/sys/dev/usb/input/wmt.c stable/11/sys/modules/usb/wmt/ - copied from r322695, head/sys/modules/usb/wmt/ Modified: stable/11/share/man/man4/Makefile stable/11/share/man/man4/usb_quirk.4 stable/11/sys/conf/files stable/11/sys/dev/usb/quirk/usb_quirk.c stable/11/sys/dev/usb/quirk/usb_quirk.h stable/11/sys/dev/usb/usb_hid.c stable/11/sys/dev/usb/usbhid.h stable/11/sys/modules/usb/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/share/man/man4/Makefile ============================================================================== --- stable/11/share/man/man4/Makefile Thu Oct 19 20:16:40 2017 (r324768) +++ stable/11/share/man/man4/Makefile Thu Oct 19 20:28:04 2017 (r324769) @@ -580,6 +580,7 @@ MAN= aac.4 \ wlan_tkip.4 \ wlan_wep.4 \ wlan_xauth.4 \ + wmt.4 \ ${_wpi.4} \ wsp.4 \ xe.4 \ Modified: stable/11/share/man/man4/usb_quirk.4 ============================================================================== --- stable/11/share/man/man4/usb_quirk.4 Thu Oct 19 20:16:40 2017 (r324768) +++ stable/11/share/man/man4/usb_quirk.4 Thu Oct 19 20:28:04 2017 (r324769) @@ -16,7 +16,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 17, 2017 +.Dd August 19, 2017 .Dt USB_QUIRK 4 .Os .Sh NAME @@ -98,6 +98,8 @@ select configuration index 4 by default select configuration index 0 by default .It UQ_ASSUME_CM_OVER_DATA assume cm over data feature +.It UQ_WMT_IGNORE +device should be ignored by wmt driver .El .Sh USB Mass Storage quirks: .Bl -tag -width Ds Copied: stable/11/share/man/man4/wmt.4 (from r322695, head/share/man/man4/wmt.4) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/share/man/man4/wmt.4 Thu Oct 19 20:28:04 2017 (r324769, copy of r322695, head/share/man/man4/wmt.4) @@ -0,0 +1,84 @@ +.\" Copyright (c) 2014-2017 Vladimir Kondratyev +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd August 19, 2017 +.Dt WMT 4 +.Os +.Sh NAME +.Nm wmt +.Nd MS Windows 7/8/10 - compatible USB HID multi-touch device driver +.Sh SYNOPSIS +To compile this driver into the kernel, place the following lines into +your kernel configuration file: +.Bd -ragged -offset indent +.Cd "device wmt" +.Cd "device usb" +.Cd "device evdev" +.Ed +.Pp +Alternatively, to load the driver as a +module at boot time, place the following line in +.Xr loader.conf 5 : +.Bd -literal -offset indent +wmt_load="YES" +.Ed +.Sh DESCRIPTION +The +.Nm +driver provides support for the MS Windows 7/8/10 - compatible USB HID +multi-touch devices found in many laptops. +.Pp +To get multi-touch device working in +.Xr X 7 , +install +.Pa ports/x11-drivers/xf86-input-evdev . +.Sh FILES +.Nm +creates a pseudo-device file, +.Pa /dev/input/eventX +which presents the multi-touch device as an input event device. +.Sh SEE ALSO +.Xr usb 4 , +.Xr loader.conf 5 , +.Xr xorg.conf 5 Pq Pa ports/x11/xorg , +.Xr evdev 4 Pq Pa ports/x11-drivers/xf86-input-evdev . +.Sh AUTHORS +.An -nosplit +The +.Nm +driver was written by +.An Vladimir Kondratyev Aq Mt wulf@FreeBSD.org . +.Sh BUGS +.Nm +works only with touchscreens now. +Neither pens nor touchpads are supported. +.Pp +.Nm +cannot act like +.Xr sysmouse 4 , +as +.Xr sysmouse 4 +does not support absolute motion events. Modified: stable/11/sys/conf/files ============================================================================== --- stable/11/sys/conf/files Thu Oct 19 20:16:40 2017 (r324768) +++ stable/11/sys/conf/files Thu Oct 19 20:28:04 2017 (r324769) @@ -2972,6 +2972,7 @@ dev/usb/input/uep.c optional uep dev/usb/input/uhid.c optional uhid dev/usb/input/ukbd.c optional ukbd dev/usb/input/ums.c optional ums +dev/usb/input/wmt.c optional wmt dev/usb/input/wsp.c optional wsp # # USB quirks Copied: stable/11/sys/dev/usb/input/wmt.c (from r322695, head/sys/dev/usb/input/wmt.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/sys/dev/usb/input/wmt.c Thu Oct 19 20:28:04 2017 (r324769, copy of r322695, head/sys/dev/usb/input/wmt.c) @@ -0,0 +1,729 @@ +/*- + * Copyright (c) 2014-2017 Vladimir Kondratyev + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +/* + * MS Windows 7/8/10 compatible USB HID Multi-touch Device driver. + * https://msdn.microsoft.com/en-us/library/windows/hardware/jj151569(v=vs.85).aspx + * https://www.kernel.org/doc/Documentation/input/multi-touch-protocol.txt + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "usbdevs.h" +#include +#include +#include +#include + +#include + +#include +#include + +#define USB_DEBUG_VAR wmt_debug +#include + +#ifdef USB_DEBUG +static int wmt_debug = 0; + +static SYSCTL_NODE(_hw_usb, OID_AUTO, wmt, CTLFLAG_RW, 0, + "USB MSWindows 7/8/10 compatible Multi-touch Device"); +SYSCTL_INT(_hw_usb_wmt, OID_AUTO, debug, CTLFLAG_RWTUN, + &wmt_debug, 1, "Debug level"); +#endif + +#define WMT_BSIZE 1024 /* bytes, buffer size */ + +enum { + WMT_INTR_DT, + WMT_N_TRANSFER, +}; + +enum { + WMT_TIP_SWITCH, +#define WMT_SLOT WMT_TIP_SWITCH + WMT_WIDTH, +#define WMT_MAJOR WMT_WIDTH + WMT_HEIGHT, +#define WMT_MINOR WMT_HEIGHT + WMT_ORIENTATION, + WMT_X, + WMT_Y, + WMT_CONTACTID, + WMT_PRESSURE, + WMT_IN_RANGE, + WMT_CONFIDENCE, + WMT_TOOL_X, + WMT_TOOL_Y, + WMT_N_USAGES, +}; + +#define WMT_NO_CODE (ABS_MAX + 10) +#define WMT_NO_USAGE -1 + +struct wmt_hid_map_item { + char name[5]; + int32_t usage; /* HID usage */ + uint32_t code; /* Evdev event code */ + bool required; /* Required for MT Digitizers */ +}; + +static const struct wmt_hid_map_item wmt_hid_map[WMT_N_USAGES] = { + + [WMT_TIP_SWITCH] = { /* WMT_SLOT */ + .name = "TIP", + .usage = HID_USAGE2(HUP_DIGITIZERS, HUD_TIP_SWITCH), + .code = ABS_MT_SLOT, + .required = true, + }, + [WMT_WIDTH] = { /* WMT_MAJOR */ + .name = "WDTH", + .usage = HID_USAGE2(HUP_DIGITIZERS, HUD_WIDTH), + .code = ABS_MT_TOUCH_MAJOR, + .required = false, + }, + [WMT_HEIGHT] = { /* WMT_MINOR */ + .name = "HGHT", + .usage = HID_USAGE2(HUP_DIGITIZERS, HUD_HEIGHT), + .code = ABS_MT_TOUCH_MINOR, + .required = false, + }, + [WMT_ORIENTATION] = { + .name = "ORIE", + .usage = WMT_NO_USAGE, + .code = ABS_MT_ORIENTATION, + .required = false, + }, + [WMT_X] = { + .name = "X", + .usage = HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_X), + .code = ABS_MT_POSITION_X, + .required = true, + }, + [WMT_Y] = { + .name = "Y", + .usage = HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_Y), + .code = ABS_MT_POSITION_Y, + .required = true, + }, + [WMT_CONTACTID] = { + .name = "C_ID", + .usage = HID_USAGE2(HUP_DIGITIZERS, HUD_CONTACTID), + .code = ABS_MT_TRACKING_ID, + .required = true, + }, + [WMT_PRESSURE] = { + .name = "PRES", + .usage = HID_USAGE2(HUP_DIGITIZERS, HUD_TIP_PRESSURE), + .code = ABS_MT_PRESSURE, + .required = false, + }, + [WMT_IN_RANGE] = { + .name = "RANG", + .usage = HID_USAGE2(HUP_DIGITIZERS, HUD_IN_RANGE), + .code = ABS_MT_DISTANCE, + .required = false, + }, + [WMT_CONFIDENCE] = { + .name = "CONF", + .usage = HID_USAGE2(HUP_DIGITIZERS, HUD_CONFIDENCE), + .code = WMT_NO_CODE, + .required = false, + }, + [WMT_TOOL_X] = { /* Shares HID usage with WMT_X */ + .name = "TL_X", + .usage = HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_X), + .code = ABS_MT_TOOL_X, + .required = false, + }, + [WMT_TOOL_Y] = { /* Shares HID usage with WMT_Y */ + .name = "TL_Y", + .usage = HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_Y), + .code = ABS_MT_TOOL_Y, + .required = false, + }, +}; + +struct wmt_absinfo { + int32_t min; + int32_t max; + int32_t res; +}; + +struct wmt_softc +{ + device_t dev; + struct mtx mtx; + struct wmt_absinfo ai[WMT_N_USAGES]; + struct hid_location locs[MAX_MT_SLOTS][WMT_N_USAGES]; + struct hid_location nconts_loc; + + struct usb_xfer *xfer[WMT_N_TRANSFER]; + struct evdev_dev *evdev; + + uint32_t slot_data[WMT_N_USAGES]; + uint32_t caps; + uint32_t isize; + uint32_t nconts_max; + uint8_t report_id; + + uint8_t buf[WMT_BSIZE] __aligned(4); +}; + +#define USAGE_SUPPORTED(caps, usage) ((caps) & (1 << (usage))) +#define WMT_FOREACH_USAGE(caps, usage) \ + for ((usage) = 0; (usage) < WMT_N_USAGES; ++(usage)) \ + if (USAGE_SUPPORTED((caps), (usage))) + +static bool wmt_hid_parse(struct wmt_softc *, const void *, uint16_t); + +static usb_callback_t wmt_intr_callback; + +static device_probe_t wmt_probe; +static device_attach_t wmt_attach; +static device_detach_t wmt_detach; + +static evdev_open_t wmt_ev_open; +static evdev_close_t wmt_ev_close; + +static const struct evdev_methods wmt_evdev_methods = { + .ev_open = &wmt_ev_open, + .ev_close = &wmt_ev_close, +}; + +static const struct usb_config wmt_config[WMT_N_TRANSFER] = { + + [WMT_INTR_DT] = { + .type = UE_INTERRUPT, + .endpoint = UE_ADDR_ANY, + .direction = UE_DIR_IN, + .flags = { .pipe_bof = 1, .short_xfer_ok = 1 }, + .bufsize = WMT_BSIZE, + .callback = &wmt_intr_callback, + }, +}; + +static int +wmt_probe(device_t dev) +{ + struct usb_attach_arg *uaa = device_get_ivars(dev); + void *d_ptr; + uint16_t d_len; + int err; + + if (uaa->usb_mode != USB_MODE_HOST) + return (ENXIO); + + if (uaa->info.bInterfaceClass != UICLASS_HID) + return (ENXIO); + + if (usb_test_quirk(uaa, UQ_WMT_IGNORE)) + return (ENXIO); + + err = usbd_req_get_hid_desc(uaa->device, NULL, + &d_ptr, &d_len, M_TEMP, uaa->info.bIfaceIndex); + if (err) + return (ENXIO); + + if (wmt_hid_parse(NULL, d_ptr, d_len)) + err = BUS_PROBE_DEFAULT; + else + err = ENXIO; + + free(d_ptr, M_TEMP); + return (err); +} + +static int +wmt_attach(device_t dev) +{ + struct usb_attach_arg *uaa = device_get_ivars(dev); + struct wmt_softc *sc = device_get_softc(dev); + void *d_ptr; + uint16_t d_len; + size_t i; + int err; + + device_set_usb_desc(dev); + sc->dev = dev; + + /* Get HID descriptor */ + err = usbd_req_get_hid_desc(uaa->device, NULL, + &d_ptr, &d_len, M_TEMP, uaa->info.bIfaceIndex); + if (err) { + DPRINTF("usbd_req_get_hid_desc error=%s\n", usbd_errstr(err)); + return (ENXIO); + } + + mtx_init(&sc->mtx, "wmt lock", NULL, MTX_DEF); + + /* Get HID report length */ + sc->isize = hid_report_size(d_ptr, d_len, hid_input, NULL); + if (sc->isize <= 0 || sc->isize > WMT_BSIZE) { + DPRINTF("Input size invalid or too large: %d\n", sc->isize); + goto detach; + } + + err = usbd_transfer_setup(uaa->device, &uaa->info.bIfaceIndex, + sc->xfer, wmt_config, WMT_N_TRANSFER, sc, &sc->mtx); + if (err) { + DPRINTF("usbd_transfer_setup error=%s\n", usbd_errstr(err)); + goto detach; + } + + if (!wmt_hid_parse(sc, d_ptr, d_len)) + goto detach; + + sc->evdev = evdev_alloc(); + evdev_set_name(sc->evdev, device_get_desc(dev)); + evdev_set_phys(sc->evdev, device_get_nameunit(dev)); + evdev_set_id(sc->evdev, BUS_USB, uaa->info.idVendor, + uaa->info.idProduct, 0); + evdev_set_serial(sc->evdev, usb_get_serial(uaa->device)); + evdev_set_methods(sc->evdev, sc, &wmt_evdev_methods); + evdev_set_flag(sc->evdev, EVDEV_FLAG_MT_STCOMPAT); + evdev_support_prop(sc->evdev, INPUT_PROP_DIRECT); + evdev_support_event(sc->evdev, EV_SYN); + evdev_support_event(sc->evdev, EV_ABS); + WMT_FOREACH_USAGE(sc->caps, i) { + if (wmt_hid_map[i].code != WMT_NO_CODE) + evdev_support_abs(sc->evdev, wmt_hid_map[i].code, 0, + sc->ai[i].min, sc->ai[i].max, 0, 0, sc->ai[i].res); + } + + err = evdev_register_mtx(sc->evdev, &sc->mtx); + if (err) + goto detach; + + return (0); + +detach: + free(d_ptr, M_TEMP); + wmt_detach(dev); + return (ENXIO); +} + +static int +wmt_detach(device_t dev) +{ + struct wmt_softc *sc = device_get_softc(dev); + + evdev_free(sc->evdev); + usbd_transfer_unsetup(sc->xfer, WMT_N_TRANSFER); + mtx_destroy(&sc->mtx); + return (0); +} + +static void +wmt_process_report(struct wmt_softc *sc, uint8_t *buf, int len) +{ + size_t usage; + uint32_t *slot_data = sc->slot_data; + uint32_t cont; + uint32_t nconts; + uint32_t width; + uint32_t height; + int32_t slot; + + nconts = hid_get_data_unsigned(buf, len, &sc->nconts_loc); + +#ifdef USB_DEBUG + DPRINTFN(6, "nconts = %u ", (unsigned)nconts); + if (wmt_debug >= 6) { + WMT_FOREACH_USAGE(sc->caps, usage) { + if (wmt_hid_map[usage].usage != WMT_NO_USAGE) + printf(" %-4s", wmt_hid_map[usage].name); + } + printf("\n"); + } +#endif + + if (nconts > sc->nconts_max) { + DPRINTF("Contact count overflow %u\n", (unsigned)nconts); + nconts = sc->nconts_max; + } + + /* Use protocol Type B for reporting events */ + for (cont = 0; cont < nconts; cont++) { + + bzero(slot_data, sizeof(sc->slot_data)); + WMT_FOREACH_USAGE(sc->caps, usage) { + if (sc->locs[cont][usage].size > 0) + slot_data[usage] = hid_get_data_unsigned( + buf, len, &sc->locs[cont][usage]); + } + + slot = evdev_get_mt_slot_by_tracking_id(sc->evdev, + slot_data[WMT_CONTACTID]); + +#ifdef USB_DEBUG + DPRINTFN(6, "cont%01x: data = ", cont); + if (wmt_debug >= 6) { + WMT_FOREACH_USAGE(sc->caps, usage) { + if (wmt_hid_map[usage].usage != WMT_NO_USAGE) + printf("%04x ", slot_data[usage]); + } + printf("slot = %d\n", (int)slot); + } +#endif + + if (slot == -1) { + DPRINTF("Slot overflow for contact_id %u\n", + (unsigned)slot_data[WMT_CONTACTID]); + continue; + } + + if (slot_data[WMT_TIP_SWITCH] != 0 && + !(USAGE_SUPPORTED(sc->caps, WMT_CONFIDENCE) && + slot_data[WMT_CONFIDENCE] == 0)) { + /* This finger is in proximity of the sensor */ + slot_data[WMT_SLOT] = slot; + slot_data[WMT_IN_RANGE] = !slot_data[WMT_IN_RANGE]; + /* Divided by two to match visual scale of touch */ + width = slot_data[WMT_WIDTH] >> 1; + height = slot_data[WMT_HEIGHT] >> 1; + slot_data[WMT_ORIENTATION] = width > height; + slot_data[WMT_MAJOR] = MAX(width, height); + slot_data[WMT_MINOR] = MIN(width, height); + + WMT_FOREACH_USAGE(sc->caps, usage) + if (wmt_hid_map[usage].code != WMT_NO_CODE) + evdev_push_abs(sc->evdev, + wmt_hid_map[usage].code, + slot_data[usage]); + } else { + evdev_push_abs(sc->evdev, ABS_MT_SLOT, slot); + evdev_push_abs(sc->evdev, ABS_MT_TRACKING_ID, -1); + } + } + evdev_sync(sc->evdev); +} + +static void +wmt_intr_callback(struct usb_xfer *xfer, usb_error_t error) +{ + struct wmt_softc *sc = usbd_xfer_softc(xfer); + struct usb_page_cache *pc; + uint8_t *buf = sc->buf; + int len; + + usbd_xfer_status(xfer, &len, NULL, NULL, NULL); + + switch (USB_GET_STATE(xfer)) { + case USB_ST_TRANSFERRED: + pc = usbd_xfer_get_frame(xfer, 0); + + DPRINTFN(6, "sc=%p actlen=%d\n", sc, len); + + if (len >= (int)sc->isize || (len > 0 && sc->report_id != 0)) { + /* Limit report length to the maximum */ + if (len > (int)sc->isize) + len = sc->isize; + + usbd_copy_out(pc, 0, buf, len); + + /* Ignore irrelevant reports */ + if (sc->report_id && *buf != sc->report_id) + goto tr_ignore; + + /* Make sure we don't process old data */ + if (len < sc->isize) + bzero(buf + len, sc->isize - len); + + /* Strip leading "report ID" byte */ + if (sc->report_id) { + len--; + buf++; + } + + wmt_process_report(sc, buf, len); + } else { +tr_ignore: + DPRINTF("Ignored transfer, %d bytes\n", len); + } + + case USB_ST_SETUP: +tr_setup: + usbd_xfer_set_frame_len(xfer, 0, sc->isize); + usbd_transfer_submit(xfer); + break; + default: + if (error != USB_ERR_CANCELLED) { + /* Try clear stall first */ + usbd_xfer_set_stall(xfer); + goto tr_setup; + } + break; + } +} + +static void +wmt_ev_close(struct evdev_dev *evdev, void *ev_softc) +{ + struct wmt_softc *sc = (struct wmt_softc *)ev_softc; + + mtx_assert(&sc->mtx, MA_OWNED); + usbd_transfer_stop(sc->xfer[WMT_INTR_DT]); +} + +static int +wmt_ev_open(struct evdev_dev *evdev, void *ev_softc) +{ + struct wmt_softc *sc = (struct wmt_softc *)ev_softc; + + mtx_assert(&sc->mtx, MA_OWNED); + usbd_transfer_start(sc->xfer[WMT_INTR_DT]); + + return (0); +} + +static bool +wmt_hid_parse(struct wmt_softc *sc, const void *d_ptr, uint16_t d_len) +{ + struct hid_item hi; + struct hid_data *hd; + size_t i; + size_t cont = 0; + uint32_t caps = 0; + int32_t cont_count_max = 0; + uint8_t report_id = 0; + bool touch_coll = false; + bool finger_coll = false; + bool cont_count_found = false; + bool scan_time_found = false; + +#define WMT_HI_ABSOLUTE(hi) \ + (((hi).flags & (HIO_CONST|HIO_VARIABLE|HIO_RELATIVE)) == HIO_VARIABLE) + + /* Parse features for maximum contact count */ + hd = hid_start_parse(d_ptr, d_len, 1 << hid_feature); + while (hid_get_item(hd, &hi)) { + switch (hi.kind) { + case hid_collection: + if (hi.collevel == 1 && hi.usage == + HID_USAGE2(HUP_DIGITIZERS, HUD_TOUCHSCREEN)) + touch_coll = true; + break; + case hid_endcollection: + if (hi.collevel == 0 && touch_coll) + touch_coll = false; + break; + case hid_feature: + if (hi.collevel == 1 && touch_coll && + WMT_HI_ABSOLUTE(hi) && hi.usage == + HID_USAGE2(HUP_DIGITIZERS, HUD_CONTACT_MAX)) + cont_count_max = hi.logical_maximum; + break; + default: + break; + } + } + hid_end_parse(hd); + + /* Maximum contact count is required usage */ + if (cont_count_max < 1) + return (false); + + touch_coll = false; + + /* Parse input for other parameters */ + hd = hid_start_parse(d_ptr, d_len, 1 << hid_input); + while (hid_get_item(hd, &hi)) { + switch (hi.kind) { + case hid_collection: + if (hi.collevel == 1 && hi.usage == + HID_USAGE2(HUP_DIGITIZERS, HUD_TOUCHSCREEN)) + touch_coll = true; + else if (touch_coll && hi.collevel == 2 && + (report_id == 0 || report_id == hi.report_ID) && + hi.usage == HID_USAGE2(HUP_DIGITIZERS, HUD_FINGER)) + finger_coll = true; + break; + case hid_endcollection: + if (hi.collevel == 1 && finger_coll) { + finger_coll = false; + cont++; + } else if (hi.collevel == 0 && touch_coll) + touch_coll = false; + break; + case hid_input: + /* + * Ensure that all usages are located within the same + * report and proper collection. + */ + if (WMT_HI_ABSOLUTE(hi) && touch_coll && + (report_id == 0 || report_id == hi.report_ID)) + report_id = hi.report_ID; + else + break; + + if (hi.collevel == 1 && hi.usage == + HID_USAGE2(HUP_DIGITIZERS, HUD_CONTACTCOUNT)) { + cont_count_found = true; + if (sc != NULL) + sc->nconts_loc = hi.loc; + break; + } + /* Scan time is required but clobbered by evdev */ + if (hi.collevel == 1 && hi.usage == + HID_USAGE2(HUP_DIGITIZERS, HUD_SCAN_TIME)) { + scan_time_found = true; + break; + } + + if (!finger_coll || hi.collevel != 2) + break; + if (sc == NULL && cont > 0) + break; + if (cont >= MAX_MT_SLOTS) { + DPRINTF("Finger %zu ignored\n", cont); + break; + } + + for (i = 0; i < WMT_N_USAGES; i++) { + if (hi.usage == wmt_hid_map[i].usage) { + if (sc == NULL) { + if (USAGE_SUPPORTED(caps, i)) + continue; + caps |= 1 << i; + break; + } + /* + * HUG_X usage is an array mapped to + * both ABS_MT_POSITION and ABS_MT_TOOL + * events. So don`t stop search if we + * already have HUG_X mapping done. + */ + if (sc->locs[cont][i].size) + continue; + sc->locs[cont][i] = hi.loc; + /* + * Hid parser returns valid logical and + * physical sizes for first finger only + * at least on ElanTS 0x04f3:0x0012. + */ + if (cont > 0) + break; + caps |= 1 << i; + sc->ai[i] = (struct wmt_absinfo) { + .max = hi.logical_maximum, + .min = hi.logical_minimum, + .res = hid_item_resolution(&hi), + }; + break; + } + } + break; + default: + break; + } + } + hid_end_parse(hd); + + /* Check for required HID Usages */ + if (!cont_count_found || !scan_time_found || cont == 0) + return (false); + for (i = 0; i < WMT_N_USAGES; i++) { + if (wmt_hid_map[i].required && !USAGE_SUPPORTED(caps, i)) + return (false); + } + + /* Stop probing here */ + if (sc == NULL) + return (true); + + /* Cap contact count maximum to MAX_MT_SLOTS */ + if (cont_count_max > MAX_MT_SLOTS) { + DPRINTF("Hardware reported %d contacts while only %d is " + "supported\n", (int)cont_count_max, MAX_MT_SLOTS); + cont_count_max = MAX_MT_SLOTS; + } + + /* Set number of MT protocol type B slots */ + sc->ai[WMT_SLOT] = (struct wmt_absinfo) { + .min = 0, + .max = cont_count_max - 1, + .res = 0, + }; + + /* Report touch orientation if both width and height are supported */ + if (USAGE_SUPPORTED(caps, WMT_WIDTH) && + USAGE_SUPPORTED(caps, WMT_HEIGHT)) { + caps |= (1 << WMT_ORIENTATION); + sc->ai[WMT_ORIENTATION].max = 1; + } + + sc->report_id = report_id; + sc->caps = caps; + sc->nconts_max = cont; + + /* Announce information about the touch device */ + device_printf(sc->dev, + "%d contacts and [%s%s%s%s%s]. Report range [%d:%d] - [%d:%d]\n", + (int)cont_count_max, + USAGE_SUPPORTED(sc->caps, WMT_IN_RANGE) ? "R" : "", + USAGE_SUPPORTED(sc->caps, WMT_CONFIDENCE) ? "C" : "", + USAGE_SUPPORTED(sc->caps, WMT_WIDTH) ? "W" : "", + USAGE_SUPPORTED(sc->caps, WMT_HEIGHT) ? "H" : "", + USAGE_SUPPORTED(sc->caps, WMT_PRESSURE) ? "P" : "", + (int)sc->ai[WMT_X].min, (int)sc->ai[WMT_Y].min, + (int)sc->ai[WMT_X].max, (int)sc->ai[WMT_Y].max); + return (true); +} + +static devclass_t wmt_devclass; + +static device_method_t wmt_methods[] = { + DEVMETHOD(device_probe, wmt_probe), + DEVMETHOD(device_attach, wmt_attach), + DEVMETHOD(device_detach, wmt_detach), + + DEVMETHOD_END +}; + +static driver_t wmt_driver = { + .name = "wmt", + .methods = wmt_methods, + .size = sizeof(struct wmt_softc), +}; + +DRIVER_MODULE(wmt, uhub, wmt_driver, wmt_devclass, NULL, 0); +MODULE_DEPEND(wmt, usb, 1, 1, 1); +MODULE_DEPEND(wmt, evdev, 1, 1, 1); +MODULE_VERSION(wmt, 1); Modified: stable/11/sys/dev/usb/quirk/usb_quirk.c ============================================================================== --- stable/11/sys/dev/usb/quirk/usb_quirk.c Thu Oct 19 20:16:40 2017 (r324768) +++ stable/11/sys/dev/usb/quirk/usb_quirk.c Thu Oct 19 20:28:04 2017 (r324769) @@ -609,6 +609,7 @@ static const char *usb_quirk_str[USB_QUIRK_MAX] = { [UQ_SINGLE_CMD_MIDI] = "UQ_SINGLE_CMD_MIDI", [UQ_MSC_DYMO_EJECT] = "UQ_MSC_DYMO_EJECT", [UQ_AU_SET_SPDIF_CM6206] = "UQ_AU_SET_SPDIF_CM6206", + [UQ_WMT_IGNORE] = "UQ_WMT_IGNORE", }; /*------------------------------------------------------------------------* Modified: stable/11/sys/dev/usb/quirk/usb_quirk.h ============================================================================== --- stable/11/sys/dev/usb/quirk/usb_quirk.h Thu Oct 19 20:16:40 2017 (r324768) +++ stable/11/sys/dev/usb/quirk/usb_quirk.h Thu Oct 19 20:28:04 2017 (r324769) @@ -110,6 +110,7 @@ enum { UQ_SINGLE_CMD_MIDI, /* at most one command per USB packet */ UQ_MSC_DYMO_EJECT, /* ejects Dymo MSC device */ UQ_AU_SET_SPDIF_CM6206, /* enable S/PDIF audio output */ + UQ_WMT_IGNORE, /* device should be ignored by wmt driver */ USB_QUIRK_MAX }; Modified: stable/11/sys/dev/usb/usb_hid.c ============================================================================== --- stable/11/sys/dev/usb/usb_hid.c Thu Oct 19 20:16:40 2017 (r324768) +++ stable/11/sys/dev/usb/usb_hid.c Thu Oct 19 20:28:04 2017 (r324769) @@ -849,6 +849,80 @@ usbd_req_get_hid_desc(struct usb_device *udev, struct } /*------------------------------------------------------------------------* + * calculate HID item resolution. unit/mm for distances, unit/rad for angles + *------------------------------------------------------------------------*/ +int32_t +hid_item_resolution(struct hid_item *hi) +{ + /* + * hid unit scaling table according to HID Usage Table Review + * Request 39 Tbl 17 http://www.usb.org/developers/hidpage/HUTRR39b.pdf + */ + static const int64_t scale[0x10][2] = { + [0x00] = { 1, 1 }, + [0x01] = { 1, 10 }, + [0x02] = { 1, 100 }, + [0x03] = { 1, 1000 }, + [0x04] = { 1, 10000 }, + [0x05] = { 1, 100000 }, + [0x06] = { 1, 1000000 }, + [0x07] = { 1, 10000000 }, + [0x08] = { 100000000, 1 }, + [0x09] = { 10000000, 1 }, + [0x0A] = { 1000000, 1 }, + [0x0B] = { 100000, 1 }, + [0x0C] = { 10000, 1 }, + [0x0D] = { 1000, 1 }, + [0x0E] = { 100, 1 }, + [0x0F] = { 10, 1 }, + }; + int64_t logical_size; + int64_t physical_size; + int64_t multiplier; + int64_t divisor; + int64_t resolution; + + switch (hi->unit) { + case HUM_CENTIMETER: + multiplier = 1; + divisor = 10; + break; + case HUM_INCH: + multiplier = 10; + divisor = 254; + break; + case HUM_RADIAN: + multiplier = 1; + divisor = 1; + break; + case HUM_DEGREE: + multiplier = 573; + divisor = 10; + break; + default: + return (0); + } + + if ((hi->logical_maximum <= hi->logical_minimum) || + (hi->physical_maximum <= hi->physical_minimum) || + (hi->unit_exponent < 0) || (hi->unit_exponent >= nitems(scale))) + return (0); + + logical_size = (int64_t)hi->logical_maximum - + (int64_t)hi->logical_minimum; + physical_size = (int64_t)hi->physical_maximum - + (int64_t)hi->physical_minimum; + /* Round to ceiling */ + resolution = logical_size * multiplier * scale[hi->unit_exponent][0] / + (physical_size * divisor * scale[hi->unit_exponent][1]); + + if (resolution > INT32_MAX) + return (0); + + return (resolution); +} + +/*------------------------------------------------------------------------* * hid_is_mouse * * This function will decide if a USB descriptor belongs to a USB mouse. Modified: stable/11/sys/dev/usb/usbhid.h ============================================================================== --- stable/11/sys/dev/usb/usbhid.h Thu Oct 19 20:16:40 2017 (r324768) +++ stable/11/sys/dev/usb/usbhid.h Thu Oct 19 20:28:04 2017 (r324769) @@ -134,6 +134,12 @@ struct usb_hid_descriptor { /* Usages Digitizers */ #define HUD_UNDEFINED 0x0000 +#define HUD_DIGITIZER 0x0001 +#define HUD_PEN 0x0002 +#define HUD_TOUCHSCREEN 0x0004 +#define HUD_TOUCHPAD 0x0005 +#define HUD_CONFIG 0x000e +#define HUD_FINGER 0x0022 #define HUD_TIP_PRESSURE 0x0030 #define HUD_BARREL_PRESSURE 0x0031 #define HUD_IN_RANGE 0x0032 @@ -157,6 +163,16 @@ struct usb_hid_descriptor { #define HUD_BARREL_SWITCH 0x0044 #define HUD_ERASER 0x0045 #define HUD_TABLET_PICK 0x0046 +#define HUD_CONFIDENCE 0x0047 +#define HUD_WIDTH 0x0048 +#define HUD_HEIGHT 0x0049 +#define HUD_CONTACTID 0x0051 +#define HUD_INPUT_MODE 0x0052 +#define HUD_DEVICE_INDEX 0x0053 +#define HUD_CONTACTCOUNT 0x0054 +#define HUD_CONTACT_MAX 0x0055 +#define HUD_SCAN_TIME 0x0056 +#define HUD_BUTTON_TYPE 0x0059 /* Usages, Consumer */ #define HUC_AC_PAN 0x0238 @@ -178,6 +194,12 @@ struct usb_hid_descriptor { #define HIO_VOLATILE 0x080 #define HIO_BUFBYTES 0x100 +/* Units of Measure */ +#define HUM_CENTIMETER 0x11 *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-11@freebsd.org Fri Oct 20 00:29:40 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E26BBE4B1FB; Fri, 20 Oct 2017 00:29:40 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B0F671551; Fri, 20 Oct 2017 00:29:40 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9K0TdKn037366; Fri, 20 Oct 2017 00:29:39 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9K0TdsI037365; Fri, 20 Oct 2017 00:29:39 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201710200029.v9K0TdsI037365@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Fri, 20 Oct 2017 00:29:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324777 - stable/11/usr.bin/truss X-SVN-Group: stable-11 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/11/usr.bin/truss X-SVN-Commit-Revision: 324777 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Oct 2017 00:29:41 -0000 Author: emaste Date: Fri Oct 20 00:29:39 2017 New Revision: 324777 URL: https://svnweb.freebsd.org/changeset/base/324777 Log: MFC r324594: truss: mention 'H' in usage r295930 (MFC of r295930) introduced the 'H' option to display thread IDs, but did not add the option to usage(). PR: 222837 Submitted by: Oliver Kiddle Modified: stable/11/usr.bin/truss/main.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/truss/main.c ============================================================================== --- stable/11/usr.bin/truss/main.c Thu Oct 19 21:57:14 2017 (r324776) +++ stable/11/usr.bin/truss/main.c Fri Oct 20 00:29:39 2017 (r324777) @@ -57,8 +57,8 @@ static void usage(void) { fprintf(stderr, "%s\n%s\n", - "usage: truss [-cfaedDS] [-o file] [-s strsize] -p pid", - " truss [-cfaedDS] [-o file] [-s strsize] command [args]"); + "usage: truss [-cfaedDHS] [-o file] [-s strsize] -p pid", + " truss [-cfaedDHS] [-o file] [-s strsize] command [args]"); exit(1); } From owner-svn-src-stable-11@freebsd.org Fri Oct 20 00:36:27 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 160C7E4B574; Fri, 20 Oct 2017 00:36:27 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D91381DCB; Fri, 20 Oct 2017 00:36:26 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9K0aQJm041541; Fri, 20 Oct 2017 00:36:26 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9K0aQIh041540; Fri, 20 Oct 2017 00:36:26 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201710200036.v9K0aQIh041540@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Fri, 20 Oct 2017 00:36:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324781 - stable/11/sys/vm X-SVN-Group: stable-11 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/11/sys/vm X-SVN-Commit-Revision: 324781 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Oct 2017 00:36:27 -0000 Author: emaste Date: Fri Oct 20 00:36:25 2017 New Revision: 324781 URL: https://svnweb.freebsd.org/changeset/base/324781 Log: MFC r324595: ANSIfy vm_kern.c PR: 222673 Submitted by: ota@j.email.ne.jp Modified: stable/11/sys/vm/vm_kern.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/vm/vm_kern.c ============================================================================== --- stable/11/sys/vm/vm_kern.c Fri Oct 20 00:34:25 2017 (r324780) +++ stable/11/sys/vm/vm_kern.c Fri Oct 20 00:36:25 2017 (r324781) @@ -121,8 +121,7 @@ SYSCTL_ULONG(_vm, OID_AUTO, max_kernel_address, CTLFLA * a mapping on demand through vm_fault() will result in a panic. */ vm_offset_t -kva_alloc(size) - vm_size_t size; +kva_alloc(vm_size_t size) { vm_offset_t addr; @@ -143,9 +142,7 @@ kva_alloc(size) * This routine may not block on kernel maps. */ void -kva_free(addr, size) - vm_offset_t addr; - vm_size_t size; +kva_free(vm_offset_t addr, vm_size_t size) { size = round_page(size); @@ -430,9 +427,7 @@ kmem_free(struct vmem *vmem, vm_offset_t addr, vm_size * This routine may block. */ vm_offset_t -kmap_alloc_wait(map, size) - vm_map_t map; - vm_size_t size; +kmap_alloc_wait(vm_map_t map, vm_size_t size) { vm_offset_t addr; @@ -470,10 +465,7 @@ kmap_alloc_wait(map, size) * waiting for memory in that map. */ void -kmap_free_wakeup(map, addr, size) - vm_map_t map; - vm_offset_t addr; - vm_size_t size; +kmap_free_wakeup(vm_map_t map, vm_offset_t addr, vm_size_t size) { vm_map_lock(map); @@ -517,8 +509,7 @@ kmem_init_zero_region(void) * `start' as allocated, and the range between `start' and `end' as free. */ void -kmem_init(start, end) - vm_offset_t start, end; +kmem_init(vm_offset_t start, vm_offset_t end) { vm_map_t m; From owner-svn-src-stable-11@freebsd.org Fri Oct 20 07:40:13 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 48137E51E7D; Fri, 20 Oct 2017 07:40:13 +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 150656C0FD; Fri, 20 Oct 2017 07:40:13 +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 v9K7eCe4016317; Fri, 20 Oct 2017 07:40:12 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9K7eCgC016316; Fri, 20 Oct 2017 07:40:12 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201710200740.v9K7eCgC016316@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Fri, 20 Oct 2017 07:40:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324790 - stable/11/sys/netpfil/ipfw X-SVN-Group: stable-11 X-SVN-Commit-Author: ae X-SVN-Commit-Paths: stable/11/sys/netpfil/ipfw X-SVN-Commit-Revision: 324790 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Oct 2017 07:40:13 -0000 Author: ae Date: Fri Oct 20 07:40:11 2017 New Revision: 324790 URL: https://svnweb.freebsd.org/changeset/base/324790 Log: MFC r324593: Fix regression in handling O_FORWARD_IP opcode after r279948. To properly handle 'fwd tablearg,port' opcode, copy sin_port value from sockaddr_in structure stored in the opcode into corresponding hopstore field. PR: 222953 Modified: stable/11/sys/netpfil/ipfw/ip_fw2.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netpfil/ipfw/ip_fw2.c ============================================================================== --- stable/11/sys/netpfil/ipfw/ip_fw2.c Fri Oct 20 04:02:53 2017 (r324789) +++ stable/11/sys/netpfil/ipfw/ip_fw2.c Fri Oct 20 07:40:11 2017 (r324790) @@ -2442,6 +2442,7 @@ do { \ sa6->sin6_len = sizeof(*sa6); sa6->sin6_addr = TARG_VAL( chain, tablearg, nh6); + sa6->sin6_port = sa->sin_port; /* * Set sin6_scope_id only for * link-local unicast addresses. @@ -2455,6 +2456,8 @@ do { \ } else #endif { + args->hopstore.sin_port = + sa->sin_port; sa = args->next_hop = &args->hopstore; sa->sin_family = AF_INET; From owner-svn-src-stable-11@freebsd.org Fri Oct 20 07:42:01 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 868ABE52066; Fri, 20 Oct 2017 07:42:01 +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 28A356C475; Fri, 20 Oct 2017 07:42:01 +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 v9K7g0sa019337; Fri, 20 Oct 2017 07:42:00 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9K7g0Ft019336; Fri, 20 Oct 2017 07:42:00 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201710200742.v9K7g0Ft019336@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Fri, 20 Oct 2017 07:42:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324791 - stable/11/sbin/ipfw X-SVN-Group: stable-11 X-SVN-Commit-Author: ae X-SVN-Commit-Paths: stable/11/sbin/ipfw X-SVN-Commit-Revision: 324791 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Oct 2017 07:42:01 -0000 Author: ae Date: Fri Oct 20 07:42:00 2017 New Revision: 324791 URL: https://svnweb.freebsd.org/changeset/base/324791 Log: MFC r324592: Return 'errno' value from the table_do_modify_record(), it is expected by table_modify_record(). This makes quiet operations with tables really quiet. PR: 222953 Modified: stable/11/sbin/ipfw/tables.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/ipfw/tables.c ============================================================================== --- stable/11/sbin/ipfw/tables.c Fri Oct 20 07:40:11 2017 (r324790) +++ stable/11/sbin/ipfw/tables.c Fri Oct 20 07:42:00 2017 (r324791) @@ -885,6 +885,8 @@ table_do_modify_record(int cmd, ipfw_obj_header *oh, sz += sizeof(*oh); error = do_get3(cmd, &oh->opheader, &sz); + if (error != 0) + error = errno; tent = (ipfw_obj_tentry *)(ctlv + 1); /* Copy result back to provided buffer */ memcpy(tent_base, ctlv + 1, sizeof(*tent) * count); From owner-svn-src-stable-11@freebsd.org Fri Oct 20 09:21:38 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 58859E2C003; Fri, 20 Oct 2017 09:21:38 +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 24C8B6F175; Fri, 20 Oct 2017 09:21:38 +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 v9K9LbX6060632; Fri, 20 Oct 2017 09:21:37 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9K9LbJC060631; Fri, 20 Oct 2017 09:21:37 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201710200921.v9K9LbJC060631@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 20 Oct 2017 09:21:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324796 - stable/11/sys/vm X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/vm X-SVN-Commit-Revision: 324796 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Oct 2017 09:21:38 -0000 Author: kib Date: Fri Oct 20 09:21:37 2017 New Revision: 324796 URL: https://svnweb.freebsd.org/changeset/base/324796 Log: MFC r324600, r324716: Evaluate the real size of the sblk_zone. Modified: stable/11/sys/vm/swap_pager.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/vm/swap_pager.c ============================================================================== --- stable/11/sys/vm/swap_pager.c Fri Oct 20 09:10:49 2017 (r324795) +++ stable/11/sys/vm/swap_pager.c Fri Oct 20 09:21:37 2017 (r324796) @@ -540,7 +540,15 @@ swap_pager_swap_init(void) */ n -= ((n + 2) / 3); } while (n > 0); - if (n2 != n) + + /* + * Often uma_zone_reserve_kva() cannot reserve exactly the + * requested size. Account for the difference when + * calculating swap_maxpages. + */ + n = uma_zone_get_max(swblk_zone); + + if (n < n2) printf("Swap blk zone entries reduced from %lu to %lu.\n", n2, n); swap_maxpages = n * SWAP_META_PAGES; From owner-svn-src-stable-11@freebsd.org Fri Oct 20 09:59:40 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 99312E2C9FD; Fri, 20 Oct 2017 09:59:40 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 58C9F700AA; Fri, 20 Oct 2017 09:59:40 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9K9xdf2073910; Fri, 20 Oct 2017 09:59:39 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9K9xdQS073909; Fri, 20 Oct 2017 09:59:39 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201710200959.v9K9xdQS073909@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Fri, 20 Oct 2017 09:59:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324797 - stable/11/sys/dev/usb X-SVN-Group: stable-11 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/11/sys/dev/usb X-SVN-Commit-Revision: 324797 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Oct 2017 09:59:40 -0000 Author: hselasky Date: Fri Oct 20 09:59:39 2017 New Revision: 324797 URL: https://svnweb.freebsd.org/changeset/base/324797 Log: MFC r323916: Extend sysctl description for hw.usb.disable_enumeration . PR: 222505 Submitted by: Julian H. Stacey Sponsored by: Mellanox Technologies Modified: stable/11/sys/dev/usb/usb_hub.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/usb/usb_hub.c ============================================================================== --- stable/11/sys/dev/usb/usb_hub.c Fri Oct 20 09:21:37 2017 (r324796) +++ stable/11/sys/dev/usb/usb_hub.c Fri Oct 20 09:59:39 2017 (r324797) @@ -100,7 +100,9 @@ SYSCTL_INT(_hw_usb, OID_AUTO, power_timeout, CTLFLAG_R #if USB_HAVE_DISABLE_ENUM static int usb_disable_enumeration = 0; SYSCTL_INT(_hw_usb, OID_AUTO, disable_enumeration, CTLFLAG_RWTUN, - &usb_disable_enumeration, 0, "Set to disable all USB device enumeration."); + &usb_disable_enumeration, 0, "Set to disable all USB device enumeration. " + "This can secure against USB devices turning evil, " + "for example a USB memory stick becoming a USB keyboard."); static int usb_disable_port_power = 0; SYSCTL_INT(_hw_usb, OID_AUTO, disable_port_power, CTLFLAG_RWTUN, From owner-svn-src-stable-11@freebsd.org Fri Oct 20 10:04:44 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AABB8E2CDC5; Fri, 20 Oct 2017 10:04:44 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 765A1705F1; Fri, 20 Oct 2017 10:04:44 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9KA4hAu078079; Fri, 20 Oct 2017 10:04:43 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9KA4ha3078078; Fri, 20 Oct 2017 10:04:43 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201710201004.v9KA4ha3078078@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Fri, 20 Oct 2017 10:04:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324799 - stable/11/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/11/sys/kern X-SVN-Commit-Revision: 324799 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Oct 2017 10:04:44 -0000 Author: hselasky Date: Fri Oct 20 10:04:43 2017 New Revision: 324799 URL: https://svnweb.freebsd.org/changeset/base/324799 Log: MFC r324445: When showing the sleepqueues from the in-kernel debugger, properly dump all the sleepqueues and not just the first one History: It appears that in the commit which introduced the code, r165272, the array indexes of "sq_blocked[0]" and "td_name[i]" were interchanged. In r180927 "td_name[i]" was corrected to "td_name[0]", but "sq_blocked[0]" was left unchanged. PR: 222624 Discussed with: kmacy @ Sponsored by: Mellanox Technologies Modified: stable/11/sys/kern/subr_sleepqueue.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/subr_sleepqueue.c ============================================================================== --- stable/11/sys/kern/subr_sleepqueue.c Fri Oct 20 10:01:21 2017 (r324798) +++ stable/11/sys/kern/subr_sleepqueue.c Fri Oct 20 10:04:43 2017 (r324799) @@ -1435,7 +1435,7 @@ found: if (TAILQ_EMPTY(&sq->sq_blocked[i])) db_printf("\tempty\n"); else - TAILQ_FOREACH(td, &sq->sq_blocked[0], + TAILQ_FOREACH(td, &sq->sq_blocked[i], td_slpq) { db_printf("\t%p (tid %d, pid %d, \"%s\")\n", td, td->td_tid, td->td_proc->p_pid, From owner-svn-src-stable-11@freebsd.org Sat Oct 21 10:21:35 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9E2F8E52AC7; Sat, 21 Oct 2017 10:21:35 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5FB617F215; Sat, 21 Oct 2017 10:21:35 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9LALYwE091252; Sat, 21 Oct 2017 10:21:34 GMT (envelope-from avos@FreeBSD.org) Received: (from avos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9LALYoh091251; Sat, 21 Oct 2017 10:21:34 GMT (envelope-from avos@FreeBSD.org) Message-Id: <201710211021.v9LALYoh091251@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avos set sender to avos@FreeBSD.org using -f From: Andriy Voskoboinyk Date: Sat, 21 Oct 2017 10:21:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324812 - stable/11/sys/net X-SVN-Group: stable-11 X-SVN-Commit-Author: avos X-SVN-Commit-Paths: stable/11/sys/net X-SVN-Commit-Revision: 324812 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Oct 2017 10:21:35 -0000 Author: avos Date: Sat Oct 21 10:21:34 2017 New Revision: 324812 URL: https://svnweb.freebsd.org/changeset/base/324812 Log: MFC r324672: ifnet(9): split ifc_alloc_unit() (should simplify code flow) Allocate smallest unit number from pool via ifc_alloc_unit_next() and exact unit number (if available) via ifc_alloc_unit_specific(). While here, address possible deadlock (mentioned in PR). PR: 217401 Differential Revision: https://reviews.freebsd.org/D12551 Modified: stable/11/sys/net/if_clone.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/net/if_clone.c ============================================================================== --- stable/11/sys/net/if_clone.c Sat Oct 21 07:23:45 2017 (r324811) +++ stable/11/sys/net/if_clone.c Sat Oct 21 10:21:34 2017 (r324812) @@ -595,44 +595,56 @@ ifc_name2unit(const char *name, int *unit) return (0); } -int -ifc_alloc_unit(struct if_clone *ifc, int *unit) +static int +ifc_alloc_unit_specific(struct if_clone *ifc, int *unit) { char name[IFNAMSIZ]; - int wildcard; - wildcard = (*unit < 0); -retry: if (*unit > ifc->ifc_maxunit) return (ENOSPC); - if (*unit < 0) { - *unit = alloc_unr(ifc->ifc_unrhdr); - if (*unit == -1) - return (ENOSPC); - } else { - *unit = alloc_unr_specific(ifc->ifc_unrhdr, *unit); - if (*unit == -1) { - if (wildcard) { - (*unit)++; - goto retry; - } else - return (EEXIST); - } - } + if (alloc_unr_specific(ifc->ifc_unrhdr, *unit) == -1) + return (EEXIST); + snprintf(name, IFNAMSIZ, "%s%d", ifc->ifc_name, *unit); if (ifunit(name) != NULL) { free_unr(ifc->ifc_unrhdr, *unit); - if (wildcard) { - (*unit)++; - goto retry; - } else - return (EEXIST); + return (EEXIST); } IF_CLONE_ADDREF(ifc); return (0); +} + +static int +ifc_alloc_unit_next(struct if_clone *ifc, int *unit) +{ + int error; + + *unit = alloc_unr(ifc->ifc_unrhdr); + if (*unit == -1) + return (ENOSPC); + + free_unr(ifc->ifc_unrhdr, *unit); + for (;;) { + error = ifc_alloc_unit_specific(ifc, unit); + if (error != EEXIST) + break; + + (*unit)++; + } + + return (error); +} + +int +ifc_alloc_unit(struct if_clone *ifc, int *unit) +{ + if (*unit < 0) + return (ifc_alloc_unit_next(ifc, unit)); + else + return (ifc_alloc_unit_specific(ifc, unit)); } void From owner-svn-src-stable-11@freebsd.org Sat Oct 21 19:26:48 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 568C0E37C31; Sat, 21 Oct 2017 19:26:48 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 23E2667830; Sat, 21 Oct 2017 19:26:48 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9LJQlnd015196; Sat, 21 Oct 2017 19:26:47 GMT (envelope-from oshogbo@FreeBSD.org) Received: (from oshogbo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9LJQls7015195; Sat, 21 Oct 2017 19:26:47 GMT (envelope-from oshogbo@FreeBSD.org) Message-Id: <201710211926.v9LJQls7015195@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: oshogbo set sender to oshogbo@FreeBSD.org using -f From: Mariusz Zaborski Date: Sat, 21 Oct 2017 19:26:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324827 - stable/11/sys/contrib/libnv X-SVN-Group: stable-11 X-SVN-Commit-Author: oshogbo X-SVN-Commit-Paths: stable/11/sys/contrib/libnv X-SVN-Commit-Revision: 324827 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Oct 2017 19:26:48 -0000 Author: oshogbo Date: Sat Oct 21 19:26:47 2017 New Revision: 324827 URL: https://svnweb.freebsd.org/changeset/base/324827 Log: MFC r323859: Simplify the code by _not_ expecting success under 'fail'. Submitted by: pjd@ and oshogbo@ MFC after: 1 month Sponsored by: Wheel Systems Modified: stable/11/sys/contrib/libnv/nvpair.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/contrib/libnv/nvpair.c ============================================================================== --- stable/11/sys/contrib/libnv/nvpair.c Sat Oct 21 19:14:45 2017 (r324826) +++ stable/11/sys/contrib/libnv/nvpair.c Sat Oct 21 19:26:47 2017 (r324827) @@ -1740,7 +1740,6 @@ nvpair_move_descriptor_array(const char *name, int *va nvpair_t *nvp; size_t i; - nvp = NULL; if (value == NULL || nitems == 0) { ERRNO_SET(EINVAL); return (NULL); @@ -1755,19 +1754,20 @@ nvpair_move_descriptor_array(const char *name, int *va nvp = nvpair_allocv(name, NV_TYPE_DESCRIPTOR_ARRAY, (uint64_t)(uintptr_t)value, sizeof(value[0]) * nitems, nitems); + if (nvp == NULL) + goto fail; + return (nvp); fail: - if (nvp == NULL) { - ERRNO_SAVE(); - for (i = 0; i < nitems; i++) { - if (fd_is_valid(value[i])) - close(value[i]); - } - nv_free(value); - ERRNO_RESTORE(); + ERRNO_SAVE(); + for (i = 0; i < nitems; i++) { + if (fd_is_valid(value[i])) + close(value[i]); } + nv_free(value); + ERRNO_RESTORE(); - return (nvp); + return (NULL); } #endif From owner-svn-src-stable-11@freebsd.org Sat Oct 21 19:30:34 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 372BDE37F08; Sat, 21 Oct 2017 19:30:34 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 05A4067BB8; Sat, 21 Oct 2017 19:30:33 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9LJUXFx015388; Sat, 21 Oct 2017 19:30:33 GMT (envelope-from oshogbo@FreeBSD.org) Received: (from oshogbo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9LJUX3m015387; Sat, 21 Oct 2017 19:30:33 GMT (envelope-from oshogbo@FreeBSD.org) Message-Id: <201710211930.v9LJUX3m015387@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: oshogbo set sender to oshogbo@FreeBSD.org using -f From: Mariusz Zaborski Date: Sat, 21 Oct 2017 19:30:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324828 - stable/11/sys/contrib/libnv X-SVN-Group: stable-11 X-SVN-Commit-Author: oshogbo X-SVN-Commit-Paths: stable/11/sys/contrib/libnv X-SVN-Commit-Revision: 324828 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Oct 2017 19:30:34 -0000 Author: oshogbo Date: Sat Oct 21 19:30:33 2017 New Revision: 324828 URL: https://svnweb.freebsd.org/changeset/base/324828 Log: MFC r323852: The 'while (array != NULL) { }' suggests scan-build that array may be initially NULL, which is not possible. Change the loop to 'do {} while (array != NULL)' to satisfy scan-build and assert that array really cannot be NULL just in case. Submitted by: pjd@ Found by: scan-build MFC after: 1 month Sponsored by: Wheel Systems Modified: stable/11/sys/contrib/libnv/nvlist.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/contrib/libnv/nvlist.c ============================================================================== --- stable/11/sys/contrib/libnv/nvlist.c Sat Oct 21 19:26:47 2017 (r324827) +++ stable/11/sys/contrib/libnv/nvlist.c Sat Oct 21 19:30:33 2017 (r324828) @@ -1204,12 +1204,13 @@ nvlist_xunpack(const void *buf, size_t size, const int &array); if (ptr == NULL) goto failed; + PJDLOG_ASSERT(array != NULL); tmpnvl = array; - while (array != NULL) { + do { nvlist_set_parent(array, nvp); array = __DECONST(nvlist_t *, nvlist_get_array_next(array)); - } + } while (array != NULL); ptr = nvlist_unpack_header(tmpnvl, ptr, nfds, &isbe, &left); break; From owner-svn-src-stable-11@freebsd.org Sat Oct 21 19:32:00 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E9E74E380D1; Sat, 21 Oct 2017 19:32:00 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C2FDB67DD6; Sat, 21 Oct 2017 19:32:00 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9LJVxbt016236; Sat, 21 Oct 2017 19:31:59 GMT (envelope-from oshogbo@FreeBSD.org) Received: (from oshogbo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9LJVxfQ016234; Sat, 21 Oct 2017 19:31:59 GMT (envelope-from oshogbo@FreeBSD.org) Message-Id: <201710211931.v9LJVxfQ016234@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: oshogbo set sender to oshogbo@FreeBSD.org using -f From: Mariusz Zaborski Date: Sat, 21 Oct 2017 19:31:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324829 - stable/11/sys/contrib/libnv X-SVN-Group: stable-11 X-SVN-Commit-Author: oshogbo X-SVN-Commit-Paths: stable/11/sys/contrib/libnv X-SVN-Commit-Revision: 324829 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Oct 2017 19:32:01 -0000 Author: oshogbo Date: Sat Oct 21 19:31:59 2017 New Revision: 324829 URL: https://svnweb.freebsd.org/changeset/base/324829 Log: MFC r323853: Make the code consistent by always using 'fail' label. Submitted by: pjd@ and oshogbo@ Sponsored by: Wheel Systems Modified: stable/11/sys/contrib/libnv/nvlist.c stable/11/sys/contrib/libnv/nvpair.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/contrib/libnv/nvlist.c ============================================================================== --- stable/11/sys/contrib/libnv/nvlist.c Sat Oct 21 19:30:33 2017 (r324828) +++ stable/11/sys/contrib/libnv/nvlist.c Sat Oct 21 19:31:59 2017 (r324829) @@ -1071,24 +1071,24 @@ nvlist_unpack_header(nvlist_t *nvl, const unsigned cha int inarrayf; if (*leftp < sizeof(nvlhdr)) - goto failed; + goto fail; memcpy(&nvlhdr, ptr, sizeof(nvlhdr)); if (!nvlist_check_header(&nvlhdr)) - goto failed; + goto fail; if (nvlhdr.nvlh_size != *leftp - sizeof(nvlhdr)) - goto failed; + goto fail; /* * nvlh_descriptors might be smaller than nfds in embedded nvlists. */ if (nvlhdr.nvlh_descriptors > nfds) - goto failed; + goto fail; if ((nvlhdr.nvlh_flags & ~NV_FLAG_ALL_MASK) != 0) - goto failed; + goto fail; inarrayf = (nvl->nvl_flags & NV_FLAG_IN_ARRAY); nvl->nvl_flags = (nvlhdr.nvlh_flags & NV_FLAG_PUBLIC_MASK) | inarrayf; @@ -1099,7 +1099,7 @@ nvlist_unpack_header(nvlist_t *nvl, const unsigned cha *leftp -= sizeof(nvlhdr); return (ptr); -failed: +fail: ERRNO_SET(EINVAL); return (NULL); } @@ -1122,20 +1122,20 @@ nvlist_xunpack(const void *buf, size_t size, const int tmpnvl = array = NULL; nvl = retnvl = nvlist_create(0); if (nvl == NULL) - goto failed; + goto fail; ptr = nvlist_unpack_header(nvl, ptr, nfds, &isbe, &left); if (ptr == NULL) - goto failed; + goto fail; if (nvl->nvl_flags != flags) { ERRNO_SET(EILSEQ); - goto failed; + goto fail; } while (left > 0) { ptr = nvpair_unpack(isbe, ptr, &left, &nvp); if (ptr == NULL) - goto failed; + goto fail; switch (nvpair_type(nvp)) { case NV_TYPE_NULL: ptr = nvpair_unpack_null(isbe, nvp, ptr, &left); @@ -1153,7 +1153,7 @@ nvlist_xunpack(const void *buf, size_t size, const int ptr = nvpair_unpack_nvlist(isbe, nvp, ptr, &left, nfds, &tmpnvl); if (tmpnvl == NULL || ptr == NULL) - goto failed; + goto fail; nvlist_set_parent(tmpnvl, nvp); break; #ifndef _KERNEL @@ -1171,14 +1171,14 @@ nvlist_xunpack(const void *buf, size_t size, const int break; case NV_TYPE_NVLIST_UP: if (nvl->nvl_parent == NULL) - goto failed; + goto fail; nvl = nvpair_nvlist(nvl->nvl_parent); nvpair_free_structure(nvp); continue; case NV_TYPE_NVLIST_ARRAY_NEXT: if (nvl->nvl_array_next == NULL) { if (nvl->nvl_parent == NULL) - goto failed; + goto fail; nvl = nvpair_nvlist(nvl->nvl_parent); } else { nvl = __DECONST(nvlist_t *, @@ -1186,7 +1186,7 @@ nvlist_xunpack(const void *buf, size_t size, const int ptr = nvlist_unpack_header(nvl, ptr, nfds, &isbe, &left); if (ptr == NULL) - goto failed; + goto fail; } nvpair_free_structure(nvp); continue; @@ -1203,7 +1203,7 @@ nvlist_xunpack(const void *buf, size_t size, const int ptr = nvpair_unpack_nvlist_array(isbe, nvp, ptr, &left, &array); if (ptr == NULL) - goto failed; + goto fail; PJDLOG_ASSERT(array != NULL); tmpnvl = array; do { @@ -1218,9 +1218,9 @@ nvlist_xunpack(const void *buf, size_t size, const int PJDLOG_ABORT("Invalid type (%d).", nvpair_type(nvp)); } if (ptr == NULL) - goto failed; + goto fail; if (!nvlist_move_nvpair(nvl, nvp)) - goto failed; + goto fail; if (tmpnvl != NULL) { nvl = tmpnvl; tmpnvl = NULL; @@ -1228,7 +1228,7 @@ nvlist_xunpack(const void *buf, size_t size, const int } return (retnvl); -failed: +fail: nvlist_destroy(retnvl); return (NULL); } Modified: stable/11/sys/contrib/libnv/nvpair.c ============================================================================== --- stable/11/sys/contrib/libnv/nvpair.c Sat Oct 21 19:30:33 2017 (r324828) +++ stable/11/sys/contrib/libnv/nvpair.c Sat Oct 21 19:31:59 2017 (r324829) @@ -614,7 +614,7 @@ nvpair_unpack_header(bool isbe, nvpair_t *nvp, const u struct nvpair_header nvphdr; if (*leftp < sizeof(nvphdr)) - goto failed; + goto fail; memcpy(&nvphdr, ptr, sizeof(nvphdr)); ptr += sizeof(nvphdr); @@ -622,12 +622,12 @@ nvpair_unpack_header(bool isbe, nvpair_t *nvp, const u #if NV_TYPE_FIRST > 0 if (nvphdr.nvph_type < NV_TYPE_FIRST) - goto failed; + goto fail; #endif if (nvphdr.nvph_type > NV_TYPE_LAST && nvphdr.nvph_type != NV_TYPE_NVLIST_UP && nvphdr.nvph_type != NV_TYPE_NVLIST_ARRAY_NEXT) { - goto failed; + goto fail; } #if BYTE_ORDER == BIG_ENDIAN @@ -643,14 +643,14 @@ nvpair_unpack_header(bool isbe, nvpair_t *nvp, const u #endif if (nvphdr.nvph_namesize > NV_NAME_MAX) - goto failed; + goto fail; if (*leftp < nvphdr.nvph_namesize) - goto failed; + goto fail; if (nvphdr.nvph_namesize < 1) - goto failed; + goto fail; if (strnlen((const char *)ptr, nvphdr.nvph_namesize) != (size_t)(nvphdr.nvph_namesize - 1)) { - goto failed; + goto fail; } memcpy(nvp->nvp_name, ptr, nvphdr.nvph_namesize); @@ -658,7 +658,7 @@ nvpair_unpack_header(bool isbe, nvpair_t *nvp, const u *leftp -= nvphdr.nvph_namesize; if (*leftp < nvphdr.nvph_datasize) - goto failed; + goto fail; nvp->nvp_type = nvphdr.nvph_type; nvp->nvp_data = 0; @@ -666,7 +666,7 @@ nvpair_unpack_header(bool isbe, nvpair_t *nvp, const u nvp->nvp_nitems = nvphdr.nvph_nitems; return (ptr); -failed: +fail: ERRNO_SET(EINVAL); return (NULL); } @@ -1108,10 +1108,10 @@ nvpair_unpack(bool isbe, const unsigned char *ptr, siz ptr = nvpair_unpack_header(isbe, nvp, ptr, leftp); if (ptr == NULL) - goto failed; + goto fail; tmp = nv_realloc(nvp, sizeof(*nvp) + strlen(nvp->nvp_name) + 1); if (tmp == NULL) - goto failed; + goto fail; nvp = tmp; /* Update nvp_name after realloc(). */ @@ -1120,7 +1120,7 @@ nvpair_unpack(bool isbe, const unsigned char *ptr, siz nvp->nvp_magic = NVPAIR_MAGIC; *nvpp = nvp; return (ptr); -failed: +fail: nv_free(nvp); return (NULL); } From owner-svn-src-stable-11@freebsd.org Sat Oct 21 19:33:32 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E38C3E38167; Sat, 21 Oct 2017 19:33:32 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B070368194; Sat, 21 Oct 2017 19:33:32 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9LJXV30019414; Sat, 21 Oct 2017 19:33:31 GMT (envelope-from oshogbo@FreeBSD.org) Received: (from oshogbo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9LJXV4w019413; Sat, 21 Oct 2017 19:33:31 GMT (envelope-from oshogbo@FreeBSD.org) Message-Id: <201710211933.v9LJXV4w019413@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: oshogbo set sender to oshogbo@FreeBSD.org using -f From: Mariusz Zaborski Date: Sat, 21 Oct 2017 19:33:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324830 - stable/11/sys/contrib/libnv X-SVN-Group: stable-11 X-SVN-Commit-Author: oshogbo X-SVN-Commit-Paths: stable/11/sys/contrib/libnv X-SVN-Commit-Revision: 324830 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Oct 2017 19:33:33 -0000 Author: oshogbo Date: Sat Oct 21 19:33:31 2017 New Revision: 324830 URL: https://svnweb.freebsd.org/changeset/base/324830 Log: MFC r323854: Because nvp wasn't initialized on every loop iteration once we jumped to 'fail' on error it was treated as success, because nvp!=NULL. Fix this by not handling success under 'fail' label and by using separate variable for parent nvpair. If we succeeded to allocate nvlist, but failed to allocated nvpair we would leak nvls[ii] on return. Destroy it when we cannot allocate nvpair, before we goto fail. Submitted by: pjd@ and oshogbo@ (minor changes) Found by: scan-build Sponsored by: Wheel Systems Modified: stable/11/sys/contrib/libnv/nvpair.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/contrib/libnv/nvpair.c ============================================================================== --- stable/11/sys/contrib/libnv/nvpair.c Sat Oct 21 19:31:59 2017 (r324829) +++ stable/11/sys/contrib/libnv/nvpair.c Sat Oct 21 19:33:31 2017 (r324830) @@ -1407,10 +1407,9 @@ nvpair_create_nvlist_array(const char *name, const nvl { unsigned int ii; nvlist_t **nvls; - nvpair_t *nvp; + nvpair_t *parent; int flags; - nvp = NULL; nvls = NULL; ii = 0; @@ -1434,33 +1433,40 @@ nvpair_create_nvlist_array(const char *name, const nvl goto fail; if (ii > 0) { + nvpair_t *nvp; + nvp = nvpair_allocv(" ", NV_TYPE_NVLIST, (uint64_t)(uintptr_t)nvls[ii], 0, 0); - if (nvp == NULL) + if (nvp == NULL) { + ERRNO_SAVE(); + nvlist_destroy(nvls[ii]); + ERRNO_RESTORE(); goto fail; + } nvlist_set_array_next(nvls[ii - 1], nvp); } } flags = nvlist_flags(nvls[nitems - 1]) | NV_FLAG_IN_ARRAY; nvlist_set_flags(nvls[nitems - 1], flags); - nvp = nvpair_allocv(name, NV_TYPE_NVLIST_ARRAY, + parent = nvpair_allocv(name, NV_TYPE_NVLIST_ARRAY, (uint64_t)(uintptr_t)nvls, 0, nitems); + if (parent == NULL) + goto fail; -fail: - if (nvp == NULL) { - ERRNO_SAVE(); - for (; ii > 0; ii--) - nvlist_destroy(nvls[ii - 1]); + for (ii = 0; ii < nitems; ii++) + nvlist_set_parent(nvls[ii], parent); - nv_free(nvls); - ERRNO_RESTORE(); - } else { - for (ii = 0; ii < nitems; ii++) - nvlist_set_parent(nvls[ii], nvp); - } + return (parent); - return (nvp); +fail: + ERRNO_SAVE(); + for (; ii > 0; ii--) + nvlist_destroy(nvls[ii - 1]); + nv_free(nvls); + ERRNO_RESTORE(); + + return (NULL); } #ifndef _KERNEL From owner-svn-src-stable-11@freebsd.org Sat Oct 21 19:34:56 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2CBE7E38236; Sat, 21 Oct 2017 19:34:56 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 06ACC682E6; Sat, 21 Oct 2017 19:34:55 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9LJYtU1019512; Sat, 21 Oct 2017 19:34:55 GMT (envelope-from oshogbo@FreeBSD.org) Received: (from oshogbo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9LJYsmW019509; Sat, 21 Oct 2017 19:34:55 GMT (envelope-from oshogbo@FreeBSD.org) Message-Id: <201710211934.v9LJYsmW019509@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: oshogbo set sender to oshogbo@FreeBSD.org using -f From: Mariusz Zaborski Date: Sat, 21 Oct 2017 19:34:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324831 - in stable/11: lib/libnv sys/contrib/libnv X-SVN-Group: stable-11 X-SVN-Commit-Author: oshogbo X-SVN-Commit-Paths: in stable/11: lib/libnv sys/contrib/libnv X-SVN-Commit-Revision: 324831 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Oct 2017 19:34:56 -0000 Author: oshogbo Date: Sat Oct 21 19:34:54 2017 New Revision: 324831 URL: https://svnweb.freebsd.org/changeset/base/324831 Log: MFC r323851: Remove redundant initialization. Don't use variable - just return the value. Make scan-build happy by casting to 'void *' instead of 'void **'. Submitted by: pjd@ Found by: scan-build and cppcheck Sponsored by: Wheel Systems Modified: stable/11/lib/libnv/msgio.c stable/11/sys/contrib/libnv/nvlist.c stable/11/sys/contrib/libnv/nvpair.c Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libnv/msgio.c ============================================================================== --- stable/11/lib/libnv/msgio.c Sat Oct 21 19:33:31 2017 (r324830) +++ stable/11/lib/libnv/msgio.c Sat Oct 21 19:34:54 2017 (r324831) @@ -299,7 +299,6 @@ fd_package_recv(int sock, int *fds, size_t nfds) PJDLOG_ASSERT(nfds > 0); PJDLOG_ASSERT(fds != NULL); - i = 0; bzero(&msg, sizeof(msg)); bzero(&iov, sizeof(iov)); Modified: stable/11/sys/contrib/libnv/nvlist.c ============================================================================== --- stable/11/sys/contrib/libnv/nvlist.c Sat Oct 21 19:33:31 2017 (r324830) +++ stable/11/sys/contrib/libnv/nvlist.c Sat Oct 21 19:34:54 2017 (r324831) @@ -281,8 +281,7 @@ nvlist_get_pararr(const nvlist_t *nvl, void **cookiep) return (ret); } - ret = nvlist_get_parent(nvl, cookiep); - return (ret); + return (nvlist_get_parent(nvl, cookiep)); } bool @@ -710,7 +709,6 @@ static int * nvlist_xdescriptors(const nvlist_t *nvl, int *descs) { nvpair_t *nvp; - const char *name; int type; NVLIST_ASSERT(nvl); @@ -718,7 +716,7 @@ nvlist_xdescriptors(const nvlist_t *nvl, int *descs) nvp = NULL; do { - while ((name = nvlist_next(nvl, &type, (void**)&nvp)) != NULL) { + while (nvlist_next(nvl, &type, (void *)&nvp) != NULL) { switch (type) { case NV_TYPE_DESCRIPTOR: *descs = nvpair_get_descriptor(nvp); @@ -757,7 +755,7 @@ nvlist_xdescriptors(const nvlist_t *nvl, int *descs) } } } - } while ((nvl = nvlist_get_pararr(nvl, (void**)&nvp)) != NULL); + } while ((nvl = nvlist_get_pararr(nvl, (void *)&nvp)) != NULL); return (descs); } @@ -788,7 +786,6 @@ nvlist_ndescriptors(const nvlist_t *nvl) { #ifndef _KERNEL nvpair_t *nvp; - const char *name; size_t ndescs; int type; @@ -798,7 +795,7 @@ nvlist_ndescriptors(const nvlist_t *nvl) ndescs = 0; nvp = NULL; do { - while ((name = nvlist_next(nvl, &type, (void**)&nvp)) != NULL) { + while (nvlist_next(nvl, &type, (void *)&nvp) != NULL) { switch (type) { case NV_TYPE_DESCRIPTOR: ndescs++; @@ -831,7 +828,7 @@ nvlist_ndescriptors(const nvlist_t *nvl) } } } - } while ((nvl = nvlist_get_pararr(nvl, (void**)&nvp)) != NULL); + } while ((nvl = nvlist_get_pararr(nvl, (void *)&nvp)) != NULL); return (ndescs); #else @@ -1260,7 +1257,6 @@ nvlist_send(int sock, const nvlist_t *nvl) return (-1); ret = -1; - data = NULL; fdidx = 0; data = nvlist_xpack(nvl, &fdidx, &datasize); Modified: stable/11/sys/contrib/libnv/nvpair.c ============================================================================== --- stable/11/sys/contrib/libnv/nvpair.c Sat Oct 21 19:33:31 2017 (r324830) +++ stable/11/sys/contrib/libnv/nvpair.c Sat Oct 21 19:34:54 2017 (r324831) @@ -1411,7 +1411,6 @@ nvpair_create_nvlist_array(const char *name, const nvl int flags; nvls = NULL; - ii = 0; if (value == NULL || nitems == 0) { ERRNO_SET(EINVAL); From owner-svn-src-stable-11@freebsd.org Sat Oct 21 19:36:23 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 57D37E382F0; Sat, 21 Oct 2017 19:36:23 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 113226841E; Sat, 21 Oct 2017 19:36:22 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9LJaM1x019623; Sat, 21 Oct 2017 19:36:22 GMT (envelope-from oshogbo@FreeBSD.org) Received: (from oshogbo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9LJaMQ7019622; Sat, 21 Oct 2017 19:36:22 GMT (envelope-from oshogbo@FreeBSD.org) Message-Id: <201710211936.v9LJaMQ7019622@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: oshogbo set sender to oshogbo@FreeBSD.org using -f From: Mariusz Zaborski Date: Sat, 21 Oct 2017 19:36:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324832 - stable/11/sys/contrib/libnv X-SVN-Group: stable-11 X-SVN-Commit-Author: oshogbo X-SVN-Commit-Paths: stable/11/sys/contrib/libnv X-SVN-Commit-Revision: 324832 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Oct 2017 19:36:23 -0000 Author: oshogbo Date: Sat Oct 21 19:36:22 2017 New Revision: 324832 URL: https://svnweb.freebsd.org/changeset/base/324832 Log: MFC r323856: Free 'value' only once we are done freeing all individual Submitted by: pjd@ Found by: scan-build Sponsored by: Wheel Systems Modified: stable/11/sys/contrib/libnv/nvpair.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/contrib/libnv/nvpair.c ============================================================================== --- stable/11/sys/contrib/libnv/nvpair.c Sat Oct 21 19:34:54 2017 (r324831) +++ stable/11/sys/contrib/libnv/nvpair.c Sat Oct 21 19:36:22 2017 (r324832) @@ -1727,8 +1727,8 @@ fail: nvlist_get_pararr(value[ii], NULL) != NULL) { nvlist_destroy(value[ii]); } - nv_free(value); } + nv_free(value); ERRNO_RESTORE(); } else { for (ii = 0; ii < nitems; ii++) From owner-svn-src-stable-11@freebsd.org Sat Oct 21 19:37:27 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 32C81E38388; Sat, 21 Oct 2017 19:37:27 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F28B56856E; Sat, 21 Oct 2017 19:37:26 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9LJbQIr019710; Sat, 21 Oct 2017 19:37:26 GMT (envelope-from oshogbo@FreeBSD.org) Received: (from oshogbo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9LJbQ4m019709; Sat, 21 Oct 2017 19:37:26 GMT (envelope-from oshogbo@FreeBSD.org) Message-Id: <201710211937.v9LJbQ4m019709@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: oshogbo set sender to oshogbo@FreeBSD.org using -f From: Mariusz Zaborski Date: Sat, 21 Oct 2017 19:37:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324833 - stable/11/sys/contrib/libnv X-SVN-Group: stable-11 X-SVN-Commit-Author: oshogbo X-SVN-Commit-Paths: stable/11/sys/contrib/libnv X-SVN-Commit-Revision: 324833 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Oct 2017 19:37:27 -0000 Author: oshogbo Date: Sat Oct 21 19:37:25 2017 New Revision: 324833 URL: https://svnweb.freebsd.org/changeset/base/324833 Log: MFC r323858: IMHO it is possible that failure will be treated as success because we don't initialize nvp on every loop iteration and the code under 'fail'(!) label detects success by checking of nvp != NULL. Submitted by: pjd@ Sponsored by: Wheel Systems Modified: stable/11/sys/contrib/libnv/nvpair.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/contrib/libnv/nvpair.c ============================================================================== --- stable/11/sys/contrib/libnv/nvpair.c Sat Oct 21 19:36:22 2017 (r324832) +++ stable/11/sys/contrib/libnv/nvpair.c Sat Oct 21 19:37:25 2017 (r324833) @@ -1690,11 +1690,10 @@ nvpair_move_number_array(const char *name, uint64_t *v nvpair_t * nvpair_move_nvlist_array(const char *name, nvlist_t **value, size_t nitems) { + nvpair_t *parent; unsigned int ii; - nvpair_t *nvp; int flags; - nvp = NULL; if (value == NULL || nitems == 0) { ERRNO_SET(EINVAL); return (NULL); @@ -1707,6 +1706,8 @@ nvpair_move_nvlist_array(const char *name, nvlist_t ** goto fail; } if (ii > 0) { + nvpair_t *nvp; + nvp = nvpair_allocv(" ", NV_TYPE_NVLIST, (uint64_t)(uintptr_t)value[ii], 0, 0); if (nvp == NULL) @@ -1717,25 +1718,27 @@ nvpair_move_nvlist_array(const char *name, nvlist_t ** flags = nvlist_flags(value[nitems - 1]) | NV_FLAG_IN_ARRAY; nvlist_set_flags(value[nitems - 1], flags); - nvp = nvpair_allocv(name, NV_TYPE_NVLIST_ARRAY, + parent = nvpair_allocv(name, NV_TYPE_NVLIST_ARRAY, (uint64_t)(uintptr_t)value, 0, nitems); + if (parent == NULL) + goto fail; + + for (ii = 0; ii < nitems; ii++) + nvlist_set_parent(value[ii], parent); + + return (parent); fail: - if (nvp == NULL) { - ERRNO_SAVE(); - for (ii = 0; ii < nitems; ii++) { - if (value[ii] != NULL && - nvlist_get_pararr(value[ii], NULL) != NULL) { - nvlist_destroy(value[ii]); - } + ERRNO_SAVE(); + for (ii = 0; ii < nitems; ii++) { + if (value[ii] != NULL && + nvlist_get_pararr(value[ii], NULL) != NULL) { + nvlist_destroy(value[ii]); } - nv_free(value); - ERRNO_RESTORE(); - } else { - for (ii = 0; ii < nitems; ii++) - nvlist_set_parent(value[ii], nvp); } + nv_free(value); + ERRNO_RESTORE(); - return (nvp); + return (NULL); } #ifndef _KERNEL From owner-svn-src-stable-11@freebsd.org Sat Oct 21 19:38:37 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 863CBE38409; Sat, 21 Oct 2017 19:38:37 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 50D0A686AC; Sat, 21 Oct 2017 19:38:37 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9LJcadS019803; Sat, 21 Oct 2017 19:38:36 GMT (envelope-from oshogbo@FreeBSD.org) Received: (from oshogbo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9LJcaTW019802; Sat, 21 Oct 2017 19:38:36 GMT (envelope-from oshogbo@FreeBSD.org) Message-Id: <201710211938.v9LJcaTW019802@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: oshogbo set sender to oshogbo@FreeBSD.org using -f From: Mariusz Zaborski Date: Sat, 21 Oct 2017 19:38:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324834 - stable/11/sys/contrib/libnv X-SVN-Group: stable-11 X-SVN-Commit-Author: oshogbo X-SVN-Commit-Paths: stable/11/sys/contrib/libnv X-SVN-Commit-Revision: 324834 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Oct 2017 19:38:37 -0000 Author: oshogbo Date: Sat Oct 21 19:38:36 2017 New Revision: 324834 URL: https://svnweb.freebsd.org/changeset/base/324834 Log: MFC r323860: Plug memory leak in case when nvlist allocation succeeds, but nvpair allocation fails. Submitted by: pjd@ Sponsored by: Wheel Systems Modified: stable/11/sys/contrib/libnv/nvpair.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/contrib/libnv/nvpair.c ============================================================================== --- stable/11/sys/contrib/libnv/nvpair.c Sat Oct 21 19:37:25 2017 (r324833) +++ stable/11/sys/contrib/libnv/nvpair.c Sat Oct 21 19:38:36 2017 (r324834) @@ -1087,7 +1087,7 @@ nvpair_unpack_nvlist_array(bool isbe __unused, nvpair_ return (ptr); fail: ERRNO_SAVE(); - for (j = 0; j < ii; j++) + for (j = 0; j <= ii; j++) nvlist_destroy(value[j]); nv_free(value); ERRNO_RESTORE();