From owner-svn-src-stable-9@FreeBSD.ORG Sun Jun 24 09:41:28 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 29D7A1065677; Sun, 24 Jun 2012 09:41:28 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EE3A38FC12; Sun, 24 Jun 2012 09:41:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5O9fRBS001330; Sun, 24 Jun 2012 09:41:27 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5O9fRkm001327; Sun, 24 Jun 2012 09:41:27 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201206240941.q5O9fRkm001327@svn.freebsd.org> From: Alexander Motin Date: Sun, 24 Jun 2012 09:41:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237532 - stable/9/sys/cam/scsi X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Jun 2012 09:41:28 -0000 Author: mav Date: Sun Jun 24 09:41:27 2012 New Revision: 237532 URL: http://svn.freebsd.org/changeset/base/237532 Log: MFC r237225: Remove never used CD/DA_FLAG_TAGGED_QUEUING flags. Modified: stable/9/sys/cam/scsi/scsi_cd.c stable/9/sys/cam/scsi/scsi_da.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/cam/scsi/scsi_cd.c ============================================================================== --- stable/9/sys/cam/scsi/scsi_cd.c Sun Jun 24 09:19:24 2012 (r237531) +++ stable/9/sys/cam/scsi/scsi_cd.c Sun Jun 24 09:41:27 2012 (r237532) @@ -97,7 +97,6 @@ typedef enum { CD_FLAG_NEW_DISC = 0x0002, CD_FLAG_DISC_LOCKED = 0x0004, CD_FLAG_DISC_REMOVABLE = 0x0008, - CD_FLAG_TAGGED_QUEUING = 0x0010, CD_FLAG_CHANGER = 0x0040, CD_FLAG_ACTIVE = 0x0080, CD_FLAG_SCHED_ON_COMP = 0x0100, @@ -652,8 +651,6 @@ cdregister(struct cam_periph *periph, vo bioq_init(&softc->bio_queue); if (SID_IS_REMOVABLE(&cgd->inq_data)) softc->flags |= CD_FLAG_DISC_REMOVABLE; - if ((cgd->inq_data.flags & SID_CmdQue) != 0) - softc->flags |= CD_FLAG_TAGGED_QUEUING; periph->softc = softc; softc->periph = periph; Modified: stable/9/sys/cam/scsi/scsi_da.c ============================================================================== --- stable/9/sys/cam/scsi/scsi_da.c Sun Jun 24 09:19:24 2012 (r237531) +++ stable/9/sys/cam/scsi/scsi_da.c Sun Jun 24 09:41:27 2012 (r237532) @@ -77,7 +77,6 @@ typedef enum { DA_FLAG_NEW_PACK = 0x002, DA_FLAG_PACK_LOCKED = 0x004, DA_FLAG_PACK_REMOVABLE = 0x008, - DA_FLAG_TAGGED_QUEUING = 0x010, DA_FLAG_NEED_OTAG = 0x020, DA_FLAG_WENT_IDLE = 0x040, DA_FLAG_RETRY_UA = 0x080, @@ -1540,8 +1539,6 @@ daregister(struct cam_periph *periph, vo bioq_init(&softc->delete_run_queue); if (SID_IS_REMOVABLE(&cgd->inq_data)) softc->flags |= DA_FLAG_PACK_REMOVABLE; - if ((cgd->inq_data.flags & SID_CmdQue) != 0) - softc->flags |= DA_FLAG_TAGGED_QUEUING; softc->unmap_max_ranges = UNMAP_MAX_RANGES; softc->unmap_max_lba = 1024*1024*2; From owner-svn-src-stable-9@FreeBSD.ORG Sun Jun 24 13:39:42 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6471B106567A; Sun, 24 Jun 2012 13:39:42 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 34AF68FC12; Sun, 24 Jun 2012 13:39:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5ODdgNB012904; Sun, 24 Jun 2012 13:39:42 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5ODdgOv012902; Sun, 24 Jun 2012 13:39:42 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201206241339.q5ODdgOv012902@svn.freebsd.org> From: Rick Macklem Date: Sun, 24 Jun 2012 13:39:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237534 - stable/9/sys/fs/nfsclient X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Jun 2012 13:39:42 -0000 Author: rmacklem Date: Sun Jun 24 13:39:41 2012 New Revision: 237534 URL: http://svn.freebsd.org/changeset/base/237534 Log: MFC: r237200 Move the nfsrpc_close() call in ncl_reclaim() for the NFSv4 client to below the vnode_destroy_vobject() call, since that is where writes are flushed. Modified: stable/9/sys/fs/nfsclient/nfs_clnode.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/dev/isp/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/modules/ (props changed) Modified: stable/9/sys/fs/nfsclient/nfs_clnode.c ============================================================================== --- stable/9/sys/fs/nfsclient/nfs_clnode.c Sun Jun 24 09:42:36 2012 (r237533) +++ stable/9/sys/fs/nfsclient/nfs_clnode.c Sun Jun 24 13:39:41 2012 (r237534) @@ -257,15 +257,6 @@ ncl_reclaim(struct vop_reclaim_args *ap) struct nfsnode *np = VTONFS(vp); struct nfsdmap *dp, *dp2; - if (NFS_ISV4(vp) && vp->v_type == VREG) - /* - * Since mmap()'d files do I/O after VOP_CLOSE(), the NFSv4 - * Close operations are delayed until ncl_inactive(). - * However, since VOP_INACTIVE() is not guaranteed to be - * called, we need to do it again here. - */ - (void) nfsrpc_close(vp, 1, ap->a_td); - /* * If the NLM is running, give it a chance to abort pending * locks. @@ -278,6 +269,15 @@ ncl_reclaim(struct vop_reclaim_args *ap) */ vnode_destroy_vobject(vp); + if (NFS_ISV4(vp) && vp->v_type == VREG) + /* + * We can now safely close any remaining NFSv4 Opens for + * this file. Most opens will have already been closed by + * ncl_inactive(), but there are cases where it is not + * called, so we need to do it again here. + */ + (void) nfsrpc_close(vp, 1, ap->a_td); + vfs_hash_remove(vp); /* From owner-svn-src-stable-9@FreeBSD.ORG Sun Jun 24 17:02:29 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 861241065676; Sun, 24 Jun 2012 17:02:29 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 57F438FC17; Sun, 24 Jun 2012 17:02:29 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5OH2T4H021238; Sun, 24 Jun 2012 17:02:29 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5OH2Tvv021236; Sun, 24 Jun 2012 17:02:29 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <201206241702.q5OH2Tvv021236@svn.freebsd.org> From: Luigi Rizzo Date: Sun, 24 Jun 2012 17:02:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237536 - stable/9/release/picobsd/build X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Jun 2012 17:02:29 -0000 Author: luigi Date: Sun Jun 24 17:02:28 2012 New Revision: 237536 URL: http://svn.freebsd.org/changeset/base/237536 Log: partial MFC. Mostly, do not build clang when initializing picobsd Modified: stable/9/release/picobsd/build/picobsd Modified: stable/9/release/picobsd/build/picobsd ============================================================================== --- stable/9/release/picobsd/build/picobsd Sun Jun 24 16:56:48 2012 (r237535) +++ stable/9/release/picobsd/build/picobsd Sun Jun 24 17:02:28 2012 (r237536) @@ -164,6 +164,7 @@ create_includes_and_libraries2() { # opt log "create_includes_and_libraries2() for ${SRC} $1" if [ ${OSVERSION} -ge 600000 ] ; then no="-DNO_CLEAN -DNO_PROFILE -DNO_GAMES -DNO_LIBC_R" # WITHOUT_CDDL=1" + no="$no -DWITHOUT_CLANG" else no="-DNOCLEAN -DNOPROFILE -DNOGAMES -DNOLIBC_R" fi @@ -441,7 +442,7 @@ do_kernel() { # OK [ "${o_do_modules}" = "yes" ] && export MODULES="" ${BINMAKE} ${o_par} KERNCONF=${l_kernconf} \ -v -f ${PICO_TREE}/build/Makefile.conf ) || \ - fail $? missing_kernel + fail $? missing_kernel } # Populate the variable part of the floppy filesystem. Must be done before @@ -591,7 +592,7 @@ find_progs() { # programs if [ "$old_libs" = "$i" ] ; then log "libraries for: $my_progs ($u_progs) are ($i) $u_libs" log "--- done find_progs ---" - return 0 + return 0 else # logverbose "old--- $old_libs --- new +++ $i +++" fi @@ -881,11 +882,11 @@ fill_floppy_image() { fi log "Compress with kgzip and copy to floppy image" - mkdir -p ${dst}/boot/kernel + mkdir -p ${dst}/boot/kernel # XXX update loader.conf - echo "hint.acpi.0.disabled=\"1\"" > ${dst}/boot/loader.conf - echo "console=\"comconsole\"" >> ${dst}/boot/loader.conf - cp -p /boot/loader ${dst}/boot/loader || fail $? no_space "copying bootloader" + echo "hint.acpi.0.disabled=\"1\"" > ${dst}/boot/loader.conf + echo "console=\"comconsole\"" >> ${dst}/boot/loader.conf + cp -p /boot/loader ${dst}/boot/loader || fail $? no_space "copying bootloader" gzip -c kernel > ${dst}/boot/kernel/kernel.gz || fail $? no_space "copying kernel" # now transfer the floppy tree. If it is already in mfs, dont bother. From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 25 01:48:19 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 39D6B1065673; Mon, 25 Jun 2012 01:48:19 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1B15C8FC17; Mon, 25 Jun 2012 01:48:19 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5P1mI22043071; Mon, 25 Jun 2012 01:48:18 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5P1mIr8043069; Mon, 25 Jun 2012 01:48:18 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201206250148.q5P1mIr8043069@svn.freebsd.org> From: Rick Macklem Date: Mon, 25 Jun 2012 01:48:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237543 - stable/9/sys/fs/nfsclient X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jun 2012 01:48:19 -0000 Author: rmacklem Date: Mon Jun 25 01:48:18 2012 New Revision: 237543 URL: http://svn.freebsd.org/changeset/base/237543 Log: MFC: r237244 Fix the NFSv4 client for the case where mmap'd files are written, but not msync'd by a process. A VOP_PUTPAGES() called when VOP_RECLAIM() happens will usually fail, since the NFSv4 Open has already been closed by VOP_INACTIVE(). Add a vm_object_page_clean() call to the NFSv4 client's VOP_INACTIVE(), so that the write happens before the NFSv4 Open is closed. kib@ suggested using vgone() instead and I will explore this, but this patch fixes things in the meantime. For some reason, the VOP_PUTPAGES() is still attaempted in VOP_RECLAIM(), but having this fail doesn't cause any problems except a "stateid0 in write" being logged. Modified: stable/9/sys/fs/nfsclient/nfs_clnode.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/dev/isp/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/modules/ (props changed) Modified: stable/9/sys/fs/nfsclient/nfs_clnode.c ============================================================================== --- stable/9/sys/fs/nfsclient/nfs_clnode.c Sun Jun 24 23:12:24 2012 (r237542) +++ stable/9/sys/fs/nfsclient/nfs_clnode.c Mon Jun 25 01:48:18 2012 (r237543) @@ -210,18 +210,28 @@ ncl_inactive(struct vop_inactive_args *a struct nfsnode *np; struct sillyrename *sp; struct vnode *vp = ap->a_vp; + boolean_t retv; np = VTONFS(vp); if (NFS_ISV4(vp) && vp->v_type == VREG) { /* * Since mmap()'d files do I/O after VOP_CLOSE(), the NFSv4 - * Close operations are delayed until now. Any dirty buffers - * must be flushed before the close, so that the stateid is - * available for the writes. + * Close operations are delayed until now. Any dirty + * buffers/pages must be flushed before the close, so that the + * stateid is available for the writes. */ - (void) ncl_flush(vp, MNT_WAIT, NULL, ap->a_td, 1, 0); - (void) nfsrpc_close(vp, 1, ap->a_td); + if (vp->v_object != NULL) { + VM_OBJECT_LOCK(vp->v_object); + retv = vm_object_page_clean(vp->v_object, 0, 0, + OBJPC_SYNC); + VM_OBJECT_UNLOCK(vp->v_object); + } else + retv = TRUE; + if (retv == TRUE) { + (void)ncl_flush(vp, MNT_WAIT, NULL, ap->a_td, 1, 0); + (void)nfsrpc_close(vp, 1, ap->a_td); + } } mtx_lock(&np->n_mtx); From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 25 07:06:58 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id EB5AE1065675; Mon, 25 Jun 2012 07:06:58 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D71D08FC0A; Mon, 25 Jun 2012 07:06:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5P76wVX056608; Mon, 25 Jun 2012 07:06:58 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5P76w57056606; Mon, 25 Jun 2012 07:06:58 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201206250706.q5P76w57056606@svn.freebsd.org> From: Alexander Motin Date: Mon, 25 Jun 2012 07:06:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237548 - stable/9/sys/cam X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jun 2012 07:06:59 -0000 Author: mav Date: Mon Jun 25 07:06:58 2012 New Revision: 237548 URL: http://svn.freebsd.org/changeset/base/237548 Log: MFC r237446: Don't print SCSI Queue Full and CAM_REQUEUE_REQ statuses as errors if they were handled and retried. They are part of normal operation for SCSI TCQ. Modified: stable/9/sys/cam/cam_periph.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/cam/cam_periph.c ============================================================================== --- stable/9/sys/cam/cam_periph.c Mon Jun 25 05:47:12 2012 (r237547) +++ stable/9/sys/cam/cam_periph.c Mon Jun 25 07:06:58 2012 (r237548) @@ -1325,6 +1325,7 @@ camperiphscsistatuserror(union ccb *ccb, } *timeout = 0; error = ERESTART; + *print = 0; break; } /* FALLTHROUGH */ @@ -1654,8 +1655,10 @@ cam_periph_error(union ccb *ccb, cam_fla } else if (sense_flags & SF_NO_RETRY) { error = EIO; action_string = "Retry was blocked"; - } else + } else { error = ERESTART; + print = 0; + } break; case CAM_RESRC_UNAVAIL: /* Wait a bit for the resource shortage to abate. */ From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 25 07:09:37 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5F65E1065673; Mon, 25 Jun 2012 07:09:37 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4A8D88FC08; Mon, 25 Jun 2012 07:09:37 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5P79bq5056758; Mon, 25 Jun 2012 07:09:37 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5P79bVW056756; Mon, 25 Jun 2012 07:09:37 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201206250709.q5P79bVW056756@svn.freebsd.org> From: Alexander Motin Date: Mon, 25 Jun 2012 07:09:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237549 - stable/9/sys/dev/twa X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jun 2012 07:09:37 -0000 Author: mav Date: Mon Jun 25 07:09:36 2012 New Revision: 237549 URL: http://svn.freebsd.org/changeset/base/237549 Log: MFC r237460: Return CAM_SEL_TIMEOUT and CAM_DEV_NOT_THERE instead of CAM_TID_INVALID and CAM_LUN_INVALID for case of missing devices. In removes tons of error messages from CAM during bus scans. Reported and tested by: Mike Tancsa Modified: stable/9/sys/dev/twa/tw_osl_cam.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/twa/tw_osl_cam.c ============================================================================== --- stable/9/sys/dev/twa/tw_osl_cam.c Mon Jun 25 07:06:58 2012 (r237548) +++ stable/9/sys/dev/twa/tw_osl_cam.c Mon Jun 25 07:09:36 2012 (r237549) @@ -678,9 +678,9 @@ tw_osl_complete_io(struct tw_cl_req_hand ccb->ccb_h.status = CAM_REQ_CMP; else { if (req_pkt->status & TW_CL_ERR_REQ_INVALID_TARGET) - ccb->ccb_h.status |= CAM_TID_INVALID; + ccb->ccb_h.status |= CAM_SEL_TIMEOUT; else if (req_pkt->status & TW_CL_ERR_REQ_INVALID_LUN) - ccb->ccb_h.status |= CAM_LUN_INVALID; + ccb->ccb_h.status |= CAM_DEV_NOT_THERE; else if (req_pkt->status & TW_CL_ERR_REQ_SCSI_ERROR) ccb->ccb_h.status |= CAM_SCSI_STATUS_ERROR; else if (req_pkt->status & TW_CL_ERR_REQ_BUS_RESET) From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 25 07:27:32 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3EBF61065673; Mon, 25 Jun 2012 07:27:32 +0000 (UTC) (envelope-from fabient@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 292DC8FC12; Mon, 25 Jun 2012 07:27:32 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5P7RVTV057646; Mon, 25 Jun 2012 07:27:31 GMT (envelope-from fabient@svn.freebsd.org) Received: (from fabient@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5P7RVRp057644; Mon, 25 Jun 2012 07:27:31 GMT (envelope-from fabient@svn.freebsd.org) Message-Id: <201206250727.q5P7RVRp057644@svn.freebsd.org> From: Fabien Thomas Date: Mon, 25 Jun 2012 07:27:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237552 - stable/9/sys/dev/xen/balloon X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jun 2012 07:27:32 -0000 Author: fabient Date: Mon Jun 25 07:27:31 2012 New Revision: 237552 URL: http://svn.freebsd.org/changeset/base/237552 Log: MFC r237322: Allow booting XENHVM kernel without Xen hypervisor. Modified: stable/9/sys/dev/xen/balloon/balloon.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/xen/balloon/balloon.c ============================================================================== --- stable/9/sys/dev/xen/balloon/balloon.c Mon Jun 25 07:13:25 2012 (r237551) +++ stable/9/sys/dev/xen/balloon/balloon.c Mon Jun 25 07:27:31 2012 (r237552) @@ -437,6 +437,9 @@ balloon_init_watcher(void *arg) { int err; + if (!is_running_on_xen()) + return; + err = xs_register_watch(&target_watch); if (err) printf("Failed to set balloon watcher\n"); From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 25 07:33:55 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 435AD106567D; Mon, 25 Jun 2012 07:33:55 +0000 (UTC) (envelope-from fabient@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2D86B8FC15; Mon, 25 Jun 2012 07:33:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5P7XtW4058018; Mon, 25 Jun 2012 07:33:55 GMT (envelope-from fabient@svn.freebsd.org) Received: (from fabient@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5P7Xssb058016; Mon, 25 Jun 2012 07:33:54 GMT (envelope-from fabient@svn.freebsd.org) Message-Id: <201206250733.q5P7Xssb058016@svn.freebsd.org> From: Fabien Thomas Date: Mon, 25 Jun 2012 07:33:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237554 - stable/9/sys/dev/viawd X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jun 2012 07:33:55 -0000 Author: fabient Date: Mon Jun 25 07:33:54 2012 New Revision: 237554 URL: http://svn.freebsd.org/changeset/base/237554 Log: MFC r237295: Fix viawd(4) that was only working as a module. Modified: stable/9/sys/dev/viawd/viawd.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/viawd/viawd.c ============================================================================== --- stable/9/sys/dev/viawd/viawd.c Mon Jun 25 07:29:14 2012 (r237553) +++ stable/9/sys/dev/viawd/viawd.c Mon Jun 25 07:33:54 2012 (r237554) @@ -168,14 +168,18 @@ viawd_attach(device_t dev) } /* Allocate I/O register space. */ - sc->wd_rid = 0; - sc->wd_res = bus_alloc_resource(dev, SYS_RES_MEMORY, &sc->wd_rid, - pmbase, pmbase + VIAWD_MEM_LEN - 1, VIAWD_MEM_LEN, + sc->wd_rid = VIAWD_CONFIG_BASE; + sc->wd_res = bus_alloc_resource_any(sb_dev, SYS_RES_MEMORY, &sc->wd_rid, RF_ACTIVE | RF_SHAREABLE); if (sc->wd_res == NULL) { device_printf(dev, "Unable to map watchdog memory\n"); goto fail; } + if (rman_get_size(sc->wd_res) < VIAWD_MEM_LEN) { + device_printf(dev, "Bad size for watchdog memory: %#x\n", + (unsigned)rman_get_size(sc->wd_res)); + goto fail; + } /* Check if watchdog fired last boot. */ reg = viawd_read_4(sc, VIAWD_MEM_CTRL); @@ -192,7 +196,7 @@ viawd_attach(device_t dev) return (0); fail: if (sc->wd_res != NULL) - bus_release_resource(dev, SYS_RES_MEMORY, + bus_release_resource(sb_dev, SYS_RES_MEMORY, sc->wd_rid, sc->wd_res); return (ENXIO); } @@ -224,7 +228,7 @@ viawd_detach(device_t dev) } if (sc->wd_res != NULL) - bus_release_resource(sc->dev, SYS_RES_MEMORY, + bus_release_resource(sc->sb_dev, SYS_RES_MEMORY, sc->wd_rid, sc->wd_res); return (0); From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 25 07:56:23 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C6C53106566C; Mon, 25 Jun 2012 07:56:23 +0000 (UTC) (envelope-from fabient@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B13388FC14; Mon, 25 Jun 2012 07:56:23 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5P7uNbx059036; Mon, 25 Jun 2012 07:56:23 GMT (envelope-from fabient@svn.freebsd.org) Received: (from fabient@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5P7uNxw059033; Mon, 25 Jun 2012 07:56:23 GMT (envelope-from fabient@svn.freebsd.org) Message-Id: <201206250756.q5P7uNxw059033@svn.freebsd.org> From: Fabien Thomas Date: Mon, 25 Jun 2012 07:56:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237556 - in stable/9/sys: arm/include dev/hwpmc X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jun 2012 07:56:23 -0000 Author: fabient Date: Mon Jun 25 07:56:23 2012 New Revision: 237556 URL: http://svn.freebsd.org/changeset/base/237556 Log: MFC r236997: Add ARM callchain support for hwpmc. Modified: stable/9/sys/arm/include/pmc_mdep.h stable/9/sys/dev/hwpmc/hwpmc_arm.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/arm/include/pmc_mdep.h ============================================================================== --- stable/9/sys/arm/include/pmc_mdep.h Mon Jun 25 07:36:00 2012 (r237555) +++ stable/9/sys/arm/include/pmc_mdep.h Mon Jun 25 07:56:23 2012 (r237556) @@ -50,9 +50,17 @@ union pmc_md_pmc { struct pmc_md_xscale_pmc pm_xscale; }; -#define PMC_TRAPFRAME_TO_PC(TF) ((TF)->tf_pc) -#define PMC_TRAPFRAME_TO_FP(TF) ((TF)->tf_usr_lr) -#define PMC_TRAPFRAME_TO_SP(TF) ((TF)->tf_usr_sp) +#define PMC_IN_KERNEL_STACK(S,START,END) \ + ((S) >= (START) && (S) < (END)) +#define PMC_IN_KERNEL(va) (((va) >= USRSTACK) && \ + ((va) < VM_MAX_KERNEL_ADDRESS)) + +#define PMC_IN_USERSPACE(va) ((va) <= VM_MAXUSER_ADDRESS) + +#define PMC_TRAPFRAME_TO_PC(TF) ((TF)->tf_pc) +#define PMC_TRAPFRAME_TO_FP(TF) ((TF)->tf_r11) +#define PMC_TRAPFRAME_TO_SVC_SP(TF) ((TF)->tf_svc_sp) +#define PMC_TRAPFRAME_TO_USR_SP(TF) ((TF)->tf_usr_sp) /* Build a fake kernel trapframe from current instruction pointer. */ #define PMC_FAKE_TRAPFRAME(TF) \ Modified: stable/9/sys/dev/hwpmc/hwpmc_arm.c ============================================================================== --- stable/9/sys/dev/hwpmc/hwpmc_arm.c Mon Jun 25 07:36:00 2012 (r237555) +++ stable/9/sys/dev/hwpmc/hwpmc_arm.c Mon Jun 25 07:56:23 2012 (r237556) @@ -30,10 +30,16 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include -#include +#include #include +#include + +#include +#include +#include struct pmc_mdep * pmc_md_initialize() @@ -58,27 +64,101 @@ pmc_md_finalize(struct pmc_mdep *md) #endif } -static int -pmc_save_callchain(uintptr_t *cc, int maxsamples, - struct trapframe *tf) -{ - - *cc = PMC_TRAPFRAME_TO_PC(tf); - return (1); -} - int pmc_save_kernel_callchain(uintptr_t *cc, int maxsamples, struct trapframe *tf) { + uintptr_t pc, r, stackstart, stackend, fp; + struct thread *td; + int count; + + KASSERT(TRAPF_USERMODE(tf) == 0,("[arm,%d] not a kernel backtrace", + __LINE__)); + + pc = PMC_TRAPFRAME_TO_PC(tf); + *cc++ = pc; + + if ((td = curthread) == NULL) + return (1); + + if (maxsamples <= 1) + return (1); + + stackstart = (uintptr_t) td->td_kstack; + stackend = (uintptr_t) td->td_kstack + td->td_kstack_pages * PAGE_SIZE; + fp = PMC_TRAPFRAME_TO_FP(tf); + + if (!PMC_IN_KERNEL(pc) || + !PMC_IN_KERNEL_STACK(fp, stackstart, stackend)) + return (1); + + for (count = 1; count < maxsamples; count++) { + /* Use saved lr as pc. */ + r = fp - sizeof(uintptr_t); + if (!PMC_IN_KERNEL_STACK(r, stackstart, stackend)) + break; + pc = *(uintptr_t *)r; + if (!PMC_IN_KERNEL(pc)) + break; + + *cc++ = pc; + + /* Switch to next frame up */ + r = fp - 3 * sizeof(uintptr_t); + if (!PMC_IN_KERNEL_STACK(r, stackstart, stackend)) + break; + fp = *(uintptr_t *)r; + if (!PMC_IN_KERNEL_STACK(fp, stackstart, stackend)) + break; + } - return pmc_save_callchain(cc, maxsamples, tf); + return (count); } int pmc_save_user_callchain(uintptr_t *cc, int maxsamples, struct trapframe *tf) { + uintptr_t pc, r, oldfp, fp; + struct thread *td; + int count; + + KASSERT(TRAPF_USERMODE(tf), ("[x86,%d] Not a user trap frame tf=%p", + __LINE__, (void *) tf)); + + pc = PMC_TRAPFRAME_TO_PC(tf); + *cc++ = pc; + + if ((td = curthread) == NULL) + return (1); + + if (maxsamples <= 1) + return (1); + + oldfp = fp = PMC_TRAPFRAME_TO_FP(tf); + + if (!PMC_IN_USERSPACE(pc) || + !PMC_IN_USERSPACE(fp)) + return (1); + + for (count = 1; count < maxsamples; count++) { + /* Use saved lr as pc. */ + r = fp - sizeof(uintptr_t); + if (copyin((void *)r, &pc, sizeof(pc)) != 0) + break; + if (!PMC_IN_USERSPACE(pc)) + break; + + *cc++ = pc; + + /* Switch to next frame up */ + oldfp = fp; + r = fp - 3 * sizeof(uintptr_t); + if (copyin((void *)r, &fp, sizeof(fp)) != 0) + break; + if (fp < oldfp || !PMC_IN_USERSPACE(fp)) + break; + } - return pmc_save_callchain(cc, maxsamples, tf); + return (count); } From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 25 09:41:48 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 65FFF1065680; Mon, 25 Jun 2012 09:41:48 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5077C8FC08; Mon, 25 Jun 2012 09:41:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5P9fm0L063470; Mon, 25 Jun 2012 09:41:48 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5P9fmFS063468; Mon, 25 Jun 2012 09:41:48 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206250941.q5P9fmFS063468@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 25 Jun 2012 09:41:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237559 - stable/9/sys/amd64/amd64 X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jun 2012 09:41:48 -0000 Author: kib Date: Mon Jun 25 09:41:47 2012 New Revision: 237559 URL: http://svn.freebsd.org/changeset/base/237559 Log: MFC r237243: Adjust the fix in r236953, by not generating the signal manually, but performing the return to usermode using full return path. Modified: stable/9/sys/amd64/amd64/trap.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/amd64/amd64/trap.c ============================================================================== --- stable/9/sys/amd64/amd64/trap.c Mon Jun 25 08:34:14 2012 (r237558) +++ stable/9/sys/amd64/amd64/trap.c Mon Jun 25 09:41:47 2012 (r237559) @@ -982,16 +982,10 @@ amd64_syscall(struct thread *td, int tra * If the user-supplied value of %rip is not a canonical * address, then some CPUs will trigger a ring 0 #GP during * the sysret instruction. However, the fault handler would - * execute with the user's %gs and %rsp in ring 0 which would - * not be safe. Instead, preemptively kill the thread with a - * SIGBUS. + * execute in ring 0 with the user's %gs and %rsp which would + * not be safe. Instead, use the full return path which + * catches the problem safely. */ - if (td->td_frame->tf_rip >= VM_MAXUSER_ADDRESS) { - ksiginfo_init_trap(&ksi); - ksi.ksi_signo = SIGBUS; - ksi.ksi_code = BUS_OBJERR; - ksi.ksi_trapno = T_PROTFLT; - ksi.ksi_addr = (void *)td->td_frame->tf_rip; - trapsignal(td, &ksi); - } + if (td->td_frame->tf_rip >= VM_MAXUSER_ADDRESS) + set_pcb_flags(td->td_pcb, PCB_FULL_IRET); } From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 25 23:39:35 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BA4C41065672; Mon, 25 Jun 2012 23:39:35 +0000 (UTC) (envelope-from wblock@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A4F5A8FC18; Mon, 25 Jun 2012 23:39:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5PNdZjw002788; Mon, 25 Jun 2012 23:39:35 GMT (envelope-from wblock@svn.freebsd.org) Received: (from wblock@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5PNdZGA002786; Mon, 25 Jun 2012 23:39:35 GMT (envelope-from wblock@svn.freebsd.org) Message-Id: <201206252339.q5PNdZGA002786@svn.freebsd.org> From: Warren Block Date: Mon, 25 Jun 2012 23:39:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237584 - stable/9/lib/libc/locale X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jun 2012 23:39:35 -0000 Author: wblock (doc committer) Date: Mon Jun 25 23:39:35 2012 New Revision: 237584 URL: http://svn.freebsd.org/changeset/base/237584 Log: MFC r225808: Fix grammar. PR: 140457 Submitted by: jeremyhu AT apple.com Approved by: gjb (mentor) Modified: stable/9/lib/libc/locale/isspace.3 Directory Properties: stable/9/lib/libc/ (props changed) Modified: stable/9/lib/libc/locale/isspace.3 ============================================================================== --- stable/9/lib/libc/locale/isspace.3 Mon Jun 25 23:22:43 2012 (r237583) +++ stable/9/lib/libc/locale/isspace.3 Mon Jun 25 23:39:35 2012 (r237584) @@ -47,16 +47,16 @@ .Sh DESCRIPTION The .Fn isspace -function tests for the white-space characters. +function tests for white-space characters. For any locale, this includes the following standard characters: .Pp .Bl -column \&`\et''___ \&``\et''___ \&``\et''___ \&``\et''___ \&``\et''___ \&``\et''___ .It "\&``\et''\t``\en''\t``\ev''\t``\ef''\t``\er''\t`` ''" .El .Pp -In the "C" locale +In the "C" locale, .Fn isspace -successful test is limited to this characters only. +returns non-zero for these characters only. The value of the argument must be representable as an .Vt "unsigned char" or the value of From owner-svn-src-stable-9@FreeBSD.ORG Tue Jun 26 03:05:18 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AF3EA1065672; Tue, 26 Jun 2012 03:05:18 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 971C38FC16; Tue, 26 Jun 2012 03:05:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5Q35IA8011357; Tue, 26 Jun 2012 03:05:18 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5Q35IZ5011345; Tue, 26 Jun 2012 03:05:18 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201206260305.q5Q35IZ5011345@svn.freebsd.org> From: Eitan Adler Date: Tue, 26 Jun 2012 03:05:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237589 - stable/9/usr.sbin/mfiutil X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jun 2012 03:05:18 -0000 Author: eadler Date: Tue Jun 26 03:05:17 2012 New Revision: 237589 URL: http://svn.freebsd.org/changeset/base/237589 Log: MFC r237259 r237260 r237329: Allow users with RO privilege to the device to read the RO attributes. [0] Add __unused macros to appropriate places in order to allow building with WARNS=6 on base gcc, gcc46, and clang PR: bin/167302 [0] Approved by: cperciva (implicit) Modified: stable/9/usr.sbin/mfiutil/Makefile stable/9/usr.sbin/mfiutil/mfi_cmd.c stable/9/usr.sbin/mfiutil/mfi_config.c stable/9/usr.sbin/mfiutil/mfi_drive.c stable/9/usr.sbin/mfiutil/mfi_evt.c stable/9/usr.sbin/mfiutil/mfi_flash.c stable/9/usr.sbin/mfiutil/mfi_patrol.c stable/9/usr.sbin/mfiutil/mfi_show.c stable/9/usr.sbin/mfiutil/mfi_volume.c stable/9/usr.sbin/mfiutil/mfiutil.c stable/9/usr.sbin/mfiutil/mfiutil.h Directory Properties: stable/9/usr.sbin/mfiutil/ (props changed) Modified: stable/9/usr.sbin/mfiutil/Makefile ============================================================================== --- stable/9/usr.sbin/mfiutil/Makefile Tue Jun 26 01:32:58 2012 (r237588) +++ stable/9/usr.sbin/mfiutil/Makefile Tue Jun 26 03:05:17 2012 (r237589) @@ -6,7 +6,6 @@ SRCS= mfiutil.c mfi_cmd.c mfi_config.c m MAN8= mfiutil.8 CFLAGS+= -fno-builtin-strftime -WARNS?=3 DPADD= ${LIBUTIL} LDADD= -lutil Modified: stable/9/usr.sbin/mfiutil/mfi_cmd.c ============================================================================== --- stable/9/usr.sbin/mfiutil/mfi_cmd.c Tue Jun 26 01:32:58 2012 (r237588) +++ stable/9/usr.sbin/mfiutil/mfi_cmd.c Tue Jun 26 03:05:17 2012 (r237589) @@ -301,12 +301,12 @@ mfi_ctrl_get_info(int fd, struct mfi_ctr } int -mfi_open(int unit) +mfi_open(int unit, int acs) { char path[MAXPATHLEN]; snprintf(path, sizeof(path), "/dev/mfi%d", unit); - return (open(path, O_RDWR)); + return (open(path, acs)); } void Modified: stable/9/usr.sbin/mfiutil/mfi_config.c ============================================================================== --- stable/9/usr.sbin/mfiutil/mfi_config.c Tue Jun 26 01:32:58 2012 (r237588) +++ stable/9/usr.sbin/mfiutil/mfi_config.c Tue Jun 26 03:05:17 2012 (r237589) @@ -35,6 +35,7 @@ #endif #include #include +#include #include #ifdef DEBUG #include @@ -151,13 +152,13 @@ mfi_config_lookup_volume(struct mfi_conf } static int -clear_config(int ac, char **av) +clear_config(int ac __unused, char **av __unused) { struct mfi_ld_list list; int ch, error, fd; u_int i; - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -410,7 +411,7 @@ find_next_volume(struct config_id_state /* Populate an array with drives. */ static void -build_array(int fd, char *arrayp, struct array_info *array_info, +build_array(int fd __unused, char *arrayp, struct array_info *array_info, struct config_id_state *state, int verbose) { struct mfi_array *ar = (struct mfi_array *)arrayp; @@ -575,7 +576,7 @@ create_volume(int ac, char **av) narrays = 0; error = 0; - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -857,7 +858,7 @@ delete_volume(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -925,7 +926,7 @@ add_spare(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -1050,7 +1051,7 @@ remove_spare(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -1196,7 +1197,7 @@ debug_config(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -1233,7 +1234,7 @@ dump(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); Modified: stable/9/usr.sbin/mfiutil/mfi_drive.c ============================================================================== --- stable/9/usr.sbin/mfiutil/mfi_drive.c Tue Jun 26 01:32:58 2012 (r237588) +++ stable/9/usr.sbin/mfiutil/mfi_drive.c Tue Jun 26 03:05:17 2012 (r237589) @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -71,7 +72,7 @@ mfi_drive_name(struct mfi_pd_info *pinfo else snprintf(buf, sizeof(buf), "%2u", device_id); - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { warn("mfi_open"); return (buf); @@ -329,11 +330,13 @@ cam_strvis(char *dst, const char *src, i const char * mfi_pd_inq_string(struct mfi_pd_info *info) { - struct scsi_inquiry_data *inq_data; + struct scsi_inquiry_data iqd, *inq_data = &iqd; char vendor[16], product[48], revision[16], rstr[12], serial[SID_VENDOR_SPECIFIC_0_SIZE]; static char inq_string[64]; - inq_data = (struct scsi_inquiry_data *)info->inquiry_data; + memcpy(inq_data, info->inquiry_data, + (sizeof (iqd) < sizeof (info->inquiry_data))? + sizeof (iqd) : sizeof (info->inquiry_data)); if (SID_QUAL_IS_VENDOR_UNIQUE(inq_data)) return (NULL); if (SID_TYPE(inq_data) != T_DIRECT) @@ -383,7 +386,7 @@ drive_set_state(char *drive, uint16_t ne uint8_t mbox[6]; int error, fd; - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -484,7 +487,7 @@ start_rebuild(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -541,7 +544,7 @@ abort_rebuild(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -597,7 +600,7 @@ drive_progress(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -663,7 +666,7 @@ drive_clear(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -723,7 +726,7 @@ drive_locate(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); Modified: stable/9/usr.sbin/mfiutil/mfi_evt.c ============================================================================== --- stable/9/usr.sbin/mfiutil/mfi_evt.c Tue Jun 26 01:32:58 2012 (r237588) +++ stable/9/usr.sbin/mfiutil/mfi_evt.c Tue Jun 26 03:05:17 2012 (r237589) @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -63,7 +64,7 @@ mfi_get_events(int fd, struct mfi_evt_li } static int -show_logstate(int ac, char **av) +show_logstate(int ac, char **av __unused) { struct mfi_evt_log_state info; int error, fd; @@ -73,7 +74,7 @@ show_logstate(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -541,7 +542,7 @@ show_events(int ac, char **av) int ch, error, fd, num_events, verbose; u_int i; - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); Modified: stable/9/usr.sbin/mfiutil/mfi_flash.c ============================================================================== --- stable/9/usr.sbin/mfiutil/mfi_flash.c Tue Jun 26 01:32:58 2012 (r237588) +++ stable/9/usr.sbin/mfiutil/mfi_flash.c Tue Jun 26 03:05:17 2012 (r237589) @@ -150,7 +150,7 @@ flash_adapter(int ac, char **av) goto error; } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); Modified: stable/9/usr.sbin/mfiutil/mfi_patrol.c ============================================================================== --- stable/9/usr.sbin/mfiutil/mfi_patrol.c Tue Jun 26 01:32:58 2012 (r237588) +++ stable/9/usr.sbin/mfiutil/mfi_patrol.c Tue Jun 26 03:05:17 2012 (r237589) @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -74,7 +75,7 @@ patrol_get_props(int fd, struct mfi_pr_p } static int -show_patrol(int ac, char **av) +show_patrol(int ac __unused, char **av __unused) { struct mfi_pr_properties prop; struct mfi_pr_status status; @@ -86,7 +87,7 @@ show_patrol(int ac, char **av) int error, fd; u_int i; - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -192,11 +193,11 @@ show_patrol(int ac, char **av) MFI_COMMAND(show, patrol, show_patrol); static int -start_patrol(int ac, char **av) +start_patrol(int ac __unused, char **av __unused) { int error, fd; - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -218,11 +219,11 @@ start_patrol(int ac, char **av) MFI_COMMAND(start, patrol, start_patrol); static int -stop_patrol(int ac, char **av) +stop_patrol(int ac __unused, char **av __unused) { int error, fd; - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -292,7 +293,7 @@ patrol_config(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); Modified: stable/9/usr.sbin/mfiutil/mfi_show.c ============================================================================== --- stable/9/usr.sbin/mfiutil/mfi_show.c Tue Jun 26 01:32:58 2012 (r237588) +++ stable/9/usr.sbin/mfiutil/mfi_show.c Tue Jun 26 03:05:17 2012 (r237589) @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -50,7 +51,7 @@ format_stripe(char *buf, size_t buflen, } static int -show_adapter(int ac, char **av) +show_adapter(int ac, char **av __unused) { struct mfi_ctrl_info info; char stripe[5]; @@ -61,7 +62,7 @@ show_adapter(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDONLY); if (fd < 0) { error = errno; warn("mfi_open"); @@ -135,7 +136,7 @@ show_adapter(int ac, char **av) MFI_COMMAND(show, adapter, show_adapter); static int -show_battery(int ac, char **av) +show_battery(int ac, char **av __unused) { struct mfi_bbu_capacity_info cap; struct mfi_bbu_design_info design; @@ -148,7 +149,7 @@ show_battery(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDONLY); if (fd < 0) { error = errno; warn("mfi_open"); @@ -303,7 +304,7 @@ print_pd(struct mfi_pd_info *info, int s } static int -show_config(int ac, char **av) +show_config(int ac, char **av __unused) { struct mfi_config_data *config; struct mfi_array *ar; @@ -320,7 +321,7 @@ show_config(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDONLY); if (fd < 0) { error = errno; warn("mfi_open"); @@ -409,7 +410,7 @@ show_config(int ac, char **av) MFI_COMMAND(show, config, show_config); static int -show_volumes(int ac, char **av) +show_volumes(int ac, char **av __unused) { struct mfi_ld_list list; struct mfi_ld_info info; @@ -421,7 +422,7 @@ show_volumes(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDONLY); if (fd < 0) { error = errno; warn("mfi_open"); @@ -492,7 +493,7 @@ show_volumes(int ac, char **av) MFI_COMMAND(show, volumes, show_volumes); static int -show_drives(int ac, char **av) +show_drives(int ac, char **av __unused) { struct mfi_pd_list *list; struct mfi_pd_info info; @@ -504,7 +505,7 @@ show_drives(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDONLY); if (fd < 0) { error = errno; warn("mfi_open"); @@ -600,7 +601,7 @@ display_firmware(struct mfi_info_compone } static int -show_firmware(int ac, char **av) +show_firmware(int ac, char **av __unused) { struct mfi_ctrl_info info; struct mfi_info_component header; @@ -612,7 +613,7 @@ show_firmware(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDONLY); if (fd < 0) { error = errno; warn("mfi_open"); @@ -656,7 +657,7 @@ show_firmware(int ac, char **av) MFI_COMMAND(show, firmware, show_firmware); static int -show_progress(int ac, char **av) +show_progress(int ac, char **av __unused) { struct mfi_ld_list llist; struct mfi_pd_list *plist; @@ -672,7 +673,7 @@ show_progress(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDONLY); if (fd < 0) { error = errno; warn("mfi_open"); Modified: stable/9/usr.sbin/mfiutil/mfi_volume.c ============================================================================== --- stable/9/usr.sbin/mfiutil/mfi_volume.c Tue Jun 26 01:32:58 2012 (r237588) +++ stable/9/usr.sbin/mfiutil/mfi_volume.c Tue Jun 26 03:05:17 2012 (r237589) @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -294,7 +295,7 @@ volume_cache(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -402,7 +403,7 @@ volume_name(int ac, char **av) return (ENOSPC); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -453,7 +454,7 @@ volume_progress(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit); + fd = mfi_open(mfi_unit, O_RDONLY); if (fd < 0) { error = errno; warn("mfi_open"); Modified: stable/9/usr.sbin/mfiutil/mfiutil.c ============================================================================== --- stable/9/usr.sbin/mfiutil/mfiutil.c Tue Jun 26 01:32:58 2012 (r237588) +++ stable/9/usr.sbin/mfiutil/mfiutil.c Tue Jun 26 03:05:17 2012 (r237589) @@ -92,10 +92,10 @@ usage(void) } static int -version(int ac, char **av) +version(int ac __unused, char **av __unused) { - printf("mfiutil version 1.0.13"); + printf("mfiutil version 1.0.14"); #ifdef DEBUG printf(" (DEBUG)"); #endif Modified: stable/9/usr.sbin/mfiutil/mfiutil.h ============================================================================== --- stable/9/usr.sbin/mfiutil/mfiutil.h Tue Jun 26 01:32:58 2012 (r237588) +++ stable/9/usr.sbin/mfiutil/mfiutil.h Tue Jun 26 03:05:17 2012 (r237589) @@ -139,7 +139,7 @@ int mfi_lookup_drive(int fd, char *drive int mfi_lookup_volume(int fd, const char *name, uint8_t *target_id); int mfi_dcmd_command(int fd, uint32_t opcode, void *buf, size_t bufsize, uint8_t *mbox, size_t mboxlen, uint8_t *statusp); -int mfi_open(int unit); +int mfi_open(int unit, int acs); int mfi_ctrl_get_info(int fd, struct mfi_ctrl_info *info, uint8_t *statusp); int mfi_ld_get_info(int fd, uint8_t target_id, struct mfi_ld_info *info, uint8_t *statusp); From owner-svn-src-stable-9@FreeBSD.ORG Tue Jun 26 10:32:10 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3C34A1065672; Tue, 26 Jun 2012 10:32:10 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 269568FC14; Tue, 26 Jun 2012 10:32:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5QAWAmf029589; Tue, 26 Jun 2012 10:32:10 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5QAW9C2029587; Tue, 26 Jun 2012 10:32:09 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206261032.q5QAW9C2029587@svn.freebsd.org> From: Konstantin Belousov Date: Tue, 26 Jun 2012 10:32:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237594 - stable/9/sys/dev/agp X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jun 2012 10:32:10 -0000 Author: kib Date: Tue Jun 26 10:32:09 2012 New Revision: 237594 URL: http://svn.freebsd.org/changeset/base/237594 Log: MFC r237484: Correct device id for GPU on some server SandyBridge model. Modified: stable/9/sys/dev/agp/agp_i810.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/agp/agp_i810.c ============================================================================== --- stable/9/sys/dev/agp/agp_i810.c Tue Jun 26 07:56:15 2012 (r237593) +++ stable/9/sys/dev/agp/agp_i810.c Tue Jun 26 10:32:09 2012 (r237594) @@ -700,7 +700,7 @@ static const struct agp_i810_match { .driver = &agp_i810_sb_driver }, { - .devid = 0x01088086, + .devid = 0x010a8086, .name = "SandyBridge server IG", .driver = &agp_i810_sb_driver }, From owner-svn-src-stable-9@FreeBSD.ORG Tue Jun 26 15:29:38 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E15D5106566B; Tue, 26 Jun 2012 15:29:38 +0000 (UTC) (envelope-from iwasaki@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C85DB8FC1B; Tue, 26 Jun 2012 15:29:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5QFTc2P048201; Tue, 26 Jun 2012 15:29:38 GMT (envelope-from iwasaki@svn.freebsd.org) Received: (from iwasaki@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5QFTcX4048199; Tue, 26 Jun 2012 15:29:38 GMT (envelope-from iwasaki@svn.freebsd.org) Message-Id: <201206261529.q5QFTcX4048199@svn.freebsd.org> From: Mitsuru IWASAKI Date: Tue, 26 Jun 2012 15:29:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237602 - stable/9/sys/dev/acpi_support X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jun 2012 15:29:39 -0000 Author: iwasaki Date: Tue Jun 26 15:29:38 2012 New Revision: 237602 URL: http://svn.freebsd.org/changeset/base/237602 Log: MFC 237493: - Add in-driver event handler. Modified: stable/9/sys/dev/acpi_support/acpi_ibm.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/acpi_support/acpi_ibm.c ============================================================================== --- stable/9/sys/dev/acpi_support/acpi_ibm.c Tue Jun 26 14:51:35 2012 (r237601) +++ stable/9/sys/dev/acpi_support/acpi_ibm.c Tue Jun 26 15:29:38 2012 (r237602) @@ -50,6 +50,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include #include @@ -70,6 +72,7 @@ ACPI_MODULE_NAME("IBM") #define ACPI_IBM_METHOD_FANLEVEL 11 #define ACPI_IBM_METHOD_FANSTATUS 12 #define ACPI_IBM_METHOD_THERMAL 13 +#define ACPI_IBM_METHOD_HANDLEREVENTS 14 /* Hotkeys/Buttons */ #define IBM_RTC_HOTKEY1 0x64 @@ -126,6 +129,21 @@ ACPI_MODULE_NAME("IBM") #define IBM_NAME_EVENTS_GET "MHKP" #define IBM_NAME_EVENTS_AVAILMASK "MHKA" +/* Event Code */ +#define IBM_EVENT_LCD_BACKLIGHT 0x03 +#define IBM_EVENT_SUSPEND_TO_RAM 0x04 +#define IBM_EVENT_BLUETOOTH 0x05 +#define IBM_EVENT_SCREEN_EXPAND 0x07 +#define IBM_EVENT_SUSPEND_TO_DISK 0x0c +#define IBM_EVENT_BRIGHTNESS_UP 0x10 +#define IBM_EVENT_BRIGHTNESS_DOWN 0x11 +#define IBM_EVENT_THINKLIGHT 0x12 +#define IBM_EVENT_ZOOM 0x14 +#define IBM_EVENT_VOLUME_UP 0x15 +#define IBM_EVENT_VOLUME_DOWN 0x16 +#define IBM_EVENT_MUTE 0x17 +#define IBM_EVENT_ACCESS_IBM_BUTTON 0x18 + #define ABS(x) (((x) < 0)? -(x) : (x)) struct acpi_ibm_softc { @@ -164,6 +182,8 @@ struct acpi_ibm_softc { int events_mask_supported; int events_enable; + unsigned int handler_events; + struct sysctl_ctx_list *sysctl_ctx; struct sysctl_oid *sysctl_tree; }; @@ -267,8 +287,15 @@ static int acpi_ibm_sysctl_set(struct ac static int acpi_ibm_eventmask_set(struct acpi_ibm_softc *sc, int val); static int acpi_ibm_thermal_sysctl(SYSCTL_HANDLER_ARGS); +static int acpi_ibm_handlerevents_sysctl(SYSCTL_HANDLER_ARGS); static void acpi_ibm_notify(ACPI_HANDLE h, UINT32 notify, void *context); +static int acpi_ibm_brightness_set(struct acpi_ibm_softc *sc, int arg); +static int acpi_ibm_bluetooth_set(struct acpi_ibm_softc *sc, int arg); +static int acpi_ibm_thinklight_set(struct acpi_ibm_softc *sc, int arg); +static int acpi_ibm_volume_set(struct acpi_ibm_softc *sc, int arg); +static int acpi_ibm_mute_set(struct acpi_ibm_softc *sc, int arg); + static device_method_t acpi_ibm_methods[] = { /* Device interface */ DEVMETHOD(device_probe, acpi_ibm_probe), @@ -404,6 +431,15 @@ acpi_ibm_attach(device_t dev) "Thermal zones"); } + /* Hook up handlerevents node */ + if (acpi_ibm_sysctl_init(sc, ACPI_IBM_METHOD_HANDLEREVENTS)) { + SYSCTL_ADD_PROC(sc->sysctl_ctx, + SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, + "handlerevents", CTLTYPE_STRING | CTLFLAG_RW, + sc, 0, acpi_ibm_handlerevents_sysctl, "I", + "devd(8) events handled by acpi_ibm"); + } + /* Handle notifies */ AcpiInstallNotifyHandler(sc->handle, ACPI_DEVICE_NOTIFY, acpi_ibm_notify, dev); @@ -656,10 +692,8 @@ acpi_ibm_sysctl_get(struct acpi_ibm_soft static int acpi_ibm_sysctl_set(struct acpi_ibm_softc *sc, int method, int arg) { - int val, step; + int val; UINT64 val_ec; - ACPI_OBJECT Arg; - ACPI_OBJECT_LIST Args; ACPI_STATUS status; ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); @@ -683,101 +717,23 @@ acpi_ibm_sysctl_set(struct acpi_ibm_soft break; case ACPI_IBM_METHOD_BRIGHTNESS: - if (arg < 0 || arg > 7) - return (EINVAL); - - if (sc->cmos_handle) { - /* Read the current brightness */ - status = ACPI_EC_READ(sc->ec_dev, IBM_EC_BRIGHTNESS, &val_ec, 1); - if (ACPI_FAILURE(status)) - return (status); - val = val_ec & IBM_EC_MASK_BRI; - - Args.Count = 1; - Args.Pointer = &Arg; - Arg.Type = ACPI_TYPE_INTEGER; - Arg.Integer.Value = (arg > val) ? IBM_CMOS_BRIGHTNESS_UP : IBM_CMOS_BRIGHTNESS_DOWN; - - step = (arg > val) ? 1 : -1; - for (int i = val; i != arg; i += step) { - status = AcpiEvaluateObject(sc->cmos_handle, NULL, &Args, NULL); - if (ACPI_FAILURE(status)) - break; - } - } - return ACPI_EC_WRITE(sc->ec_dev, IBM_EC_BRIGHTNESS, arg, 1); + return acpi_ibm_brightness_set(sc, arg); break; case ACPI_IBM_METHOD_VOLUME: - if (arg < 0 || arg > 14) - return (EINVAL); - - status = ACPI_EC_READ(sc->ec_dev, IBM_EC_VOLUME, &val_ec, 1); - if (ACPI_FAILURE(status)) - return (status); - - if (sc->cmos_handle) { - val = val_ec & IBM_EC_MASK_VOL; - - Args.Count = 1; - Args.Pointer = &Arg; - Arg.Type = ACPI_TYPE_INTEGER; - Arg.Integer.Value = (arg > val) ? IBM_CMOS_VOLUME_UP : IBM_CMOS_VOLUME_DOWN; - - step = (arg > val) ? 1 : -1; - for (int i = val; i != arg; i += step) { - status = AcpiEvaluateObject(sc->cmos_handle, NULL, &Args, NULL); - if (ACPI_FAILURE(status)) - break; - } - } - return ACPI_EC_WRITE(sc->ec_dev, IBM_EC_VOLUME, arg + (val_ec & (~IBM_EC_MASK_VOL)), 1); + return acpi_ibm_volume_set(sc, arg); break; case ACPI_IBM_METHOD_MUTE: - if (arg < 0 || arg > 1) - return (EINVAL); - - status = ACPI_EC_READ(sc->ec_dev, IBM_EC_VOLUME, &val_ec, 1); - if (ACPI_FAILURE(status)) - return (status); - - if (sc->cmos_handle) { - Args.Count = 1; - Args.Pointer = &Arg; - Arg.Type = ACPI_TYPE_INTEGER; - Arg.Integer.Value = IBM_CMOS_VOLUME_MUTE; - - status = AcpiEvaluateObject(sc->cmos_handle, NULL, &Args, NULL); - if (ACPI_FAILURE(status)) - break; - } - return ACPI_EC_WRITE(sc->ec_dev, IBM_EC_VOLUME, (arg==1) ? val_ec | IBM_EC_MASK_MUTE : val_ec & (~IBM_EC_MASK_MUTE), 1); + return acpi_ibm_mute_set(sc, arg); break; case ACPI_IBM_METHOD_THINKLIGHT: - if (arg < 0 || arg > 1) - return (EINVAL); - - if (sc->light_set_supported) { - Args.Count = 1; - Args.Pointer = &Arg; - Arg.Type = ACPI_TYPE_INTEGER; - Arg.Integer.Value = arg ? sc->light_cmd_on : sc->light_cmd_off; - - status = AcpiEvaluateObject(sc->light_handle, NULL, &Args, NULL); - if (ACPI_SUCCESS(status)) - sc->light_val = arg; - return (status); - } + return acpi_ibm_thinklight_set(sc, arg); break; case ACPI_IBM_METHOD_BLUETOOTH: - if (arg < 0 || arg > 1) - return (EINVAL); - - val = (arg == 1) ? sc->wlan_bt_flags | IBM_NAME_MASK_BT : sc->wlan_bt_flags & (~IBM_NAME_MASK_BT); - return acpi_SetInteger(sc->handle, IBM_NAME_WLAN_BT_SET, val); + return acpi_ibm_bluetooth_set(sc, arg); break; case ACPI_IBM_METHOD_FANLEVEL: @@ -898,6 +854,9 @@ acpi_ibm_sysctl_init(struct acpi_ibm_sof return (TRUE); } return (FALSE); + + case ACPI_IBM_METHOD_HANDLEREVENTS: + return (TRUE); } return (FALSE); } @@ -937,6 +896,328 @@ acpi_ibm_thermal_sysctl(SYSCTL_HANDLER_A return (error); } +static int +acpi_ibm_handlerevents_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct acpi_ibm_softc *sc; + int error = 0; + struct sbuf sb; + char *cp, *ep; + int l, val; + unsigned int handler_events; + + ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); + + sc = (struct acpi_ibm_softc *)oidp->oid_arg1; + + if (sbuf_new(&sb, NULL, 128, SBUF_AUTOEXTEND) == NULL) + return (ENOMEM); + + ACPI_SERIAL_BEGIN(ibm); + + /* Get old values if this is a get request. */ + if (req->newptr == NULL) { + for (int i = 0; i < 8 * sizeof(sc->handler_events); i++) + if (sc->handler_events & (1 << i)) + sbuf_printf(&sb, "0x%02x ", i + 1); + if (sbuf_len(&sb) == 0) + sbuf_printf(&sb, "NONE"); + } + + sbuf_trim(&sb); + sbuf_finish(&sb); + + /* Copy out the old values to the user. */ + error = SYSCTL_OUT(req, sbuf_data(&sb), sbuf_len(&sb)); + sbuf_delete(&sb); + + if (error != 0 || req->newptr == NULL) + goto out; + + /* If the user is setting a string, parse it. */ + handler_events = 0; + cp = (char *)req->newptr; + while (*cp) { + if (isspace(*cp)) { + cp++; + continue; + } + + ep = cp; + + while (*ep && !isspace(*ep)) + ep++; + + l = ep - cp; + if (l == 0) + break; + + if (strncmp(cp, "NONE", 4) == 0) { + cp = ep; + continue; + } + + if (l >= 3 && cp[0] == '0' && (cp[1] == 'X' || cp[1] == 'x')) + val = strtoul(cp, &ep, 16); + else + val = strtoul(cp, &ep, 10); + + if (val == 0 || ep == cp || val >= 8 * sizeof(handler_events)) { + cp[l] = '\0'; + device_printf(sc->dev, "invalid event code: %s\n", cp); + error = EINVAL; + goto out; + } + + handler_events |= 1 << (val - 1); + + cp = ep; + } + + sc->handler_events = handler_events; +out: + ACPI_SERIAL_END(ibm); + return (error); +} + +static int +acpi_ibm_brightness_set(struct acpi_ibm_softc *sc, int arg) +{ + int val, step; + UINT64 val_ec; + ACPI_OBJECT Arg; + ACPI_OBJECT_LIST Args; + ACPI_STATUS status; + + ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); + ACPI_SERIAL_ASSERT(ibm); + + if (arg < 0 || arg > 7) + return (EINVAL); + + /* Read the current brightness */ + status = ACPI_EC_READ(sc->ec_dev, IBM_EC_BRIGHTNESS, &val_ec, 1); + if (ACPI_FAILURE(status)) + return (status); + + if (sc->cmos_handle) { + val = val_ec & IBM_EC_MASK_BRI; + + Args.Count = 1; + Args.Pointer = &Arg; + Arg.Type = ACPI_TYPE_INTEGER; + Arg.Integer.Value = (arg > val) ? IBM_CMOS_BRIGHTNESS_UP : + IBM_CMOS_BRIGHTNESS_DOWN; + + step = (arg > val) ? 1 : -1; + for (int i = val; i != arg; i += step) { + status = AcpiEvaluateObject(sc->cmos_handle, NULL, + &Args, NULL); + if (ACPI_FAILURE(status)) { + /* Record the last value */ + if (i != val) { + ACPI_EC_WRITE(sc->ec_dev, + IBM_EC_BRIGHTNESS, i - step, 1); + } + return (status); + } + } + } + + return ACPI_EC_WRITE(sc->ec_dev, IBM_EC_BRIGHTNESS, arg, 1); +} + +static int +acpi_ibm_bluetooth_set(struct acpi_ibm_softc *sc, int arg) +{ + int val; + + ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); + ACPI_SERIAL_ASSERT(ibm); + + if (arg < 0 || arg > 1) + return (EINVAL); + + val = (arg == 1) ? sc->wlan_bt_flags | IBM_NAME_MASK_BT : + sc->wlan_bt_flags & (~IBM_NAME_MASK_BT); + return acpi_SetInteger(sc->handle, IBM_NAME_WLAN_BT_SET, val); +} + +static int +acpi_ibm_thinklight_set(struct acpi_ibm_softc *sc, int arg) +{ + ACPI_OBJECT Arg; + ACPI_OBJECT_LIST Args; + ACPI_STATUS status; + + ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); + ACPI_SERIAL_ASSERT(ibm); + + if (arg < 0 || arg > 1) + return (EINVAL); + + if (sc->light_set_supported) { + Args.Count = 1; + Args.Pointer = &Arg; + Arg.Type = ACPI_TYPE_INTEGER; + Arg.Integer.Value = arg ? sc->light_cmd_on : sc->light_cmd_off; + + status = AcpiEvaluateObject(sc->light_handle, NULL, + &Args, NULL); + if (ACPI_SUCCESS(status)) + sc->light_val = arg; + return (status); + } + + return (0); +} + +static int +acpi_ibm_volume_set(struct acpi_ibm_softc *sc, int arg) +{ + int val, step; + UINT64 val_ec; + ACPI_OBJECT Arg; + ACPI_OBJECT_LIST Args; + ACPI_STATUS status; + + ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); + ACPI_SERIAL_ASSERT(ibm); + + if (arg < 0 || arg > 14) + return (EINVAL); + + /* Read the current volume */ + status = ACPI_EC_READ(sc->ec_dev, IBM_EC_VOLUME, &val_ec, 1); + if (ACPI_FAILURE(status)) + return (status); + + if (sc->cmos_handle) { + val = val_ec & IBM_EC_MASK_VOL; + + Args.Count = 1; + Args.Pointer = &Arg; + Arg.Type = ACPI_TYPE_INTEGER; + Arg.Integer.Value = (arg > val) ? IBM_CMOS_VOLUME_UP : + IBM_CMOS_VOLUME_DOWN; + + step = (arg > val) ? 1 : -1; + for (int i = val; i != arg; i += step) { + status = AcpiEvaluateObject(sc->cmos_handle, NULL, + &Args, NULL); + if (ACPI_FAILURE(status)) { + /* Record the last value */ + if (i != val) { + val_ec = i - step + + (val_ec & (~IBM_EC_MASK_VOL)); + ACPI_EC_WRITE(sc->ec_dev, IBM_EC_VOLUME, + val_ec, 1); + } + return (status); + } + } + } + + val_ec = arg + (val_ec & (~IBM_EC_MASK_VOL)); + return ACPI_EC_WRITE(sc->ec_dev, IBM_EC_VOLUME, val_ec, 1); +} + +static int +acpi_ibm_mute_set(struct acpi_ibm_softc *sc, int arg) +{ + UINT64 val_ec; + ACPI_OBJECT Arg; + ACPI_OBJECT_LIST Args; + ACPI_STATUS status; + + ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); + ACPI_SERIAL_ASSERT(ibm); + + if (arg < 0 || arg > 1) + return (EINVAL); + + status = ACPI_EC_READ(sc->ec_dev, IBM_EC_VOLUME, &val_ec, 1); + if (ACPI_FAILURE(status)) + return (status); + + if (sc->cmos_handle) { + Args.Count = 1; + Args.Pointer = &Arg; + Arg.Type = ACPI_TYPE_INTEGER; + Arg.Integer.Value = IBM_CMOS_VOLUME_MUTE; + + status = AcpiEvaluateObject(sc->cmos_handle, NULL, &Args, NULL); + if (ACPI_FAILURE(status)) + return (status); + } + + val_ec = (arg == 1) ? val_ec | IBM_EC_MASK_MUTE : + val_ec & (~IBM_EC_MASK_MUTE); + return ACPI_EC_WRITE(sc->ec_dev, IBM_EC_VOLUME, val_ec, 1); +} + +static void +acpi_ibm_eventhandler(struct acpi_ibm_softc *sc, int arg) +{ + int val; + UINT64 val_ec; + ACPI_STATUS status; + + ACPI_SERIAL_BEGIN(ibm); + switch (arg) { + case IBM_EVENT_SUSPEND_TO_RAM: + power_pm_suspend(POWER_SLEEP_STATE_SUSPEND); + break; + + case IBM_EVENT_BLUETOOTH: + acpi_ibm_bluetooth_set(sc, (sc->wlan_bt_flags == 0)); + break; + + case IBM_EVENT_BRIGHTNESS_UP: + case IBM_EVENT_BRIGHTNESS_DOWN: + /* Read the current brightness */ + status = ACPI_EC_READ(sc->ec_dev, IBM_EC_BRIGHTNESS, + &val_ec, 1); + if (ACPI_FAILURE(status)) + return; + + val = val_ec & IBM_EC_MASK_BRI; + val = (arg == IBM_EVENT_BRIGHTNESS_UP) ? val + 1 : val - 1; + acpi_ibm_brightness_set(sc, val); + break; + + case IBM_EVENT_THINKLIGHT: + acpi_ibm_thinklight_set(sc, (sc->light_val == 0)); + break; + + case IBM_EVENT_VOLUME_UP: + case IBM_EVENT_VOLUME_DOWN: + /* Read the current volume */ + status = ACPI_EC_READ(sc->ec_dev, IBM_EC_VOLUME, &val_ec, 1); + if (ACPI_FAILURE(status)) + return; + + val = val_ec & IBM_EC_MASK_VOL; + val = (arg == IBM_EVENT_VOLUME_UP) ? val + 1 : val - 1; + acpi_ibm_volume_set(sc, val); + break; + + case IBM_EVENT_MUTE: + /* Read the current value */ + status = ACPI_EC_READ(sc->ec_dev, IBM_EC_VOLUME, &val_ec, 1); + if (ACPI_FAILURE(status)) + return; + + val = ((val_ec & IBM_EC_MASK_MUTE) == IBM_EC_MASK_MUTE); + acpi_ibm_mute_set(sc, (val == 0)); + break; + + default: + break; + } + ACPI_SERIAL_END(ibm); +} + static void acpi_ibm_notify(ACPI_HANDLE h, UINT32 notify, void *context) { @@ -965,6 +1246,10 @@ acpi_ibm_notify(ACPI_HANDLE h, UINT32 no break; } + /* Execute event handler */ + if (sc->handler_events & (1 << (arg - 1))) + acpi_ibm_eventhandler(sc, (arg & 0xff)); + /* Notify devd(8) */ acpi_UserNotify("IBM", h, (arg & 0xff)); break; From owner-svn-src-stable-9@FreeBSD.ORG Tue Jun 26 15:30:36 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0A8521065674; Tue, 26 Jun 2012 15:30:36 +0000 (UTC) (envelope-from iwasaki@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E9F198FC17; Tue, 26 Jun 2012 15:30:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5QFUZLp048288; Tue, 26 Jun 2012 15:30:35 GMT (envelope-from iwasaki@svn.freebsd.org) Received: (from iwasaki@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5QFUZoM048286; Tue, 26 Jun 2012 15:30:35 GMT (envelope-from iwasaki@svn.freebsd.org) Message-Id: <201206261530.q5QFUZoM048286@svn.freebsd.org> From: Mitsuru IWASAKI Date: Tue, 26 Jun 2012 15:30:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237603 - stable/9/share/man/man4 X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jun 2012 15:30:36 -0000 Author: iwasaki Date: Tue Jun 26 15:30:35 2012 New Revision: 237603 URL: http://svn.freebsd.org/changeset/base/237603 Log: MFC 237494: - Add description about dev.acpi_ibm.0.handlerevents. Modified: stable/9/share/man/man4/acpi_ibm.4 Directory Properties: stable/9/share/ (props changed) stable/9/share/man/ (props changed) stable/9/share/man/man4/ (props changed) Modified: stable/9/share/man/man4/acpi_ibm.4 ============================================================================== --- stable/9/share/man/man4/acpi_ibm.4 Tue Jun 26 15:29:38 2012 (r237602) +++ stable/9/share/man/man4/acpi_ibm.4 Tue Jun 26 15:30:35 2012 (r237603) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 8, 2010 +.Dd June 24, 2012 .Dt ACPI_IBM 4 .Os .Sh NAME @@ -335,6 +335,17 @@ Built-in battery .It UltraBay battery .El +.It Va dev.acpi_ibm.0.handlerevents +.Xr devd 8 +events handled by +.Nm +when +.Va events +is set to 1. +Events are specified as a whitespace-separated list of event code in +hexadecimal or decimal form. +Note that the event maybe handled twice (eg. Brightness up/down) if ACPI BIOS +already handled the event. .El .Pp Defaults for these sysctls can be set in @@ -436,6 +447,20 @@ then fi exit 0 .Ed +.Pp +The following example specify that event code 0x04 (Suspend to RAM), +0x10 (Brightness up) and 0x11 (Brightness down) are handled by +.Nm . +.Bd -literal -offset indent +sysctl dev.acpi_ibm.0.handlerevents='0x04 0x10 0x11' +.Ed +.Pp +in +.Xr sysctl.conf 5 : +.Bd -literal -offset indent +dev.acpi_ibm.0.handlerevents=0x04\\ 0x10\\ 0x11 +.Ed +.Pp .Sh SEE ALSO .Xr acpi 4 , .Xr led 4 , From owner-svn-src-stable-9@FreeBSD.ORG Wed Jun 27 00:31:31 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 40550106566B; Wed, 27 Jun 2012 00:31:31 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 105F28FC1A; Wed, 27 Jun 2012 00:31:31 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5R0VUrT071079; Wed, 27 Jun 2012 00:31:30 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5R0VU2U071077; Wed, 27 Jun 2012 00:31:30 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201206270031.q5R0VU2U071077@svn.freebsd.org> From: Xin LI Date: Wed, 27 Jun 2012 00:31:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237615 - stable/9/bin/rm X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jun 2012 00:31:31 -0000 Author: delphij Date: Wed Jun 27 00:31:30 2012 New Revision: 237615 URL: http://svn.freebsd.org/changeset/base/237615 Log: MFC r237339: Polish previous revision: if the fts_* routines have lstat()'ed the directory entry then use the struct stat from that instead of doing it again, and skip the rm_overwrite() call if fts_read() indicated that the entry couldn't be a regular file. Obtained from: OpenBSD MFC r237284 (kevlo): Fix potential symlink race condition in "rm -P" by adding a check that the file we have opened is the one we expected. Also open in non-blocking mode to avoid a potential hang with FIFOs. Obtained from: NetBSD via OpenBSD Modified: stable/9/bin/rm/rm.c Directory Properties: stable/9/bin/rm/ (props changed) Modified: stable/9/bin/rm/rm.c ============================================================================== --- stable/9/bin/rm/rm.c Tue Jun 26 23:31:57 2012 (r237614) +++ stable/9/bin/rm/rm.c Wed Jun 27 00:31:30 2012 (r237615) @@ -301,10 +301,16 @@ rm_tree(char **argv) if (fflag) continue; /* FALLTHROUGH */ - default: + + case FTS_F: + case FTS_NSOK: if (Pflag) - if (!rm_overwrite(p->fts_accpath, NULL)) + if (!rm_overwrite(p->fts_accpath, p->fts_info == + FTS_NSOK ? NULL : p->fts_statp)) continue; + /* FALLTHROUGH */ + + default: rval = unlink(p->fts_accpath); if (rval == 0 || (fflag && errno == ENOENT)) { if (rval == 0 && vflag) @@ -408,7 +414,7 @@ rm_file(char **argv) int rm_overwrite(char *file, struct stat *sbp) { - struct stat sb; + struct stat sb, sb2; struct statfs fsb; off_t len; int bsize, fd, wlen; @@ -427,8 +433,15 @@ rm_overwrite(char *file, struct stat *sb file, sbp->st_ino); return (0); } - if ((fd = open(file, O_WRONLY, 0)) == -1) + if ((fd = open(file, O_WRONLY|O_NONBLOCK|O_NOFOLLOW, 0)) == -1) + goto err; + if (fstat(fd, &sb2)) goto err; + if (sb2.st_dev != sbp->st_dev || sb2.st_ino != sbp->st_ino || + !S_ISREG(sb2.st_mode)) { + errno = EPERM; + goto err; + } if (fstatfs(fd, &fsb) == -1) goto err; bsize = MAX(fsb.f_iosize, 1024); From owner-svn-src-stable-9@FreeBSD.ORG Wed Jun 27 05:38:40 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 400E5106566C; Wed, 27 Jun 2012 05:38:40 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 287918FC0C; Wed, 27 Jun 2012 05:38:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5R5ceAl084332; Wed, 27 Jun 2012 05:38:40 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5R5cdjZ084328; Wed, 27 Jun 2012 05:38:39 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201206270538.q5R5cdjZ084328@svn.freebsd.org> From: Alan Cox Date: Wed, 27 Jun 2012 05:38:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237627 - in stable/9/sys/sparc64: include sparc64 X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jun 2012 05:38:40 -0000 Author: alc Date: Wed Jun 27 05:38:39 2012 New Revision: 237627 URL: http://svn.freebsd.org/changeset/base/237627 Log: MFC r236214 Replace all uses of the vm page queues lock by a r/w lock that is private to this pmap.c. Modified: stable/9/sys/sparc64/include/pmap.h stable/9/sys/sparc64/sparc64/pmap.c stable/9/sys/sparc64/sparc64/tsb.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/sparc64/include/pmap.h ============================================================================== --- stable/9/sys/sparc64/include/pmap.h Wed Jun 27 05:23:33 2012 (r237626) +++ stable/9/sys/sparc64/include/pmap.h Wed Jun 27 05:38:39 2012 (r237627) @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -101,6 +102,7 @@ void pmap_set_kctx(void); extern struct pmap kernel_pmap_store; #define kernel_pmap (&kernel_pmap_store) +extern struct rwlock tte_list_global_lock; extern vm_paddr_t phys_avail[]; extern vm_offset_t virtual_avail; extern vm_offset_t virtual_end; Modified: stable/9/sys/sparc64/sparc64/pmap.c ============================================================================== --- stable/9/sys/sparc64/sparc64/pmap.c Wed Jun 27 05:23:33 2012 (r237626) +++ stable/9/sys/sparc64/sparc64/pmap.c Wed Jun 27 05:38:39 2012 (r237627) @@ -71,6 +71,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -134,6 +135,11 @@ vm_offset_t vm_max_kernel_address; struct pmap kernel_pmap_store; /* + * Global tte list lock + */ +struct rwlock tte_list_global_lock; + +/* * Allocate physical memory for use in pmap_bootstrap. */ static vm_paddr_t pmap_bootstrap_alloc(vm_size_t size, uint32_t colors); @@ -666,6 +672,11 @@ pmap_bootstrap(u_int cpu_impl) pm->pm_context[i] = TLB_CTX_KERNEL; CPU_FILL(&pm->pm_active); + /* + * Initialize the global tte list lock. + */ + rw_init(&tte_list_global_lock, "tte list global"); + /* * Flush all non-locked TLB entries possibly left over by the * firmware. @@ -876,7 +887,7 @@ pmap_cache_enter(vm_page_t m, vm_offset_ struct tte *tp; int color; - mtx_assert(&vm_page_queue_mtx, MA_OWNED); + rw_assert(&tte_list_global_lock, RA_WLOCKED); KASSERT((m->flags & PG_FICTITIOUS) == 0, ("pmap_cache_enter: fake page")); PMAP_STATS_INC(pmap_ncache_enter); @@ -951,7 +962,7 @@ pmap_cache_remove(vm_page_t m, vm_offset struct tte *tp; int color; - mtx_assert(&vm_page_queue_mtx, MA_OWNED); + rw_assert(&tte_list_global_lock, RA_WLOCKED); CTR3(KTR_PMAP, "pmap_cache_remove: m=%p va=%#lx c=%d", m, va, m->md.colors[DCACHE_COLOR(va)]); KASSERT((m->flags & PG_FICTITIOUS) == 0, @@ -1026,7 +1037,7 @@ pmap_kenter(vm_offset_t va, vm_page_t m) vm_page_t om; u_long data; - mtx_assert(&vm_page_queue_mtx, MA_OWNED); + rw_assert(&tte_list_global_lock, RA_WLOCKED); PMAP_STATS_INC(pmap_nkenter); tp = tsb_kvtotte(va); CTR4(KTR_PMAP, "pmap_kenter: va=%#lx pa=%#lx tp=%p data=%#lx", @@ -1088,7 +1099,7 @@ pmap_kremove(vm_offset_t va) struct tte *tp; vm_page_t m; - mtx_assert(&vm_page_queue_mtx, MA_OWNED); + rw_assert(&tte_list_global_lock, RA_WLOCKED); PMAP_STATS_INC(pmap_nkremove); tp = tsb_kvtotte(va); CTR3(KTR_PMAP, "pmap_kremove: va=%#lx tp=%p data=%#lx", va, tp, @@ -1139,19 +1150,16 @@ void pmap_qenter(vm_offset_t sva, vm_page_t *m, int count) { vm_offset_t va; - int locked; PMAP_STATS_INC(pmap_nqenter); va = sva; - if (!(locked = mtx_owned(&vm_page_queue_mtx))) - vm_page_lock_queues(); + rw_wlock(&tte_list_global_lock); while (count-- > 0) { pmap_kenter(va, *m); va += PAGE_SIZE; m++; } - if (!locked) - vm_page_unlock_queues(); + rw_wunlock(&tte_list_global_lock); tlb_range_demap(kernel_pmap, sva, va); } @@ -1163,18 +1171,15 @@ void pmap_qremove(vm_offset_t sva, int count) { vm_offset_t va; - int locked; PMAP_STATS_INC(pmap_nqremove); va = sva; - if (!(locked = mtx_owned(&vm_page_queue_mtx))) - vm_page_lock_queues(); + rw_wlock(&tte_list_global_lock); while (count-- > 0) { pmap_kremove(va); va += PAGE_SIZE; } - if (!locked) - vm_page_unlock_queues(); + rw_wunlock(&tte_list_global_lock); tlb_range_demap(kernel_pmap, sva, va); } @@ -1322,7 +1327,7 @@ pmap_remove_tte(struct pmap *pm, struct vm_page_t m; u_long data; - mtx_assert(&vm_page_queue_mtx, MA_OWNED); + rw_assert(&tte_list_global_lock, RA_WLOCKED); data = atomic_readandclear_long(&tp->tte_data); if ((data & TD_FAKE) == 0) { m = PHYS_TO_VM_PAGE(TD_PA(data)); @@ -1359,7 +1364,7 @@ pmap_remove(pmap_t pm, vm_offset_t start pm->pm_context[curcpu], start, end); if (PMAP_REMOVE_DONE(pm)) return; - vm_page_lock_queues(); + rw_wlock(&tte_list_global_lock); PMAP_LOCK(pm); if (end - start > PMAP_TSB_THRESH) { tsb_foreach(pm, NULL, start, end, pmap_remove_tte); @@ -1372,7 +1377,7 @@ pmap_remove(pmap_t pm, vm_offset_t start tlb_range_demap(pm, start, end - 1); } PMAP_UNLOCK(pm); - vm_page_unlock_queues(); + rw_wunlock(&tte_list_global_lock); } void @@ -1385,7 +1390,7 @@ pmap_remove_all(vm_page_t m) KASSERT((m->oflags & VPO_UNMANAGED) == 0, ("pmap_remove_all: page %p is not managed", m)); - vm_page_lock_queues(); + rw_wlock(&tte_list_global_lock); for (tp = TAILQ_FIRST(&m->md.tte_list); tp != NULL; tp = tpn) { tpn = TAILQ_NEXT(tp, tte_link); if ((tp->tte_data & TD_PV) == 0) @@ -1408,7 +1413,7 @@ pmap_remove_all(vm_page_t m) PMAP_UNLOCK(pm); } vm_page_aflag_clear(m, PGA_WRITEABLE); - vm_page_unlock_queues(); + rw_wunlock(&tte_list_global_lock); } static int @@ -1470,10 +1475,10 @@ pmap_enter(pmap_t pm, vm_offset_t va, vm vm_prot_t prot, boolean_t wired) { - vm_page_lock_queues(); + rw_wlock(&tte_list_global_lock); PMAP_LOCK(pm); pmap_enter_locked(pm, va, m, prot, wired); - vm_page_unlock_queues(); + rw_wunlock(&tte_list_global_lock); PMAP_UNLOCK(pm); } @@ -1493,7 +1498,7 @@ pmap_enter_locked(pmap_t pm, vm_offset_t vm_page_t real; u_long data; - mtx_assert(&vm_page_queue_mtx, MA_OWNED); + rw_assert(&tte_list_global_lock, RA_WLOCKED); PMAP_LOCK_ASSERT(pm, MA_OWNED); KASSERT((m->oflags & (VPO_UNMANAGED | VPO_BUSY)) != 0 || VM_OBJECT_LOCKED(m->object), @@ -1636,14 +1641,14 @@ pmap_enter_object(pmap_t pm, vm_offset_t psize = atop(end - start); m = m_start; - vm_page_lock_queues(); + rw_wlock(&tte_list_global_lock); PMAP_LOCK(pm); while (m != NULL && (diff = m->pindex - m_start->pindex) < psize) { pmap_enter_locked(pm, start + ptoa(diff), m, prot & (VM_PROT_READ | VM_PROT_EXECUTE), FALSE); m = TAILQ_NEXT(m, listq); } - vm_page_unlock_queues(); + rw_wunlock(&tte_list_global_lock); PMAP_UNLOCK(pm); } @@ -1651,11 +1656,11 @@ void pmap_enter_quick(pmap_t pm, vm_offset_t va, vm_page_t m, vm_prot_t prot) { - vm_page_lock_queues(); + rw_wlock(&tte_list_global_lock); PMAP_LOCK(pm); pmap_enter_locked(pm, va, m, prot & (VM_PROT_READ | VM_PROT_EXECUTE), FALSE); - vm_page_unlock_queues(); + rw_wunlock(&tte_list_global_lock); PMAP_UNLOCK(pm); } @@ -1721,7 +1726,7 @@ pmap_copy(pmap_t dst_pmap, pmap_t src_pm if (dst_addr != src_addr) return; - vm_page_lock_queues(); + rw_wlock(&tte_list_global_lock); if (dst_pmap < src_pmap) { PMAP_LOCK(dst_pmap); PMAP_LOCK(src_pmap); @@ -1739,7 +1744,7 @@ pmap_copy(pmap_t dst_pmap, pmap_t src_pm pmap_copy_tte(src_pmap, dst_pmap, tp, va); tlb_range_demap(dst_pmap, src_addr, src_addr + len - 1); } - vm_page_unlock_queues(); + rw_wunlock(&tte_list_global_lock); PMAP_UNLOCK(src_pmap); PMAP_UNLOCK(dst_pmap); } @@ -1938,7 +1943,7 @@ pmap_page_exists_quick(pmap_t pm, vm_pag ("pmap_page_exists_quick: page %p is not managed", m)); loops = 0; rv = FALSE; - vm_page_lock_queues(); + rw_wlock(&tte_list_global_lock); TAILQ_FOREACH(tp, &m->md.tte_list, tte_link) { if ((tp->tte_data & TD_PV) == 0) continue; @@ -1949,7 +1954,7 @@ pmap_page_exists_quick(pmap_t pm, vm_pag if (++loops >= 16) break; } - vm_page_unlock_queues(); + rw_wunlock(&tte_list_global_lock); return (rv); } @@ -1966,11 +1971,11 @@ pmap_page_wired_mappings(vm_page_t m) count = 0; if ((m->oflags & VPO_UNMANAGED) != 0) return (count); - vm_page_lock_queues(); + rw_wlock(&tte_list_global_lock); TAILQ_FOREACH(tp, &m->md.tte_list, tte_link) if ((tp->tte_data & (TD_PV | TD_WIRED)) == (TD_PV | TD_WIRED)) count++; - vm_page_unlock_queues(); + rw_wunlock(&tte_list_global_lock); return (count); } @@ -1997,13 +2002,13 @@ pmap_page_is_mapped(vm_page_t m) rv = FALSE; if ((m->oflags & VPO_UNMANAGED) != 0) return (rv); - vm_page_lock_queues(); + rw_wlock(&tte_list_global_lock); TAILQ_FOREACH(tp, &m->md.tte_list, tte_link) if ((tp->tte_data & TD_PV) != 0) { rv = TRUE; break; } - vm_page_unlock_queues(); + rw_wunlock(&tte_list_global_lock); return (rv); } @@ -2029,7 +2034,7 @@ pmap_ts_referenced(vm_page_t m) KASSERT((m->oflags & VPO_UNMANAGED) == 0, ("pmap_ts_referenced: page %p is not managed", m)); count = 0; - vm_page_lock_queues(); + rw_wlock(&tte_list_global_lock); if ((tp = TAILQ_FIRST(&m->md.tte_list)) != NULL) { tpf = tp; do { @@ -2043,7 +2048,7 @@ pmap_ts_referenced(vm_page_t m) break; } while ((tp = tpn) != NULL && tp != tpf); } - vm_page_unlock_queues(); + rw_wunlock(&tte_list_global_lock); return (count); } @@ -2066,7 +2071,7 @@ pmap_is_modified(vm_page_t m) if ((m->oflags & VPO_BUSY) == 0 && (m->aflags & PGA_WRITEABLE) == 0) return (rv); - vm_page_lock_queues(); + rw_wlock(&tte_list_global_lock); TAILQ_FOREACH(tp, &m->md.tte_list, tte_link) { if ((tp->tte_data & TD_PV) == 0) continue; @@ -2075,7 +2080,7 @@ pmap_is_modified(vm_page_t m) break; } } - vm_page_unlock_queues(); + rw_wunlock(&tte_list_global_lock); return (rv); } @@ -2109,7 +2114,7 @@ pmap_is_referenced(vm_page_t m) KASSERT((m->oflags & VPO_UNMANAGED) == 0, ("pmap_is_referenced: page %p is not managed", m)); rv = FALSE; - vm_page_lock_queues(); + rw_wlock(&tte_list_global_lock); TAILQ_FOREACH(tp, &m->md.tte_list, tte_link) { if ((tp->tte_data & TD_PV) == 0) continue; @@ -2118,7 +2123,7 @@ pmap_is_referenced(vm_page_t m) break; } } - vm_page_unlock_queues(); + rw_wunlock(&tte_list_global_lock); return (rv); } @@ -2141,7 +2146,7 @@ pmap_clear_modify(vm_page_t m) */ if ((m->aflags & PGA_WRITEABLE) == 0) return; - vm_page_lock_queues(); + rw_wlock(&tte_list_global_lock); TAILQ_FOREACH(tp, &m->md.tte_list, tte_link) { if ((tp->tte_data & TD_PV) == 0) continue; @@ -2149,7 +2154,7 @@ pmap_clear_modify(vm_page_t m) if ((data & TD_W) != 0) tlb_page_demap(TTE_GET_PMAP(tp), TTE_GET_VA(tp)); } - vm_page_unlock_queues(); + rw_wunlock(&tte_list_global_lock); } void @@ -2160,7 +2165,7 @@ pmap_clear_reference(vm_page_t m) KASSERT((m->oflags & VPO_UNMANAGED) == 0, ("pmap_clear_reference: page %p is not managed", m)); - vm_page_lock_queues(); + rw_wlock(&tte_list_global_lock); TAILQ_FOREACH(tp, &m->md.tte_list, tte_link) { if ((tp->tte_data & TD_PV) == 0) continue; @@ -2168,7 +2173,7 @@ pmap_clear_reference(vm_page_t m) if ((data & TD_REF) != 0) tlb_page_demap(TTE_GET_PMAP(tp), TTE_GET_VA(tp)); } - vm_page_unlock_queues(); + rw_wunlock(&tte_list_global_lock); } void @@ -2189,7 +2194,7 @@ pmap_remove_write(vm_page_t m) if ((m->oflags & VPO_BUSY) == 0 && (m->aflags & PGA_WRITEABLE) == 0) return; - vm_page_lock_queues(); + rw_wlock(&tte_list_global_lock); TAILQ_FOREACH(tp, &m->md.tte_list, tte_link) { if ((tp->tte_data & TD_PV) == 0) continue; @@ -2200,7 +2205,7 @@ pmap_remove_write(vm_page_t m) } } vm_page_aflag_clear(m, PGA_WRITEABLE); - vm_page_unlock_queues(); + rw_wunlock(&tte_list_global_lock); } int Modified: stable/9/sys/sparc64/sparc64/tsb.c ============================================================================== --- stable/9/sys/sparc64/sparc64/tsb.c Wed Jun 27 05:23:33 2012 (r237626) +++ stable/9/sys/sparc64/sparc64/tsb.c Wed Jun 27 05:38:39 2012 (r237627) @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -131,7 +132,7 @@ tsb_tte_enter(pmap_t pm, vm_page_t m, vm PMAP_STATS_INC(tsb_nenter_u_oc); } - mtx_assert(&vm_page_queue_mtx, MA_OWNED); + rw_assert(&tte_list_global_lock, RA_WLOCKED); PMAP_LOCK_ASSERT(pm, MA_OWNED); if (pm == kernel_pmap) { PMAP_STATS_INC(tsb_nenter_k); From owner-svn-src-stable-9@FreeBSD.ORG Wed Jun 27 06:41:00 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 63E61106566C; Wed, 27 Jun 2012 06:41:00 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4B9AA8FC08; Wed, 27 Jun 2012 06:41:00 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5R6f073087560; Wed, 27 Jun 2012 06:41:00 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5R6f0Vb087557; Wed, 27 Jun 2012 06:41:00 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201206270641.q5R6f0Vb087557@svn.freebsd.org> From: Eitan Adler Date: Wed, 27 Jun 2012 06:41:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237632 - stable/9/lib/libc/gen X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jun 2012 06:41:00 -0000 Author: eadler Date: Wed Jun 27 06:40:59 2012 New Revision: 237632 URL: http://svn.freebsd.org/changeset/base/237632 Log: MFC r237286, r237523: Don't close an uninitialized descriptor. PR: bin/167302 Approved by: cperciva (implicit) Modified: stable/9/lib/libc/gen/syslog.c Directory Properties: stable/9/lib/libc/ (props changed) Modified: stable/9/lib/libc/gen/syslog.c ============================================================================== --- stable/9/lib/libc/gen/syslog.c Wed Jun 27 06:08:02 2012 (r237631) +++ stable/9/lib/libc/gen/syslog.c Wed Jun 27 06:40:59 2012 (r237632) @@ -413,8 +413,10 @@ void closelog(void) { THREAD_LOCK(); - (void)_close(LogFile); - LogFile = -1; + if (LogFile != -1) { + (void)_close(LogFile); + LogFile = -1; + } LogTag = NULL; status = NOCONN; THREAD_UNLOCK(); From owner-svn-src-stable-9@FreeBSD.ORG Wed Jun 27 06:43:26 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1D1F51065674 for ; Wed, 27 Jun 2012 06:43:26 +0000 (UTC) (envelope-from lists@eitanadler.com) Received: from mail-ob0-f182.google.com (mail-ob0-f182.google.com [209.85.214.182]) by mx1.freebsd.org (Postfix) with ESMTP id CCF5F8FC18 for ; Wed, 27 Jun 2012 06:43:25 +0000 (UTC) Received: by obbun3 with SMTP id un3so1318467obb.13 for ; Tue, 26 Jun 2012 23:43:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eitanadler.com; s=0xdeadbeef; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:content-type :content-transfer-encoding; bh=bqfAN8BoMlLUpbxDfuW+RzwSNdywBROTmAPRcJRdXfk=; b=GpphY9tYnUjkHcJr+X8DIJ4npcOzsdDMaH7pG1DTHtBjPkjt/qE5iX5+OPXVPTqLOb Y7yBy9/v+85mNBrs6xtZJAgBVE0mkKW29C32FvR8sG14VLAgqbJ7AE8YVhE/2t4urYay gsxGik942vScNk/GqikNVVaaBJikGrqDAVn5Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:content-type :content-transfer-encoding:x-gm-message-state; bh=bqfAN8BoMlLUpbxDfuW+RzwSNdywBROTmAPRcJRdXfk=; b=TQ10XQAnHZk24aBEI9VbVXK6wf5IT2UIZJN6rS4tJxMfUov68ze46D2mwIl1TqxF2M P98wATXakja91Up+RM38g/dfbJlA+OXdeD99DMr3e+pZ+bD7CJlJqpg0PfgOKRyC2bFt R95IaEXcNSrnE6Y5Gthwu3kPovLImlRciiR29NO9NZ57bKubtZ5knKRBQpydVNMrRm0q 6Evs8zMoDY1wpafQ2rFCE0PNO1XNYUoKI3P+TzWx46c07tFkbrhdcVGdTeK6NCY4HUfT sT3hQS7MrzpjWthbfpRb1nE7ht5jlAA3sWxd0AZ04l2pGsDZH3j7ZK3tS/+V4SEhYLas WEuA== Received: by 10.60.168.230 with SMTP id zz6mr12996474oeb.11.1340779405104; Tue, 26 Jun 2012 23:43:25 -0700 (PDT) MIME-Version: 1.0 Sender: lists@eitanadler.com Received: by 10.182.125.70 with HTTP; Tue, 26 Jun 2012 23:42:54 -0700 (PDT) In-Reply-To: <201206270641.q5R6f0Vb087557@svn.freebsd.org> References: <201206270641.q5R6f0Vb087557@svn.freebsd.org> From: Eitan Adler Date: Tue, 26 Jun 2012 23:42:54 -0700 X-Google-Sender-Auth: ChXdSav3XO-UpoGI2NGal-B6q1o Message-ID: To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQkU1+a6KTPxSdLY6YhcADMFVNGLQTdngFy5x54cR21+3K+QPIIIvnXRSMc8gSn8PrER6ju0 Cc: Subject: Re: svn commit: r237632 - stable/9/lib/libc/gen X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jun 2012 06:43:26 -0000 On 26 June 2012 23:41, Eitan Adler wrote: > Author: eadler > Date: Wed Jun 27 06:40:59 2012 > New Revision: 237632 > URL: http://svn.freebsd.org/changeset/base/237632 > > Log: > =C2=A0MFC r237286, r237523: > =C2=A0 =C2=A0 =C2=A0 =C2=A0Don't close an uninitialized descriptor. > > =C2=A0PR: =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 bin/167302 > =C2=A0Approved by: =C2=A0cperciva (implicit) These were supposed to be PR 139080 - I'll fix the PRs --=20 Eitan Adler Source & Ports committer X11, Bugbusting teams From owner-svn-src-stable-9@FreeBSD.ORG Wed Jun 27 11:02:35 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id BA5431065674; Wed, 27 Jun 2012 11:02:35 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A47458FC19; Wed, 27 Jun 2012 11:02:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5RB2Zts006380; Wed, 27 Jun 2012 11:02:35 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5RB2ZLE006378; Wed, 27 Jun 2012 11:02:35 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201206271102.q5RB2ZLE006378@svn.freebsd.org> From: Alexander Motin Date: Wed, 27 Jun 2012 11:02:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237637 - stable/9/sys/cam X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jun 2012 11:02:35 -0000 Author: mav Date: Wed Jun 27 11:02:35 2012 New Revision: 237637 URL: http://svn.freebsd.org/changeset/base/237637 Log: MFC r237398: In camisr() clear CAM_SIM_ON_DONEQ flag after camisr_runqueue() purged SIM done queue. Clearing it before caused extra SIM queueing in some cases. It was invisible during normal operation, but during USB device unplug and respective SIM destruction it could keep pointer on SIM without having counted reference and as result crash the system by use afer free. PR: usb/168743 Modified: stable/9/sys/cam/cam_xpt.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/cam/cam_xpt.c ============================================================================== --- stable/9/sys/cam/cam_xpt.c Wed Jun 27 10:07:29 2012 (r237636) +++ stable/9/sys/cam/cam_xpt.c Wed Jun 27 11:02:35 2012 (r237637) @@ -4990,8 +4990,8 @@ camisr(void *dummy) while ((sim = TAILQ_FIRST(&queue)) != NULL) { TAILQ_REMOVE(&queue, sim, links); CAM_SIM_LOCK(sim); - sim->flags &= ~CAM_SIM_ON_DONEQ; camisr_runqueue(&sim->sim_doneq); + sim->flags &= ~CAM_SIM_ON_DONEQ; CAM_SIM_UNLOCK(sim); } mtx_lock(&cam_simq_lock); From owner-svn-src-stable-9@FreeBSD.ORG Wed Jun 27 11:07:02 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 29A93106566C; Wed, 27 Jun 2012 11:07:02 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 14C558FC0A; Wed, 27 Jun 2012 11:07:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5RB71dp006676; Wed, 27 Jun 2012 11:07:01 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5RB71nK006674; Wed, 27 Jun 2012 11:07:01 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201206271107.q5RB71nK006674@svn.freebsd.org> From: Alexander Motin Date: Wed, 27 Jun 2012 11:07:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237639 - stable/9/sys/cam X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jun 2012 11:07:02 -0000 Author: mav Date: Wed Jun 27 11:07:01 2012 New Revision: 237639 URL: http://svn.freebsd.org/changeset/base/237639 Log: MFC r237401: Make cam_periph_hold() behavior consistent: drop taken reference and return ENXIO if periph was invalidated while we were waiting for it. Modified: stable/9/sys/cam/cam_periph.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/cam/cam_periph.c ============================================================================== --- stable/9/sys/cam/cam_periph.c Wed Jun 27 11:04:04 2012 (r237638) +++ stable/9/sys/cam/cam_periph.c Wed Jun 27 11:07:01 2012 (r237639) @@ -440,6 +440,10 @@ cam_periph_hold(struct cam_periph *perip cam_periph_release_locked(periph); return (error); } + if (periph->flags & CAM_PERIPH_INVALID) { + cam_periph_release_locked(periph); + return (ENXIO); + } } periph->flags |= CAM_PERIPH_LOCKED; From owner-svn-src-stable-9@FreeBSD.ORG Wed Jun 27 11:59:57 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B4C1E106564A; Wed, 27 Jun 2012 11:59:57 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 85A1B8FC0A; Wed, 27 Jun 2012 11:59:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5RBxv12008988; Wed, 27 Jun 2012 11:59:57 GMT (envelope-from mm@svn.freebsd.org) Received: (from mm@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5RBxv6D008986; Wed, 27 Jun 2012 11:59:57 GMT (envelope-from mm@svn.freebsd.org) Message-Id: <201206271159.q5RBxv6D008986@svn.freebsd.org> From: Martin Matuska Date: Wed, 27 Jun 2012 11:59:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237643 - stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jun 2012 11:59:57 -0000 Author: mm Date: Wed Jun 27 11:59:57 2012 New Revision: 237643 URL: http://svn.freebsd.org/changeset/base/237643 Log: MFC r236823 (pjd): ds_guid of 0 is special, as it is used by snapshot receive code to differentiate between an incremental and full stream. Be sure not to generate guid equal to 0. Reported by: someone who saw 0 being generated as 64bit random guid Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c ============================================================================== --- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c Wed Jun 27 11:36:33 2012 (r237642) +++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c Wed Jun 27 11:59:57 2012 (r237643) @@ -809,8 +809,10 @@ dsl_dataset_create_sync_dd(dsl_dir_t *dd dsphys->ds_dir_obj = dd->dd_object; dsphys->ds_flags = flags; dsphys->ds_fsid_guid = unique_create(); - (void) random_get_pseudo_bytes((void*)&dsphys->ds_guid, - sizeof (dsphys->ds_guid)); + do { + (void) random_get_pseudo_bytes((void*)&dsphys->ds_guid, + sizeof (dsphys->ds_guid)); + } while (dsphys->ds_guid == 0); dsphys->ds_snapnames_zapobj = zap_create_norm(mos, U8_TEXTPREP_TOUPPER, DMU_OT_DSL_DS_SNAP_MAP, DMU_OT_NONE, 0, tx); @@ -2082,8 +2084,10 @@ dsl_dataset_snapshot_sync(void *arg1, vo bzero(dsphys, sizeof (dsl_dataset_phys_t)); dsphys->ds_dir_obj = ds->ds_dir->dd_object; dsphys->ds_fsid_guid = unique_create(); - (void) random_get_pseudo_bytes((void*)&dsphys->ds_guid, - sizeof (dsphys->ds_guid)); + do { + (void) random_get_pseudo_bytes((void*)&dsphys->ds_guid, + sizeof (dsphys->ds_guid)); + } while (dsphys->ds_guid == 0); dsphys->ds_prev_snap_obj = ds->ds_phys->ds_prev_snap_obj; dsphys->ds_prev_snap_txg = ds->ds_phys->ds_prev_snap_txg; dsphys->ds_next_snap_obj = ds->ds_object; From owner-svn-src-stable-9@FreeBSD.ORG Wed Jun 27 21:05:21 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 85FEF10656A6; Wed, 27 Jun 2012 21:05:21 +0000 (UTC) (envelope-from gavin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7095A8FC15; Wed, 27 Jun 2012 21:05:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5RL5L0I032628; Wed, 27 Jun 2012 21:05:21 GMT (envelope-from gavin@svn.freebsd.org) Received: (from gavin@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5RL5LEr032626; Wed, 27 Jun 2012 21:05:21 GMT (envelope-from gavin@svn.freebsd.org) Message-Id: <201206272105.q5RL5LEr032626@svn.freebsd.org> From: Gavin Atkinson Date: Wed, 27 Jun 2012 21:05:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237662 - stable/9/sys/dev/drm2 X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jun 2012 21:05:21 -0000 Author: gavin Date: Wed Jun 27 21:05:21 2012 New Revision: 237662 URL: http://svn.freebsd.org/changeset/base/237662 Log: Merge r237411 from head (originally by emast): Add PCI IDs for Ivy Bridge Requested by: emaste Modified: stable/9/sys/dev/drm2/drm_pciids.h Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/drm2/drm_pciids.h ============================================================================== --- stable/9/sys/dev/drm2/drm_pciids.h Wed Jun 27 20:34:29 2012 (r237661) +++ stable/9/sys/dev/drm2/drm_pciids.h Wed Jun 27 21:05:21 2012 (r237662) @@ -566,6 +566,12 @@ {0x8086, 0x0116, CHIP_I9XX|CHIP_I915, "Intel SandyBridge (M)"}, \ {0x8086, 0x0126, CHIP_I9XX|CHIP_I915, "Intel SandyBridge (M)"}, \ {0x8086, 0x010A, CHIP_I9XX|CHIP_I915, "Intel SandyBridge (M)"}, \ + {0x8086, 0x0152, CHIP_I9XX|CHIP_I915, "Intel IvyBridge"}, \ + {0x8086, 0x0162, CHIP_I9XX|CHIP_I915, "Intel IvyBridge"}, \ + {0x8086, 0x0156, CHIP_I9XX|CHIP_I915, "Intel IvyBridge (M)"}, \ + {0x8086, 0x0166, CHIP_I9XX|CHIP_I915, "Intel IvyBridge (M)"}, \ + {0x8086, 0x015A, CHIP_I9XX|CHIP_I915, "Intel IvyBridge (S)"}, \ + {0x8086, 0x016A, CHIP_I9XX|CHIP_I915, "Intel IvyBridge (S)"}, \ {0x8086, 0xA001, CHIP_I9XX|CHIP_I965, "Intel Pineview"}, \ {0x8086, 0xA011, CHIP_I9XX|CHIP_I965, "Intel Pineview (M)"}, \ {0, 0, 0, NULL} From owner-svn-src-stable-9@FreeBSD.ORG Wed Jun 27 21:12:16 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E994310657A5; Wed, 27 Jun 2012 21:12:16 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CC02E8FC14; Wed, 27 Jun 2012 21:12:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5RLCGsX032960; Wed, 27 Jun 2012 21:12:16 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5RLCGPK032949; Wed, 27 Jun 2012 21:12:16 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201206272112.q5RLCGPK032949@svn.freebsd.org> From: John Baldwin Date: Wed, 27 Jun 2012 21:12:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237663 - in stable/9: sys/kern sys/sys sys/vm usr.bin/kdump usr.bin/ktrace X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jun 2012 21:12:17 -0000 Author: jhb Date: Wed Jun 27 21:12:15 2012 New Revision: 237663 URL: http://svn.freebsd.org/changeset/base/237663 Log: MFC 233925,236357: Add new ktrace records for the start and end of VM faults. This gives a pair of records similar to syscall entry and return that a user can use to determine how long page faults take. The new ktrace records are enabled via the 'p' trace type, but are not enabled in the default set of trace points. Modified: stable/9/sys/kern/kern_ktrace.c stable/9/sys/sys/ktrace.h stable/9/sys/vm/vm_fault.c stable/9/usr.bin/kdump/kdump.1 stable/9/usr.bin/kdump/kdump.c stable/9/usr.bin/kdump/kdump_subr.h stable/9/usr.bin/kdump/mksubr stable/9/usr.bin/ktrace/ktrace.1 stable/9/usr.bin/ktrace/ktrace.h stable/9/usr.bin/ktrace/subr.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/dev/isp/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/modules/ (props changed) stable/9/usr.bin/kdump/ (props changed) stable/9/usr.bin/ktrace/ (props changed) Modified: stable/9/sys/kern/kern_ktrace.c ============================================================================== --- stable/9/sys/kern/kern_ktrace.c Wed Jun 27 21:05:21 2012 (r237662) +++ stable/9/sys/kern/kern_ktrace.c Wed Jun 27 21:12:15 2012 (r237663) @@ -100,6 +100,8 @@ struct ktr_request { struct ktr_genio ktr_genio; struct ktr_psig ktr_psig; struct ktr_csw ktr_csw; + struct ktr_fault ktr_fault; + struct ktr_faultend ktr_faultend; } ktr_data; STAILQ_ENTRY(ktr_request) ktr_list; }; @@ -117,6 +119,8 @@ static int data_lengths[] = { 0, /* KTR_SYSCTL */ sizeof(struct ktr_proc_ctor), /* KTR_PROCCTOR */ 0, /* KTR_PROCDTOR */ + sizeof(struct ktr_fault), /* KTR_FAULT */ + sizeof(struct ktr_faultend), /* KTR_FAULTEND */ }; static STAILQ_HEAD(, ktr_request) ktr_free; @@ -768,6 +772,42 @@ ktrstruct(name, data, datalen) req->ktr_header.ktr_len = buflen; ktr_submitrequest(curthread, req); } + +void +ktrfault(vaddr, type) + vm_offset_t vaddr; + int type; +{ + struct thread *td = curthread; + struct ktr_request *req; + struct ktr_fault *kf; + + req = ktr_getrequest(KTR_FAULT); + if (req == NULL) + return; + kf = &req->ktr_data.ktr_fault; + kf->vaddr = vaddr; + kf->type = type; + ktr_enqueuerequest(td, req); + ktrace_exit(td); +} + +void +ktrfaultend(result) + int result; +{ + struct thread *td = curthread; + struct ktr_request *req; + struct ktr_faultend *kf; + + req = ktr_getrequest(KTR_FAULTEND); + if (req == NULL) + return; + kf = &req->ktr_data.ktr_faultend; + kf->result = result; + ktr_enqueuerequest(td, req); + ktrace_exit(td); +} #endif /* KTRACE */ /* Interface and common routines */ Modified: stable/9/sys/sys/ktrace.h ============================================================================== --- stable/9/sys/sys/ktrace.h Wed Jun 27 21:05:21 2012 (r237662) +++ stable/9/sys/sys/ktrace.h Wed Jun 27 21:12:15 2012 (r237663) @@ -178,6 +178,23 @@ struct ktr_proc_ctor { #define KTR_PROCDTOR 11 /* + * KTR_FAULT - page fault record + */ +#define KTR_FAULT 13 +struct ktr_fault { + vm_offset_t vaddr; + int type; +}; + +/* + * KTR_FAULTEND - end of page fault record + */ +#define KTR_FAULTEND 14 +struct ktr_faultend { + int result; +}; + +/* * KTR_DROP - If this bit is set in ktr_type, then at least one event * between the previous record and this record was dropped. */ @@ -198,6 +215,8 @@ struct ktr_proc_ctor { #define KTRFAC_SYSCTL (1< __FBSDID("$FreeBSD$"); +#include "opt_ktrace.h" #include "opt_vm.h" #include @@ -86,6 +87,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef KTRACE +#include +#endif #include #include @@ -212,10 +216,23 @@ int vm_fault(vm_map_t map, vm_offset_t vaddr, vm_prot_t fault_type, int fault_flags) { + struct thread *td; + int result; - if ((curthread->td_pflags & TDP_NOFAULTING) != 0) + td = curthread; + if ((td->td_pflags & TDP_NOFAULTING) != 0) return (KERN_PROTECTION_FAILURE); - return (vm_fault_hold(map, vaddr, fault_type, fault_flags, NULL)); +#ifdef KTRACE + if (map != kernel_map && KTRPOINT(td, KTR_FAULT)) + ktrfault(vaddr, fault_type); +#endif + result = vm_fault_hold(map, trunc_page(vaddr), fault_type, fault_flags, + NULL); +#ifdef KTRACE + if (map != kernel_map && KTRPOINT(td, KTR_FAULTEND)) + ktrfaultend(result); +#endif + return (result); } int Modified: stable/9/usr.bin/kdump/kdump.1 ============================================================================== --- stable/9/usr.bin/kdump/kdump.1 Wed Jun 27 21:05:21 2012 (r237662) +++ stable/9/usr.bin/kdump/kdump.1 Wed Jun 27 21:12:15 2012 (r237663) @@ -28,7 +28,7 @@ .\" @(#)kdump.1 8.1 (Berkeley) 6/6/93 .\" $FreeBSD$ .\" -.Dd February 23, 2008 +.Dd April 5, 2012 .Dt KDUMP 1 .Os .Sh NAME @@ -171,6 +171,8 @@ The possible operations are: .It Li USER Ta data from user process Ta the data .It Li STRU Ta various syscalls Ta structure .It Li SCTL Ta Xr sysctl 3 requests Ta MIB name +.It Li PFLT Ta enter page fault Ta fault address and type +.It Li PRET Ta return from page fault Ta fault result .El .Sh SEE ALSO .Xr ktrace 1 Modified: stable/9/usr.bin/kdump/kdump.c ============================================================================== --- stable/9/usr.bin/kdump/kdump.c Wed Jun 27 21:05:21 2012 (r237662) +++ stable/9/usr.bin/kdump/kdump.c Wed Jun 27 21:12:15 2012 (r237663) @@ -99,6 +99,8 @@ void ktruser(int, unsigned char *); void ktrsockaddr(struct sockaddr *); void ktrstat(struct stat *); void ktrstruct(char *, size_t); +void ktrfault(struct ktr_fault *); +void ktrfaultend(struct ktr_faultend *); void usage(void); void sockfamilyname(int); const char *ioctlname(u_long); @@ -302,6 +304,12 @@ main(int argc, char *argv[]) case KTR_STRUCT: ktrstruct(m, ktrlen); break; + case KTR_FAULT: + ktrfault((struct ktr_fault *)m); + break; + case KTR_FAULTEND: + ktrfaultend((struct ktr_faultend *)m); + break; default: printf("\n"); break; @@ -441,6 +449,12 @@ dumpheader(struct ktr_header *kth) /* FALLTHROUGH */ case KTR_PROCDTOR: return; + case KTR_FAULT: + type = "PFLT"; + break; + case KTR_FAULTEND: + type = "PRET"; + break; default: (void)sprintf(unknown, "UNKNOWN(%d)", kth->ktr_type); type = unknown; @@ -1512,6 +1526,23 @@ invalid: printf("invalid record\n"); } +void +ktrfault(struct ktr_fault *ktr) +{ + + printf("0x%jx ", ktr->vaddr); + vmprotname(ktr->type); + printf("\n"); +} + +void +ktrfaultend(struct ktr_faultend *ktr) +{ + + vmresultname(ktr->result); + printf("\n"); +} + #if defined(__amd64__) || defined(__i386__) void linux_ktrsyscall(struct ktr_syscall *ktr) Modified: stable/9/usr.bin/kdump/kdump_subr.h ============================================================================== --- stable/9/usr.bin/kdump/kdump_subr.h Wed Jun 27 21:05:21 2012 (r237662) +++ stable/9/usr.bin/kdump/kdump_subr.h Wed Jun 27 21:12:15 2012 (r237663) @@ -46,3 +46,5 @@ void lio_listioname (int); void minheritname (int); void quotactlname (int); void ptraceopname (int); +void vmprotname (int); +void vmresultname (int); Modified: stable/9/usr.bin/kdump/mksubr ============================================================================== --- stable/9/usr.bin/kdump/mksubr Wed Jun 27 21:05:21 2012 (r237662) +++ stable/9/usr.bin/kdump/mksubr Wed Jun 27 21:12:15 2012 (r237663) @@ -185,6 +185,8 @@ cat <<_EOF_ #include #include #include +#include +#include #include "kdump_subr.h" @@ -329,6 +331,26 @@ sockoptlevelname (int level, int decimal } } +/* + * MANUAL + * + * Used for page fault type. Cannot use auto_or_type since the macro + * values contain a cast. Also, VM_PROT_NONE has to be handled specially. + */ +void +vmprotname (int type) +{ + int or = 0; + + if (type == VM_PROT_NONE) { + (void)printf("VM_PROT_NONE"); + return; + } + if_print_or(type, VM_PROT_READ, or); + if_print_or(type, VM_PROT_WRITE, or); + if_print_or(type, VM_PROT_EXECUTE, or); + if_print_or(type, VM_PROT_COPY, or); +} _EOF_ auto_or_type "modename" "S_[A-Z]+[[:space:]]+[0-6]{7}" "sys/stat.h" @@ -370,6 +392,7 @@ auto_if_type "sockipprotoname" "IPPROTO_ auto_switch_type "sockoptname" "SO_[A-Z]+[[:space:]]+0x[0-9]+" "sys/socket.h" auto_switch_type "socktypename" "SOCK_[A-Z]+[[:space:]]+[1-9]+[0-9]*" "sys/socket.h" auto_switch_type "ptraceopname" "PT_[[:alnum:]_]+[[:space:]]+[0-9]+" "sys/ptrace.h" +auto_switch_type "vmresultname" "KERN_[A-Z]+[[:space:]]+[0-9]+" "vm/vm_param.h" cat <<_EOF_ /* Modified: stable/9/usr.bin/ktrace/ktrace.1 ============================================================================== --- stable/9/usr.bin/ktrace/ktrace.1 Wed Jun 27 21:05:21 2012 (r237662) +++ stable/9/usr.bin/ktrace/ktrace.1 Wed Jun 27 21:12:15 2012 (r237663) @@ -28,7 +28,7 @@ .\" @(#)ktrace.1 8.1 (Berkeley) 6/6/93 .\" $FreeBSD$ .\" -.Dd February 23, 2008 +.Dd May 31, 2012 .Dt KTRACE 1 .Os .Sh NAME @@ -108,6 +108,8 @@ The following table equates the letters .Bl -tag -width flag -compact .It Cm c trace system calls +.It Cm f +trace page faults .It Cm i trace .Tn I/O Modified: stable/9/usr.bin/ktrace/ktrace.h ============================================================================== --- stable/9/usr.bin/ktrace/ktrace.h Wed Jun 27 21:05:21 2012 (r237662) +++ stable/9/usr.bin/ktrace/ktrace.h Wed Jun 27 21:12:15 2012 (r237663) @@ -36,7 +36,8 @@ #define PROC_ABI_POINTS (KTRFAC_PROCCTOR | KTRFAC_PROCDTOR) -#define ALL_POINTS (DEF_POINTS | KTRFAC_CSW | PROC_ABI_POINTS) +#define ALL_POINTS (DEF_POINTS | KTRFAC_CSW | PROC_ABI_POINTS | \ + KTRFAC_FAULT | KTRFAC_FAULTEND) #define DEF_TRACEFILE "ktrace.out" Modified: stable/9/usr.bin/ktrace/subr.c ============================================================================== --- stable/9/usr.bin/ktrace/subr.c Wed Jun 27 21:05:21 2012 (r237662) +++ stable/9/usr.bin/ktrace/subr.c Wed Jun 27 21:12:15 2012 (r237663) @@ -61,6 +61,9 @@ getpoints(char *s) case 'c': facs |= KTRFAC_SYSCALL | KTRFAC_SYSRET; break; + case 'f': + facs |= KTRFAC_FAULT | KTRFAC_FAULTEND; + break; case 'n': facs |= KTRFAC_NAMEI; break; From owner-svn-src-stable-9@FreeBSD.ORG Wed Jun 27 21:18:48 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 225DD106566C; Wed, 27 Jun 2012 21:18:48 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0D6AD8FC0C; Wed, 27 Jun 2012 21:18:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5RLIl26033353; Wed, 27 Jun 2012 21:18:47 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5RLIlqO033351; Wed, 27 Jun 2012 21:18:47 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <201206272118.q5RLIlqO033351@svn.freebsd.org> From: Jung-uk Kim Date: Wed, 27 Jun 2012 21:18:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237665 - stable/9/sys/sys X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jun 2012 21:18:48 -0000 Author: jkim Date: Wed Jun 27 21:18:47 2012 New Revision: 237665 URL: http://svn.freebsd.org/changeset/base/237665 Log: MFC: r237025 Add a convenience macro for the fastcall attribute. Modified: stable/9/sys/sys/cdefs.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/sys/cdefs.h ============================================================================== --- stable/9/sys/sys/cdefs.h Wed Jun 27 21:13:00 2012 (r237664) +++ stable/9/sys/sys/cdefs.h Wed Jun 27 21:18:47 2012 (r237665) @@ -293,6 +293,12 @@ #define __nonnull(x) #endif +#if __GNUC_PREREQ__(3, 4) +#define __fastcall __attribute__((__fastcall__)) +#else +#define __fastcall +#endif + #if __GNUC_PREREQ__(4, 1) #define __returns_twice __attribute__((__returns_twice__)) #else From owner-svn-src-stable-9@FreeBSD.ORG Wed Jun 27 22:06:43 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6E64B1065672; Wed, 27 Jun 2012 22:06:43 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 57A238FC12; Wed, 27 Jun 2012 22:06:43 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5RM6hfm035443; Wed, 27 Jun 2012 22:06:43 GMT (envelope-from thompsa@svn.freebsd.org) Received: (from thompsa@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5RM6hVT035441; Wed, 27 Jun 2012 22:06:43 GMT (envelope-from thompsa@svn.freebsd.org) Message-Id: <201206272206.q5RM6hVT035441@svn.freebsd.org> From: Andrew Thompson Date: Wed, 27 Jun 2012 22:06:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237669 - stable/9/sys/net X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jun 2012 22:06:43 -0000 Author: thompsa Date: Wed Jun 27 22:06:42 2012 New Revision: 237669 URL: http://svn.freebsd.org/changeset/base/237669 Log: MFC r236062 Turn LACP debugging from a compile time option to a sysctl, it is very handy to be able to turn it on when negotiation to a switch misbehaves. Modified: stable/9/sys/net/ieee8023ad_lacp.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/dev/isp/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/modules/ (props changed) Modified: stable/9/sys/net/ieee8023ad_lacp.c ============================================================================== --- stable/9/sys/net/ieee8023ad_lacp.c Wed Jun 27 21:48:56 2012 (r237668) +++ stable/9/sys/net/ieee8023ad_lacp.c Wed Jun 27 22:06:42 2012 (r237669) @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include /* hz */ #include /* for net/if.h */ #include +#include #include #include #include @@ -168,7 +169,8 @@ static void lacp_enable_distributing(str static int lacp_xmit_lacpdu(struct lacp_port *); static int lacp_xmit_marker(struct lacp_port *); -#if defined(LACP_DEBUG) +/* Debugging */ + static void lacp_dump_lacpdu(const struct lacpdu *); static const char *lacp_format_partner(const struct lacp_peerinfo *, char *, size_t); @@ -184,10 +186,14 @@ static const char *lacp_format_portid(co size_t); static void lacp_dprintf(const struct lacp_port *, const char *, ...) __attribute__((__format__(__printf__, 2, 3))); -#define LACP_DPRINTF(a) lacp_dprintf a -#else -#define LACP_DPRINTF(a) /* nothing */ -#endif + +static int lacp_debug = 0; +SYSCTL_INT(_net, OID_AUTO, lacp_debug, CTLFLAG_RW | CTLFLAG_TUN, + &lacp_debug, 0, "Enable LACP debug logging (1=debug, 2=trace)"); +TUNABLE_INT("net.lacp_debug", &lacp_debug); + +#define LACP_DPRINTF(a) if (lacp_debug > 0) { lacp_dprintf a ; } +#define LACP_TRACE(a) if (lacp_debug > 1) { lacp_dprintf(a,"%s\n",__func__); } /* * partner administration variables. @@ -290,10 +296,10 @@ lacp_pdu_input(struct lacp_port *lp, str goto bad; } -#if defined(LACP_DEBUG) - LACP_DPRINTF((lp, "lacpdu receive\n")); - lacp_dump_lacpdu(du); -#endif /* defined(LACP_DEBUG) */ + if (lacp_debug > 0) { + lacp_dprintf(lp, "lacpdu receive\n"); + lacp_dump_lacpdu(du); + } LACP_LOCK(lsc); lacp_sm_rx(lp, du); @@ -370,10 +376,10 @@ lacp_xmit_lacpdu(struct lacp_port *lp) sizeof(du->ldu_collector)); du->ldu_collector.lci_maxdelay = 0; -#if defined(LACP_DEBUG) - LACP_DPRINTF((lp, "lacpdu transmit\n")); - lacp_dump_lacpdu(du); -#endif /* defined(LACP_DEBUG) */ + if (lacp_debug > 0) { + lacp_dprintf(lp, "lacpdu transmit\n"); + lacp_dump_lacpdu(du); + } m->m_flags |= M_MCAST; @@ -647,9 +653,7 @@ lacp_disable_distributing(struct lacp_po { struct lacp_aggregator *la = lp->lp_aggregator; struct lacp_softc *lsc = lp->lp_lsc; -#if defined(LACP_DEBUG) char buf[LACP_LAGIDSTR_MAX+1]; -#endif /* defined(LACP_DEBUG) */ LACP_LOCK_ASSERT(lsc); @@ -684,9 +688,7 @@ lacp_enable_distributing(struct lacp_por { struct lacp_aggregator *la = lp->lp_aggregator; struct lacp_softc *lsc = lp->lp_lsc; -#if defined(LACP_DEBUG) char buf[LACP_LAGIDSTR_MAX+1]; -#endif /* defined(LACP_DEBUG) */ LACP_LOCK_ASSERT(lsc); @@ -720,7 +722,8 @@ lacp_transit_expire(void *vp) LACP_LOCK_ASSERT(lsc); - LACP_DPRINTF((NULL, "%s\n", __func__)); + LACP_TRACE(NULL); + lsc->lsc_suppress_distributing = FALSE; } @@ -838,7 +841,8 @@ lacp_suppress_distributing(struct lacp_s return; } - LACP_DPRINTF((NULL, "%s\n", __func__)); + LACP_TRACE(NULL); + lsc->lsc_suppress_distributing = TRUE; /* send a marker frame down each port to verify the queues are empty */ @@ -908,11 +912,9 @@ lacp_select_active_aggregator(struct lac struct lacp_aggregator *la; struct lacp_aggregator *best_la = NULL; uint64_t best_speed = 0; -#if defined(LACP_DEBUG) char buf[LACP_LAGIDSTR_MAX+1]; -#endif /* defined(LACP_DEBUG) */ - LACP_DPRINTF((NULL, "%s:\n", __func__)); + LACP_TRACE(NULL); TAILQ_FOREACH(la, &lsc->lsc_aggregators, la_q) { uint64_t speed; @@ -946,7 +948,6 @@ lacp_select_active_aggregator(struct lac KASSERT(best_la == NULL || !TAILQ_EMPTY(&best_la->la_ports), ("invalid aggregator list")); -#if defined(LACP_DEBUG) if (lsc->lsc_active_aggregator != best_la) { LACP_DPRINTF((NULL, "active aggregator changed\n")); LACP_DPRINTF((NULL, "old %s\n", @@ -957,7 +958,6 @@ lacp_select_active_aggregator(struct lac } LACP_DPRINTF((NULL, "new %s\n", lacp_format_lagid_aggregator(best_la, buf, sizeof(buf)))); -#endif /* defined(LACP_DEBUG) */ if (lsc->lsc_active_aggregator != best_la) { sc->sc_ifp->if_baudrate = best_speed; @@ -1040,9 +1040,7 @@ lacp_compose_key(struct lacp_port *lp) static void lacp_aggregator_addref(struct lacp_softc *lsc, struct lacp_aggregator *la) { -#if defined(LACP_DEBUG) char buf[LACP_LAGIDSTR_MAX+1]; -#endif LACP_DPRINTF((NULL, "%s: lagid=%s, refcnt %d -> %d\n", __func__, @@ -1058,9 +1056,7 @@ lacp_aggregator_addref(struct lacp_softc static void lacp_aggregator_delref(struct lacp_softc *lsc, struct lacp_aggregator *la) { -#if defined(LACP_DEBUG) char buf[LACP_LAGIDSTR_MAX+1]; -#endif LACP_DPRINTF((NULL, "%s: lagid=%s, refcnt %d -> %d\n", __func__, @@ -1195,9 +1191,7 @@ lacp_select(struct lacp_port *lp) { struct lacp_softc *lsc = lp->lp_lsc; struct lacp_aggregator *la; -#if defined(LACP_DEBUG) char buf[LACP_LAGIDSTR_MAX+1]; -#endif if (lp->lp_aggregator) { return; @@ -1278,7 +1272,8 @@ lacp_sm_mux(struct lacp_port *lp) enum lacp_selected selected = lp->lp_selected; struct lacp_aggregator *la; - /* LACP_DPRINTF((lp, "%s: state %d\n", __func__, lp->lp_mux_state)); */ + if (lacp_debug > 1) + lacp_dprintf(lp, "%s: state %d\n", __func__, lp->lp_mux_state); re_eval: la = lp->lp_aggregator; @@ -1387,9 +1382,7 @@ static void lacp_sm_mux_timer(struct lacp_port *lp) { struct lacp_aggregator *la = lp->lp_aggregator; -#if defined(LACP_DEBUG) char buf[LACP_LAGIDSTR_MAX+1]; -#endif KASSERT(la->la_pending > 0, ("no pending event")); @@ -1537,11 +1530,9 @@ lacp_sm_rx_record_pdu(struct lacp_port * { boolean_t active; uint8_t oldpstate; -#if defined(LACP_DEBUG) char buf[LACP_STATESTR_MAX+1]; -#endif - /* LACP_DPRINTF((lp, "%s\n", __func__)); */ + LACP_TRACE(lp); oldpstate = lp->lp_partner.lip_state; @@ -1576,7 +1567,8 @@ lacp_sm_rx_record_pdu(struct lacp_port * static void lacp_sm_rx_update_ntt(struct lacp_port *lp, const struct lacpdu *du) { - /* LACP_DPRINTF((lp, "%s\n", __func__)); */ + + LACP_TRACE(lp); if (lacp_compare_peerinfo(&lp->lp_actor, &du->ldu_partner) || !LACP_STATE_EQ(lp->lp_state, du->ldu_partner.lip_state, @@ -1591,7 +1583,7 @@ lacp_sm_rx_record_default(struct lacp_po { uint8_t oldpstate; - /* LACP_DPRINTF((lp, "%s\n", __func__)); */ + LACP_TRACE(lp); oldpstate = lp->lp_partner.lip_state; lp->lp_partner = lacp_partner_admin; @@ -1603,7 +1595,8 @@ static void lacp_sm_rx_update_selected_from_peerinfo(struct lacp_port *lp, const struct lacp_peerinfo *info) { - /* LACP_DPRINTF((lp, "%s\n", __func__)); */ + + LACP_TRACE(lp); if (lacp_compare_peerinfo(&lp->lp_partner, info) || !LACP_STATE_EQ(lp->lp_partner.lip_state, info->lip_state, @@ -1616,7 +1609,8 @@ lacp_sm_rx_update_selected_from_peerinfo static void lacp_sm_rx_update_selected(struct lacp_port *lp, const struct lacpdu *du) { - /* LACP_DPRINTF((lp, "%s\n", __func__)); */ + + LACP_TRACE(lp); lacp_sm_rx_update_selected_from_peerinfo(lp, &du->ldu_actor); } @@ -1624,7 +1618,8 @@ lacp_sm_rx_update_selected(struct lacp_p static void lacp_sm_rx_update_default_selected(struct lacp_port *lp) { - /* LACP_DPRINTF((lp, "%s\n", __func__)); */ + + LACP_TRACE(lp); lacp_sm_rx_update_selected_from_peerinfo(lp, &lacp_partner_admin); } @@ -1812,7 +1807,7 @@ tlv_check(const void *p, size_t size, co return (0); } -#if defined(LACP_DEBUG) +/* Debugging */ const char * lacp_format_mac(const uint8_t *mac, char *buf, size_t buflen) { @@ -1942,4 +1937,3 @@ lacp_dprintf(const struct lacp_port *lp, vprintf(fmt, va); va_end(va); } -#endif From owner-svn-src-stable-9@FreeBSD.ORG Wed Jun 27 22:09:05 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 085231065676; Wed, 27 Jun 2012 22:09:05 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CE1488FC0A; Wed, 27 Jun 2012 22:09:04 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5RM94ES035570; Wed, 27 Jun 2012 22:09:04 GMT (envelope-from thompsa@svn.freebsd.org) Received: (from thompsa@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5RM94nk035567; Wed, 27 Jun 2012 22:09:04 GMT (envelope-from thompsa@svn.freebsd.org) Message-Id: <201206272209.q5RM94nk035567@svn.freebsd.org> From: Andrew Thompson Date: Wed, 27 Jun 2012 22:09:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237670 - in stable/9: sbin/ifconfig sys/net X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jun 2012 22:09:05 -0000 Author: thompsa Date: Wed Jun 27 22:09:04 2012 New Revision: 237670 URL: http://svn.freebsd.org/changeset/base/237670 Log: MFC r236178 if_lagg: allow to invoke SIOCSLAGGPORT multiple times in a row Modified: stable/9/sbin/ifconfig/iflagg.c stable/9/sys/net/if_lagg.c Directory Properties: stable/9/sbin/ifconfig/ (props changed) stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/dev/isp/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/modules/ (props changed) Modified: stable/9/sbin/ifconfig/iflagg.c ============================================================================== --- stable/9/sbin/ifconfig/iflagg.c Wed Jun 27 22:06:42 2012 (r237669) +++ stable/9/sbin/ifconfig/iflagg.c Wed Jun 27 22:09:04 2012 (r237670) @@ -40,7 +40,8 @@ setlaggport(const char *val, int d, int strlcpy(rp.rp_ifname, name, sizeof(rp.rp_ifname)); strlcpy(rp.rp_portname, val, sizeof(rp.rp_portname)); - if (ioctl(s, SIOCSLAGGPORT, &rp)) + /* Don't choke if the port is already in this lagg. */ + if (ioctl(s, SIOCSLAGGPORT, &rp) && errno != EEXIST) err(1, "SIOCSLAGGPORT"); } Modified: stable/9/sys/net/if_lagg.c ============================================================================== --- stable/9/sys/net/if_lagg.c Wed Jun 27 22:06:42 2012 (r237669) +++ stable/9/sys/net/if_lagg.c Wed Jun 27 22:09:04 2012 (r237670) @@ -516,8 +516,13 @@ lagg_port_create(struct lagg_softc *sc, return (ENOSPC); /* Check if port has already been associated to a lagg */ - if (ifp->if_lagg != NULL) + if (ifp->if_lagg != NULL) { + /* Port is already in the current lagg? */ + lp = (struct lagg_port *)ifp->if_lagg; + if (lp->lp_softc == sc) + return (EEXIST); return (EBUSY); + } /* XXX Disallow non-ethernet interfaces (this should be any of 802) */ if (ifp->if_type != IFT_ETHER) From owner-svn-src-stable-9@FreeBSD.ORG Wed Jun 27 22:11:32 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0A7E0106566B; Wed, 27 Jun 2012 22:11:32 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E97728FC16; Wed, 27 Jun 2012 22:11:31 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5RMBVUq035787; Wed, 27 Jun 2012 22:11:31 GMT (envelope-from thompsa@svn.freebsd.org) Received: (from thompsa@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5RMBVV0035784; Wed, 27 Jun 2012 22:11:31 GMT (envelope-from thompsa@svn.freebsd.org) Message-Id: <201206272211.q5RMBVV0035784@svn.freebsd.org> From: Andrew Thompson Date: Wed, 27 Jun 2012 22:11:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237671 - stable/9/usr.bin/sockstat X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jun 2012 22:11:32 -0000 Author: thompsa Date: Wed Jun 27 22:11:31 2012 New Revision: 237671 URL: http://svn.freebsd.org/changeset/base/237671 Log: MFC r235870 Allow the socket list to be limited to a specific jail id. Modified: stable/9/usr.bin/sockstat/sockstat.1 stable/9/usr.bin/sockstat/sockstat.c Directory Properties: stable/9/usr.bin/sockstat/ (props changed) Modified: stable/9/usr.bin/sockstat/sockstat.1 ============================================================================== --- stable/9/usr.bin/sockstat/sockstat.1 Wed Jun 27 22:09:04 2012 (r237670) +++ stable/9/usr.bin/sockstat/sockstat.1 Wed Jun 27 22:11:31 2012 (r237671) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 24, 2012 +.Dd May 16, 2012 .Dt SOCKSTAT 1 .Os .Sh NAME @@ -36,6 +36,7 @@ .Sh SYNOPSIS .Nm .Op Fl 46cLlu +.Op Fl j Ar jid .Op Fl p Ar ports .Op Fl P Ar protocols .Sh DESCRIPTION @@ -57,6 +58,8 @@ Show (IPv6) sockets. .It Fl c Show connected sockets. +.It Fl j Ar jid +Show only sockets belonging to the specified jail ID. .It Fl L Only show Internet sockets if the local or foreign addresses are not in the loopback network prefix Modified: stable/9/usr.bin/sockstat/sockstat.c ============================================================================== --- stable/9/usr.bin/sockstat/sockstat.c Wed Jun 27 22:09:04 2012 (r237670) +++ stable/9/usr.bin/sockstat/sockstat.c Wed Jun 27 22:11:31 2012 (r237671) @@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$"); static int opt_4; /* Show IPv4 sockets */ static int opt_6; /* Show IPv6 sockets */ static int opt_c; /* Show connected sockets */ +static int opt_j; /* Show specified jail */ static int opt_L; /* Don't show IPv4 or IPv6 loopback sockets */ static int opt_l; /* Show listening sockets */ static int opt_u; /* Show Unix domain sockets */ @@ -549,6 +550,27 @@ getprocname(pid_t pid) } static int +getprocjid(pid_t pid) +{ + static struct kinfo_proc proc; + size_t len; + int mib[4]; + + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_PID; + mib[3] = (int)pid; + len = sizeof proc; + if (sysctl(mib, 4, &proc, &len, NULL, 0) == -1) { + /* Do not warn if the process exits before we get its jid. */ + if (errno != ESRCH) + warn("sysctl()"); + return (-1); + } + return (proc.ki_jid); +} + +static int check_ports(struct sock *s) { int port; @@ -643,6 +665,8 @@ display(void) for (xf = xfiles, n = 0; n < nxfiles; ++n, ++xf) { if (xf->xf_data == NULL) continue; + if (opt_j >= 0 && opt_j != getprocjid(xf->xf_pid)) + continue; hash = (int)((uintptr_t)xf->xf_data % HASHSIZE); for (s = sockhash[hash]; s != NULL; s = s->next) if ((void *)s->socket == xf->xf_data) @@ -668,6 +692,8 @@ display(void) pos += xprintf("%d ", xf->xf_fd); displaysock(s, pos); } + if (opt_j >= 0) + return; for (hash = 0; hash < HASHSIZE; hash++) { for (s = sockhash[hash]; s != NULL; s = s->next) { if (s->shown) @@ -716,7 +742,8 @@ main(int argc, char *argv[]) int protos_defined = -1; int o, i; - while ((o = getopt(argc, argv, "46cLlp:P:uv")) != -1) + opt_j = -1; + while ((o = getopt(argc, argv, "46cj:Llp:P:uv")) != -1) switch (o) { case '4': opt_4 = 1; @@ -727,6 +754,9 @@ main(int argc, char *argv[]) case 'c': opt_c = 1; break; + case 'j': + opt_j = atoi(optarg); + break; case 'L': opt_L = 1; break; From owner-svn-src-stable-9@FreeBSD.ORG Thu Jun 28 01:02:50 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id CABF7106564A; Thu, 28 Jun 2012 01:02:50 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AB2D08FC08; Thu, 28 Jun 2012 01:02:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5S12osc043151; Thu, 28 Jun 2012 01:02:50 GMT (envelope-from pfg@svn.freebsd.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5S12oC3043145; Thu, 28 Jun 2012 01:02:50 GMT (envelope-from pfg@svn.freebsd.org) Message-Id: <201206280102.q5S12oC3043145@svn.freebsd.org> From: "Pedro F. Giffuni" Date: Thu, 28 Jun 2012 01:02:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237678 - stable/9/contrib/gcc X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jun 2012 01:02:50 -0000 Author: pfg Date: Thu Jun 28 01:02:50 2012 New Revision: 237678 URL: http://svn.freebsd.org/changeset/base/237678 Log: MFC r237406: Bring a couple of fixes for gcc optimizations. The GCC4.3 branch contains some optimization fixes that were not considered regressions and therefore were never backported. We are bringing a couple of them that are under GPLv2 since they were made before the license switch upstream. Modified: stable/9/contrib/gcc/ChangeLog.gcc43 stable/9/contrib/gcc/fold-const.c stable/9/contrib/gcc/gimplify.c stable/9/contrib/gcc/tree-ssa-ccp.c stable/9/contrib/gcc/tree-ssa-pre.c Directory Properties: stable/9/contrib/gcc/ (props changed) Modified: stable/9/contrib/gcc/ChangeLog.gcc43 ============================================================================== --- stable/9/contrib/gcc/ChangeLog.gcc43 Thu Jun 28 00:17:45 2012 (r237677) +++ stable/9/contrib/gcc/ChangeLog.gcc43 Thu Jun 28 01:02:50 2012 (r237678) @@ -5,6 +5,18 @@ with SSE3 instruction set support. * doc/invoke.texi: Likewise. +2007-04-12 Richard Guenther (r123736) + + PR tree-optimization/24689 + PR tree-optimization/31307 + * fold-const.c (operand_equal_p): Compare INTEGER_CST array + indices by value. + * gimplify.c (canonicalize_addr_expr): To be consistent with + gimplify_compound_lval only set operands two and three of + ARRAY_REFs if they are not gimple_min_invariant. This makes + it never at this place. + * tree-ssa-ccp.c (maybe_fold_offset_to_array_ref): Likewise. + 2007-04-07 H.J. Lu (r123639) * config/i386/i386.c (ix86_handle_option): Handle SSSE3. @@ -96,7 +108,7 @@ * doc/invoke.texi: Add entry about geode processor. -2006-10-24 Richard Guenther +2006-10-24 Richard Guenther (r118001) PR middle-end/28796 * builtins.c (fold_builtin_classify): Use HONOR_INFINITIES @@ -170,7 +182,13 @@ * doc/invoke.texi: Document -mssse3/-mno-ssse3 switches. -2006-10-21 Richard Guenther +2006-10-21 Richard Guenther (r117932) + + PR tree-optimization/3511 + * tree-ssa-pre.c (phi_translate): Fold CALL_EXPRs that + got new invariant arguments during PHI translation. + +2006-10-21 Richard Guenther (r117929) * builtins.c (fold_builtin_classify): Fix typo. Modified: stable/9/contrib/gcc/fold-const.c ============================================================================== --- stable/9/contrib/gcc/fold-const.c Thu Jun 28 00:17:45 2012 (r237677) +++ stable/9/contrib/gcc/fold-const.c Thu Jun 28 01:02:50 2012 (r237678) @@ -2802,9 +2802,13 @@ operand_equal_p (tree arg0, tree arg1, u case ARRAY_REF: case ARRAY_RANGE_REF: - /* Operands 2 and 3 may be null. */ + /* Operands 2 and 3 may be null. + Compare the array index by value if it is constant first as we + may have different types but same value here. */ return (OP_SAME (0) - && OP_SAME (1) + && (tree_int_cst_equal (TREE_OPERAND (arg0, 1), + TREE_OPERAND (arg1, 1)) + || OP_SAME (1)) && OP_SAME_WITH_NULL (2) && OP_SAME_WITH_NULL (3)); Modified: stable/9/contrib/gcc/gimplify.c ============================================================================== --- stable/9/contrib/gcc/gimplify.c Thu Jun 28 00:17:45 2012 (r237677) +++ stable/9/contrib/gcc/gimplify.c Thu Jun 28 01:02:50 2012 (r237678) @@ -1600,9 +1600,7 @@ canonicalize_addr_expr (tree *expr_p) /* All checks succeeded. Build a new node to merge the cast. */ *expr_p = build4 (ARRAY_REF, dctype, obj_expr, TYPE_MIN_VALUE (TYPE_DOMAIN (datype)), - TYPE_MIN_VALUE (TYPE_DOMAIN (datype)), - size_binop (EXACT_DIV_EXPR, TYPE_SIZE_UNIT (dctype), - size_int (TYPE_ALIGN_UNIT (dctype)))); + NULL_TREE, NULL_TREE); *expr_p = build1 (ADDR_EXPR, ctype, *expr_p); } Modified: stable/9/contrib/gcc/tree-ssa-ccp.c ============================================================================== --- stable/9/contrib/gcc/tree-ssa-ccp.c Thu Jun 28 00:17:45 2012 (r237677) +++ stable/9/contrib/gcc/tree-ssa-ccp.c Thu Jun 28 01:02:50 2012 (r237678) @@ -1621,9 +1621,7 @@ maybe_fold_offset_to_array_ref (tree bas if (!integer_zerop (elt_offset)) idx = int_const_binop (PLUS_EXPR, idx, elt_offset, 0); - return build4 (ARRAY_REF, orig_type, base, idx, min_idx, - size_int (tree_low_cst (elt_size, 1) - / (TYPE_ALIGN_UNIT (elt_type)))); + return build4 (ARRAY_REF, orig_type, base, idx, NULL_TREE, NULL_TREE); } Modified: stable/9/contrib/gcc/tree-ssa-pre.c ============================================================================== --- stable/9/contrib/gcc/tree-ssa-pre.c Thu Jun 28 00:17:45 2012 (r237677) +++ stable/9/contrib/gcc/tree-ssa-pre.c Thu Jun 28 01:02:50 2012 (r237678) @@ -1076,6 +1076,7 @@ phi_translate (tree expr, value_set_t se tree newexpr; tree vh = get_value_handle (expr); bool listchanged = false; + bool invariantarg = false; VEC (tree, gc) *vuses = VALUE_HANDLE_VUSES (vh); VEC (tree, gc) *tvuses; @@ -1134,10 +1135,26 @@ phi_translate (tree expr, value_set_t se if (newval != oldval) { listchanged = true; + invariantarg |= is_gimple_min_invariant (newval); TREE_VALUE (newwalker) = get_value_handle (newval); } } } + + /* In case of new invariant args we might try to fold the call + again. */ + if (invariantarg) + { + tree tmp = fold_ternary (CALL_EXPR, TREE_TYPE (expr), + newop0, newarglist, newop2); + if (tmp) + { + STRIP_TYPE_NOPS (tmp); + if (is_gimple_min_invariant (tmp)) + return tmp; + } + } + if (listchanged) vn_lookup_or_add (newarglist, NULL); From owner-svn-src-stable-9@FreeBSD.ORG Thu Jun 28 07:08:49 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7A52E106566C; Thu, 28 Jun 2012 07:08:49 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 602B38FC15; Thu, 28 Jun 2012 07:08:49 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5S78nqK058814; Thu, 28 Jun 2012 07:08:49 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5S78nZR058799; Thu, 28 Jun 2012 07:08:49 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201206280708.q5S78nZR058799@svn.freebsd.org> From: Xin LI Date: Thu, 28 Jun 2012 07:08:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237691 - in stable/9: lib/libstand lib/libz lib/libz/contrib lib/libz/contrib/asm686 lib/libz/contrib/gcc_gvmat64 lib/libz/doc lib/libz/test sys/boot/userboot/libstand usr.bin/minigzip X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jun 2012 07:08:49 -0000 Author: delphij Date: Thu Jun 28 07:08:48 2012 New Revision: 237691 URL: http://svn.freebsd.org/changeset/base/237691 Log: MFC r237410: zlib 1.2.7. Added: stable/9/lib/libz/test/ - copied from r237677, head/lib/libz/test/ Deleted: stable/9/lib/libz/example.c stable/9/lib/libz/minigzip.c Modified: stable/9/lib/libstand/Makefile stable/9/lib/libz/ChangeLog stable/9/lib/libz/FAQ stable/9/lib/libz/FREEBSD-upgrade (contents, props changed) stable/9/lib/libz/Makefile (contents, props changed) stable/9/lib/libz/README stable/9/lib/libz/Symbol.map (contents, props changed) stable/9/lib/libz/Versions.def (contents, props changed) stable/9/lib/libz/adler32.c stable/9/lib/libz/contrib/asm686/match.S (contents, props changed) stable/9/lib/libz/crc32.c stable/9/lib/libz/crc32.h stable/9/lib/libz/deflate.c stable/9/lib/libz/deflate.h stable/9/lib/libz/doc/algorithm.txt (contents, props changed) stable/9/lib/libz/gzguts.h (contents, props changed) stable/9/lib/libz/gzlib.c stable/9/lib/libz/gzread.c stable/9/lib/libz/gzwrite.c stable/9/lib/libz/infback.c stable/9/lib/libz/inffixed.h stable/9/lib/libz/inflate.c stable/9/lib/libz/inftrees.c stable/9/lib/libz/trees.c stable/9/lib/libz/zconf.h stable/9/lib/libz/zlib.3 stable/9/lib/libz/zlib.h stable/9/lib/libz/zopen.c (contents, props changed) stable/9/lib/libz/zutil.c stable/9/lib/libz/zutil.h stable/9/sys/boot/userboot/libstand/Makefile stable/9/usr.bin/minigzip/Makefile Directory Properties: stable/9/lib/libstand/ (props changed) stable/9/lib/libz/ (props changed) stable/9/lib/libz/contrib/ (props changed) stable/9/lib/libz/contrib/README.contrib (props changed) stable/9/lib/libz/contrib/asm686/ (props changed) stable/9/lib/libz/contrib/asm686/README.686 (props changed) stable/9/lib/libz/contrib/gcc_gvmat64/ (props changed) stable/9/lib/libz/contrib/gcc_gvmat64/gvmat64.S (props changed) stable/9/lib/libz/doc/ (props changed) stable/9/lib/libz/doc/rfc1950.txt (props changed) stable/9/lib/libz/doc/rfc1951.txt (props changed) stable/9/lib/libz/doc/rfc1952.txt (props changed) stable/9/lib/libz/doc/txtvsbin.txt (props changed) stable/9/lib/libz/gzclose.c (props changed) stable/9/sys/ (props changed) stable/9/sys/boot/ (props changed) stable/9/usr.bin/minigzip/ (props changed) Modified: stable/9/lib/libstand/Makefile ============================================================================== --- stable/9/lib/libstand/Makefile Thu Jun 28 07:02:15 2012 (r237690) +++ stable/9/lib/libstand/Makefile Thu Jun 28 07:08:48 2012 (r237691) @@ -38,7 +38,7 @@ CFLAGS+= -msoft-float -D_STANDALONE .endif # standalone components and stuff we have modified locally -SRCS+= zutil.h __main.c assert.c bcd.c bswap.c environment.c getopt.c gets.c \ +SRCS+= gzguts.h zutil.h __main.c assert.c bcd.c bswap.c environment.c getopt.c gets.c \ globals.c pager.c printf.c strdup.c strerror.c strtol.c random.c \ sbrk.c twiddle.c zalloc.c zalloc_malloc.c @@ -119,23 +119,29 @@ libstand_bzlib_private.h: bzlib_private. # decompression functionality from libz .PATH: ${.CURDIR}/../libz CFLAGS+=-DHAVE_MEMCPY -I${.CURDIR}/../libz -SRCS+= adler32.c crc32.c libstand_zutil.h +SRCS+= adler32.c crc32.c libstand_zutil.h libstand_gzguts.h .for file in infback.c inffast.c inflate.c inftrees.c zutil.c SRCS+= _${file} CLEANFILES+= _${file} _${file}: ${file} - sed "s|zutil\.h|libstand_zutil.h|" ${.ALLSRC} > ${.TARGET} + sed -e "s|zutil\.h|libstand_zutil.h|" \ + -e "s|gzguts\.h|libstand_gzguts.h|" \ + ${.ALLSRC} > ${.TARGET} .endfor # depend on stand.h being able to be included multiple times -CLEANFILES+= libstand_zutil.h -libstand_zutil.h: zutil.h - sed -e 's||"stand.h"|' \ +.for file in zutil.h gzguts.h +CLEANFILES+= libstand_${file} +libstand_${file}: ${file} + sed -e 's||"stand.h"|' \ + -e 's||"stand.h"|' \ -e 's||"stand.h"|' \ + -e 's||"stand.h"|' \ -e 's||"stand.h"|' \ ${.ALLSRC} > ${.TARGET} +.endfor # io routines SRCS+= closeall.c dev.c ioctl.c nullfs.c stat.c \ Modified: stable/9/lib/libz/ChangeLog ============================================================================== --- stable/9/lib/libz/ChangeLog Thu Jun 28 07:02:15 2012 (r237690) +++ stable/9/lib/libz/ChangeLog Thu Jun 28 07:08:48 2012 (r237691) @@ -1,12 +1,213 @@ ChangeLog file for zlib +Changes in 1.2.7 (2 May 2012) +- Replace use of memmove() with a simple copy for portability +- Test for existence of strerror +- Restore gzgetc_ for backward compatibility with 1.2.6 +- Fix build with non-GNU make on Solaris +- Require gcc 4.0 or later on Mac OS X to use the hidden attribute +- Include unistd.h for Watcom C +- Use __WATCOMC__ instead of __WATCOM__ +- Do not use the visibility attribute if NO_VIZ defined +- Improve the detection of no hidden visibility attribute +- Avoid using __int64 for gcc or solo compilation +- Cast to char * in gzprintf to avoid warnings [Zinser] +- Fix make_vms.com for VAX [Zinser] +- Don't use library or built-in byte swaps +- Simplify test and use of gcc hidden attribute +- Fix bug in gzclose_w() when gzwrite() fails to allocate memory +- Add "x" (O_EXCL) and "e" (O_CLOEXEC) modes support to gzopen() +- Fix bug in test/minigzip.c for configure --solo +- Fix contrib/vstudio project link errors [Mohanathas] +- Add ability to choose the builder in make_vms.com [Schweda] +- Add DESTDIR support to mingw32 win32/Makefile.gcc +- Fix comments in win32/Makefile.gcc for proper usage +- Allow overriding the default install locations for cmake +- Generate and install the pkg-config file with cmake +- Build both a static and a shared version of zlib with cmake +- Include version symbols for cmake builds +- If using cmake with MSVC, add the source directory to the includes +- Remove unneeded EXTRA_CFLAGS from win32/Makefile.gcc [Truta] +- Move obsolete emx makefile to old [Truta] +- Allow the use of -Wundef when compiling or using zlib +- Avoid the use of the -u option with mktemp +- Improve inflate() documentation on the use of Z_FINISH +- Recognize clang as gcc +- Add gzopen_w() in Windows for wide character path names +- Rename zconf.h in CMakeLists.txt to move it out of the way +- Add source directory in CMakeLists.txt for building examples +- Look in build directory for zlib.pc in CMakeLists.txt +- Remove gzflags from zlibvc.def in vc9 and vc10 +- Fix contrib/minizip compilation in the MinGW environment +- Update ./configure for Solaris, support --64 [Mooney] +- Remove -R. from Solaris shared build (possible security issue) +- Avoid race condition for parallel make (-j) running example +- Fix type mismatch between get_crc_table() and crc_table +- Fix parsing of version with "-" in CMakeLists.txt [Snider, Ziegler] +- Fix the path to zlib.map in CMakeLists.txt +- Force the native libtool in Mac OS X to avoid GNU libtool [Beebe] +- Add instructions to win32/Makefile.gcc for shared install [Torri] + +Changes in 1.2.6.1 (12 Feb 2012) +- Avoid the use of the Objective-C reserved name "id" +- Include io.h in gzguts.h for Microsoft compilers +- Fix problem with ./configure --prefix and gzgetc macro +- Include gz_header definition when compiling zlib solo +- Put gzflags() functionality back in zutil.c +- Avoid library header include in crc32.c for Z_SOLO +- Use name in GCC_CLASSIC as C compiler for coverage testing, if set +- Minor cleanup in contrib/minizip/zip.c [Vollant] +- Update make_vms.com [Zinser] +- Remove unnecessary gzgetc_ function +- Use optimized byte swap operations for Microsoft and GNU [Snyder] +- Fix minor typo in zlib.h comments [Rzesniowiecki] + +Changes in 1.2.6 (29 Jan 2012) +- Update the Pascal interface in contrib/pascal +- Fix function numbers for gzgetc_ in zlibvc.def files +- Fix configure.ac for contrib/minizip [Schiffer] +- Fix large-entry detection in minizip on 64-bit systems [Schiffer] +- Have ./configure use the compiler return code for error indication +- Fix CMakeLists.txt for cross compilation [McClure] +- Fix contrib/minizip/zip.c for 64-bit architectures [Dalsnes] +- Fix compilation of contrib/minizip on FreeBSD [Marquez] +- Correct suggested usages in win32/Makefile.msc [Shachar, Horvath] +- Include io.h for Turbo C / Borland C on all platforms [Truta] +- Make version explicit in contrib/minizip/configure.ac [Bosmans] +- Avoid warning for no encryption in contrib/minizip/zip.c [Vollant] +- Minor cleanup up contrib/minizip/unzip.c [Vollant] +- Fix bug when compiling minizip with C++ [Vollant] +- Protect for long name and extra fields in contrib/minizip [Vollant] +- Avoid some warnings in contrib/minizip [Vollant] +- Add -I../.. -L../.. to CFLAGS for minizip and miniunzip +- Add missing libs to minizip linker command +- Add support for VPATH builds in contrib/minizip +- Add an --enable-demos option to contrib/minizip/configure +- Add the generation of configure.log by ./configure +- Exit when required parameters not provided to win32/Makefile.gcc +- Have gzputc return the character written instead of the argument +- Use the -m option on ldconfig for BSD systems [Tobias] +- Correct in zlib.map when deflateResetKeep was added + +Changes in 1.2.5.3 (15 Jan 2012) +- Restore gzgetc function for binary compatibility +- Do not use _lseeki64 under Borland C++ [Truta] +- Update win32/Makefile.msc to build test/*.c [Truta] +- Remove old/visualc6 given CMakefile and other alternatives +- Update AS400 build files and documentation [Monnerat] +- Update win32/Makefile.gcc to build test/*.c [Truta] +- Permit stronger flushes after Z_BLOCK flushes +- Avoid extraneous empty blocks when doing empty flushes +- Permit Z_NULL arguments to deflatePending +- Allow deflatePrime() to insert bits in the middle of a stream +- Remove second empty static block for Z_PARTIAL_FLUSH +- Write out all of the available bits when using Z_BLOCK +- Insert the first two strings in the hash table after a flush + +Changes in 1.2.5.2 (17 Dec 2011) +- fix ld error: unable to find version dependency 'ZLIB_1.2.5' +- use relative symlinks for shared libs +- Avoid searching past window for Z_RLE strategy +- Assure that high-water mark initialization is always applied in deflate +- Add assertions to fill_window() in deflate.c to match comments +- Update python link in README +- Correct spelling error in gzread.c +- Fix bug in gzgets() for a concatenated empty gzip stream +- Correct error in comment for gz_make() +- Change gzread() and related to ignore junk after gzip streams +- Allow gzread() and related to continue after gzclearerr() +- Allow gzrewind() and gzseek() after a premature end-of-file +- Simplify gzseek() now that raw after gzip is ignored +- Change gzgetc() to a macro for speed (~40% speedup in testing) +- Fix gzclose() to return the actual error last encountered +- Always add large file support for windows +- Include zconf.h for windows large file support +- Include zconf.h.cmakein for windows large file support +- Update zconf.h.cmakein on make distclean +- Merge vestigial vsnprintf determination from zutil.h to gzguts.h +- Clarify how gzopen() appends in zlib.h comments +- Correct documentation of gzdirect() since junk at end now ignored +- Add a transparent write mode to gzopen() when 'T' is in the mode +- Update python link in zlib man page +- Get inffixed.h and MAKEFIXED result to match +- Add a ./config --solo option to make zlib subset with no libary use +- Add undocumented inflateResetKeep() function for CAB file decoding +- Add --cover option to ./configure for gcc coverage testing +- Add #define ZLIB_CONST option to use const in the z_stream interface +- Add comment to gzdopen() in zlib.h to use dup() when using fileno() +- Note behavior of uncompress() to provide as much data as it can +- Add files in contrib/minizip to aid in building libminizip +- Split off AR options in Makefile.in and configure +- Change ON macro to Z_ARG to avoid application conflicts +- Facilitate compilation with Borland C++ for pragmas and vsnprintf +- Include io.h for Turbo C / Borland C++ +- Move example.c and minigzip.c to test/ +- Simplify incomplete code table filling in inflate_table() +- Remove code from inflate.c and infback.c that is impossible to execute +- Test the inflate code with full coverage +- Allow deflateSetDictionary, inflateSetDictionary at any time (in raw) +- Add deflateResetKeep and fix inflateResetKeep to retain dictionary +- Fix gzwrite.c to accommodate reduced memory zlib compilation +- Have inflate() with Z_FINISH avoid the allocation of a window +- Do not set strm->adler when doing raw inflate +- Fix gzeof() to behave just like feof() when read is not past end of file +- Fix bug in gzread.c when end-of-file is reached +- Avoid use of Z_BUF_ERROR in gz* functions except for premature EOF +- Document gzread() capability to read concurrently written files +- Remove hard-coding of resource compiler in CMakeLists.txt [Blammo] + +Changes in 1.2.5.1 (10 Sep 2011) +- Update FAQ entry on shared builds (#13) +- Avoid symbolic argument to chmod in Makefile.in +- Fix bug and add consts in contrib/puff [Oberhumer] +- Update contrib/puff/zeros.raw test file to have all block types +- Add full coverage test for puff in contrib/puff/Makefile +- Fix static-only-build install in Makefile.in +- Fix bug in unzGetCurrentFileInfo() in contrib/minizip [Kuno] +- Add libz.a dependency to shared in Makefile.in for parallel builds +- Spell out "number" (instead of "nb") in zlib.h for total_in, total_out +- Replace $(...) with `...` in configure for non-bash sh [Bowler] +- Add darwin* to Darwin* and solaris* to SunOS\ 5* in configure [Groffen] +- Add solaris* to Linux* in configure to allow gcc use [Groffen] +- Add *bsd* to Linux* case in configure [Bar-Lev] +- Add inffast.obj to dependencies in win32/Makefile.msc +- Correct spelling error in deflate.h [Kohler] +- Change libzdll.a again to libz.dll.a (!) in win32/Makefile.gcc +- Add test to configure for GNU C looking for gcc in output of $cc -v +- Add zlib.pc generation to win32/Makefile.gcc [Weigelt] +- Fix bug in zlib.h for _FILE_OFFSET_BITS set and _LARGEFILE64_SOURCE not +- Add comment in zlib.h that adler32_combine with len2 < 0 makes no sense +- Make NO_DIVIDE option in adler32.c much faster (thanks to John Reiser) +- Make stronger test in zconf.h to include unistd.h for LFS +- Apply Darwin patches for 64-bit file offsets to contrib/minizip [Slack] +- Fix zlib.h LFS support when Z_PREFIX used +- Add updated as400 support (removed from old) [Monnerat] +- Avoid deflate sensitivity to volatile input data +- Avoid division in adler32_combine for NO_DIVIDE +- Clarify the use of Z_FINISH with deflateBound() amount of space +- Set binary for output file in puff.c +- Use u4 type for crc_table to avoid conversion warnings +- Apply casts in zlib.h to avoid conversion warnings +- Add OF to prototypes for adler32_combine_ and crc32_combine_ [Miller] +- Improve inflateSync() documentation to note indeterminancy +- Add deflatePending() function to return the amount of pending output +- Correct the spelling of "specification" in FAQ [Randers-Pehrson] +- Add a check in configure for stdarg.h, use for gzprintf() +- Check that pointers fit in ints when gzprint() compiled old style +- Add dummy name before $(SHAREDLIBV) in Makefile [Bar-Lev, Bowler] +- Delete line in configure that adds -L. libz.a to LDFLAGS [Weigelt] +- Add debug records in assmebler code [Londer] +- Update RFC references to use http://tools.ietf.org/html/... [Li] +- Add --archs option, use of libtool to configure for Mac OS X [Borstel] + Changes in 1.2.5 (19 Apr 2010) - Disable visibility attribute in win32/Makefile.gcc [Bar-Lev] - Default to libdir as sharedlibdir in configure [Nieder] - Update copyright dates on modified source files - Update trees.c to be able to generate modified trees.h - Exit configure for MinGW, suggesting win32/Makefile.gcc +- Check for NULL path in gz_open [Homurlu] Changes in 1.2.4.5 (18 Apr 2010) - Set sharedlibdir in configure [Torok] @@ -261,7 +462,7 @@ Changes in 1.2.3.4 (21 Dec 2009) - Clear bytes after deflate lookahead to avoid use of uninitialized data - Change a limit in inftrees.c to be more transparent to Coverity Prevent - Update win32/zlib.def with exported symbols from zlib.h -- Correct spelling error in zlib.h [Willem] +- Correct spelling errors in zlib.h [Willem, Sobrado] - Allow Z_BLOCK for deflate() to force a new block - Allow negative bits in inflatePrime() to delete existing bit buffer - Add Z_TREES flush option to inflate() to return at end of trees Modified: stable/9/lib/libz/FAQ ============================================================================== --- stable/9/lib/libz/FAQ Thu Jun 28 07:02:15 2012 (r237690) +++ stable/9/lib/libz/FAQ Thu Jun 28 07:08:48 2012 (r237691) @@ -44,8 +44,8 @@ The lastest zlib FAQ is at http://zlib.n 6. Where's the zlib documentation (man pages, etc.)? - It's in zlib.h . Examples of zlib usage are in the files example.c and - minigzip.c, with more in examples/ . + It's in zlib.h . Examples of zlib usage are in the files test/example.c + and test/minigzip.c, with more in examples/ . 7. Why don't you use GNU autoconf or libtool or ...? @@ -84,8 +84,10 @@ The lastest zlib FAQ is at http://zlib.n 13. How can I make a Unix shared library? - make clean - ./configure -s + By default a shared (and a static) library is built for Unix. So: + + make distclean + ./configure make 14. How do I install a shared zlib library on Unix? @@ -325,7 +327,7 @@ The lastest zlib FAQ is at http://zlib.n correctly points to the zlib specification in RFC 1950 for the "deflate" transfer encoding, there have been reports of servers and browsers that incorrectly produce or expect raw deflate data per the deflate - specficiation in RFC 1951, most notably Microsoft. So even though the + specification in RFC 1951, most notably Microsoft. So even though the "deflate" transfer encoding using the zlib format would be the more efficient approach (and in fact exactly what the zlib format was designed for), using the "gzip" transfer encoding is probably more reliable due to Modified: stable/9/lib/libz/FREEBSD-upgrade ============================================================================== --- stable/9/lib/libz/FREEBSD-upgrade Thu Jun 28 07:02:15 2012 (r237690) +++ stable/9/lib/libz/FREEBSD-upgrade Thu Jun 28 07:08:48 2012 (r237691) @@ -1,4 +1,4 @@ -$FreeBSD$ +$FreeBSD: stable/9/lib/libz/FREEBSD-upgrade 146082 2005-05-11 03:50:50Z kientzle $ ZLib 1.2.2 Modified: stable/9/lib/libz/Makefile ============================================================================== --- stable/9/lib/libz/Makefile Thu Jun 28 07:02:15 2012 (r237690) +++ stable/9/lib/libz/Makefile Thu Jun 28 07:08:48 2012 (r237691) @@ -1,5 +1,5 @@ # -# $FreeBSD$ +# $FreeBSD: stable/9/lib/libz/Makefile 232930 2012-03-13 18:39:57Z dim $ # LIB= z @@ -35,12 +35,12 @@ SRCS+= uncompr.c SRCS+= zopen.c SRCS+= zutil.c -.if ${MACHINE_ARCH} == "i386" && ${MACHINE_CPU:M*i686*} -.PATH: ${.CURDIR}/contrib/asm686 -SRCS+= match.S -CFLAGS+= -DASMV -DNO_UNDERLINE -ACFLAGS+= -Wa,--noexecstack -.endif +#.if ${MACHINE_ARCH} == "i386" && ${MACHINE_CPU:M*i686*} +#.PATH: ${.CURDIR}/contrib/asm686 +#SRCS+= match.S +#CFLAGS+= -DASMV -DNO_UNDERLINE +#ACFLAGS+= -Wa,--noexecstack +#.endif #.if ${MACHINE_ARCH} == "amd64" #.PATH: ${.CURDIR}/contrib/gcc_gvmat64 Modified: stable/9/lib/libz/README ============================================================================== --- stable/9/lib/libz/README Thu Jun 28 07:02:15 2012 (r237690) +++ stable/9/lib/libz/README Thu Jun 28 07:08:48 2012 (r237691) @@ -1,22 +1,22 @@ ZLIB DATA COMPRESSION LIBRARY -zlib 1.2.5 is a general purpose data compression library. All the code is +zlib 1.2.7 is a general purpose data compression library. All the code is thread safe. The data format used by the zlib library is described by RFCs (Request for Comments) 1950 to 1952 in the files -http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format) -and rfc1952.txt (gzip format). +http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and +rfc1952 (gzip format). All functions of the compression library are documented in the file zlib.h (volunteer to write man pages welcome, contact zlib@gzip.org). A usage example -of the library is given in the file example.c which also tests that the library -is working correctly. Another example is given in the file minigzip.c. The -compression library itself is composed of all source files except example.c and -minigzip.c. +of the library is given in the file test/example.c which also tests that +the library is working correctly. Another example is given in the file +test/minigzip.c. The compression library itself is composed of all source +files in the root directory. To compile all files and run the test program, follow the instructions given at the top of Makefile.in. In short "./configure; make test", and if that goes -well, "make install" should work for most flavors of Unix. For Windows, use one -of the special makefiles in win32/ or contrib/vstudio/ . For VMS, use +well, "make install" should work for most flavors of Unix. For Windows, use +one of the special makefiles in win32/ or contrib/vstudio/ . For VMS, use make_vms.com. Questions about zlib should be sent to , or to Gilles Vollant @@ -31,7 +31,7 @@ Mark Nelson wrote an ar issue of Dr. Dobb's Journal; a copy of the article is available at http://marknelson.us/1997/01/01/zlib-engine/ . -The changes made in version 1.2.5 are documented in the file ChangeLog. +The changes made in version 1.2.7 are documented in the file ChangeLog. Unsupported third party contributions are provided in directory contrib/ . @@ -44,7 +44,7 @@ http://search.cpan.org/~pmqs/IO-Compress A Python interface to zlib written by A.M. Kuchling is available in Python 1.5 and later versions, see -http://www.python.org/doc/lib/module-zlib.html . +http://docs.python.org/library/zlib.html . zlib is built into tcl: http://wiki.tcl.tk/4610 . @@ -84,7 +84,7 @@ Acknowledgments: Copyright notice: - (C) 1995-2010 Jean-loup Gailly and Mark Adler + (C) 1995-2012 Jean-loup Gailly and Mark Adler This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages Modified: stable/9/lib/libz/Symbol.map ============================================================================== --- stable/9/lib/libz/Symbol.map Thu Jun 28 07:02:15 2012 (r237690) +++ stable/9/lib/libz/Symbol.map Thu Jun 28 07:08:48 2012 (r237691) @@ -1,7 +1,14 @@ /* - * $FreeBSD$ + * $FreeBSD: stable/9/lib/libz/Symbol.map 206709 2010-04-16 20:07:24Z delphij $ */ +ZLIB_1.2.7.0 { + deflatePending; + deflateResetKeep; + gzgetc_; + inflateResetKeep; +}; + ZLIB_1.2.4.0 { adler32; adler32_combine; Modified: stable/9/lib/libz/Versions.def ============================================================================== --- stable/9/lib/libz/Versions.def Thu Jun 28 07:02:15 2012 (r237690) +++ stable/9/lib/libz/Versions.def Thu Jun 28 07:08:48 2012 (r237691) @@ -1,8 +1,11 @@ -# $FreeBSD$ +# $FreeBSD: stable/9/lib/libz/Versions.def 205486 2010-03-22 22:12:27Z delphij $ ZLIB_1.2.4.0 { }; +ZLIB_1.2.7.0 { +} ZLIB_1.2.4.0; + FBSD_1.2 { } ZLIB_1.2.4.0; Modified: stable/9/lib/libz/adler32.c ============================================================================== --- stable/9/lib/libz/adler32.c Thu Jun 28 07:02:15 2012 (r237690) +++ stable/9/lib/libz/adler32.c Thu Jun 28 07:08:48 2012 (r237691) @@ -1,5 +1,5 @@ /* adler32.c -- compute the Adler-32 checksum of a data stream - * Copyright (C) 1995-2007 Mark Adler + * Copyright (C) 1995-2011 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -9,9 +9,9 @@ #define local static -local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2); +local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2)); -#define BASE 65521UL /* largest prime smaller than 65536 */ +#define BASE 65521 /* largest prime smaller than 65536 */ #define NMAX 5552 /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ @@ -21,39 +21,44 @@ local uLong adler32_combine_(uLong adler #define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); #define DO16(buf) DO8(buf,0); DO8(buf,8); -/* use NO_DIVIDE if your processor does not do division in hardware */ +/* use NO_DIVIDE if your processor does not do division in hardware -- + try it both ways to see which is faster */ #ifdef NO_DIVIDE -# define MOD(a) \ +/* note that this assumes BASE is 65521, where 65536 % 65521 == 15 + (thank you to John Reiser for pointing this out) */ +# define CHOP(a) \ + do { \ + unsigned long tmp = a >> 16; \ + a &= 0xffffUL; \ + a += (tmp << 4) - tmp; \ + } while (0) +# define MOD28(a) \ do { \ - if (a >= (BASE << 16)) a -= (BASE << 16); \ - if (a >= (BASE << 15)) a -= (BASE << 15); \ - if (a >= (BASE << 14)) a -= (BASE << 14); \ - if (a >= (BASE << 13)) a -= (BASE << 13); \ - if (a >= (BASE << 12)) a -= (BASE << 12); \ - if (a >= (BASE << 11)) a -= (BASE << 11); \ - if (a >= (BASE << 10)) a -= (BASE << 10); \ - if (a >= (BASE << 9)) a -= (BASE << 9); \ - if (a >= (BASE << 8)) a -= (BASE << 8); \ - if (a >= (BASE << 7)) a -= (BASE << 7); \ - if (a >= (BASE << 6)) a -= (BASE << 6); \ - if (a >= (BASE << 5)) a -= (BASE << 5); \ - if (a >= (BASE << 4)) a -= (BASE << 4); \ - if (a >= (BASE << 3)) a -= (BASE << 3); \ - if (a >= (BASE << 2)) a -= (BASE << 2); \ - if (a >= (BASE << 1)) a -= (BASE << 1); \ + CHOP(a); \ if (a >= BASE) a -= BASE; \ } while (0) -# define MOD4(a) \ +# define MOD(a) \ do { \ - if (a >= (BASE << 4)) a -= (BASE << 4); \ - if (a >= (BASE << 3)) a -= (BASE << 3); \ - if (a >= (BASE << 2)) a -= (BASE << 2); \ - if (a >= (BASE << 1)) a -= (BASE << 1); \ + CHOP(a); \ + MOD28(a); \ + } while (0) +# define MOD63(a) \ + do { /* this assumes a is not negative */ \ + z_off64_t tmp = a >> 32; \ + a &= 0xffffffffL; \ + a += (tmp << 8) - (tmp << 5) + tmp; \ + tmp = a >> 16; \ + a &= 0xffffL; \ + a += (tmp << 4) - tmp; \ + tmp = a >> 16; \ + a &= 0xffffL; \ + a += (tmp << 4) - tmp; \ if (a >= BASE) a -= BASE; \ } while (0) #else # define MOD(a) a %= BASE -# define MOD4(a) a %= BASE +# define MOD28(a) a %= BASE +# define MOD63(a) a %= BASE #endif /* ========================================================================= */ @@ -92,7 +97,7 @@ uLong ZEXPORT adler32(adler, buf, len) } if (adler >= BASE) adler -= BASE; - MOD4(sum2); /* only added so many BASE's */ + MOD28(sum2); /* only added so many BASE's */ return adler | (sum2 << 16); } @@ -137,8 +142,13 @@ local uLong adler32_combine_(adler1, adl unsigned long sum2; unsigned rem; + /* for negative len, return invalid adler32 as a clue for debugging */ + if (len2 < 0) + return 0xffffffffUL; + /* the derivation of this formula is left as an exercise for the reader */ - rem = (unsigned)(len2 % BASE); + MOD63(len2); /* assumes len2 >= 0 */ + rem = (unsigned)len2; sum1 = adler1 & 0xffff; sum2 = rem * sum1; MOD(sum2); Modified: stable/9/lib/libz/contrib/asm686/match.S ============================================================================== --- stable/9/lib/libz/contrib/asm686/match.S Thu Jun 28 07:02:15 2012 (r237690) +++ stable/9/lib/libz/contrib/asm686/match.S Thu Jun 28 07:08:48 2012 (r237691) @@ -83,17 +83,25 @@ .text /* uInt longest_match(deflate_state *deflatestate, IPos curmatch) */ +.cfi_sections .debug_frame longest_match: +.cfi_startproc /* Save registers that the compiler may be using, and adjust %esp to */ /* make room for our stack frame. */ pushl %ebp + .cfi_def_cfa_offset 8 + .cfi_offset ebp, -8 pushl %edi + .cfi_def_cfa_offset 12 pushl %esi + .cfi_def_cfa_offset 16 pushl %ebx + .cfi_def_cfa_offset 20 subl $LocalVarsSize, %esp + .cfi_def_cfa_offset LocalVarsSize+20 /* Retrieve the function arguments. %ecx will hold cur_match */ /* throughout the entire function. %edx will hold the pointer to the */ @@ -108,7 +116,7 @@ longest_match: /* if (s->prev_length >= s->good_match) { */ /* chain_length >>= 2; */ /* } */ - + movl dsPrevLen(%edx), %eax movl dsGoodMatch(%edx), %ebx cmpl %ebx, %eax @@ -336,8 +344,14 @@ LookaheadRet: /* Restore the stack and return from whence we came. */ addl $LocalVarsSize, %esp + .cfi_def_cfa_offset 20 popl %ebx + .cfi_def_cfa_offset 16 popl %esi + .cfi_def_cfa_offset 12 popl %edi + .cfi_def_cfa_offset 8 popl %ebp + .cfi_def_cfa_offset 4 +.cfi_endproc match_init: ret Modified: stable/9/lib/libz/crc32.c ============================================================================== --- stable/9/lib/libz/crc32.c Thu Jun 28 07:02:15 2012 (r237690) +++ stable/9/lib/libz/crc32.c Thu Jun 28 07:08:48 2012 (r237691) @@ -1,5 +1,5 @@ /* crc32.c -- compute the CRC-32 of a data stream - * Copyright (C) 1995-2006, 2010 Mark Adler + * Copyright (C) 1995-2006, 2010, 2011, 2012 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h * * Thanks to Rodney Brown for his contribution of faster @@ -17,6 +17,8 @@ of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should first call get_crc_table() to initialize the tables before allowing more than one thread to use crc32(). + + DYNAMIC_CRC_TABLE and MAKECRCH can be #defined to write out crc32.h. */ #ifdef MAKECRCH @@ -30,31 +32,11 @@ #define local static -/* Find a four-byte integer type for crc32_little() and crc32_big(). */ -#ifndef NOBYFOUR -# ifdef STDC /* need ANSI C limits.h to determine sizes */ -# include -# define BYFOUR -# if (UINT_MAX == 0xffffffffUL) - typedef unsigned int u4; -# else -# if (ULONG_MAX == 0xffffffffUL) - typedef unsigned long u4; -# else -# if (USHRT_MAX == 0xffffffffUL) - typedef unsigned short u4; -# else -# undef BYFOUR /* can't find a four-byte integer type! */ -# endif -# endif -# endif -# endif /* STDC */ -#endif /* !NOBYFOUR */ - /* Definitions for doing the crc four data bytes at a time. */ +#if !defined(NOBYFOUR) && defined(Z_U4) +# define BYFOUR +#endif #ifdef BYFOUR -# define REV(w) ((((w)>>24)&0xff)+(((w)>>8)&0xff00)+ \ - (((w)&0xff00)<<8)+(((w)&0xff)<<24)) local unsigned long crc32_little OF((unsigned long, const unsigned char FAR *, unsigned)); local unsigned long crc32_big OF((unsigned long, @@ -68,16 +50,16 @@ local unsigned long gf2_matrix_times OF((unsigned long *mat, unsigned long vec)); local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat)); -local uLong crc32_combine_(uLong crc1, uLong crc2, z_off64_t len2); +local uLong crc32_combine_ OF((uLong crc1, uLong crc2, z_off64_t len2)); #ifdef DYNAMIC_CRC_TABLE local volatile int crc_table_empty = 1; -local unsigned long FAR crc_table[TBLS][256]; +local z_crc_t FAR crc_table[TBLS][256]; local void make_crc_table OF((void)); #ifdef MAKECRCH - local void write_table OF((FILE *, const unsigned long FAR *)); + local void write_table OF((FILE *, const z_crc_t FAR *)); #endif /* MAKECRCH */ /* Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: @@ -107,9 +89,9 @@ local void make_crc_table OF((void)); */ local void make_crc_table() { - unsigned long c; + z_crc_t c; int n, k; - unsigned long poly; /* polynomial exclusive-or pattern */ + z_crc_t poly; /* polynomial exclusive-or pattern */ /* terms of polynomial defining this crc (except x^32): */ static volatile int first = 1; /* flag to limit concurrent making */ static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; @@ -121,13 +103,13 @@ local void make_crc_table() first = 0; /* make exclusive-or pattern from polynomial (0xedb88320UL) */ - poly = 0UL; - for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++) - poly |= 1UL << (31 - p[n]); + poly = 0; + for (n = 0; n < (int)(sizeof(p)/sizeof(unsigned char)); n++) + poly |= (z_crc_t)1 << (31 - p[n]); /* generate a crc for every 8-bit value */ for (n = 0; n < 256; n++) { - c = (unsigned long)n; + c = (z_crc_t)n; for (k = 0; k < 8; k++) c = c & 1 ? poly ^ (c >> 1) : c >> 1; crc_table[0][n] = c; @@ -138,11 +120,11 @@ local void make_crc_table() and then the byte reversal of those as well as the first table */ for (n = 0; n < 256; n++) { c = crc_table[0][n]; - crc_table[4][n] = REV(c); + crc_table[4][n] = ZSWAP32(c); for (k = 1; k < 4; k++) { c = crc_table[0][c & 0xff] ^ (c >> 8); crc_table[k][n] = c; - crc_table[k + 4][n] = REV(c); + crc_table[k + 4][n] = ZSWAP32(c); } } #endif /* BYFOUR */ @@ -164,7 +146,7 @@ local void make_crc_table() if (out == NULL) return; fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n"); fprintf(out, " * Generated automatically by crc32.c\n */\n\n"); - fprintf(out, "local const unsigned long FAR "); + fprintf(out, "local const z_crc_t FAR "); fprintf(out, "crc_table[TBLS][256] =\n{\n {\n"); write_table(out, crc_table[0]); # ifdef BYFOUR @@ -184,12 +166,13 @@ local void make_crc_table() #ifdef MAKECRCH local void write_table(out, table) FILE *out; - const unsigned long FAR *table; + const z_crc_t FAR *table; { int n; for (n = 0; n < 256; n++) - fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", table[n], + fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", + (unsigned long)(table[n]), n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", ")); } #endif /* MAKECRCH */ @@ -204,13 +187,13 @@ local void write_table(out, table) /* ========================================================================= * This function can be used by asm versions of crc32() */ -const unsigned long FAR * ZEXPORT get_crc_table() +const z_crc_t FAR * ZEXPORT get_crc_table() { #ifdef DYNAMIC_CRC_TABLE if (crc_table_empty) make_crc_table(); #endif /* DYNAMIC_CRC_TABLE */ - return (const unsigned long FAR *)crc_table; + return (const z_crc_t FAR *)crc_table; } /* ========================================================================= */ @@ -232,7 +215,7 @@ unsigned long ZEXPORT crc32(crc, buf, le #ifdef BYFOUR if (sizeof(void *) == sizeof(ptrdiff_t)) { - u4 endian; + z_crc_t endian; endian = 1; if (*((unsigned char *)(&endian))) @@ -266,17 +249,17 @@ local unsigned long crc32_little(crc, bu const unsigned char FAR *buf; unsigned len; { - register u4 c; - register const u4 FAR *buf4; + register z_crc_t c; + register const z_crc_t FAR *buf4; - c = (u4)crc; + c = (z_crc_t)crc; c = ~c; while (len && ((ptrdiff_t)buf & 3)) { c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); len--; } - buf4 = (const u4 FAR *)(const void FAR *)buf; + buf4 = (const z_crc_t FAR *)(const void FAR *)buf; while (len >= 32) { DOLIT32; len -= 32; @@ -306,17 +289,17 @@ local unsigned long crc32_big(crc, buf, const unsigned char FAR *buf; unsigned len; { - register u4 c; - register const u4 FAR *buf4; + register z_crc_t c; + register const z_crc_t FAR *buf4; - c = REV((u4)crc); + c = ZSWAP32((z_crc_t)crc); c = ~c; while (len && ((ptrdiff_t)buf & 3)) { c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); len--; } - buf4 = (const u4 FAR *)(const void FAR *)buf; + buf4 = (const z_crc_t FAR *)(const void FAR *)buf; buf4--; while (len >= 32) { DOBIG32; @@ -333,7 +316,7 @@ local unsigned long crc32_big(crc, buf, c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); } while (--len); c = ~c; - return (unsigned long)(REV(c)); + return (unsigned long)(ZSWAP32(c)); } #endif /* BYFOUR */ Modified: stable/9/lib/libz/crc32.h ============================================================================== --- stable/9/lib/libz/crc32.h Thu Jun 28 07:02:15 2012 (r237690) +++ stable/9/lib/libz/crc32.h Thu Jun 28 07:08:48 2012 (r237691) @@ -2,7 +2,7 @@ * Generated automatically by crc32.c */ -local const unsigned long FAR crc_table[TBLS][256] = +local const z_crc_t FAR crc_table[TBLS][256] = { { 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL, Modified: stable/9/lib/libz/deflate.c ============================================================================== --- stable/9/lib/libz/deflate.c Thu Jun 28 07:02:15 2012 (r237690) +++ stable/9/lib/libz/deflate.c Thu Jun 28 07:08:48 2012 (r237691) @@ -1,5 +1,5 @@ /* deflate.c -- compress data using the deflation algorithm - * Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler + * Copyright (C) 1995-2012 Jean-loup Gailly and Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -37,7 +37,7 @@ * REFERENCES * * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification". - * Available in http://www.ietf.org/rfc/rfc1951.txt + * Available in http://tools.ietf.org/html/rfc1951 * * A description of the Rabin and Karp algorithm is given in the book * "Algorithms" by R. Sedgewick, Addison-Wesley, p252. @@ -52,7 +52,7 @@ #include "deflate.h" const char deflate_copyright[] = - " deflate 1.2.5 Copyright 1995-2010 Jean-loup Gailly and Mark Adler "; + " deflate 1.2.7 Copyright 1995-2012 Jean-loup Gailly and Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot @@ -155,6 +155,9 @@ local const config configuration_table[1 struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ #endif +/* rank Z_BLOCK between Z_NO_FLUSH and Z_PARTIAL_FLUSH */ +#define RANK(f) (((f) << 1) - ((f) > 4 ? 9 : 0)) + /* =========================================================================== * Update a hash value with the given input byte * IN assertion: all calls to to UPDATE_HASH are made with consecutive @@ -235,10 +238,19 @@ int ZEXPORT deflateInit2_(strm, level, m strm->msg = Z_NULL; if (strm->zalloc == (alloc_func)0) { +#ifdef Z_SOLO + return Z_STREAM_ERROR; +#else strm->zalloc = zcalloc; strm->opaque = (voidpf)0; +#endif } - if (strm->zfree == (free_func)0) strm->zfree = zcfree; + if (strm->zfree == (free_func)0) +#ifdef Z_SOLO + return Z_STREAM_ERROR; +#else + strm->zfree = zcfree; +#endif #ifdef FASTEST if (level != 0) level = 1; @@ -314,43 +326,70 @@ int ZEXPORT deflateSetDictionary (strm, uInt dictLength; { deflate_state *s; - uInt length = dictLength; - uInt n; - IPos hash_head = 0; - - if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL || - strm->state->wrap == 2 || - (strm->state->wrap == 1 && strm->state->status != INIT_STATE)) - return Z_STREAM_ERROR; + uInt str, n; + int wrap; + unsigned avail; + unsigned char *next; + if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL) + return Z_STREAM_ERROR; s = strm->state; - if (s->wrap) + wrap = s->wrap; + if (wrap == 2 || (wrap == 1 && s->status != INIT_STATE) || s->lookahead) + return Z_STREAM_ERROR; + + /* when using zlib wrappers, compute Adler-32 for provided dictionary */ + if (wrap == 1) strm->adler = adler32(strm->adler, dictionary, dictLength); + s->wrap = 0; /* avoid computing Adler-32 in read_buf */ - if (length < MIN_MATCH) return Z_OK; - if (length > s->w_size) { - length = s->w_size; - dictionary += dictLength - length; /* use the tail of the dictionary */ - } - zmemcpy(s->window, dictionary, length); - s->strstart = length; - s->block_start = (long)length; - - /* Insert all strings in the hash table (except for the last two bytes). - * s->lookahead stays null, so s->ins_h will be recomputed at the next - * call of fill_window. - */ - s->ins_h = s->window[0]; - UPDATE_HASH(s, s->ins_h, s->window[1]); - for (n = 0; n <= length - MIN_MATCH; n++) { - INSERT_STRING(s, n, hash_head); - } - if (hash_head) hash_head = 0; /* to make compiler happy */ + /* if dictionary would fill window, just replace the history */ + if (dictLength >= s->w_size) { + if (wrap == 0) { /* already empty otherwise */ + CLEAR_HASH(s); + s->strstart = 0; + s->block_start = 0L; + s->insert = 0; + } + dictionary += dictLength - s->w_size; /* use the tail */ + dictLength = s->w_size; + } + + /* insert dictionary into window and hash */ + avail = strm->avail_in; + next = strm->next_in; + strm->avail_in = dictLength; + strm->next_in = (Bytef *)dictionary; + fill_window(s); + while (s->lookahead >= MIN_MATCH) { + str = s->strstart; + n = s->lookahead - (MIN_MATCH-1); + do { + UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); +#ifndef FASTEST + s->prev[str & s->w_mask] = s->head[s->ins_h]; +#endif + s->head[s->ins_h] = (Pos)str; + str++; + } while (--n); + s->strstart = str; + s->lookahead = MIN_MATCH-1; + fill_window(s); + } + s->strstart += s->lookahead; + s->block_start = (long)s->strstart; + s->insert = s->lookahead; + s->lookahead = 0; + s->match_length = s->prev_length = MIN_MATCH-1; + s->match_available = 0; + strm->next_in = next; + strm->avail_in = avail; + s->wrap = wrap; return Z_OK; } /* ========================================================================= */ -int ZEXPORT deflateReset (strm) +int ZEXPORT deflateResetKeep (strm) z_streamp strm; { deflate_state *s; @@ -380,12 +419,23 @@ int ZEXPORT deflateReset (strm) s->last_flush = Z_NO_FLUSH; _tr_init(s); - lm_init(s); return Z_OK; } *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-9@FreeBSD.ORG Thu Jun 28 09:18:12 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4D12C1065672; Thu, 28 Jun 2012 09:18:12 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1E2648FC0A; Thu, 28 Jun 2012 09:18:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5S9IBwA064630; Thu, 28 Jun 2012 09:18:11 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5S9IBuu064627; Thu, 28 Jun 2012 09:18:11 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201206280918.q5S9IBuu064627@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 28 Jun 2012 09:18:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237698 - stable/9/lib/libkiconv X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jun 2012 09:18:12 -0000 Author: gabor Date: Thu Jun 28 09:18:11 2012 New Revision: 237698 URL: http://svn.freebsd.org/changeset/base/237698 Log: MFC 236028, 236185, 236972 - Add support for BSD iconv when it is built into libc Modified: stable/9/lib/libkiconv/Makefile stable/9/lib/libkiconv/xlat16_iconv.c Directory Properties: stable/9/lib/libkiconv/ (props changed) Modified: stable/9/lib/libkiconv/Makefile ============================================================================== --- stable/9/lib/libkiconv/Makefile Thu Jun 28 08:25:19 2012 (r237697) +++ stable/9/lib/libkiconv/Makefile Thu Jun 28 09:18:11 2012 (r237698) @@ -1,7 +1,10 @@ # $FreeBSD$ -LIB= kiconv SHLIBDIR?= /lib + +.include + +LIB= kiconv SRCS= kiconv_sysctl.c xlat16_iconv.c xlat16_sysctl.c SRCS+= quirks.c @@ -17,4 +20,8 @@ CFLAGS+= -I${.CURDIR}/../../sys WARNS?= 1 +.if ${MK_ICONV} == "no" +CFLAGS+= -DICONV_DLOPEN +.endif + .include Modified: stable/9/lib/libkiconv/xlat16_iconv.c ============================================================================== --- stable/9/lib/libkiconv/xlat16_iconv.c Thu Jun 28 08:25:19 2012 (r237697) +++ stable/9/lib/libkiconv/xlat16_iconv.c Thu Jun 28 09:18:11 2012 (r237698) @@ -60,10 +60,18 @@ struct xlat16_table { static struct xlat16_table kiconv_xlat16_open(const char *, const char *, int); static int chklocale(int, const char *); +#ifdef ICONV_DLOPEN static int my_iconv_init(void); static iconv_t (*my_iconv_open)(const char *, const char *); static size_t (*my_iconv)(iconv_t, const char **, size_t *, char **, size_t *); static int (*my_iconv_close)(iconv_t); +#else +#include +#define my_iconv_init() 0 +#define my_iconv_open iconv_open +#define my_iconv iconv +#define my_iconv_close iconv_close +#endif static size_t my_iconv_char(iconv_t, const u_char **, size_t *, u_char **, size_t *); int @@ -310,6 +318,7 @@ chklocale(int category, const char *code return (error); } +#ifdef ICONV_DLOPEN static int my_iconv_init(void) { @@ -327,6 +336,7 @@ my_iconv_init(void) return (0); } +#endif static size_t my_iconv_char(iconv_t cd, const u_char **ibuf, size_t * ilen, u_char **obuf, From owner-svn-src-stable-9@FreeBSD.ORG Thu Jun 28 10:05:46 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6A3461065676; Thu, 28 Jun 2012 10:05:46 +0000 (UTC) (envelope-from issyl0@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 536848FC14; Thu, 28 Jun 2012 10:05:46 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5SA5kNg066633; Thu, 28 Jun 2012 10:05:46 GMT (envelope-from issyl0@svn.freebsd.org) Received: (from issyl0@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5SA5kui066627; Thu, 28 Jun 2012 10:05:46 GMT (envelope-from issyl0@svn.freebsd.org) Message-Id: <201206281005.q5SA5kui066627@svn.freebsd.org> From: Isabell Long Date: Thu, 28 Jun 2012 10:05:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237699 - stable/9/lib/libc/string X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jun 2012 10:05:46 -0000 Author: issyl0 (doc committer) Date: Thu Jun 28 10:05:45 2012 New Revision: 237699 URL: http://svn.freebsd.org/changeset/base/237699 Log: Merge head revisions 237393, 237409: Locale-specific man page edits: - libc/string/strcoll.3 - libc/string/strstr.3 - libc/string/strxfrm.3 - libc/string/strcasecmp.3 - libc/string/Makefile.inc Approved by: gabor (mentor) Modified: stable/9/lib/libc/string/Makefile.inc stable/9/lib/libc/string/strcasecmp.3 stable/9/lib/libc/string/strcoll.3 stable/9/lib/libc/string/strstr.3 stable/9/lib/libc/string/strxfrm.3 Directory Properties: stable/9/lib/libc/ (props changed) Modified: stable/9/lib/libc/string/Makefile.inc ============================================================================== --- stable/9/lib/libc/string/Makefile.inc Thu Jun 28 09:18:11 2012 (r237698) +++ stable/9/lib/libc/string/Makefile.inc Thu Jun 28 10:05:45 2012 (r237699) @@ -42,10 +42,13 @@ MLINKS+=ffs.3 ffsl.3 \ ffs.3 flsll.3 MLINKS+=index.3 rindex.3 MLINKS+=memchr.3 memrchr.3 -MLINKS+=strcasecmp.3 strncasecmp.3 +MLINKS+=strcasecmp.3 strncasecmp.3 \ + strcasecmp.3 strcasecmp_l.3 \ + strcasecmp.3 strncasecmp_l.3 MLINKS+=strcat.3 strncat.3 MLINKS+=strchr.3 strrchr.3 MLINKS+=strcmp.3 strncmp.3 +MLINKS+=strcoll.3 strcoll_l.3 MLINKS+=strcpy.3 stpcpy.3 \ strcpy.3 stpncpy.3 \ strcpy.3 strncpy.3 @@ -57,8 +60,10 @@ MLINKS+=strerror.3 perror.3 \ MLINKS+=strlcpy.3 strlcat.3 MLINKS+=strlen.3 strnlen.3 MLINKS+=strstr.3 strcasestr.3 \ - strstr.3 strnstr.3 + strstr.3 strnstr.3 \ + strstr.3 strcasestr_l.3 MLINKS+=strtok.3 strtok_r.3 +MLINKS+=strxfrm.3 strxfrm_l.3 MLINKS+=wmemchr.3 wcpcpy.3 \ wmemchr.3 wcpncpy.3 \ wmemchr.3 wcscasecmp.3 \ Modified: stable/9/lib/libc/string/strcasecmp.3 ============================================================================== --- stable/9/lib/libc/string/strcasecmp.3 Thu Jun 28 09:18:11 2012 (r237698) +++ stable/9/lib/libc/string/strcasecmp.3 Thu Jun 28 10:05:45 2012 (r237699) @@ -45,6 +45,12 @@ .Fn strcasecmp "const char *s1" "const char *s2" .Ft int .Fn strncasecmp "const char *s1" "const char *s2" "size_t len" +.In string.h +.In xlocale.h +.Ft int +.Fn strcasecmp_l "const char *s1" "const char *s2" "locale_t loc" +.Ft int +.Fn strncasecmp_l "const char *s1" "const char *s2" "site_t len" "locale_t loc" .Sh DESCRIPTION The .Fn strcasecmp @@ -58,16 +64,22 @@ and .Pp The .Fn strncasecmp -compares at most +function compares at most .Fa len characters. -.Sh RETURN VALUES The +.Fn strcasecmp_l +and +.Fn strncasecmp_l +functions do the same as their non-locale versions above, but take an +explicit locale rather than using the current locale. +.Sh RETURN VALUES +The functions .Fn strcasecmp and .Fn strncasecmp return an integer greater than, equal to, or less than 0, -according as +depending on whether .Fa s1 is lexicographically greater than, equal to, or less than .Fa s2 @@ -77,6 +89,11 @@ The comparison is done using unsigned ch .Sq Li \e200 is greater than .Ql \e0 . +The functions +.Fn strcasecmp_l +and +.Fn strncasecmp_l +do the same but take explicit locales. .Sh SEE ALSO .Xr bcmp 3 , .Xr memcmp 3 , Modified: stable/9/lib/libc/string/strcoll.3 ============================================================================== --- stable/9/lib/libc/string/strcoll.3 Thu Jun 28 09:18:11 2012 (r237698) +++ stable/9/lib/libc/string/strcoll.3 Thu Jun 28 10:05:45 2012 (r237699) @@ -44,6 +44,8 @@ .In string.h .Ft int .Fn strcoll "const char *s1" "const char *s2" +.Ft int +.Fn strcoll_l "const char *s1" "const char *s2" "locale_t loc" .Sh DESCRIPTION The .Fn strcoll @@ -54,7 +56,7 @@ and .Fa s2 according to the current locale collation and returns an integer greater than, equal to, or less than 0, -according as +depending on whether .Fa s1 is greater than, equal to, or less than .Fa s2 . @@ -62,6 +64,9 @@ If information about the current locale the value of .Fn strcmp s1 s2 is returned. +The +.Fn strcoll_l +function uses an explicit locale argument rather than the system locale. .Sh SEE ALSO .Xr setlocale 3 , .Xr strcmp 3 , @@ -70,6 +75,9 @@ is returned. .Sh STANDARDS The .Fn strcoll -function -conforms to +function conforms to .St -isoC . +The +.Fn strcoll_l +function conforms to +.St -p1003.1-2008 . Modified: stable/9/lib/libc/string/strstr.3 ============================================================================== --- stable/9/lib/libc/string/strstr.3 Thu Jun 28 09:18:11 2012 (r237698) +++ stable/9/lib/libc/string/strstr.3 Thu Jun 28 10:05:45 2012 (r237699) @@ -49,6 +49,10 @@ .Fn strcasestr "const char *big" "const char *little" .Ft char * .Fn strnstr "const char *big" "const char *little" "size_t len" +.In string.h +.In xlocale.h +.Ft char * +.Fn strcasestr_l "const char *big" "const char *little" "locale_t loc" .Sh DESCRIPTION The .Fn strstr @@ -65,6 +69,12 @@ function is similar to but ignores the case of both strings. .Pp The +.Fn strcasestr_l +function does the same as +.Fn strcasestr +but takes an explicit locale rather than using the current locale. +.Pp +The .Fn strnstr function locates the first occurrence of the null-terminated string Modified: stable/9/lib/libc/string/strxfrm.3 ============================================================================== --- stable/9/lib/libc/string/strxfrm.3 Thu Jun 28 09:18:11 2012 (r237698) +++ stable/9/lib/libc/string/strxfrm.3 Thu Jun 28 10:05:45 2012 (r237699) @@ -44,6 +44,8 @@ .In string.h .Ft size_t .Fn strxfrm "char * restrict dst" "const char * restrict src" "size_t n" +.Ft size_t +.Fn strxfrm_l "char * restrict dst" "const char *restrict src" "size_t n" "locale_t loc" .Sh DESCRIPTION The .Fn strxfrm @@ -73,10 +75,16 @@ after is equal to comparing two original strings with .Fn strcoll . +.Pp +.Fn strxfrm_l +does the same, however takes an explicit locale rather than the global +locale. .Sh RETURN VALUES Upon successful completion, .Fn strxfrm -returns the length of the transformed string not including +and +.Fn strxfrm_l +return the length of the transformed string not including the terminating null character. If this value is .Fa n @@ -94,3 +102,7 @@ The function conforms to .St -isoC . +The +.Fn strxfrm_l +function conforms to +.St -p1003.1-2008 . From owner-svn-src-stable-9@FreeBSD.ORG Thu Jun 28 11:15:49 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0F17D1065673; Thu, 28 Jun 2012 11:15:49 +0000 (UTC) (envelope-from fjoe@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D4C928FC0C; Thu, 28 Jun 2012 11:15:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5SBFmlM072727; Thu, 28 Jun 2012 11:15:48 GMT (envelope-from fjoe@svn.freebsd.org) Received: (from fjoe@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5SBFm20072724; Thu, 28 Jun 2012 11:15:48 GMT (envelope-from fjoe@svn.freebsd.org) Message-Id: <201206281115.q5SBFm20072724@svn.freebsd.org> From: Max Khon Date: Thu, 28 Jun 2012 11:15:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237703 - stable/9/sys/dev/puc X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jun 2012 11:15:49 -0000 Author: fjoe Date: Thu Jun 28 11:15:48 2012 New Revision: 237703 URL: http://svn.freebsd.org/changeset/base/237703 Log: MFC: r237350, r237357 Add support for the following Moxa PCIe multiport serial boards: - CP102E - CP102EL - CP114EL - CP118EL-A - CP168EL-A Modified: stable/9/sys/dev/puc/puc_cfg.h stable/9/sys/dev/puc/pucdata.c Directory Properties: stable/9/ (props changed) stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/puc/puc_cfg.h ============================================================================== --- stable/9/sys/dev/puc/puc_cfg.h Thu Jun 28 10:40:57 2012 (r237702) +++ stable/9/sys/dev/puc/puc_cfg.h Thu Jun 28 11:15:48 2012 (r237703) @@ -79,7 +79,7 @@ struct puc_cfg { int8_t ports; int8_t rid; /* Rid of first port */ int8_t d_rid; /* Delta rid of next ports */ - int8_t d_ofs; /* Delta offset of next ports */ + int16_t d_ofs; /* Delta offset of next ports */ puc_config_f *config_function; }; Modified: stable/9/sys/dev/puc/pucdata.c ============================================================================== --- stable/9/sys/dev/puc/pucdata.c Thu Jun 28 10:40:57 2012 (r237702) +++ stable/9/sys/dev/puc/pucdata.c Thu Jun 28 11:15:48 2012 (r237703) @@ -507,6 +507,18 @@ const struct puc_cfg puc_pci_devices[] = .config_function = puc_config_quatech }, + { 0x1393, 0x1024, 0xffff, 0, + "Moxa Technologies, Smartio CP-102E/PCIe", + DEFAULT_RCLK * 8, + PUC_PORT_2S, 0x14, 0, 0x200 + }, + + { 0x1393, 0x1025, 0xffff, 0, + "Moxa Technologies, Smartio CP-102EL/PCIe", + DEFAULT_RCLK * 8, + PUC_PORT_2S, 0x14, 0, 0x200, + }, + { 0x1393, 0x1040, 0xffff, 0, "Moxa Technologies, Smartio C104H/PCI", DEFAULT_RCLK * 8, @@ -550,6 +562,19 @@ const struct puc_cfg puc_pci_devices[] = PUC_PORT_4S, 0x18, 0, 8, }, + { 0x1393, 0x1144, 0xffff, 0, + "Moxa Technologies, Smartio CP-114EL/PCIe", + DEFAULT_RCLK * 8, + PUC_PORT_4S, 0x14, 0, -1, + .config_function = puc_config_moxa + }, + + { 0x1393, 0x1182, 0xffff, 0, + "Moxa Technologies, Smartio CP-118EL-A/PCIe", + DEFAULT_RCLK * 8, + PUC_PORT_8S, 0x14, 0, 0x200, + }, + { 0x1393, 0x1680, 0xffff, 0, "Moxa Technologies, C168H/PCI", DEFAULT_RCLK * 8, @@ -568,6 +593,12 @@ const struct puc_cfg puc_pci_devices[] = PUC_PORT_8S, 0x18, 0, 8, }, + { 0x1393, 0x1683, 0xffff, 0, + "Moxa Technologies, Smartio CP-168EL-A/PCIe", + DEFAULT_RCLK * 8, + PUC_PORT_8S, 0x14, 0, 0x200, + }, + { 0x13a8, 0x0152, 0xffff, 0, "Exar XR17C/D152", DEFAULT_RCLK * 8, @@ -1121,9 +1152,7 @@ static int puc_config_moxa(struct puc_softc *sc, enum puc_cfg_cmd cmd, int port, intptr_t *res) { - const struct puc_cfg *cfg = sc->sc_cfg; - - if (cmd == PUC_CFG_GET_OFS && cfg->device == 0x1045) { + if (cmd == PUC_CFG_GET_OFS) { *res = ((port == 3) ? 7 : port) * 0x200; return 0; } From owner-svn-src-stable-9@FreeBSD.ORG Thu Jun 28 13:04:56 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 299081065673; Thu, 28 Jun 2012 13:04:56 +0000 (UTC) (envelope-from wblock@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 143688FC1C; Thu, 28 Jun 2012 13:04:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5SD4tVU077420; Thu, 28 Jun 2012 13:04:55 GMT (envelope-from wblock@svn.freebsd.org) Received: (from wblock@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5SD4tJa077418; Thu, 28 Jun 2012 13:04:55 GMT (envelope-from wblock@svn.freebsd.org) Message-Id: <201206281304.q5SD4tJa077418@svn.freebsd.org> From: Warren Block Date: Thu, 28 Jun 2012 13:04:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237706 - stable/9/sbin/geom/class/raid X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jun 2012 13:04:56 -0000 Author: wblock (doc committer) Date: Thu Jun 28 13:04:55 2012 New Revision: 237706 URL: http://svn.freebsd.org/changeset/base/237706 Log: MFC r237620: Use possessive "its", no apostrophe. Modified: stable/9/sbin/geom/class/raid/graid.8 Directory Properties: stable/9/sbin/geom/class/raid/ (props changed) Modified: stable/9/sbin/geom/class/raid/graid.8 ============================================================================== --- stable/9/sbin/geom/class/raid/graid.8 Thu Jun 28 11:58:10 2012 (r237705) +++ stable/9/sbin/geom/class/raid/graid.8 Thu Jun 28 13:04:55 2012 (r237706) @@ -85,7 +85,7 @@ utility is used to manage software RAID GEOM RAID class. GEOM RAID class uses on-disk metadata to provide access to software-RAID volumes defined by different RAID BIOSes. -Depending on RAID BIOS type and it's metadata format, different subsets of +Depending on RAID BIOS type and its metadata format, different subsets of configurations and features are supported. To allow booting from RAID volume, the metadata format should match the RAID BIOS type and its capabilities. From owner-svn-src-stable-9@FreeBSD.ORG Thu Jun 28 13:10:36 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D848C106566C; Thu, 28 Jun 2012 13:10:36 +0000 (UTC) (envelope-from wblock@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C37AB8FC1B; Thu, 28 Jun 2012 13:10:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5SDAald077811; Thu, 28 Jun 2012 13:10:36 GMT (envelope-from wblock@svn.freebsd.org) Received: (from wblock@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5SDAaFo077809; Thu, 28 Jun 2012 13:10:36 GMT (envelope-from wblock@svn.freebsd.org) Message-Id: <201206281310.q5SDAaFo077809@svn.freebsd.org> From: Warren Block Date: Thu, 28 Jun 2012 13:10:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237708 - stable/9/share/man/man7 X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jun 2012 13:10:37 -0000 Author: wblock (doc committer) Date: Thu Jun 28 13:10:36 2012 New Revision: 237708 URL: http://svn.freebsd.org/changeset/base/237708 Log: MFC r237655: Point out that /usr/src, /usr/doc, and /usr/ports may be empty or not exist until populated with csup(1) or svn(1). PR: 169487 Submitted by: Moritz Wilhelmy Modified: stable/9/share/man/man7/build.7 Directory Properties: stable/9/share/man/man7/ (props changed) Modified: stable/9/share/man/man7/build.7 ============================================================================== --- stable/9/share/man/man7/build.7 Thu Jun 28 13:05:56 2012 (r237707) +++ stable/9/share/man/man7/build.7 Thu Jun 28 13:10:36 2012 (r237708) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 29, 2011 +.Dd June 27, 2012 .Dt BUILD 7 .Os .Sh NAME @@ -39,6 +39,10 @@ normally .Pa /usr/doc , and .Pa /usr/ports . +These directories may be initially empty or non-existent until updated with +.Xr csup 1 +or +.Xr svn 1 . Directory .Pa /usr/src contains the @@ -489,7 +493,7 @@ on built objects. .It Va NO_SHARE If set, the build does not descend into the .Pa /usr/src/share -subdirectory (i.e. manpages, locale data files, timezone data files and +subdirectory (i.e., manpages, locale data files, timezone data files and other .Pa /usr/src/share files will not be rebuild from their sources). @@ -594,8 +598,10 @@ make TARGET=sparc64 DESTDIR=/clients/spa .Ed .Sh SEE ALSO .Xr cc 1 , +.Xr csup 1 , .Xr install 1 , .Xr make 1 , +.Xr svn 1 , .Xr make.conf 5 , .Xr src.conf 5 , .Xr ports 7 , From owner-svn-src-stable-9@FreeBSD.ORG Thu Jun 28 14:13:46 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0C6F51065676; Thu, 28 Jun 2012 14:13:46 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EA14A8FC14; Thu, 28 Jun 2012 14:13:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5SEDjgX080541; Thu, 28 Jun 2012 14:13:45 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5SEDjXI080538; Thu, 28 Jun 2012 14:13:45 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206281413.q5SEDjXI080538@svn.freebsd.org> From: Konstantin Belousov Date: Thu, 28 Jun 2012 14:13:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237712 - stable/9/libexec/rtld-elf X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jun 2012 14:13:46 -0000 Author: kib Date: Thu Jun 28 14:13:45 2012 New Revision: 237712 URL: http://svn.freebsd.org/changeset/base/237712 Log: MFC r237058: Eliminate the static buffer used to read the first page of the mapped object, and eliminate the pread(2) call as well. Mmap the first page of the object temporaly, and unmap it on error or last use. Potentially, this leaves one-page gap between succeeding dlopen(3), but there are other mmap(2) consumers as well. Fix several cases were the whole mapping of the object leaked on error. Use MAP_PREFAULT_READ for mmap(2) calls which map real object pages Modified: stable/9/libexec/rtld-elf/map_object.c Directory Properties: stable/9/libexec/rtld-elf/ (props changed) Modified: stable/9/libexec/rtld-elf/map_object.c ============================================================================== --- stable/9/libexec/rtld-elf/map_object.c Thu Jun 28 13:47:07 2012 (r237711) +++ stable/9/libexec/rtld-elf/map_object.c Thu Jun 28 14:13:45 2012 (r237712) @@ -38,7 +38,7 @@ #include "debug.h" #include "rtld.h" -static Elf_Ehdr *get_elf_header (int, const char *); +static Elf_Ehdr *get_elf_header(int, const char *); static int convert_prot(int); /* Elf flags -> mmap protection */ static int convert_flags(int); /* Elf flags -> mmap flags */ @@ -121,7 +121,7 @@ map_object(int fd, const char *path, con if ((segs[nsegs]->p_align & (PAGE_SIZE - 1)) != 0) { _rtld_error("%s: PT_LOAD segment %d not page-aligned", path, nsegs); - return NULL; + goto error; } break; @@ -161,12 +161,12 @@ map_object(int fd, const char *path, con } if (phdyn == NULL) { _rtld_error("%s: object is not dynamically-linked", path); - return NULL; + goto error; } if (nsegs < 0) { _rtld_error("%s: too few PT_LOAD segments", path); - return NULL; + goto error; } /* @@ -183,13 +183,12 @@ map_object(int fd, const char *path, con if (mapbase == (caddr_t) -1) { _rtld_error("%s: mmap of entire address space failed: %s", path, rtld_strerror(errno)); - return NULL; + goto error; } if (base_addr != NULL && mapbase != base_addr) { _rtld_error("%s: mmap returned wrong address: wanted %p, got %p", path, base_addr, mapbase); - munmap(mapbase, mapsize); - return NULL; + goto error1; } for (i = 0; i <= nsegs; i++) { @@ -201,10 +200,10 @@ map_object(int fd, const char *path, con data_prot = convert_prot(segs[i]->p_flags); data_flags = convert_flags(segs[i]->p_flags) | MAP_FIXED; if (mmap(data_addr, data_vlimit - data_vaddr, data_prot, - data_flags, fd, data_offset) == (caddr_t) -1) { + data_flags | MAP_PREFAULT_READ, fd, data_offset) == (caddr_t) -1) { _rtld_error("%s: mmap of data failed: %s", path, rtld_strerror(errno)); - return NULL; + goto error1; } /* Do BSS setup */ @@ -221,7 +220,7 @@ map_object(int fd, const char *path, con mprotect(clear_page, PAGE_SIZE, data_prot|PROT_WRITE)) { _rtld_error("%s: mprotect failed: %s", path, rtld_strerror(errno)); - return NULL; + goto error1; } memset(clear_addr, 0, nclear); @@ -240,7 +239,7 @@ map_object(int fd, const char *path, con data_flags | MAP_ANON, -1, 0) == (caddr_t)-1) { _rtld_error("%s: mmap of bss failed: %s", path, rtld_strerror(errno)); - return NULL; + goto error1; } } } @@ -273,7 +272,7 @@ map_object(int fd, const char *path, con if (obj->phdr == NULL) { obj_free(obj); _rtld_error("%s: cannot allocate program header", path); - return NULL; + goto error1; } memcpy((char *)obj->phdr, (char *)hdr + hdr->e_phoff, phsize); obj->phdr_alloc = true; @@ -293,63 +292,72 @@ map_object(int fd, const char *path, con obj->relro_page = obj->relocbase + trunc_page(relro_page); obj->relro_size = round_page(relro_size); - return obj; + munmap(hdr, PAGE_SIZE); + return (obj); + +error1: + munmap(mapbase, mapsize); +error: + munmap(hdr, PAGE_SIZE); + return (NULL); } static Elf_Ehdr * -get_elf_header (int fd, const char *path) +get_elf_header(int fd, const char *path) { - static union { - Elf_Ehdr hdr; - char buf[PAGE_SIZE]; - } u; - ssize_t nbytes; - - if ((nbytes = pread(fd, u.buf, PAGE_SIZE, 0)) == -1) { - _rtld_error("%s: read error: %s", path, rtld_strerror(errno)); - return NULL; - } - - /* Make sure the file is valid */ - if (nbytes < (ssize_t)sizeof(Elf_Ehdr) || !IS_ELF(u.hdr)) { - _rtld_error("%s: invalid file format", path); - return NULL; - } - if (u.hdr.e_ident[EI_CLASS] != ELF_TARG_CLASS - || u.hdr.e_ident[EI_DATA] != ELF_TARG_DATA) { - _rtld_error("%s: unsupported file layout", path); - return NULL; - } - if (u.hdr.e_ident[EI_VERSION] != EV_CURRENT - || u.hdr.e_version != EV_CURRENT) { - _rtld_error("%s: unsupported file version", path); - return NULL; - } - if (u.hdr.e_type != ET_EXEC && u.hdr.e_type != ET_DYN) { - _rtld_error("%s: unsupported file type", path); - return NULL; - } - if (u.hdr.e_machine != ELF_TARG_MACH) { - _rtld_error("%s: unsupported machine", path); - return NULL; - } + Elf_Ehdr *hdr; - /* - * We rely on the program header being in the first page. This is - * not strictly required by the ABI specification, but it seems to - * always true in practice. And, it simplifies things considerably. - */ - if (u.hdr.e_phentsize != sizeof(Elf_Phdr)) { - _rtld_error( - "%s: invalid shared object: e_phentsize != sizeof(Elf_Phdr)", path); - return NULL; - } - if (u.hdr.e_phoff + u.hdr.e_phnum * sizeof(Elf_Phdr) > (size_t)nbytes) { - _rtld_error("%s: program header too large", path); - return NULL; - } + hdr = mmap(NULL, PAGE_SIZE, PROT_READ, MAP_PRIVATE | MAP_PREFAULT_READ, + fd, 0); + if (hdr == (Elf_Ehdr *)MAP_FAILED) { + _rtld_error("%s: read error: %s", path, rtld_strerror(errno)); + return (NULL); + } + + /* Make sure the file is valid */ + if (!IS_ELF(*hdr)) { + _rtld_error("%s: invalid file format", path); + goto error; + } + if (hdr->e_ident[EI_CLASS] != ELF_TARG_CLASS || + hdr->e_ident[EI_DATA] != ELF_TARG_DATA) { + _rtld_error("%s: unsupported file layout", path); + goto error; + } + if (hdr->e_ident[EI_VERSION] != EV_CURRENT || + hdr->e_version != EV_CURRENT) { + _rtld_error("%s: unsupported file version", path); + goto error; + } + if (hdr->e_type != ET_EXEC && hdr->e_type != ET_DYN) { + _rtld_error("%s: unsupported file type", path); + goto error; + } + if (hdr->e_machine != ELF_TARG_MACH) { + _rtld_error("%s: unsupported machine", path); + goto error; + } - return (&u.hdr); + /* + * We rely on the program header being in the first page. This is + * not strictly required by the ABI specification, but it seems to + * always true in practice. And, it simplifies things considerably. + */ + if (hdr->e_phentsize != sizeof(Elf_Phdr)) { + _rtld_error( + "%s: invalid shared object: e_phentsize != sizeof(Elf_Phdr)", path); + goto error; + } + if (hdr->e_phoff + hdr->e_phnum * sizeof(Elf_Phdr) > + (size_t)PAGE_SIZE) { + _rtld_error("%s: program header too large", path); + goto error; + } + return (hdr); + +error: + munmap(hdr, PAGE_SIZE); + return (NULL); } void From owner-svn-src-stable-9@FreeBSD.ORG Thu Jun 28 14:26:56 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5EB66106566B; Thu, 28 Jun 2012 14:26:56 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2FD4E8FC19; Thu, 28 Jun 2012 14:26:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5SEQuq6081214; Thu, 28 Jun 2012 14:26:56 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5SEQtwV081212; Thu, 28 Jun 2012 14:26:55 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206281426.q5SEQtwV081212@svn.freebsd.org> From: Konstantin Belousov Date: Thu, 28 Jun 2012 14:26:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237713 - stable/9/sys/ufs/ffs X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jun 2012 14:26:56 -0000 Author: kib Date: Thu Jun 28 14:26:55 2012 New Revision: 237713 URL: http://svn.freebsd.org/changeset/base/237713 Log: Fix unbounded-length malloc, controlled from usermode. The added check is performed before exact size of the buffer is calculated, but the buffer cannot have size greater then the total space allocated for extended attributes. The existing check is executing with precise size, but it is too late, since buffer needs to be allocated in advance. Also, adapt to uio_resid being of ssize_t type. Use lblktosize instead of multiplying by fs block size by hand as well. Modified: stable/9/sys/ufs/ffs/ffs_vnops.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/ufs/ffs/ffs_vnops.c ============================================================================== --- stable/9/sys/ufs/ffs/ffs_vnops.c Thu Jun 28 14:13:45 2012 (r237712) +++ stable/9/sys/ufs/ffs/ffs_vnops.c Thu Jun 28 14:26:55 2012 (r237713) @@ -1649,7 +1649,8 @@ vop_setextattr { struct inode *ip; struct fs *fs; uint32_t ealength, ul; - int ealen, olen, eapad1, eapad2, error, i, easize; + ssize_t ealen; + int olen, eapad1, eapad2, error, i, easize; u_char *eae, *p; ip = VTOI(ap->a_vp); @@ -1668,6 +1669,10 @@ vop_setextattr { if (ap->a_vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); + ealen = ap->a_uio->uio_resid; + if (ealen < 0 || ealen > lblktosize(fs, NXADDR)) + return (EINVAL); + error = extattr_check_cred(ap->a_vp, ap->a_attrnamespace, ap->a_cred, ap->a_td, VWRITE); if (error) { @@ -1685,7 +1690,6 @@ vop_setextattr { if (error) return (error); - ealen = ap->a_uio->uio_resid; ealength = sizeof(uint32_t) + 3 + strlen(ap->a_name); eapad1 = 8 - (ealength % 8); if (eapad1 == 8) @@ -1713,7 +1717,7 @@ vop_setextattr { easize += (ealength - ul); } } - if (easize > NXADDR * fs->fs_bsize) { + if (easize > lblktosize(fs, NXADDR)) { free(eae, M_TEMP); ffs_close_ea(ap->a_vp, 0, ap->a_cred, ap->a_td); if (ip->i_ea_area != NULL && ip->i_ea_error == 0) From owner-svn-src-stable-9@FreeBSD.ORG Thu Jun 28 18:38:25 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BB5081065670; Thu, 28 Jun 2012 18:38:25 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A231B8FC08; Thu, 28 Jun 2012 18:38:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5SIcP9E092029; Thu, 28 Jun 2012 18:38:25 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5SIcP9Z092021; Thu, 28 Jun 2012 18:38:25 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201206281838.q5SIcP9Z092021@svn.freebsd.org> From: John Baldwin Date: Thu, 28 Jun 2012 18:38:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237719 - in stable/9: sys/kern sys/sys usr.bin/kdump X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jun 2012 18:38:25 -0000 Author: jhb Date: Thu Jun 28 18:38:24 2012 New Revision: 237719 URL: http://svn.freebsd.org/changeset/base/237719 Log: MFC 234494: Include the associated wait channel message for context switch ktrace records. kdump supports both the old and new messages. Modified: stable/9/sys/kern/kern_condvar.c stable/9/sys/kern/kern_ktrace.c stable/9/sys/kern/kern_synch.c stable/9/sys/kern/subr_trap.c stable/9/sys/sys/ktrace.h stable/9/usr.bin/kdump/kdump.1 stable/9/usr.bin/kdump/kdump.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/dev/isp/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/modules/ (props changed) stable/9/usr.bin/kdump/ (props changed) Modified: stable/9/sys/kern/kern_condvar.c ============================================================================== --- stable/9/sys/kern/kern_condvar.c Thu Jun 28 17:15:16 2012 (r237718) +++ stable/9/sys/kern/kern_condvar.c Thu Jun 28 18:38:24 2012 (r237719) @@ -103,7 +103,7 @@ _cv_wait(struct cv *cvp, struct lock_obj lock_state = 0; #ifdef KTRACE if (KTRPOINT(td, KTR_CSW)) - ktrcsw(1, 0); + ktrcsw(1, 0, cv_wmesg(cvp)); #endif CV_ASSERT(cvp, lock, td); WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, lock, @@ -140,7 +140,7 @@ _cv_wait(struct cv *cvp, struct lock_obj #ifdef KTRACE if (KTRPOINT(td, KTR_CSW)) - ktrcsw(0, 0); + ktrcsw(0, 0, cv_wmesg(cvp)); #endif PICKUP_GIANT(); if (lock != &Giant.lock_object) { @@ -162,7 +162,7 @@ _cv_wait_unlock(struct cv *cvp, struct l td = curthread; #ifdef KTRACE if (KTRPOINT(td, KTR_CSW)) - ktrcsw(1, 0); + ktrcsw(1, 0, cv_wmesg(cvp)); #endif CV_ASSERT(cvp, lock, td); WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, lock, @@ -197,7 +197,7 @@ _cv_wait_unlock(struct cv *cvp, struct l #ifdef KTRACE if (KTRPOINT(td, KTR_CSW)) - ktrcsw(0, 0); + ktrcsw(0, 0, cv_wmesg(cvp)); #endif PICKUP_GIANT(); } @@ -220,7 +220,7 @@ _cv_wait_sig(struct cv *cvp, struct lock lock_state = 0; #ifdef KTRACE if (KTRPOINT(td, KTR_CSW)) - ktrcsw(1, 0); + ktrcsw(1, 0, cv_wmesg(cvp)); #endif CV_ASSERT(cvp, lock, td); WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, lock, @@ -258,7 +258,7 @@ _cv_wait_sig(struct cv *cvp, struct lock #ifdef KTRACE if (KTRPOINT(td, KTR_CSW)) - ktrcsw(0, 0); + ktrcsw(0, 0, cv_wmesg(cvp)); #endif PICKUP_GIANT(); if (lock != &Giant.lock_object) { @@ -286,7 +286,7 @@ _cv_timedwait(struct cv *cvp, struct loc lock_state = 0; #ifdef KTRACE if (KTRPOINT(td, KTR_CSW)) - ktrcsw(1, 0); + ktrcsw(1, 0, cv_wmesg(cvp)); #endif CV_ASSERT(cvp, lock, td); WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, lock, @@ -324,7 +324,7 @@ _cv_timedwait(struct cv *cvp, struct loc #ifdef KTRACE if (KTRPOINT(td, KTR_CSW)) - ktrcsw(0, 0); + ktrcsw(0, 0, cv_wmesg(cvp)); #endif PICKUP_GIANT(); if (lock != &Giant.lock_object) { @@ -353,7 +353,7 @@ _cv_timedwait_sig(struct cv *cvp, struct lock_state = 0; #ifdef KTRACE if (KTRPOINT(td, KTR_CSW)) - ktrcsw(1, 0); + ktrcsw(1, 0, cv_wmesg(cvp)); #endif CV_ASSERT(cvp, lock, td); WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, lock, @@ -392,7 +392,7 @@ _cv_timedwait_sig(struct cv *cvp, struct #ifdef KTRACE if (KTRPOINT(td, KTR_CSW)) - ktrcsw(0, 0); + ktrcsw(0, 0, cv_wmesg(cvp)); #endif PICKUP_GIANT(); if (lock != &Giant.lock_object) { Modified: stable/9/sys/kern/kern_ktrace.c ============================================================================== --- stable/9/sys/kern/kern_ktrace.c Thu Jun 28 17:15:16 2012 (r237718) +++ stable/9/sys/kern/kern_ktrace.c Thu Jun 28 18:38:24 2012 (r237719) @@ -731,8 +731,9 @@ ktrpsig(sig, action, mask, code) } void -ktrcsw(out, user) +ktrcsw(out, user, wmesg) int out, user; + const char *wmesg; { struct thread *td = curthread; struct ktr_request *req; @@ -744,6 +745,10 @@ ktrcsw(out, user) kc = &req->ktr_data.ktr_csw; kc->out = out; kc->user = user; + if (wmesg != NULL) + strlcpy(kc->wmesg, wmesg, sizeof(kc->wmesg)); + else + bzero(kc->wmesg, sizeof(kc->wmesg)); ktr_enqueuerequest(td, req); ktrace_exit(td); } Modified: stable/9/sys/kern/kern_synch.c ============================================================================== --- stable/9/sys/kern/kern_synch.c Thu Jun 28 17:15:16 2012 (r237718) +++ stable/9/sys/kern/kern_synch.c Thu Jun 28 18:38:24 2012 (r237719) @@ -158,7 +158,7 @@ _sleep(void *ident, struct lock_object * p = td->td_proc; #ifdef KTRACE if (KTRPOINT(td, KTR_CSW)) - ktrcsw(1, 0); + ktrcsw(1, 0, wmesg); #endif WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, lock, "Sleeping on \"%s\"", wmesg); @@ -252,7 +252,7 @@ _sleep(void *ident, struct lock_object * } #ifdef KTRACE if (KTRPOINT(td, KTR_CSW)) - ktrcsw(0, 0); + ktrcsw(0, 0, wmesg); #endif PICKUP_GIANT(); if (lock != NULL && lock != &Giant.lock_object && !(priority & PDROP)) { @@ -314,7 +314,7 @@ msleep_spin(void *ident, struct mtx *mtx #ifdef KTRACE if (KTRPOINT(td, KTR_CSW)) { sleepq_release(ident); - ktrcsw(1, 0); + ktrcsw(1, 0, wmesg); sleepq_lock(ident); } #endif @@ -332,7 +332,7 @@ msleep_spin(void *ident, struct mtx *mtx } #ifdef KTRACE if (KTRPOINT(td, KTR_CSW)) - ktrcsw(0, 0); + ktrcsw(0, 0, wmesg); #endif PICKUP_GIANT(); mtx_lock_spin(mtx); Modified: stable/9/sys/kern/subr_trap.c ============================================================================== --- stable/9/sys/kern/subr_trap.c Thu Jun 28 17:15:16 2012 (r237718) +++ stable/9/sys/kern/subr_trap.c Thu Jun 28 18:38:24 2012 (r237719) @@ -219,7 +219,7 @@ ast(struct trapframe *framep) if (flags & TDF_NEEDRESCHED) { #ifdef KTRACE if (KTRPOINT(td, KTR_CSW)) - ktrcsw(1, 1); + ktrcsw(1, 1, __func__); #endif thread_lock(td); sched_prio(td, td->td_user_pri); @@ -227,7 +227,7 @@ ast(struct trapframe *framep) thread_unlock(td); #ifdef KTRACE if (KTRPOINT(td, KTR_CSW)) - ktrcsw(0, 1); + ktrcsw(0, 1, __func__); #endif } Modified: stable/9/sys/sys/ktrace.h ============================================================================== --- stable/9/sys/sys/ktrace.h Thu Jun 28 17:15:16 2012 (r237718) +++ stable/9/sys/sys/ktrace.h Thu Jun 28 18:38:24 2012 (r237719) @@ -135,9 +135,15 @@ struct ktr_psig { * KTR_CSW - trace context switches */ #define KTR_CSW 6 +struct ktr_csw_old { + int out; /* 1 if switch out, 0 if switch in */ + int user; /* 1 if usermode (ivcsw), 0 if kernel (vcsw) */ +}; + struct ktr_csw { int out; /* 1 if switch out, 0 if switch in */ int user; /* 1 if usermode (ivcsw), 0 if kernel (vcsw) */ + char wmesg[8]; }; /* @@ -227,7 +233,7 @@ struct ktr_faultend { #ifdef _KERNEL void ktrnamei(char *); -void ktrcsw(int, int); +void ktrcsw(int, int, const char *); void ktrpsig(int, sig_t, sigset_t *, int); void ktrfault(vm_offset_t, int); void ktrfaultend(int); Modified: stable/9/usr.bin/kdump/kdump.1 ============================================================================== --- stable/9/usr.bin/kdump/kdump.1 Thu Jun 28 17:15:16 2012 (r237718) +++ stable/9/usr.bin/kdump/kdump.1 Thu Jun 28 18:38:24 2012 (r237719) @@ -28,7 +28,7 @@ .\" @(#)kdump.1 8.1 (Berkeley) 6/6/93 .\" $FreeBSD$ .\" -.Dd April 5, 2012 +.Dd April 20, 2012 .Dt KDUMP 1 .Os .Sh NAME @@ -167,7 +167,7 @@ The possible operations are: .It Li NAMI Ta file name lookup Ta path to file .It Li GIO Ta general I/O Ta fd, read/write, number of bytes .It Li PSIG Ta signal Ta signal name, handler, mask, code -.It Li CSW Ta context switch Ta stop/resume user/kernel +.It Li CSW Ta context switch Ta stop/resume user/kernel wmesg .It Li USER Ta data from user process Ta the data .It Li STRU Ta various syscalls Ta structure .It Li SCTL Ta Xr sysctl 3 requests Ta MIB name Modified: stable/9/usr.bin/kdump/kdump.c ============================================================================== --- stable/9/usr.bin/kdump/kdump.c Thu Jun 28 17:15:16 2012 (r237718) +++ stable/9/usr.bin/kdump/kdump.c Thu Jun 28 18:38:24 2012 (r237719) @@ -95,6 +95,7 @@ void visdump(char *, int, int); void ktrgenio(struct ktr_genio *, int); void ktrpsig(struct ktr_psig *); void ktrcsw(struct ktr_csw *); +void ktrcsw_old(struct ktr_csw_old *); void ktruser(int, unsigned char *); void ktrsockaddr(struct sockaddr *); void ktrstat(struct stat *); @@ -296,7 +297,10 @@ main(int argc, char *argv[]) ktrpsig((struct ktr_psig *)m); break; case KTR_CSW: - ktrcsw((struct ktr_csw *)m); + if (ktrlen == sizeof(struct ktr_csw_old)) + ktrcsw_old((struct ktr_csw_old *)m); + else + ktrcsw((struct ktr_csw *)m); break; case KTR_USER: ktruser(ktrlen, m); @@ -1164,12 +1168,19 @@ ktrpsig(struct ktr_psig *psig) } void -ktrcsw(struct ktr_csw *cs) +ktrcsw_old(struct ktr_csw_old *cs) { (void)printf("%s %s\n", cs->out ? "stop" : "resume", cs->user ? "user" : "kernel"); } +void +ktrcsw(struct ktr_csw *cs) +{ + printf("%s %s \"%s\"\n", cs->out ? "stop" : "resume", + cs->user ? "user" : "kernel", cs->wmesg); +} + #define UTRACE_DLOPEN_START 1 #define UTRACE_DLOPEN_STOP 2 #define UTRACE_DLCLOSE_START 3 From owner-svn-src-stable-9@FreeBSD.ORG Thu Jun 28 18:52:33 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D352B1065673; Thu, 28 Jun 2012 18:52:33 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BDB088FC0A; Thu, 28 Jun 2012 18:52:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5SIqXjc092766; Thu, 28 Jun 2012 18:52:33 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5SIqXvN092764; Thu, 28 Jun 2012 18:52:33 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201206281852.q5SIqXvN092764@svn.freebsd.org> From: John Baldwin Date: Thu, 28 Jun 2012 18:52:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237721 - stable/9/etc/periodic/daily X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jun 2012 18:52:33 -0000 Author: jhb Date: Thu Jun 28 18:52:33 2012 New Revision: 237721 URL: http://svn.freebsd.org/changeset/base/237721 Log: MFC 235132: Display dropped transmit packets in the daily network interface output. Modified: stable/9/etc/periodic/daily/420.status-network Directory Properties: stable/9/etc/ (props changed) Modified: stable/9/etc/periodic/daily/420.status-network ============================================================================== --- stable/9/etc/periodic/daily/420.status-network Thu Jun 28 18:38:50 2012 (r237720) +++ stable/9/etc/periodic/daily/420.status-network Thu Jun 28 18:52:33 2012 (r237721) @@ -18,9 +18,9 @@ case "$daily_status_network_enable" in case "$daily_status_network_usedns" in [Yy][Ee][Ss]) - netstat -i && rc=0 || rc=3;; + netstat -id && rc=0 || rc=3;; *) - netstat -in && rc=0 || rc=3;; + netstat -idn && rc=0 || rc=3;; esac;; *) rc=0;; From owner-svn-src-stable-9@FreeBSD.ORG Thu Jun 28 19:34:24 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 547B81065670; Thu, 28 Jun 2012 19:34:24 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2490B8FC08; Thu, 28 Jun 2012 19:34:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5SJYOK2094598; Thu, 28 Jun 2012 19:34:24 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5SJYNHn094596; Thu, 28 Jun 2012 19:34:23 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201206281934.q5SJYNHn094596@svn.freebsd.org> From: John Baldwin Date: Thu, 28 Jun 2012 19:34:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237725 - stable/9/sys/kern X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jun 2012 19:34:24 -0000 Author: jhb Date: Thu Jun 28 19:34:23 2012 New Revision: 237725 URL: http://svn.freebsd.org/changeset/base/237725 Log: MFC 236404: Extend VERBOSE_SYSINIT to also print out the name of variables passed to SYSINIT routines if they can be resolved via symbol look up in DDB. To avoid false positives, only honor a name if the symbol resolves exactly to the pointer value (no offset). Modified: stable/9/sys/kern/init_main.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/dev/isp/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/modules/ (props changed) Modified: stable/9/sys/kern/init_main.c ============================================================================== --- stable/9/sys/kern/init_main.c Thu Jun 28 19:27:54 2012 (r237724) +++ stable/9/sys/kern/init_main.c Thu Jun 28 19:34:23 2012 (r237725) @@ -158,6 +158,24 @@ sysinit_add(struct sysinit **set, struct newsysinit_end = newset + count; } +#if defined (DDB) && defined(VERBOSE_SYSINIT) +static const char * +symbol_name(vm_offset_t va, db_strategy_t strategy) +{ + const char *name; + c_db_sym_t sym; + db_expr_t offset; + + if (va == 0) + return (NULL); + sym = db_search_symbol(va, strategy, &offset); + if (offset != 0) + return (NULL); + db_symbol_values(sym, &name, NULL); + return (name); +} +#endif + /* * System startup; initialize the world, create process 0, mount root * filesystem, and fork to create init and pagedaemon. Most of the @@ -238,15 +256,16 @@ restart: } if (verbose) { #if defined(DDB) - const char *name; - c_db_sym_t sym; - db_expr_t offset; - - sym = db_search_symbol((vm_offset_t)(*sipp)->func, - DB_STGY_PROC, &offset); - db_symbol_values(sym, &name, NULL); - if (name != NULL) - printf(" %s(%p)... ", name, (*sipp)->udata); + const char *func, *data; + + func = symbol_name((vm_offset_t)(*sipp)->func, + DB_STGY_PROC); + data = symbol_name((vm_offset_t)(*sipp)->udata, + DB_STGY_ANY); + if (func != NULL && data != NULL) + printf(" %s(&%s)... ", func, data); + else if (func != NULL) + printf(" %s(%p)... ", func, (*sipp)->udata); else #endif printf(" %p(%p)... ", (*sipp)->func, From owner-svn-src-stable-9@FreeBSD.ORG Thu Jun 28 19:55:26 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AB54B10656EB; Thu, 28 Jun 2012 19:55:26 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 950648FC18; Thu, 28 Jun 2012 19:55:26 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5SJtQt4095538; Thu, 28 Jun 2012 19:55:26 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5SJtQN8095536; Thu, 28 Jun 2012 19:55:26 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201206281955.q5SJtQN8095536@svn.freebsd.org> From: John Baldwin Date: Thu, 28 Jun 2012 19:55:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237727 - stable/9/sys/boot/i386/boot2 X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jun 2012 19:55:26 -0000 Author: jhb Date: Thu Jun 28 19:55:26 2012 New Revision: 237727 URL: http://svn.freebsd.org/changeset/base/237727 Log: MFC 236405: Remove unnecessary initializations. The BSS of boot2 is in fact zero'd when boot2 begins execution by the _start() routine in btxcsu.S. Modified: stable/9/sys/boot/i386/boot2/boot2.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/dev/isp/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/modules/ (props changed) Modified: stable/9/sys/boot/i386/boot2/boot2.c ============================================================================== --- stable/9/sys/boot/i386/boot2/boot2.c Thu Jun 28 19:39:30 2012 (r237726) +++ stable/9/sys/boot/i386/boot2/boot2.c Thu Jun 28 19:55:26 2012 (r237727) @@ -129,8 +129,8 @@ static struct dsk { int init; } dsk; static char cmd[512], cmddup[512], knamebuf[1024]; -static const char *kname = NULL; -static uint32_t opts = 0; +static const char *kname; +static uint32_t opts; static int comspeed = SIOSPD; static struct bootinfo bootinfo; static uint8_t ioctrl = IO_KEYBOARD; From owner-svn-src-stable-9@FreeBSD.ORG Thu Jun 28 21:24:09 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D83061065670; Thu, 28 Jun 2012 21:24:09 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C094B8FC0A; Thu, 28 Jun 2012 21:24:09 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5SLO9se099400; Thu, 28 Jun 2012 21:24:09 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5SLO9kC099391; Thu, 28 Jun 2012 21:24:09 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201206282124.q5SLO9kC099391@svn.freebsd.org> From: John Baldwin Date: Thu, 28 Jun 2012 21:24:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237731 - in stable/9: sys/dev/pci usr.sbin/pciconf X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jun 2012 21:24:10 -0000 Author: jhb Date: Thu Jun 28 21:24:09 2012 New Revision: 237731 URL: http://svn.freebsd.org/changeset/base/237731 Log: MFC 228161,230774,230822,236415: Add a new -e flag to pciconf(8)'s list mode to display PCI error details. Currently this dumps the status of any error bits in the PCI status register and PCI-express device status register. It also lists any errors indicated by version 1 of PCI-express Advanced Error Reporting (AER). Added: stable/9/usr.sbin/pciconf/err.c - copied unchanged from r236415, head/usr.sbin/pciconf/err.c Modified: stable/9/sys/dev/pci/pcireg.h stable/9/usr.sbin/pciconf/Makefile stable/9/usr.sbin/pciconf/cap.c stable/9/usr.sbin/pciconf/pciconf.8 stable/9/usr.sbin/pciconf/pciconf.c stable/9/usr.sbin/pciconf/pciconf.h Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/dev/isp/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/modules/ (props changed) stable/9/usr.sbin/pciconf/ (props changed) Modified: stable/9/sys/dev/pci/pcireg.h ============================================================================== --- stable/9/sys/dev/pci/pcireg.h Thu Jun 28 20:48:24 2012 (r237730) +++ stable/9/sys/dev/pci/pcireg.h Thu Jun 28 21:24:09 2012 (r237731) @@ -697,6 +697,7 @@ #define PCIR_AER_UC_STATUS 0x04 #define PCIM_AER_UC_TRAINING_ERROR 0x00000001 #define PCIM_AER_UC_DL_PROTOCOL_ERROR 0x00000010 +#define PCIM_AER_UC_SURPRISE_LINK_DOWN 0x00000020 #define PCIM_AER_UC_POISONED_TLP 0x00001000 #define PCIM_AER_UC_FC_PROTOCOL_ERROR 0x00002000 #define PCIM_AER_UC_COMPLETION_TIMEOUT 0x00004000 @@ -715,6 +716,7 @@ #define PCIM_AER_COR_BAD_DLLP 0x00000080 #define PCIM_AER_COR_REPLAY_ROLLOVER 0x00000100 #define PCIM_AER_COR_REPLAY_TIMEOUT 0x00001000 +#define PCIM_AER_COR_ADVISORY_NF_ERROR 0x00002000 #define PCIR_AER_COR_MASK 0x14 /* Shares bits with COR_STATUS */ #define PCIR_AER_CAP_CONTROL 0x18 #define PCIM_AER_FIRST_ERROR_PTR 0x0000001f Modified: stable/9/usr.sbin/pciconf/Makefile ============================================================================== --- stable/9/usr.sbin/pciconf/Makefile Thu Jun 28 20:48:24 2012 (r237730) +++ stable/9/usr.sbin/pciconf/Makefile Thu Jun 28 21:24:09 2012 (r237731) @@ -2,7 +2,7 @@ # $FreeBSD$ PROG= pciconf -SRCS= pciconf.c cap.c +SRCS= pciconf.c cap.c err.c MAN= pciconf.8 CFLAGS+= -I${.CURDIR}/../../sys Modified: stable/9/usr.sbin/pciconf/cap.c ============================================================================== --- stable/9/usr.sbin/pciconf/cap.c Thu Jun 28 20:48:24 2012 (r237730) +++ stable/9/usr.sbin/pciconf/cap.c Thu Jun 28 21:24:09 2012 (r237731) @@ -630,3 +630,59 @@ list_ecaps(int fd, struct pci_conf *p) ecap = read_config(fd, &p->pc_sel, ptr, 4); } } + +/* Find offset of a specific capability. Returns 0 on failure. */ +uint8_t +pci_find_cap(int fd, struct pci_conf *p, uint8_t id) +{ + uint16_t sta; + uint8_t ptr, cap; + + /* Are capabilities present for this device? */ + sta = read_config(fd, &p->pc_sel, PCIR_STATUS, 2); + if (!(sta & PCIM_STATUS_CAPPRESENT)) + return (0); + + switch (p->pc_hdr & PCIM_HDRTYPE) { + case PCIM_HDRTYPE_NORMAL: + case PCIM_HDRTYPE_BRIDGE: + ptr = PCIR_CAP_PTR; + break; + case PCIM_HDRTYPE_CARDBUS: + ptr = PCIR_CAP_PTR_2; + break; + default: + return (0); + } + + ptr = read_config(fd, &p->pc_sel, ptr, 1); + while (ptr != 0 && ptr != 0xff) { + cap = read_config(fd, &p->pc_sel, ptr + PCICAP_ID, 1); + if (cap == id) + return (ptr); + ptr = read_config(fd, &p->pc_sel, ptr + PCICAP_NEXTPTR, 1); + } + return (0); +} + +/* Find offset of a specific extended capability. Returns 0 on failure. */ +uint16_t +pcie_find_cap(int fd, struct pci_conf *p, uint16_t id) +{ + uint32_t ecap; + uint16_t ptr; + + ptr = PCIR_EXTCAP; + ecap = read_config(fd, &p->pc_sel, ptr, 4); + if (ecap == 0xffffffff || ecap == 0) + return (0); + for (;;) { + if (PCI_EXTCAP_ID(ecap) == id) + return (ptr); + ptr = PCI_EXTCAP_NEXTPTR(ecap); + if (ptr == 0) + break; + ecap = read_config(fd, &p->pc_sel, ptr, 4); + } + return (0); +} Copied: stable/9/usr.sbin/pciconf/err.c (from r236415, head/usr.sbin/pciconf/err.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/9/usr.sbin/pciconf/err.c Thu Jun 28 21:24:09 2012 (r237731, copy of r236415, head/usr.sbin/pciconf/err.c) @@ -0,0 +1,167 @@ +/*- + * Copyright (c) 2012 Advanced Computing Technologies LLC + * Written by: John H. Baldwin + * 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. + */ + +#ifndef lint +static const char rcsid[] = + "$FreeBSD$"; +#endif /* not lint */ + +#include +#include + +#include +#include + +#include + +#include "pciconf.h" + +struct bit_table { + uint32_t mask; + const char *desc; +}; + +/* Error indicators in the PCI status register (PCIR_STATUS). */ +static struct bit_table pci_status[] = { + { PCIM_STATUS_MDPERR, "Master Data Parity Error" }, + { PCIM_STATUS_STABORT, "Sent Target-Abort" }, + { PCIM_STATUS_RTABORT, "Received Target-Abort" }, + { PCIM_STATUS_RMABORT, "Received Master-Abort" }, + { PCIM_STATUS_SERR, "Signalled System Error" }, + { PCIM_STATUS_PERR, "Detected Parity Error" }, + { 0, NULL }, +}; + +/* Valid error indicator bits in PCIR_STATUS. */ +#define PCI_ERRORS (PCIM_STATUS_MDPERR | PCIM_STATUS_STABORT | \ + PCIM_STATUS_RTABORT | PCIM_STATUS_RMABORT | \ + PCIM_STATUS_SERR | PCIM_STATUS_PERR) + +/* Error indicators in the PCI-Express device status register. */ +static struct bit_table pcie_device_status[] = { + { PCIM_EXP_STA_CORRECTABLE_ERROR, "Correctable Error Detected" }, + { PCIM_EXP_STA_NON_FATAL_ERROR, "Non-Fatal Error Detected" }, + { PCIM_EXP_STA_FATAL_ERROR, "Fatal Error Detected" }, + { PCIM_EXP_STA_UNSUPPORTED_REQ, "Unsupported Request Detected" }, + { 0, NULL }, +}; + +/* Valid error indicator bits in the PCI-Express device status register. */ +#define PCIE_ERRORS (PCIM_EXP_STA_CORRECTABLE_ERROR | \ + PCIM_EXP_STA_NON_FATAL_ERROR | \ + PCIM_EXP_STA_FATAL_ERROR | \ + PCIM_EXP_STA_UNSUPPORTED_REQ) + +/* AER Uncorrected errors. */ +static struct bit_table aer_uc[] = { + { PCIM_AER_UC_TRAINING_ERROR, "Link Training Error" }, + { PCIM_AER_UC_DL_PROTOCOL_ERROR, "Data Link Protocol Error" }, + { PCIM_AER_UC_SURPRISE_LINK_DOWN, "Surprise Link Down Error" }, + { PCIM_AER_UC_POISONED_TLP, "Poisoned TLP" }, + { PCIM_AER_UC_FC_PROTOCOL_ERROR, "Flow Control Protocol Error" }, + { PCIM_AER_UC_COMPLETION_TIMEOUT, "Completion Timeout" }, + { PCIM_AER_UC_COMPLETER_ABORT, "Completer Abort" }, + { PCIM_AER_UC_UNEXPECTED_COMPLETION, "Unexpected Completion" }, + { PCIM_AER_UC_RECEIVER_OVERFLOW, "Receiver Overflow Error" }, + { PCIM_AER_UC_MALFORMED_TLP, "Malformed TLP" }, + { PCIM_AER_UC_ECRC_ERROR, "ECRC Error" }, + { PCIM_AER_UC_UNSUPPORTED_REQUEST, "Unsupported Request" }, + { PCIM_AER_UC_ACS_VIOLATION, "ACS Violation" }, + { 0, NULL }, +}; + +/* AER Corrected errors. */ +static struct bit_table aer_cor[] = { + { PCIM_AER_COR_RECEIVER_ERROR, "Receiver Error" }, + { PCIM_AER_COR_BAD_TLP, "Bad TLP" }, + { PCIM_AER_COR_BAD_DLLP, "Bad DLLP" }, + { PCIM_AER_COR_REPLAY_ROLLOVER, "REPLAY_NUM Rollover" }, + { PCIM_AER_COR_REPLAY_TIMEOUT, "Replay Timer Timeout" }, + { PCIM_AER_COR_ADVISORY_NF_ERROR, "Advisory Non-Fatal Error" }, + { 0, NULL }, +}; + +static void +print_bits(const char *header, struct bit_table *table, uint32_t mask) +{ + int first; + + first = 1; + for (; table->desc != NULL; table++) + if (mask & table->mask) { + if (first) { + printf("%14s = ", header); + first = 0; + } else + printf(" "); + printf("%s\n", table->desc); + mask &= ~table->mask; + } + if (mask != 0) { + if (first) + printf("%14s = ", header); + else + printf(" "); + printf("Unknown: 0x%08x\n", mask); + } +} + +void +list_errors(int fd, struct pci_conf *p) +{ + uint32_t mask, severity; + uint16_t sta, aer; + uint8_t pcie; + + /* First check for standard PCI errors. */ + sta = read_config(fd, &p->pc_sel, PCIR_STATUS, 2); + print_bits("PCI errors", pci_status, sta & PCI_ERRORS); + + /* See if this is a PCI-express device. */ + pcie = pci_find_cap(fd, p, PCIY_EXPRESS); + if (pcie == 0) + return; + + /* Check for PCI-e errors. */ + sta = read_config(fd, &p->pc_sel, pcie + PCIR_EXPRESS_DEVICE_STA, 2); + print_bits("PCI-e errors", pcie_device_status, sta & PCIE_ERRORS); + + /* See if this device supports AER. */ + aer = pcie_find_cap(fd, p, PCIZ_AER); + if (aer == 0) + return; + + /* Check for uncorrected errors. */ + mask = read_config(fd, &p->pc_sel, aer + PCIR_AER_UC_STATUS, 4); + severity = read_config(fd, &p->pc_sel, aer + PCIR_AER_UC_SEVERITY, 4); + print_bits("Fatal", aer_uc, mask & severity); + print_bits("Non-fatal", aer_uc, mask & ~severity); + + /* Check for corrected errors. */ + mask = read_config(fd, &p->pc_sel, aer + PCIR_AER_COR_STATUS, 4); + print_bits("Corrected", aer_cor, mask); +} Modified: stable/9/usr.sbin/pciconf/pciconf.8 ============================================================================== --- stable/9/usr.sbin/pciconf/pciconf.8 Thu Jun 28 20:48:24 2012 (r237730) +++ stable/9/usr.sbin/pciconf/pciconf.8 Thu Jun 28 21:24:09 2012 (r237731) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 7, 2007 +.Dd June 1, 2012 .Dt PCICONF 8 .Os .Sh NAME @@ -33,7 +33,7 @@ .Nd diagnostic utility for the PCI bus .Sh SYNOPSIS .Nm -.Fl l Op Fl bcv +.Fl l Op Fl bcev .Nm .Fl a Ar selector .Nm @@ -167,6 +167,15 @@ capability in config space in hexadecima The format of the text after the equals sign is capability-specific. .Pp If the +.Fl e +option is supplied, +.Nm +will list any errors reported for this device in standard PCI error registers. +Errors are checked for in the PCI status register, +the PCI-express device status register, +and the Advanced Error Reporting status registers. +.Pp +If the .Fl v option is supplied, .Nm Modified: stable/9/usr.sbin/pciconf/pciconf.c ============================================================================== --- stable/9/usr.sbin/pciconf/pciconf.c Thu Jun 28 20:48:24 2012 (r237730) +++ stable/9/usr.sbin/pciconf/pciconf.c Thu Jun 28 21:24:09 2012 (r237731) @@ -68,7 +68,7 @@ struct pci_vendor_info TAILQ_HEAD(,pci_vendor_info) pci_vendors; static void list_bars(int fd, struct pci_conf *p); -static void list_devs(int verbose, int bars, int caps); +static void list_devs(int verbose, int bars, int caps, int errors); static void list_verbose(struct pci_conf *p); static const char *guess_class(struct pci_conf *p); static const char *guess_subclass(struct pci_conf *p); @@ -83,7 +83,7 @@ static void usage(void) { fprintf(stderr, "%s\n%s\n%s\n%s\n", - "usage: pciconf -l [-bcv]", + "usage: pciconf -l [-bcev]", " pciconf -a selector", " pciconf -r [-b | -h] selector addr[:addr2]", " pciconf -w [-b | -h] selector addr value"); @@ -94,12 +94,14 @@ int main(int argc, char **argv) { int c; - int listmode, readmode, writemode, attachedmode, bars, caps, verbose; + int listmode, readmode, writemode, attachedmode; + int bars, caps, errors, verbose; int byte, isshort; - listmode = readmode = writemode = attachedmode = bars = caps = verbose = byte = isshort = 0; + listmode = readmode = writemode = attachedmode = 0; + bars = caps = errors = verbose = byte = isshort = 0; - while ((c = getopt(argc, argv, "abchlrwv")) != -1) { + while ((c = getopt(argc, argv, "abcehlrwv")) != -1) { switch(c) { case 'a': attachedmode = 1; @@ -114,6 +116,10 @@ main(int argc, char **argv) caps = 1; break; + case 'e': + errors = 1; + break; + case 'h': isshort = 1; break; @@ -146,7 +152,7 @@ main(int argc, char **argv) usage(); if (listmode) { - list_devs(verbose, bars, caps); + list_devs(verbose, bars, caps, errors); } else if (attachedmode) { chkattached(argv[optind]); } else if (readmode) { @@ -163,7 +169,7 @@ main(int argc, char **argv) } static void -list_devs(int verbose, int bars, int caps) +list_devs(int verbose, int bars, int caps, int errors) { int fd; struct pci_conf_io pc; @@ -173,7 +179,7 @@ list_devs(int verbose, int bars, int cap if (verbose) load_vendors(); - fd = open(_PATH_DEVPCI, caps ? O_RDWR : O_RDONLY, 0); + fd = open(_PATH_DEVPCI, (caps || errors) ? O_RDWR : O_RDONLY, 0); if (fd < 0) err(1, "%s", _PATH_DEVPCI); @@ -223,6 +229,8 @@ list_devs(int verbose, int bars, int cap list_bars(fd, p); if (caps) list_caps(fd, p); + if (errors) + list_errors(fd, p); } } while (pc.status == PCI_GETCONF_MORE_DEVS); Modified: stable/9/usr.sbin/pciconf/pciconf.h ============================================================================== --- stable/9/usr.sbin/pciconf/pciconf.h Thu Jun 28 20:48:24 2012 (r237730) +++ stable/9/usr.sbin/pciconf/pciconf.h Thu Jun 28 21:24:09 2012 (r237731) @@ -34,6 +34,9 @@ #define __PCICONF_H__ void list_caps(int fd, struct pci_conf *p); +void list_errors(int fd, struct pci_conf *p); +uint8_t pci_find_cap(int fd, struct pci_conf *p, uint8_t id); +uint16_t pcie_find_cap(int fd, struct pci_conf *p, uint16_t id); uint32_t read_config(int fd, struct pcisel *sel, long reg, int width); #endif From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 03:01:39 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C8CAD106566C; Fri, 29 Jun 2012 03:01:39 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A853A8FC0A; Fri, 29 Jun 2012 03:01:39 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5T31dbW014675; Fri, 29 Jun 2012 03:01:39 GMT (envelope-from pfg@svn.freebsd.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5T31d3S014661; Fri, 29 Jun 2012 03:01:39 GMT (envelope-from pfg@svn.freebsd.org) Message-Id: <201206290301.q5T31d3S014661@svn.freebsd.org> From: "Pedro F. Giffuni" Date: Fri, 29 Jun 2012 03:01:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237738 - stable/9/lib/libedit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 03:01:39 -0000 Author: pfg Date: Fri Jun 29 03:01:38 2012 New Revision: 237738 URL: http://svn.freebsd.org/changeset/base/237738 Log: MFC r237448: Merge changes from upstream libedit. Here we update most of the files to at least match the version available in NetBSD's snapshot of 20091228. This version was chosen because it still doesn't include wide character support (UTF-8), which involves many changes and new files. Modified: stable/9/lib/libedit/common.c stable/9/lib/libedit/editline.3 stable/9/lib/libedit/editrc.5 stable/9/lib/libedit/el.c stable/9/lib/libedit/el.h stable/9/lib/libedit/histedit.h stable/9/lib/libedit/history.c stable/9/lib/libedit/key.c stable/9/lib/libedit/key.h stable/9/lib/libedit/prompt.c stable/9/lib/libedit/prompt.h stable/9/lib/libedit/read.c stable/9/lib/libedit/refresh.c stable/9/lib/libedit/search.c stable/9/lib/libedit/sig.c stable/9/lib/libedit/sig.h stable/9/lib/libedit/term.c stable/9/lib/libedit/term.h stable/9/lib/libedit/tty.c stable/9/lib/libedit/vi.c Directory Properties: stable/9/lib/libedit/ (props changed) Modified: stable/9/lib/libedit/common.c ============================================================================== --- stable/9/lib/libedit/common.c Fri Jun 29 01:55:20 2012 (r237737) +++ stable/9/lib/libedit/common.c Fri Jun 29 03:01:38 2012 (r237738) @@ -905,7 +905,7 @@ ed_command(EditLine *el, int c __unused) int tmplen; tmplen = c_gets(el, tmpbuf, "\n: "); - term__putc('\n'); + term__putc(el, '\n'); if (tmplen < 0 || (tmpbuf[tmplen] = 0, parse_line(el, tmpbuf)) == -1) term_beep(el); Modified: stable/9/lib/libedit/editline.3 ============================================================================== --- stable/9/lib/libedit/editline.3 Fri Jun 29 01:55:20 2012 (r237737) +++ stable/9/lib/libedit/editline.3 Fri Jun 29 03:01:38 2012 (r237738) @@ -1,4 +1,4 @@ -.\" $NetBSD: editline.3,v 1.55 2007/01/12 16:31:13 christos Exp $ +.\" $NetBSD: editline.3,v 1.70 2009/07/05 21:55:24 perry Exp $ .\" .\" Copyright (c) 1997-2003 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 12, 2007 +.Dd July 5, 2009 .Dt EDITLINE 3 .Os .Sh NAME @@ -162,6 +162,14 @@ is modified to contain the number of cha Returns the line read if successful, or .Dv NULL if no characters were read or if an error occurred. +If an error occurred, +.Fa count +is set to \-1 and +.Dv errno +contains the error code that caused it. +The return value may not remain valid across calls to +.Fn el_gets +and must be copied if the data is to be retained. .It Fn el_getc Read a character from the tty. .Fa ch @@ -222,10 +230,30 @@ are supported, along with the required a Define prompt printing function as .Fa f , which is to return a string that contains the prompt. +.It Dv EL_PROMPT_ESC , Fa "char *(*f)(EditLine *)" , Fa "char c" +Same as +.Dv EL_PROMPT , +but the +.Fa c +argument indicates the start/stop literal prompt character. +.Pp +If a start/stop literal character is found in the prompt, the +character itself +is not printed, but characters after it are printed directly to the +terminal without affecting the state of the current line. +A subsequent second start/stop literal character ends this behavior. +This is typically used to embed literal escape sequences that change the +color/style of the terminal in the prompt. +.Dv 0 +unsets it. +.It Dv EL_REFRESH +Re-display the current line on the next terminal line. .It Dv EL_RPROMPT , Fa "char *(*f)(EditLine *)" Define right side prompt printing function as .Fa f , which is to return a string that contains the prompt. +.It Dv EL_RPROMPT_ESC , Fa "char *(*f)(EditLine *)" , Fa "char c" +Define the right prompt printing function but with a literal escape character. .It Dv EL_TERMINAL , Fa "const char *type" Define terminal type of the tty to be .Fa type , @@ -259,66 +287,43 @@ reading command input: and .Dv SIGWINCH . Otherwise, the current signal handlers will be used. -.It Dv EL_BIND , Xo -.Fa "const char *" , -.Fa "..." , -.Dv NULL -.Xc +.It Dv EL_BIND , Fa "const char *" , Fa "..." , Dv NULL Perform the .Ic bind builtin command. Refer to .Xr editrc 5 for more information. -.It Dv EL_ECHOTC , Xo -.Fa "const char *" , -.Fa "..." , -.Dv NULL -.Xc +.It Dv EL_ECHOTC , Fa "const char *" , Fa "..." , Dv NULL Perform the .Ic echotc builtin command. Refer to .Xr editrc 5 for more information. -.It Dv EL_SETTC , Xo -.Fa "const char *" , -.Fa "..." , -.Dv NULL -.Xc +.It Dv EL_SETTC , Fa "const char *" , Fa "..." , Dv NULL Perform the .Ic settc builtin command. Refer to .Xr editrc 5 for more information. -.It Dv EL_SETTY , Xo -.Fa "const char *" , -.Fa "..." , -.Dv NULL -.Xc +.It Dv EL_SETTY , Fa "const char *" , Fa "..." , Dv NULL Perform the .Ic setty builtin command. Refer to .Xr editrc 5 for more information. -.It Dv EL_TELLTC , Xo -.Fa "const char *" , -.Fa "..." , -.Dv NULL -.Xc +.It Dv EL_TELLTC , Fa "const char *" , Fa "..." , Dv NULL Perform the .Ic telltc builtin command. Refer to .Xr editrc 5 for more information. -.It Dv EL_ADDFN , Xo -.Fa "const char *name" , -.Fa "const char *help" , -.Fa "unsigned char (*func)(EditLine *e, int ch)" -.Xc +.It Dv EL_ADDFN , Fa "const char *name" , Fa "const char *help" , \ +Fa "unsigned char (*func)(EditLine *e, int ch)" Add a user defined function, .Fn func , referred to as @@ -360,10 +365,8 @@ Beep, and flush tty. .It Dv CC_FATAL Fatal error, reset tty to known state. .El -.It Dv EL_HIST , Xo -.Fa "History *(*func)(History *, int op, ...)" , -.Fa "const char *ptr" -.Xc +.It Dv EL_HIST , Fa "History *(*func)(History *, int op, ...)" , \ +Fa "const char *ptr" Defines which history function to use, which is usually .Fn history . .Fa ptr @@ -435,10 +438,22 @@ The following values for are supported, along with actual type of .Fa result : .Bl -tag -width 4n -.It Dv EL_PROMPT , Fa "char *(*f)(EditLine *)" -Return a pointer to the function that displays the prompt. -.It Dv EL_RPROMPT , Fa "char *(*f)(EditLine *)" -Return a pointer to the function that displays the rightside prompt. +.It Dv EL_PROMPT , Fa "char *(*f)(EditLine *)" , Fa "char *c" +Return a pointer to the function that displays the prompt in +.Fa f . +If +.Fa c +is not +.Dv NULL , +return the start/stop literal prompt character in it. +.It Dv EL_RPROMPT , Fa "char *(*f)(EditLine *)" , Fa "char *c" +Return a pointer to the function that displays the prompt in +.Fa f . +If +.Fa c +is not +.Dv NULL , +return the start/stop literal prompt character in it. .It Dv EL_EDITOR , Fa "const char *" Return the name of the editor, which will be one of .Dq emacs @@ -603,18 +618,11 @@ assumed to be created with .Fn history_init . .It Dv H_CLEAR Clear the history. -.It Dv H_FUNC , Xo -.Fa "void *ptr" , -.Fa "history_gfun_t first" , -.Fa "history_gfun_t next" , -.Fa "history_gfun_t last" , -.Fa "history_gfun_t prev" , -.Fa "history_gfun_t curr" , -.Fa "history_sfun_t set" , -.Fa "history_vfun_t clear" , -.Fa "history_efun_t enter" , -.Fa "history_efun_t add" -.Xc +.It Dv H_FUNC , Fa "void *ptr" , Fa "history_gfun_t first" , \ +Fa "history_gfun_t next" , Fa "history_gfun_t last" , \ +Fa "history_gfun_t prev" , Fa "history_gfun_t curr" , \ +Fa "history_sfun_t set" , Fa "history_vfun_t clear" , \ +Fa "history_efun_t enter" , Fa "history_efun_t add" Define functions to perform various history operations. .Fa ptr is the argument given to a function when it is invoked. Modified: stable/9/lib/libedit/editrc.5 ============================================================================== --- stable/9/lib/libedit/editrc.5 Fri Jun 29 01:55:20 2012 (r237737) +++ stable/9/lib/libedit/editrc.5 Fri Jun 29 03:01:38 2012 (r237738) @@ -1,4 +1,4 @@ -.\" $NetBSD: editrc.5,v 1.20 2006/08/21 12:45:30 christos Exp $ +.\" $NetBSD: editrc.5,v 1.24 2009/04/11 22:17:52 wiz Exp $ .\" .\" Copyright (c) 1997-2000 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -89,16 +89,8 @@ shell. .Pp The following builtin commands are available: .Bl -tag -width 4n -.It Ic bind Xo -.Op Fl a -.Op Fl e -.Op Fl k -.Op Fl l -.Op Fl r -.Op Fl s -.Op Fl v -.Op Ar key Op Ar command -.Xc +.It Ic bind Oo Fl a Oc Oo Fl e Oc Oo Fl k Oc Oo Fl l Oc Oo Fl r Oc \ +Oo Fl s Oc Oo Fl v Oc Oo Ar key Oo Ar command Oc Oc Without options, list all bound keys, and the editor command to which each is bound. If @@ -192,11 +184,7 @@ if it has any, notably .Sq \e and .Sq ^ . -.It Ic echotc Xo -.Op Fl sv -.Ar arg -.Ar ... -.Xc +.It Ic echotc Oo Fl sv Oc Ar arg Ar ... Exercise terminal capabilities given in .Ar arg Ar ... . If @@ -252,16 +240,8 @@ to as defined in .Xr termcap 5 . No sanity checking is done. -.It Ic setty Xo -.Op Fl a -.Op Fl d -.Op Fl q -.Op Fl x -.Op Ar +mode -.Op Ar -mode -.Op Ar mode -.Op Ar char=c -.Xc +.It Ic setty Oo Fl a Oc Oo Fl d Oc Oo Fl q Oc Oo Fl x Oc Oo Ar +mode Oc \ +Oo Ar -mode Oc Oo Ar mode Oc Oo Ar char=c Oc Control which tty modes that .Nm will not allow the user to change. Modified: stable/9/lib/libedit/el.c ============================================================================== --- stable/9/lib/libedit/el.c Fri Jun 29 01:55:20 2012 (r237737) +++ stable/9/lib/libedit/el.c Fri Jun 29 03:01:38 2012 (r237738) @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $NetBSD: el.c,v 1.44 2006/12/15 22:13:33 christos Exp $ + * $NetBSD: el.c,v 1.55 2009/07/25 21:19:23 christos Exp $ */ #if !defined(lint) && !defined(SCCSID) @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include "el.h" #define HAVE_ISSETUGID @@ -156,9 +157,21 @@ el_set(EditLine *el, int op, ...) switch (op) { case EL_PROMPT: - case EL_RPROMPT: - rv = prompt_set(el, va_arg(ap, el_pfunc_t), op); + case EL_RPROMPT: { + el_pfunc_t p = va_arg(ap, el_pfunc_t); + + rv = prompt_set(el, p, 0, op); break; + } + + case EL_PROMPT_ESC: + case EL_RPROMPT_ESC: { + el_pfunc_t p = va_arg(ap, el_pfunc_t); + char c = va_arg(ap, int); + + rv = prompt_set(el, p, c, op); + break; + } case EL_TERMINAL: rv = term_set(el, va_arg(ap, char *)); @@ -309,6 +322,12 @@ el_set(EditLine *el, int op, ...) break; } + case EL_REFRESH: + re_clear_display(el); + re_refresh(el); + term__flush(el); + break; + default: rv = -1; break; @@ -335,9 +354,13 @@ el_get(EditLine *el, int op, ...) switch (op) { case EL_PROMPT: - case EL_RPROMPT: - rv = prompt_get(el, va_arg(ap, el_pfunc_t *), op); + case EL_RPROMPT: { + el_pfunc_t *p = va_arg(ap, el_pfunc_t *); + char *c = va_arg(ap, char *); + + rv = prompt_get(el, p, c, op); break; + } case EL_EDITOR: rv = map_get_editor(el, va_arg(ap, const char **)); @@ -364,7 +387,7 @@ el_get(EditLine *el, int op, ...) char *argv[20]; int i; - for (i = 1; i < sizeof(argv) / sizeof(argv[0]); i++) + for (i = 1; i < (int)(sizeof(argv) / sizeof(argv[0])); i++) if ((argv[i] = va_arg(ap, char *)) == NULL) break; @@ -495,12 +518,14 @@ el_source(EditLine *el, const char *fnam FILE *fp; size_t len; char *ptr; +#ifdef HAVE_ISSETUGID + char path[MAXPATHLEN]; +#endif fp = NULL; if (fname == NULL) { #ifdef HAVE_ISSETUGID static const char elpath[] = "/.editrc"; - char path[MAXPATHLEN]; if (issetugid()) return (-1); @@ -529,6 +554,13 @@ el_source(EditLine *el, const char *fnam if (len > 0 && ptr[len - 1] == '\n') --len; ptr[len] = '\0'; + + /* loop until first non-space char or EOL */ + while (*ptr != '\0' && isspace((unsigned char)*ptr)) + ptr++; + if (*ptr == '#') + continue; /* ignore, this is a comment line */ + if (parse_line(el, ptr) == -1) { (void) fclose(fp); return (-1); Modified: stable/9/lib/libedit/el.h ============================================================================== --- stable/9/lib/libedit/el.h Fri Jun 29 01:55:20 2012 (r237737) +++ stable/9/lib/libedit/el.h Fri Jun 29 03:01:38 2012 (r237738) @@ -115,6 +115,7 @@ struct editline { FILE *el_errfile; /* Stdio stuff */ int el_infd; /* Input file descriptor */ int el_flags; /* Various flags. */ + int el_errno; /* Local copy of errno */ coord_t el_cursor; /* Cursor location */ char **el_display; /* Real screen image = what is there */ char **el_vdisplay; /* Virtual screen image = what we see */ Modified: stable/9/lib/libedit/histedit.h ============================================================================== --- stable/9/lib/libedit/histedit.h Fri Jun 29 01:55:20 2012 (r237737) +++ stable/9/lib/libedit/histedit.h Fri Jun 29 03:01:38 2012 (r237738) @@ -131,10 +131,10 @@ unsigned char _el_fn_sh_complete(EditLin #define EL_GETCFN 13 /* , el_rfunc_t); */ #define EL_CLIENTDATA 14 /* , void *); */ #define EL_UNBUFFERED 15 /* , int); */ -#define EL_PREP_TERM 16 /* , int); */ +#define EL_PREP_TERM 16 /* , int); */ #define EL_GETTC 17 /* , const char *, ..., NULL); */ -#define EL_GETFP 18 /* , int, FILE **) */ -#define EL_SETFP 19 /* , int, FILE *) */ +#define EL_GETFP 18 /* , int, FILE **); */ +#define EL_SETFP 19 /* , int, FILE *); */ #define EL_REFRESH 20 /* , void); set */ #define EL_PROMPT_ESC 21 /* , prompt_func, Char); set/get */ #define EL_RPROMPT_ESC 22 /* , prompt_func, Char); set/get */ Modified: stable/9/lib/libedit/history.c ============================================================================== --- stable/9/lib/libedit/history.c Fri Jun 29 01:55:20 2012 (r237737) +++ stable/9/lib/libedit/history.c Fri Jun 29 03:01:38 2012 (r237738) @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $NetBSD: history.c,v 1.32 2006/09/28 13:52:51 christos Exp $ + * $NetBSD: history.c,v 1.34 2009/09/07 21:24:33 christos Exp $ */ #if !defined(lint) && !defined(SCCSID) @@ -116,6 +116,7 @@ private int history_prev_string(History */ typedef struct hentry_t { HistEvent ev; /* What we return */ + void *data; /* data */ struct hentry_t *next; /* Next entry */ struct hentry_t *prev; /* Previous entry */ } hentry_t; @@ -145,6 +146,9 @@ private int history_def_init(ptr_t *, Hi private int history_def_insert(history_t *, HistEvent *, const char *); private void history_def_delete(history_t *, HistEvent *, hentry_t *); +private int history_deldata_nth(history_t *, HistEvent *, int, void **); +private int history_set_nth(ptr_t, HistEvent *, int); + #define history_def_setsize(p, num)(void) (((history_t *)p)->max = (num)) #define history_def_getsize(p) (((history_t *)p)->cur) #define history_def_getunique(p) (((((history_t *)p)->flags) & H_UNIQUE) != 0) @@ -335,6 +339,31 @@ history_def_set(ptr_t p, HistEvent *ev, } +/* history_set_nth(): + * Default function to set the current event in the history to the + * n-th one. + */ +private int +history_set_nth(ptr_t p, HistEvent *ev, int n) +{ + history_t *h = (history_t *) p; + + if (h->cur == 0) { + he_seterrev(ev, _HE_EMPTY_LIST); + return (-1); + } + for (h->cursor = h->list.prev; h->cursor != &h->list; + h->cursor = h->cursor->prev) + if (n-- <= 0) + break; + if (h->cursor == &h->list) { + he_seterrev(ev, _HE_NOT_FOUND); + return (-1); + } + return (0); +} + + /* history_def_add(): * Append string to element */ @@ -363,6 +392,24 @@ history_def_add(ptr_t p, HistEvent *ev, } +private int +history_deldata_nth(history_t *h, HistEvent *ev, + int num, void **data) +{ + if (history_set_nth(h, ev, num) != 0) + return (-1); + /* magic value to skip delete (just set to n-th history) */ + if (data == (void **)-1) + return (0); + ev->str = strdup(h->cursor->ev.str); + ev->num = h->cursor->ev.num; + if (data) + *data = h->cursor->data; + history_def_delete(h, ev, h->cursor); + return (0); +} + + /* history_def_del(): * Delete element hp of the h list */ @@ -392,8 +439,11 @@ history_def_delete(history_t *h, HistEventPrivate *evp = (void *)&hp->ev; if (hp == &h->list) abort(); - if (h->cursor == hp) + if (h->cursor == hp) { h->cursor = hp->prev; + if (h->cursor == &h->list) + h->cursor = hp->next; + } hp->prev->next = hp->next; hp->next->prev = hp->prev; h_free((ptr_t) evp->str); @@ -416,6 +466,7 @@ history_def_insert(history_t *h, HistEve h_free((ptr_t)h->cursor); goto oomem; } + h->cursor->data = NULL; h->cursor->ev.num = ++h->eventid; h->cursor->next = h->list.next; h->cursor->prev = &h->list; @@ -711,8 +762,8 @@ history_load(History *h, const char *fna (void) strunvis(ptr, line); line[sz] = c; if (HENTER(h, &ev, ptr) == -1) { - h_free((ptr_t)ptr); - return -1; + i = -1; + goto oomem; } } oomem: @@ -787,6 +838,23 @@ history_prev_event(History *h, HistEvent } +private int +history_next_evdata(History *h, HistEvent *ev, int num, void **d) +{ + int retval; + + for (retval = HCURR(h, ev); retval != -1; retval = HPREV(h, ev)) + if (num-- <= 0) { + if (d) + *d = ((history_t *)h->h_ref)->cursor->data; + return (0); + } + + he_seterrev(ev, _HE_NOT_FOUND); + return (-1); +} + + /* history_next_event(): * Find the next event, with number given */ @@ -976,11 +1044,42 @@ history(History *h, HistEvent *ev, int f retval = 0; break; + case H_NEXT_EVDATA: + { + int num = va_arg(va, int); + void **d = va_arg(va, void **); + retval = history_next_evdata(h, ev, num, d); + break; + } + + case H_DELDATA: + { + int num = va_arg(va, int); + void **d = va_arg(va, void **); + retval = history_deldata_nth((history_t *)h->h_ref, ev, num, d); + break; + } + + case H_REPLACE: /* only use after H_NEXT_EVDATA */ + { + const char *line = va_arg(va, const char *); + void *d = va_arg(va, void *); + const char *s; + if(!line || !(s = strdup(line))) { + retval = -1; + break; + } + ((history_t *)h->h_ref)->cursor->ev.str = s; + ((history_t *)h->h_ref)->cursor->data = d; + retval = 0; + break; + } + default: retval = -1; he_seterrev(ev, _HE_UNKNOWN); break; } va_end(va); - return (retval); + return retval; } Modified: stable/9/lib/libedit/key.c ============================================================================== --- stable/9/lib/libedit/key.c Fri Jun 29 01:55:20 2012 (r237737) +++ stable/9/lib/libedit/key.c Fri Jun 29 03:01:38 2012 (r237738) @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $NetBSD: key.c,v 1.19 2006/03/23 20:22:51 christos Exp $ + * $NetBSD: key.c,v 1.20 2009/02/15 21:55:23 christos Exp $ */ #if !defined(lint) && !defined(SCCSID) @@ -86,8 +86,8 @@ private void node__free(key_node_t *); private void node__put(EditLine *, key_node_t *); private int node__delete(EditLine *, key_node_t **, const char *); private int node_lookup(EditLine *, const char *, key_node_t *, - int); -private int node_enum(EditLine *, key_node_t *, int); + size_t); +private int node_enum(EditLine *, key_node_t *, size_t); #define KEY_BUFSIZ EL_BUFSIZ @@ -478,9 +478,9 @@ node__free(key_node_t *k) * Print if last node */ private int -node_lookup(EditLine *el, const char *str, key_node_t *ptr, int cnt) +node_lookup(EditLine *el, const char *str, key_node_t *ptr, size_t cnt) { - int ncnt; + size_t ncnt; if (ptr == NULL) return (-1); /* cannot have null ptr */ @@ -493,7 +493,8 @@ node_lookup(EditLine *el, const char *st /* If match put this char into el->el_key.buf. Recurse */ if (ptr->ch == *str) { /* match found */ - ncnt = key__decode_char(el->el_key.buf, KEY_BUFSIZ, cnt, + ncnt = key__decode_char(el->el_key.buf, + (size_t)KEY_BUFSIZ, cnt, (unsigned char) ptr->ch); if (ptr->next != NULL) /* not yet at leaf */ @@ -527,9 +528,9 @@ node_lookup(EditLine *el, const char *st * Traverse the node printing the characters it is bound in buffer */ private int -node_enum(EditLine *el, key_node_t *ptr, int cnt) +node_enum(EditLine *el, key_node_t *ptr, size_t cnt) { - int ncnt; + size_t ncnt; if (cnt >= KEY_BUFSIZ - 5) { /* buffer too small */ el->el_key.buf[++cnt] = '"'; @@ -547,7 +548,7 @@ node_enum(EditLine *el, key_node_t *ptr, return (-1); } /* put this char at end of str */ - ncnt = key__decode_char(el->el_key.buf, KEY_BUFSIZ, cnt, + ncnt = key__decode_char(el->el_key.buf, (size_t)KEY_BUFSIZ, cnt, (unsigned char)ptr->ch); if (ptr->next == NULL) { /* print this key and function */ @@ -615,8 +616,8 @@ key_kprint(EditLine *el, const char *key /* key__decode_char(): * Put a printable form of char in buf. */ -protected int -key__decode_char(char *buf, int cnt, int off, int ch) +protected size_t +key__decode_char(char *buf, size_t cnt, size_t off, int ch) { char *sb = buf + off; char *eb = buf + cnt; @@ -626,7 +627,7 @@ key__decode_char(char *buf, int cnt, int if (ch == 0) { ADDC('^'); ADDC('@'); - return b - sb; + return (int)(b - sb); } if (iscntrl(ch)) { ADDC('^'); @@ -648,15 +649,15 @@ key__decode_char(char *buf, int cnt, int ADDC((((unsigned int) ch >> 3) & 7) + '0'); ADDC((ch & 7) + '0'); } - return b - sb; + return (size_t)(b - sb); } /* key__decode_str(): * Make a printable version of the ey */ -protected int -key__decode_str(const char *str, char *buf, int len, const char *sep) +protected size_t +key__decode_str(const char *str, char *buf, size_t len, const char *sep) { char *b = buf, *eb = b + len; const char *p; @@ -699,7 +700,7 @@ key__decode_str(const char *str, char *b } done: ADDC('\0'); - if (b - buf >= len) + if ((size_t)(b - buf) >= len) buf[len - 1] = '\0'; - return b - buf; + return (size_t)(b - buf); } Modified: stable/9/lib/libedit/key.h ============================================================================== --- stable/9/lib/libedit/key.h Fri Jun 29 01:55:20 2012 (r237737) +++ stable/9/lib/libedit/key.h Fri Jun 29 03:01:38 2012 (r237738) @@ -76,8 +76,8 @@ protected int key_delete(EditLine *, c protected void key_print(EditLine *, const char *); protected void key_kprint(EditLine *, const char *, key_value_t *, int); -protected int key__decode_str(const char *, char *, int, +protected size_t key__decode_str(const char *, char *, size_t, const char *); -protected int key__decode_char(char *, int, int, int); +protected size_t key__decode_char(char *, size_t, size_t, int); #endif /* _h_el_key */ Modified: stable/9/lib/libedit/prompt.c ============================================================================== --- stable/9/lib/libedit/prompt.c Fri Jun 29 01:55:20 2012 (r237737) +++ stable/9/lib/libedit/prompt.c Fri Jun 29 03:01:38 2012 (r237738) @@ -85,14 +85,23 @@ prompt_print(EditLine *el, int op) { el_prompt_t *elp; char *p; + int ignore = 0; if (op == EL_PROMPT) elp = &el->el_prompt; else elp = &el->el_rprompt; - p = (elp->p_func) (el); - while (*p) - re_putc(el, *p++, 1); + + for (p = (*elp->p_func)(el); *p; p++) { + if (elp->p_ignore == *p) { + ignore = !ignore; + continue; + } + if (ignore) + term__putc(el, *p); + else + re_putc(el, *p, 1); + } elp->p_pos.v = el->el_refresh.r_cursor.v; elp->p_pos.h = el->el_refresh.r_cursor.h; @@ -109,10 +118,12 @@ prompt_init(EditLine *el) el->el_prompt.p_func = prompt_default; el->el_prompt.p_pos.v = 0; el->el_prompt.p_pos.h = 0; + el->el_prompt.p_ignore = '\0'; el->el_rprompt.p_func = prompt_default_r; el->el_rprompt.p_pos.v = 0; el->el_rprompt.p_pos.h = 0; - return (0); + el->el_rprompt.p_ignore = '\0'; + return 0; } @@ -130,24 +141,29 @@ prompt_end(EditLine *el __unused) * Install a prompt printing function */ protected int -prompt_set(EditLine *el, el_pfunc_t prf, int op) +prompt_set(EditLine *el, el_pfunc_t prf, char c, int op) { el_prompt_t *p; - if (op == EL_PROMPT) + if (op == EL_PROMPT || op == EL_PROMPT_ESC) p = &el->el_prompt; else p = &el->el_rprompt; + if (prf == NULL) { - if (op == EL_PROMPT) + if (op == EL_PROMPT || op == EL_PROMPT_ESC) p->p_func = prompt_default; else p->p_func = prompt_default_r; } else p->p_func = prf; + + p->p_ignore = c; + p->p_pos.v = 0; p->p_pos.h = 0; - return (0); + + return 0; } @@ -155,14 +171,22 @@ prompt_set(EditLine *el, el_pfunc_t prf, * Retrieve the prompt printing function */ protected int -prompt_get(EditLine *el, el_pfunc_t *prf, int op) +prompt_get(EditLine *el, el_pfunc_t *prf, char *c, int op) { + el_prompt_t *p; if (prf == NULL) - return (-1); + return -1; + if (op == EL_PROMPT) - *prf = el->el_prompt.p_func; + p = &el->el_prompt; else - *prf = el->el_rprompt.p_func; - return (0); + p = &el->el_rprompt; + + *prf = el->el_rprompt.p_func; + + if (c) + *c = p->p_ignore; + + return 0; } Modified: stable/9/lib/libedit/prompt.h ============================================================================== --- stable/9/lib/libedit/prompt.h Fri Jun 29 01:55:20 2012 (r237737) +++ stable/9/lib/libedit/prompt.h Fri Jun 29 03:01:38 2012 (r237738) @@ -47,11 +47,13 @@ typedef char * (*el_pfunc_t)(EditLine*); typedef struct el_prompt_t { el_pfunc_t p_func; /* Function to return the prompt */ coord_t p_pos; /* position in the line after prompt */ + char p_ignore; /* character to start/end literal +*/ } el_prompt_t; protected void prompt_print(EditLine *, int); -protected int prompt_set(EditLine *, el_pfunc_t, int); -protected int prompt_get(EditLine *, el_pfunc_t *, int); +protected int prompt_set(EditLine *, el_pfunc_t, char, int); +protected int prompt_get(EditLine *, el_pfunc_t *, char *, int); protected int prompt_init(EditLine *); protected void prompt_end(EditLine *); Modified: stable/9/lib/libedit/read.c ============================================================================== --- stable/9/lib/libedit/read.c Fri Jun 29 01:55:20 2012 (r237737) +++ stable/9/lib/libedit/read.c Fri Jun 29 03:01:38 2012 (r237738) @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $NetBSD: read.c,v 1.40 2007/03/01 21:41:45 christos Exp $ + * $NetBSD: read.c,v 1.52 2009/07/22 15:57:00 christos Exp $ */ #if !defined(lint) && !defined(SCCSID) @@ -49,7 +49,7 @@ __FBSDID("$FreeBSD$"); #include #include "el.h" -#define OKCMD -1 +#define OKCMD -1 /* must be -1! */ private int read__fixio(int, int); private int read_preread(EditLine *); @@ -170,7 +170,7 @@ read__fixio(int fd __unused, int e) return (e ? 0 : -1); case EINTR: - return (0); + return (-1); default: return (-1); @@ -222,7 +222,7 @@ el_push(EditLine *el, const char *str) ma->level--; } term_beep(el); - term__flush(); + term__flush(el); } @@ -235,9 +235,12 @@ read_getcmd(EditLine *el, el_action_t *c el_action_t cmd; int num; + el->el_errno = 0; do { - if ((num = el_getc(el, ch)) != 1) /* if EOF or error */ + if ((num = el_getc(el, ch)) != 1) { /* if EOF or error */ + el->el_errno = num == 0 ? 0 : errno; return (num); + } #ifdef KANJI if ((*ch & 0200)) { @@ -286,18 +289,25 @@ read_getcmd(EditLine *el, el_action_t *c private int read_char(EditLine *el, char *cp) { - int num_read; + ssize_t num_read; int tried = 0; - while ((num_read = read(el->el_infd, cp, 1)) == -1) + again: + el->el_signal->sig_no = 0; + while ((num_read = read(el->el_infd, cp, 1)) == -1) { + if (el->el_signal->sig_no == SIGCONT) { + sig_set(el); + el_set(el, EL_REFRESH); + goto again; + } if (!tried && read__fixio(el->el_infd, errno) == 0) tried = 1; else { *cp = '\0'; return (-1); } - - return (num_read); + } + return (int)num_read; } /* read_pop(): @@ -309,8 +319,9 @@ read_pop(c_macro_t *ma) int i; el_free(ma->macro[0]); - for (i = ma->level--; i > 0; i--) - ma->macro[i - 1] = ma->macro[i]; + for (i = 0; i < ma->level; i++) + ma->macro[i] = ma->macro[i + 1]; + ma->level--; ma->offset = 0; } @@ -323,7 +334,7 @@ el_getc(EditLine *el, char *cp) int num_read; c_macro_t *ma = &el->el_chared.c_macro; - term__flush(); + term__flush(el); for (;;) { if (ma->level < 0) { if (!read_preread(el)) @@ -382,7 +393,7 @@ read_prepare(EditLine *el) re_refresh(el); /* print the prompt */ if (el->el_flags & UNBUFFERED) - term__flush(); + term__flush(el); } protected void @@ -402,15 +413,20 @@ el_gets(EditLine *el, int *nread) int num; /* how many chars we have read at NL */ char ch; int crlf = 0; + int nrb; #ifdef FIONREAD c_macro_t *ma = &el->el_chared.c_macro; #endif /* FIONREAD */ + if (nread == NULL) + nread = &nrb; + *nread = 0; + if (el->el_flags & NO_TTY) { char *cp = el->el_line.buffer; size_t idx; - while ((*el->el_read.read_char)(el, cp) == 1) { + while ((num = (*el->el_read.read_char)(el, cp)) == 1) { /* make sure there is space for next character */ if (cp + 1 >= el->el_line.limit) { idx = (cp - el->el_line.buffer); @@ -424,12 +440,16 @@ el_gets(EditLine *el, int *nread) if (cp[-1] == '\r' || cp[-1] == '\n') break; } + if (num == -1) { + if (errno == EINTR) + cp = el->el_line.buffer; + el->el_errno = errno; + } el->el_line.cursor = el->el_line.lastchar = cp; *cp = '\0'; - if (nread) - *nread = el->el_line.cursor - el->el_line.buffer; - return (el->el_line.buffer); + *nread = (int)(el->el_line.cursor - el->el_line.buffer); + goto done; } @@ -440,8 +460,8 @@ el_gets(EditLine *el, int *nread) (void) ioctl(el->el_infd, FIONREAD, (ioctl_t) & chrs); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 03:37:24 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 095D0106566C; Fri, 29 Jun 2012 03:37:24 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E55E98FC18; Fri, 29 Jun 2012 03:37:23 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5T3bNx1016349; Fri, 29 Jun 2012 03:37:23 GMT (envelope-from scottl@svn.freebsd.org) Received: (from scottl@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5T3bN7E016339; Fri, 29 Jun 2012 03:37:23 GMT (envelope-from scottl@svn.freebsd.org) Message-Id: <201206290337.q5T3bN7E016339@svn.freebsd.org> From: Scott Long Date: Fri, 29 Jun 2012 03:37:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237740 - stable/9/sbin/camcontrol X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 03:37:24 -0000 Author: scottl Date: Fri Jun 29 03:37:23 2012 New Revision: 237740 URL: http://svn.freebsd.org/changeset/base/237740 Log: Merge the firmware download functionality into camcontrol, as well as several other minor code changes. Obtained from: Netflix, Inc. Added: stable/9/sbin/camcontrol/fwdownload.c - copied, changed from r227961, head/sbin/camcontrol/fwdownload.c stable/9/sbin/camcontrol/progress.c - copied unchanged from r237285, head/sbin/camcontrol/progress.c stable/9/sbin/camcontrol/progress.h - copied unchanged from r237285, head/sbin/camcontrol/progress.h Modified: stable/9/sbin/camcontrol/Makefile stable/9/sbin/camcontrol/camcontrol.8 stable/9/sbin/camcontrol/camcontrol.c stable/9/sbin/camcontrol/camcontrol.h stable/9/sbin/camcontrol/modeedit.c stable/9/sbin/camcontrol/util.c Directory Properties: stable/9/sbin/camcontrol/ (props changed) Modified: stable/9/sbin/camcontrol/Makefile ============================================================================== --- stable/9/sbin/camcontrol/Makefile Fri Jun 29 03:03:42 2012 (r237739) +++ stable/9/sbin/camcontrol/Makefile Fri Jun 29 03:37:23 2012 (r237740) @@ -3,7 +3,7 @@ PROG= camcontrol SRCS= camcontrol.c util.c .if !defined(RELEASE_CRUNCH) -SRCS+= modeedit.c +SRCS+= fwdownload.c modeedit.c progress.c .else CFLAGS+= -DMINIMALISTIC .endif Modified: stable/9/sbin/camcontrol/camcontrol.8 ============================================================================== --- stable/9/sbin/camcontrol/camcontrol.8 Fri Jun 29 03:03:42 2012 (r237739) +++ stable/9/sbin/camcontrol/camcontrol.8 Fri Jun 29 03:37:23 2012 (r237740) @@ -221,6 +221,13 @@ .Op device id .Op generic args .Nm +.Ic fwdownload +.Op device id +.Op generic args +.Aq Fl f Ar fw_image +.Op Fl y +.Op Fl s +.Nm .Ic help .Sh DESCRIPTION The @@ -1063,6 +1070,54 @@ specifies automatic standby timer value .It Ic sleep Put ATA device into SLEEP state. Note that the only way get device out of this state may be reset. +.It Ic fwdownload +Program firmware of the named SCSI device using the image file provided. +.Pp +Current list of supported vendors: +.Bl -bullet -offset indent -compact +.It +HITACHI +.It +HP +.It +IBM +.It +PLEXTOR +.It +QUANTUM +.It +SEAGATE +.El +.Pp +.Em WARNING! WARNING! WARNING! +.Pp +Little testing has been done to make sure that different device models from +each vendor work correctly with the fwdownload command. +A vendor name appearing in the supported list means only that firmware of at +least one device type from that vendor has successfully been programmed with +the fwdownload command. +Extra caution should be taken when using this command since there is no +guarantee it will not break a device from the listed vendors. +Ensure that you have a recent backup of the data on the device before +performing a firmware update. +.Bl -tag -width 11n +.It Fl f Ar fw_image +Path to the firmware image file to be downloaded to the specified device. +.It Fl y +Do not ask for confirmation. +.It Fl s +Run in simulation mode. +Packet sizes that will be sent are shown, but no actual packet is sent to the +device. +No confimation is asked in simulation mode. +.It Fl v +Besides showing sense information in case of a failure, the verbose option +causes +.Nm +to output a line for every firmware segment that is sent to the device by the +fwdownload command +-- the same as the ones shown in simulation mode. +.El .It Ic help Print out verbose usage information. .El @@ -1176,7 +1231,6 @@ camcontrol negotiate -n da -u 3 -R 20.00 Negotiate a sync rate of 20MHz and an offset of 15 with da3. Then send a Test Unit Ready command to make the settings take effect. -.Pp .Bd -literal -offset indent camcontrol smpcmd ses0 -v -r 4 "40 0 00 0" -R 1020 "s9 i1" .Ed Modified: stable/9/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/9/sbin/camcontrol/camcontrol.c Fri Jun 29 03:03:42 2012 (r237739) +++ stable/9/sbin/camcontrol/camcontrol.c Fri Jun 29 03:37:23 2012 (r237740) @@ -86,7 +86,8 @@ typedef enum { CAM_CMD_SMP_RG = 0x00000018, CAM_CMD_SMP_PC = 0x00000019, CAM_CMD_SMP_PHYLIST = 0x0000001a, - CAM_CMD_SMP_MANINFO = 0x0000001b + CAM_CMD_SMP_MANINFO = 0x0000001b, + CAM_CMD_DOWNLOAD_FW = 0x0000001c } cam_cmdmask; typedef enum { @@ -181,6 +182,7 @@ struct camcontrol_opts option_table[] = {"idle", CAM_CMD_IDLE, CAM_ARG_NONE, "t:"}, {"standby", CAM_CMD_STANDBY, CAM_ARG_NONE, "t:"}, {"sleep", CAM_CMD_SLEEP, CAM_ARG_NONE, ""}, + {"fwdownload", CAM_CMD_DOWNLOAD_FW, CAM_ARG_NONE, "f:ys"}, #endif /* MINIMALISTIC */ {"help", CAM_CMD_USAGE, CAM_ARG_NONE, NULL}, {"-?", CAM_CMD_USAGE, CAM_ARG_NONE, NULL}, @@ -223,8 +225,6 @@ static int testunitready(struct cam_devi int timeout, int quiet); static int scsistart(struct cam_device *device, int startstop, int loadeject, int retry_count, int timeout); -static int scsidoinquiry(struct cam_device *device, int argc, char **argv, - char *combinedopt, int retry_count, int timeout); static int scsiinquiry(struct cam_device *device, int retry_count, int timeout); static int scsiserial(struct cam_device *device, int retry_count, int timeout); static int camxferrate(struct cam_device *device); @@ -703,7 +703,7 @@ scsistart(struct cam_device *device, int return(error); } -static int +int scsidoinquiry(struct cam_device *device, int argc, char **argv, char *combinedopt, int retry_count, int timeout) { @@ -3071,6 +3071,26 @@ get_cgd_bailout: return(retval); } +/* return the type of disk (really the command type) */ +static const char * +get_disk_type(struct cam_device *device) +{ + struct ccb_getdev cgd; + + (void) memset(&cgd, 0x0, sizeof(cgd)); + get_cgd(device, &cgd); + switch(cgd.protocol) { + case PROTO_SCSI: + return "scsi"; + case PROTO_ATA: + case PROTO_ATAPI: + case PROTO_SATAPM: + return "ata"; + default: + return "unknown"; + } +} + static void cpi_print(struct ccb_pathinq *cpi) { @@ -3644,7 +3664,7 @@ scsiformat(struct cam_device *device, in union ccb *ccb; int c; int ycount = 0, quiet = 0; - int error = 0, response = 0, retval = 0; + int error = 0, retval = 0; int use_timeout = 10800 * 1000; int immediate = 1; struct format_defect_list_header fh; @@ -3698,27 +3718,7 @@ scsiformat(struct cam_device *device, in } if (ycount == 0) { - - do { - char str[1024]; - - fprintf(stdout, "Are you SURE you want to do " - "this? (yes/no) "); - - if (fgets(str, sizeof(str), stdin) != NULL) { - - if (strncasecmp(str, "yes", 3) == 0) - response = 1; - else if (strncasecmp(str, "no", 2) == 0) - response = -1; - else { - fprintf(stdout, "Please answer" - " \"yes\" or \"no\"\n"); - } - } - } while (response == 0); - - if (response == -1) { + if (!get_confirmation()) { error = 1; goto scsiformat_bailout; } @@ -5765,6 +5765,7 @@ usage(int verbose) " camcontrol idle [dev_id][generic args][-t time]\n" " camcontrol standby [dev_id][generic args][-t time]\n" " camcontrol sleep [dev_id][generic args]\n" +" camcontrol fwdownload [dev_id][generic args] <-f fw_image> [-y][-s]\n" #endif /* MINIMALISTIC */ " camcontrol help\n"); if (!verbose) @@ -5800,6 +5801,7 @@ usage(int verbose) "idle send the ATA IDLE command to the named device\n" "standby send the ATA STANDBY command to the named device\n" "sleep send the ATA SLEEP command to the named device\n" +"fwdownload program firmware of the named device with the given image" "help this message\n" "Device Identifiers:\n" "bus:target specify the bus and target, lun defaults to 0\n" @@ -5891,7 +5893,12 @@ usage(int verbose) "-w don't send immediate format command\n" "-y don't ask any questions\n" "idle/standby arguments:\n" -"-t number of seconds before respective state.\n"); +"-t number of seconds before respective state.\n" +"fwdownload arguments:\n" +"-f fw_image path to firmware image file\n" +"-y don't ask any questions\n" +"-s run in simulation mode\n" +"-v print info for every firmware segment sent to device\n"); #endif /* MINIMALISTIC */ } @@ -6207,6 +6214,11 @@ main(int argc, char **argv) combinedopt, retry_count, timeout); break; + case CAM_CMD_DOWNLOAD_FW: + error = fwdownload(cam_dev, argc, argv, combinedopt, + arglist & CAM_ARG_VERBOSE, retry_count, timeout, + get_disk_type(cam_dev)); + break; #endif /* MINIMALISTIC */ case CAM_CMD_USAGE: usage(1); Modified: stable/9/sbin/camcontrol/camcontrol.h ============================================================================== --- stable/9/sbin/camcontrol/camcontrol.h Fri Jun 29 03:03:42 2012 (r237739) +++ stable/9/sbin/camcontrol/camcontrol.h Fri Jun 29 03:37:23 2012 (r237740) @@ -40,6 +40,9 @@ struct get_hook int got; }; +int fwdownload(struct cam_device *device, int argc, char **argv, + char *combinedopt, int verbose, int retry_count, int timeout, + const char */*type*/); void mode_sense(struct cam_device *device, int mode_page, int page_control, int dbd, int retry_count, int timeout, u_int8_t *data, int datalen); @@ -49,8 +52,11 @@ void mode_edit(struct cam_device *device int edit, int binary, int retry_count, int timeout); void mode_list(struct cam_device *device, int page_control, int dbd, int retry_count, int timeout); +int scsidoinquiry(struct cam_device *device, int argc, char **argv, + char *combinedopt, int retry_count, int timeout); char *cget(void *hook, char *name); int iget(void *hook, char *name); void arg_put(void *hook, int letter, void *arg, int count, char *name); +int get_confirmation(void); void usage(int verbose); #endif /* _CAMCONTROL_H */ Copied and modified: stable/9/sbin/camcontrol/fwdownload.c (from r227961, head/sbin/camcontrol/fwdownload.c) ============================================================================== --- head/sbin/camcontrol/fwdownload.c Fri Nov 25 04:03:37 2011 (r227961, copy source) +++ stable/9/sbin/camcontrol/fwdownload.c Fri Jun 29 03:37:23 2012 (r237740) @@ -26,6 +26,15 @@ */ /* + * This software is derived from Andre Albsmeier's fwprog.c which contained + * the following note: + * + * Many thanks goes to Marc Frajola from + * TeraSolutions for the initial idea and his programme for upgrading + * the firmware of I*M DDYS drives. + */ + +/* * BEWARE: * * The fact that you see your favorite vendor listed below does not @@ -55,6 +64,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include "progress.h" + #include "camcontrol.h" #define CMD_TIMEOUT 50000 /* 50 seconds */ @@ -64,6 +75,7 @@ typedef enum { VENDOR_HP, VENDOR_IBM, VENDOR_PLEXTOR, + VENDOR_QUALSTAR, VENDOR_QUANTUM, VENDOR_SEAGATE, VENDOR_UNKNOWN @@ -79,32 +91,58 @@ struct fw_vendor { int inc_cdb_offset; }; -struct fw_vendor vendors_list[] = { +static const struct fw_vendor vendors_list[] = { {VENDOR_HITACHI, "HITACHI", 0x8000, 0x05, 0x05, 1, 0}, {VENDOR_HP, "HP", 0x8000, 0x07, 0x07, 0, 1}, {VENDOR_IBM, "IBM", 0x8000, 0x05, 0x05, 1, 0}, {VENDOR_PLEXTOR, "PLEXTOR", 0x2000, 0x04, 0x05, 0, 1}, + {VENDOR_QUALSTAR, "QUALSTAR", 0x2030, 0x05, 0x05, 0, 0}, {VENDOR_QUANTUM, "QUANTUM", 0x2000, 0x04, 0x05, 0, 1}, {VENDOR_SEAGATE, "SEAGATE", 0x8000, 0x07, 0x07, 0, 1}, + /* the next 2 are SATA disks going through SAS HBA */ + {VENDOR_SEAGATE, "ATA ST", 0x8000, 0x07, 0x07, 0, 1}, + {VENDOR_HITACHI, "ATA HDS", 0x8000, 0x05, 0x05, 1, 0}, {VENDOR_UNKNOWN, NULL, 0x0000, 0x00, 0x00, 0, 0} }; -static struct fw_vendor *fw_get_vendor(struct cam_device *cam_dev); -static char *fw_read_img(char *fw_img_path, struct fw_vendor *vp, - int *num_bytes); +#ifndef ATA_DOWNLOAD_MICROCODE +#define ATA_DOWNLOAD_MICROCODE 0x92 +#endif + +#define USE_OFFSETS_FEATURE 0x3 + +#ifndef LOW_SECTOR_SIZE +#define LOW_SECTOR_SIZE 512 +#endif + +#define ATA_MAKE_LBA(o, p) \ + ((((((o) / LOW_SECTOR_SIZE) >> 8) & 0xff) << 16) | \ + ((((o) / LOW_SECTOR_SIZE) & 0xff) << 8) | \ + ((((p) / LOW_SECTOR_SIZE) >> 8) & 0xff)) + +#define ATA_MAKE_SECTORS(p) (((p) / 512) & 0xff) + +#ifndef UNKNOWN_MAX_PKT_SIZE +#define UNKNOWN_MAX_PKT_SIZE 0x8000 +#endif + +static const struct fw_vendor *fw_get_vendor(struct cam_device *cam_dev); +static char *fw_read_img(const char *fw_img_path, + const struct fw_vendor *vp, int *num_bytes); static int fw_download_img(struct cam_device *cam_dev, - struct fw_vendor *vp, char *buf, int img_size, - int sim_mode, int verbose, int retry_count, int timeout); + const struct fw_vendor *vp, char *buf, int img_size, + int sim_mode, int verbose, int retry_count, int timeout, + const char */*name*/, const char */*type*/); /* * Find entry in vendors list that belongs to * the vendor of given cam device. */ -static struct fw_vendor * +static const struct fw_vendor * fw_get_vendor(struct cam_device *cam_dev) { char vendor[SID_VENDOR_SIZE + 1]; - struct fw_vendor *vp; + const struct fw_vendor *vp; if (cam_dev == NULL) return (NULL); @@ -124,7 +162,7 @@ fw_get_vendor(struct cam_device *cam_dev * in num_bytes. */ static char * -fw_read_img(char *fw_img_path, struct fw_vendor *vp, int *num_bytes) +fw_read_img(const char *fw_img_path, const struct fw_vendor *vp, int *num_bytes) { int fd; struct stat stbuf; @@ -164,6 +202,9 @@ fw_read_img(char *fw_img_path, struct fw (img_size % 512 == 80)) skip_bytes = 80; break; + case VENDOR_QUALSTAR: + skip_bytes = img_size % 1030; + break; default: break; } @@ -196,28 +237,59 @@ bailout1: * device but do not sent any actual packets */ static int -fw_download_img(struct cam_device *cam_dev, struct fw_vendor *vp, +fw_download_img(struct cam_device *cam_dev, const struct fw_vendor *vp, char *buf, int img_size, int sim_mode, int verbose, int retry_count, - int timeout) + int timeout, const char *imgname, const char *type) { struct scsi_write_buffer cdb; + progress_t progress; + int size; union ccb *ccb; int pkt_count = 0; + int max_pkt_size; u_int32_t pkt_size = 0; char *pkt_ptr = buf; u_int32_t offset; int last_pkt = 0; + int16_t *ptr; if ((ccb = cam_getccb(cam_dev)) == NULL) { warnx("Could not allocate CCB"); return (1); } - scsi_test_unit_ready(&ccb->csio, 0, NULL, MSG_SIMPLE_Q_TAG, - SSD_FULL_SIZE, 5000); + if (strcmp(type, "scsi") == 0) { + scsi_test_unit_ready(&ccb->csio, 0, NULL, MSG_SIMPLE_Q_TAG, + SSD_FULL_SIZE, 5000); + } else if (strcmp(type, "ata") == 0) { + /* cam_getccb cleans up the header, caller has to zero the payload */ + bzero(&(&ccb->ccb_h)[1], + sizeof(struct ccb_ataio) - sizeof(struct ccb_hdr)); + + ptr = (uint16_t *)malloc(sizeof(struct ata_params)); + + if (ptr == NULL) { + cam_freeccb(ccb); + warnx("can't malloc memory for identify\n"); + return(1); + } + bzero(ptr, sizeof(struct ata_params)); + cam_fill_ataio(&ccb->ataio, + 1, + NULL, + /*flags*/CAM_DIR_IN, + MSG_SIMPLE_Q_TAG, + /*data_ptr*/(uint8_t *)ptr, + /*dxfer_len*/sizeof(struct ata_params), + timeout ? timeout : 30 * 1000); + ata_28bit_cmd(&ccb->ataio, ATA_ATA_IDENTIFY, 0, 0, 0); + } else { + warnx("weird disk type '%s'", type); + return 1; + } /* Disable freezing the device queue. */ ccb->ccb_h.flags |= CAM_DEV_QFRZDIS; if (cam_send_ccb(cam_dev, ccb) < 0) { - warnx("Error sending test unit ready"); + warnx("Error sending identify/test unit ready"); if (verbose) cam_error_print(cam_dev, ccb, CAM_ESF_ALL, CAM_EPF_ALL, stderr); @@ -232,85 +304,104 @@ fw_download_img(struct cam_device *cam_d cam_freeccb(ccb); return (1); } - pkt_size = vp->max_pkt_size; - if (verbose || sim_mode) { - fprintf(stdout, - "--------------------------------------------------\n"); - fprintf(stdout, - "PktNo. PktSize BytesRemaining LastPkt\n"); - fprintf(stdout, - "--------------------------------------------------\n"); + max_pkt_size = vp->max_pkt_size; + if (vp->max_pkt_size == 0 && strcmp(type, "ata") == 0) { + max_pkt_size = UNKNOWN_MAX_PKT_SIZE; } + pkt_size = vp->max_pkt_size; + progress_init(&progress, imgname, size = img_size); /* Download single fw packets. */ do { - if (img_size <= vp->max_pkt_size) { + if (img_size <= max_pkt_size) { last_pkt = 1; pkt_size = img_size; } - if (verbose || sim_mode) - fprintf(stdout, "%3u %5u (0x%05X) %7u (0x%06X) " - "%d\n", pkt_count, pkt_size, pkt_size, - img_size - pkt_size, img_size - pkt_size, - last_pkt); + progress_update(&progress, size - img_size); + progress_draw(&progress); bzero(&cdb, sizeof(cdb)); - cdb.opcode = WRITE_BUFFER; - cdb.control = 0; - /* Parameter list length. */ - scsi_ulto3b(pkt_size, &cdb.length[0]); - offset = vp->inc_cdb_offset ? (pkt_ptr - buf) : 0; - scsi_ulto3b(offset, &cdb.offset[0]); - cdb.byte2 = last_pkt ? vp->cdb_byte2_last : vp->cdb_byte2; - cdb.buffer_id = vp->inc_cdb_buffer_id ? pkt_count : 0; - /* Zero out payload of ccb union after ccb header. */ - bzero((u_char *)ccb + sizeof(struct ccb_hdr), - sizeof(struct ccb_scsiio) - sizeof(struct ccb_hdr)); - /* Copy previously constructed cdb into ccb_scsiio struct. */ - bcopy(&cdb, &ccb->csio.cdb_io.cdb_bytes[0], - sizeof(struct scsi_write_buffer)); - /* Fill rest of ccb_scsiio struct. */ + if (strcmp(type, "scsi") == 0) { + cdb.opcode = WRITE_BUFFER; + cdb.control = 0; + /* Parameter list length. */ + scsi_ulto3b(pkt_size, &cdb.length[0]); + offset = vp->inc_cdb_offset ? (pkt_ptr - buf) : 0; + scsi_ulto3b(offset, &cdb.offset[0]); + cdb.byte2 = last_pkt ? vp->cdb_byte2_last : vp->cdb_byte2; + cdb.buffer_id = vp->inc_cdb_buffer_id ? pkt_count : 0; + /* Zero out payload of ccb union after ccb header. */ + bzero((u_char *)ccb + sizeof(struct ccb_hdr), + sizeof(struct ccb_scsiio) - sizeof(struct ccb_hdr)); + /* Copy previously constructed cdb into ccb_scsiio struct. */ + bcopy(&cdb, &ccb->csio.cdb_io.cdb_bytes[0], + sizeof(struct scsi_write_buffer)); + /* Fill rest of ccb_scsiio struct. */ + if (!sim_mode) { + cam_fill_csio(&ccb->csio, /* ccb_scsiio */ + retry_count, /* retries */ + NULL, /* cbfcnp */ + CAM_DIR_OUT | CAM_DEV_QFRZDIS, /* flags */ + CAM_TAG_ACTION_NONE, /* tag_action */ + (u_char *)pkt_ptr, /* data_ptr */ + pkt_size, /* dxfer_len */ + SSD_FULL_SIZE, /* sense_len */ + sizeof(struct scsi_write_buffer), /* cdb_len */ + timeout ? timeout : CMD_TIMEOUT); /* timeout */ + } + } else if (strcmp(type, "ata") == 0) { + bzero(&(&ccb->ccb_h)[1], + sizeof(struct ccb_ataio) - sizeof(struct ccb_hdr)); + if (!sim_mode) { + uint32_t off; + + cam_fill_ataio(&ccb->ataio, + (last_pkt) ? 256 : retry_count, + NULL, + /*flags*/CAM_DIR_OUT | CAM_DEV_QFRZDIS, + CAM_TAG_ACTION_NONE, + /*data_ptr*/(uint8_t *)pkt_ptr, + /*dxfer_len*/pkt_size, + timeout ? timeout : 30 * 1000); + off = (uint32_t)(pkt_ptr - buf); + ata_28bit_cmd(&ccb->ataio, ATA_DOWNLOAD_MICROCODE, + USE_OFFSETS_FEATURE, + ATA_MAKE_LBA(off, pkt_size), + ATA_MAKE_SECTORS(pkt_size)); + } + } if (!sim_mode) { - cam_fill_csio(&ccb->csio, /* ccb_scsiio */ - retry_count, /* retries */ - NULL, /* cbfcnp */ - CAM_DIR_OUT | CAM_DEV_QFRZDIS, /* flags */ - CAM_TAG_ACTION_NONE, /* tag_action */ - (u_char *)pkt_ptr, /* data_ptr */ - pkt_size, /* dxfer_len */ - SSD_FULL_SIZE, /* sense_len */ - sizeof(struct scsi_write_buffer), /* cdb_len */ - timeout ? timeout : CMD_TIMEOUT); /* timeout */ /* Execute the command. */ if (cam_send_ccb(cam_dev, ccb) < 0) { warnx("Error writing image to device"); if (verbose) cam_error_print(cam_dev, ccb, CAM_ESF_ALL, - CAM_EPF_ALL, stderr); + CAM_EPF_ALL, stderr); goto bailout; } + if (ccb->ataio.res.status != 0 /*&& !last_pkt*/) { + cam_error_print(cam_dev, ccb, CAM_ESF_ALL, + CAM_EPF_ALL, stderr); + } } /* Prepare next round. */ pkt_count++; pkt_ptr += pkt_size; img_size -= pkt_size; } while(!last_pkt); - if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { - if (verbose) - cam_error_print(cam_dev, ccb, CAM_ESF_ALL, - CAM_EPF_ALL, stderr); - goto bailout; - } + progress_complete(&progress, size - img_size); cam_freeccb(ccb); return (0); bailout: + progress_complete(&progress, size - img_size); cam_freeccb(ccb); return (1); } int fwdownload(struct cam_device *device, int argc, char **argv, - char *combinedopt, int verbose, int retry_count, int timeout) + char *combinedopt, int verbose, int retry_count, int timeout, + const char *type) { - struct fw_vendor *vp; + const struct fw_vendor *vp; char *fw_img_path = NULL; char *buf; int img_size; @@ -336,12 +427,13 @@ fwdownload(struct cam_device *device, in } if (fw_img_path == NULL) - errx(1, - "you must specify a firmware image file using -f option"); + errx(1, "you must specify a firmware image file using -f option"); vp = fw_get_vendor(device); - if (vp == NULL || vp->type == VENDOR_UNKNOWN) - errx(1, "Unsupported device"); + if (vp == NULL) + errx(1, "NULL vendor"); + if (vp->type == VENDOR_UNKNOWN) + warnx("Unsupported device - flashing through an HBA?"); buf = fw_read_img(fw_img_path, vp, &img_size); if (buf == NULL) @@ -351,11 +443,6 @@ fwdownload(struct cam_device *device, in fprintf(stdout, "You are about to download firmware image (%s)" " into the following device:\n", fw_img_path); - if (scsidoinquiry(device, argc, argv, combinedopt, 0, - 5000) != 0) { - warnx("Error sending inquiry"); - goto fail; - } fprintf(stdout, "\nIt may damage your drive. "); if (!get_confirmation()) goto fail; @@ -364,10 +451,11 @@ fwdownload(struct cam_device *device, in fprintf(stdout, "Running in simulation mode\n"); if (fw_download_img(device, vp, buf, img_size, sim_mode, verbose, - retry_count, timeout) != 0) { + retry_count, timeout, fw_img_path, type) != 0) { fprintf(stderr, "Firmware download failed\n"); goto fail; - } else + } + else fprintf(stdout, "Firmware download successful\n"); free(buf); Modified: stable/9/sbin/camcontrol/modeedit.c ============================================================================== --- stable/9/sbin/camcontrol/modeedit.c Fri Jun 29 03:03:42 2012 (r237739) +++ stable/9/sbin/camcontrol/modeedit.c Fri Jun 29 03:37:23 2012 (r237740) @@ -83,15 +83,15 @@ struct editentry { char *svalue; } value; }; -STAILQ_HEAD(, editentry) editlist; /* List of page entries. */ -int editlist_changed = 0; /* Whether any entries were changed. */ +static STAILQ_HEAD(, editentry) editlist; /* List of page entries. */ +static int editlist_changed = 0; /* Whether any entries were changed. */ struct pagename { SLIST_ENTRY(pagename) link; int pagenum; char *name; }; -SLIST_HEAD(, pagename) namelist; /* Page number to name mappings. */ +static SLIST_HEAD(, pagename) namelist; /* Page number to name mappings. */ static char format[MAX_FORMAT_SPEC]; /* Buffer for scsi cdb format def. */ Copied: stable/9/sbin/camcontrol/progress.c (from r237285, head/sbin/camcontrol/progress.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/9/sbin/camcontrol/progress.c Fri Jun 29 03:37:23 2012 (r237740, copy of r237285, head/sbin/camcontrol/progress.c) @@ -0,0 +1,186 @@ +/* $NetBSD: progressbar.c,v 1.21 2009/04/12 10:18:52 lukem Exp $ */ + +/*- + * Copyright (c) 1997-2009 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Luke Mewburn. + * + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +__FBSDID("$FreeBSD$"); + +#include "progress.h" + +static const char * const suffixes[] = { + "", /* 2^0 (byte) */ + "KiB", /* 2^10 Kibibyte */ + "MiB", /* 2^20 Mebibyte */ + "GiB", /* 2^30 Gibibyte */ + "TiB", /* 2^40 Tebibyte */ + "PiB", /* 2^50 Pebibyte */ + "EiB", /* 2^60 Exbibyte */ +}; + +#define NSUFFIXES (sizeof(suffixes) / sizeof(suffixes[0])) +#define SECSPERHOUR (60 * 60) +#define DEFAULT_TTYWIDTH 80 + +/* initialise progress meter structure */ +int +progress_init(progress_t *prog, const char *prefix, uint64_t total) +{ + struct winsize winsize; + int oerrno = errno; + + (void) memset(prog, 0x0, sizeof(*prog)); + prog->size = total; + prog->prefix = strdup(prefix); + prog->start = time(NULL); + if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &winsize) != -1 && + winsize.ws_col != 0) { + prog->ttywidth = winsize.ws_col; + } else { + prog->ttywidth = DEFAULT_TTYWIDTH; + } + errno = oerrno; + return 1; +} + +/* update the values in the progress meter */ +int +progress_update(progress_t *prog, uint64_t done) +{ + prog->done = done; + prog->percent = (prog->done * 100) / prog->size; + prog->now = time(NULL); + prog->elapsed = prog->now - prog->start; + if (done == 0 || prog->elapsed == 0 || prog->done / prog->elapsed == 0) { + prog->eta = 0; + } else { + prog->eta = prog->size / (prog->done / prog->elapsed) - prog->elapsed; + } + return 1; +} + +/* update the values in the progress meter */ +int +progress_reset_size(progress_t *prog, uint64_t size) +{ + prog->size = size; + return 1; +} + +/* make it look pretty at the end - display done bytes (usually total) */ +int +progress_complete(progress_t *prog, uint64_t done) +{ + progress_update(prog, done); + progress_draw(prog); + printf("\n"); + return 1; +} + +/* draw the progress meter */ +int +progress_draw(progress_t *prog) +{ +#define BAROVERHEAD 45 /* non `*' portion of progress bar */ + /* + * stars should contain at least + * sizeof(buf) - BAROVERHEAD entries + */ + static const char stars[] = +"*****************************************************************************" +"*****************************************************************************" +"*****************************************************************************"; + unsigned bytesabbrev; + unsigned bpsabbrev; + int64_t secs; + uint64_t bytespersec; + uint64_t abbrevsize; + int64_t secsleft; + size_t barlength; + size_t starc; + char hours[12]; + char buf[256]; + int len; + + barlength = MIN(sizeof(buf) - 1, (unsigned)prog->ttywidth) - BAROVERHEAD - strlen(prog->prefix); + starc = (barlength * prog->percent) / 100; + abbrevsize = prog->done; + for (bytesabbrev = 0; abbrevsize >= 100000 && bytesabbrev < NSUFFIXES; bytesabbrev++) { + abbrevsize >>= 10; + } + if (bytesabbrev == NSUFFIXES) { + bytesabbrev--; + } + bytespersec = 0; + if (prog->done > 0) { + bytespersec = prog->done; + if (prog->elapsed > 0) { + bytespersec /= prog->elapsed; + } + } + for (bpsabbrev = 1; bytespersec >= 1024000 && bpsabbrev < NSUFFIXES; bpsabbrev++) { + bytespersec >>= 10; + } + if (prog->done == 0 || prog->elapsed <= 0 || prog->done > prog->size) { + secsleft = 0; + } else { + secsleft = prog->eta; + } + if ((secs = secsleft / SECSPERHOUR) > 0) { + (void) snprintf(hours, sizeof(hours), "%2lld:", (long long)secs); + } else { + (void) snprintf(hours, sizeof(hours), " "); + } + secs = secsleft % SECSPERHOUR; + len = snprintf(buf, sizeof(buf), + "\r%s %3lld%% |%.*s%*s| %5lld %-3s %3lld.%02d %.2sB/s %s%02d:%02d ETA", + (prog->prefix) ? prog->prefix : "", + (long long)prog->percent, + (int)starc, stars, (int)(barlength - starc), "", + (long long)abbrevsize, + suffixes[bytesabbrev], + (long long)(bytespersec / 1024), + (int)((bytespersec % 1024) * 100 / 1024), + suffixes[bpsabbrev], + hours, + (int)secs / 60, (int)secs % 60); + return (int)write(STDOUT_FILENO, buf, len); +} Copied: stable/9/sbin/camcontrol/progress.h (from r237285, head/sbin/camcontrol/progress.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/9/sbin/camcontrol/progress.h Fri Jun 29 03:37:23 2012 (r237740, copy of r237285, head/sbin/camcontrol/progress.h) @@ -0,0 +1,60 @@ +/* $NetBSD: progressbar.c,v 1.21 2009/04/12 10:18:52 lukem Exp $ */ + +/*- + * Copyright (c) 1997-2012 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Luke Mewburn. + * + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef PROGRESS_H_ +#define PROGRESS_H_ 20100228 + +#include + +#include + +/* structure used to display a progress meter */ +typedef struct progress_t { + char *prefix; /* any prefix explanation */ + uint64_t size; /* total of bytes/units to be counted */ + uint64_t done; /* number of units counted to date */ + uint64_t percent; /* cache the percentage complete */ + time_t start; /* time we started this */ + time_t now; /* time now */ + time_t eta; /* estimated # of secs until completion */ + int64_t elapsed; /* cached # of elapsed seconds */ + int32_t ttywidth; /* width of tty in columns */ +} progress_t; + +int progress_init(progress_t */*meter*/, const char */*prefix*/, uint64_t /*size*/); +int progress_update(progress_t */*meter*/, uint64_t /*done*/); +int progress_draw(progress_t */*meter*/); +int progress_reset_size(progress_t */*meter*/, uint64_t /*size*/); +int progress_complete(progress_t */*meter*/, uint64_t /*done*/); + +#endif Modified: stable/9/sbin/camcontrol/util.c ============================================================================== --- stable/9/sbin/camcontrol/util.c Fri Jun 29 03:03:42 2012 (r237739) +++ stable/9/sbin/camcontrol/util.c Fri Jun 29 03:37:23 2012 (r237740) @@ -154,3 +154,31 @@ arg_put(void *hook __unused, int letter, if (verbose) putchar('\n'); } + +/* + * Get confirmation from user + * Return values: + * 1: confirmed + * 0: unconfirmed + */ +int +get_confirmation(void) +{ + char str[1024]; + int response = -1; + + do { + fprintf(stdout, "Are you SURE you want to do this? (yes/no) "); + if (fgets(str, sizeof(str), stdin) != NULL) { + if (strncasecmp(str, "yes", 3) == 0) + response = 1; + else if (strncasecmp(str, "no", 2) == 0) + response = 0; + else + fprintf(stdout, + "Please answer \"yes\" or \"no\"\n"); + } else + response = 0; + } while (response == -1); + return (response); +} From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 04:49:58 2012 Return-Path: Delivered-To: svn-src-stable-9@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DE9CF1065730; Fri, 29 Jun 2012 04:49:57 +0000 (UTC) (envelope-from tim@kientzle.com) Received: from monday.kientzle.com (99-115-135-74.uvs.sntcca.sbcglobal.net [99.115.135.74]) by mx1.freebsd.org (Postfix) with ESMTP id 8FC848FC0C; Fri, 29 Jun 2012 04:49:51 +0000 (UTC) Received: (from root@localhost) by monday.kientzle.com (8.14.4/8.14.4) id q5T4npSY054800; Fri, 29 Jun 2012 04:49:51 GMT (envelope-from tim@kientzle.com) Received: from [192.168.2.143] (CiscoE3000 [192.168.1.65]) by kientzle.com with SMTP id mkid99a5getb6spxz29hzfcsp6; Fri, 29 Jun 2012 04:49:51 +0000 (UTC) (envelope-from tim@kientzle.com) Mime-Version: 1.0 (Apple Message framework v1278) Content-Type: text/plain; charset=us-ascii From: Tim Kientzle In-Reply-To: <201206281310.q5SDAaFo077809@svn.freebsd.org> Date: Thu, 28 Jun 2012 21:49:50 -0700 Content-Transfer-Encoding: 7bit Message-Id: <3B21BB89-B719-4CB9-8821-C27500C8D259@kientzle.com> References: <201206281310.q5SDAaFo077809@svn.freebsd.org> To: Warren Block X-Mailer: Apple Mail (2.1278) Cc: svn-src-stable@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, svn-src-stable-9@FreeBSD.org Subject: Re: svn commit: r237708 - stable/9/share/man/man7 X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 04:49:58 -0000 On Jun 28, 2012, at 6:10 AM, Warren Block wrote: > Author: wblock (doc committer) > Date: Thu Jun 28 13:10:36 2012 > New Revision: 237708 > URL: http://svn.freebsd.org/changeset/base/237708 > > Log: > MFC r237655: > > Point out that /usr/src, /usr/doc, and /usr/ports may be empty or not > exist until populated with csup(1) or svn(1). > > PR: 169487 Probably should also cross-reference portsnap(8) here. Tim From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 06:41:04 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1C6EC106566C; Fri, 29 Jun 2012 06:41:04 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0668F8FC12; Fri, 29 Jun 2012 06:41:04 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5T6f3OY024044; Fri, 29 Jun 2012 06:41:03 GMT (envelope-from mm@svn.freebsd.org) Received: (from mm@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5T6f3uj024042; Fri, 29 Jun 2012 06:41:03 GMT (envelope-from mm@svn.freebsd.org) Message-Id: <201206290641.q5T6f3uj024042@svn.freebsd.org> From: Martin Matuska Date: Fri, 29 Jun 2012 06:41:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237746 - stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 06:41:04 -0000 Author: mm Date: Fri Jun 29 06:41:03 2012 New Revision: 237746 URL: http://svn.freebsd.org/changeset/base/237746 Log: MFC r237458: Import Illumos revision 13736:9f1d48e1681f 2901 ZFS receive fails for exabyte sparse files References: https://www.illumos.org/issues/2901 Obtained from: illumos (issue #2901) Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c ============================================================================== --- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c Fri Jun 29 06:06:19 2012 (r237745) +++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c Fri Jun 29 06:41:03 2012 (r237746) @@ -96,6 +96,9 @@ dump_free(dmu_sendarg_t *dsp, uint64_t o { struct drr_free *drrf = &(dsp->dsa_drr->drr_u.drr_free); + if (length != -1ULL && offset + length < offset) + length = -1ULL; + /* * If there is a pending op, but it's not PENDING_FREE, push it out, * since free block aggregation can only be done for blocks of the From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 09:17:50 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 554C1106564A; Fri, 29 Jun 2012 09:17:50 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 357818FC12; Fri, 29 Jun 2012 09:17:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5T9HoYR030644; Fri, 29 Jun 2012 09:17:50 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5T9HnsR030640; Fri, 29 Jun 2012 09:17:49 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201206290917.q5T9HnsR030640@svn.freebsd.org> From: Andriy Gapon Date: Fri, 29 Jun 2012 09:17:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237752 - in stable/9/sys/boot: common i386/efi sparc64/loader X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 09:17:50 -0000 Author: avg Date: Fri Jun 29 09:17:49 2012 New Revision: 237752 URL: http://svn.freebsd.org/changeset/base/237752 Log: MFC r235153: sys/boot: add common CTASSERT definition Modified: stable/9/sys/boot/common/bootstrap.h stable/9/sys/boot/i386/efi/reloc.c stable/9/sys/boot/sparc64/loader/main.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/dev/isp/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/modules/ (props changed) Modified: stable/9/sys/boot/common/bootstrap.h ============================================================================== --- stable/9/sys/boot/common/bootstrap.h Fri Jun 29 09:03:47 2012 (r237751) +++ stable/9/sys/boot/common/bootstrap.h Fri Jun 29 09:17:49 2012 (r237752) @@ -327,4 +327,10 @@ void dev_cleanup(void); time_t time(time_t *tloc); +#ifndef CTASSERT /* Allow lint to override */ +#define CTASSERT(x) _CTASSERT(x, __LINE__) +#define _CTASSERT(x, y) __CTASSERT(x, y) +#define __CTASSERT(x, y) typedef char __assert ## y[(x) ? 1 : -1] +#endif + #endif /* !_BOOTSTRAP_H_ */ Modified: stable/9/sys/boot/i386/efi/reloc.c ============================================================================== --- stable/9/sys/boot/i386/efi/reloc.c Fri Jun 29 09:03:47 2012 (r237751) +++ stable/9/sys/boot/i386/efi/reloc.c Fri Jun 29 09:17:49 2012 (r237752) @@ -30,16 +30,7 @@ __FBSDID("$FreeBSD$"); #include #include #include - -/* - * XXX: we can't include sys/systm.h. - */ -#ifndef CTASSERT /* Allow lint to override */ -#define CTASSERT(x) _CTASSERT(x, __LINE__) -#define _CTASSERT(x, y) __CTASSERT(x, y) -#define __CTASSERT(x, y) typedef char __assert ## y[(x) ? 1 : -1] -#endif - +#include /* * A simple relocator for IA32 EFI binaries. Modified: stable/9/sys/boot/sparc64/loader/main.c ============================================================================== --- stable/9/sys/boot/sparc64/loader/main.c Fri Jun 29 09:03:47 2012 (r237751) +++ stable/9/sys/boot/sparc64/loader/main.c Fri Jun 29 09:17:49 2012 (r237752) @@ -74,12 +74,6 @@ __FBSDID("$FreeBSD$"); #include "libofw.h" #include "dev_net.h" -#ifndef CTASSERT -#define CTASSERT(x) _CTASSERT(x, __LINE__) -#define _CTASSERT(x, y) __CTASSERT(x, y) -#define __CTASSERT(x, y) typedef char __assert ## y[(x) ? 1 : -1] -#endif - extern char bootprog_name[], bootprog_rev[], bootprog_date[], bootprog_maker[]; enum { From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 09:41:09 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D6231106564A; Fri, 29 Jun 2012 09:41:09 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B6BC58FC15; Fri, 29 Jun 2012 09:41:09 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5T9f9ZD031621; Fri, 29 Jun 2012 09:41:09 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5T9f9es031613; Fri, 29 Jun 2012 09:41:09 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206290941.q5T9f9es031613@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 29 Jun 2012 09:41:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237753 - in stable/9/sys: amd64/include arm/include i386/include ia64/include mips/include powerpc/include sparc64/include X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 09:41:10 -0000 Author: kib Date: Fri Jun 29 09:41:09 2012 New Revision: 237753 URL: http://svn.freebsd.org/changeset/base/237753 Log: MFC r237430: Reserve AT_TIMEKEEP auxv entry for providing usermode the pointer to timekeeping information. Modified: stable/9/sys/amd64/include/elf.h stable/9/sys/arm/include/elf.h stable/9/sys/i386/include/elf.h stable/9/sys/ia64/include/elf.h stable/9/sys/mips/include/elf.h stable/9/sys/powerpc/include/elf.h stable/9/sys/sparc64/include/elf.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/amd64/include/elf.h ============================================================================== --- stable/9/sys/amd64/include/elf.h Fri Jun 29 09:17:49 2012 (r237752) +++ stable/9/sys/amd64/include/elf.h Fri Jun 29 09:41:09 2012 (r237753) @@ -94,6 +94,7 @@ __ElfType(Auxinfo); #define AT_NCPUS 19 /* Number of CPUs. */ #define AT_PAGESIZES 20 /* Pagesizes. */ #define AT_PAGESIZESLEN 21 /* Number of pagesizes. */ +#define AT_TIMEKEEP 22 /* Pointer to timehands. */ #define AT_STACKPROT 23 /* Initial stack protection. */ #define AT_COUNT 24 /* Count of defined aux entry types. */ Modified: stable/9/sys/arm/include/elf.h ============================================================================== --- stable/9/sys/arm/include/elf.h Fri Jun 29 09:17:49 2012 (r237752) +++ stable/9/sys/arm/include/elf.h Fri Jun 29 09:41:09 2012 (r237753) @@ -82,6 +82,7 @@ __ElfType(Auxinfo); #define AT_NCPUS 19 /* Number of CPUs. */ #define AT_PAGESIZES 20 /* Pagesizes. */ #define AT_PAGESIZESLEN 21 /* Number of pagesizes. */ +#define AT_TIMEKEEP 22 /* Pointer to timehands. */ #define AT_STACKPROT 23 /* Initial stack protection. */ #define AT_COUNT 24 /* Count of defined aux entry types. */ Modified: stable/9/sys/i386/include/elf.h ============================================================================== --- stable/9/sys/i386/include/elf.h Fri Jun 29 09:17:49 2012 (r237752) +++ stable/9/sys/i386/include/elf.h Fri Jun 29 09:41:09 2012 (r237753) @@ -96,6 +96,7 @@ __ElfType(Auxinfo); #define AT_NCPUS 19 /* Number of CPUs. */ #define AT_PAGESIZES 20 /* Pagesizes. */ #define AT_PAGESIZESLEN 21 /* Number of pagesizes. */ +#define AT_TIMEKEEP 22 /* Pointer to timehands. */ #define AT_STACKPROT 23 /* Initial stack protection. */ #define AT_COUNT 24 /* Count of defined aux entry types. */ Modified: stable/9/sys/ia64/include/elf.h ============================================================================== --- stable/9/sys/ia64/include/elf.h Fri Jun 29 09:17:49 2012 (r237752) +++ stable/9/sys/ia64/include/elf.h Fri Jun 29 09:41:09 2012 (r237753) @@ -95,6 +95,7 @@ __ElfType(Auxinfo); #define AT_NCPUS 19 /* Number of CPUs. */ #define AT_PAGESIZES 20 /* Pagesizes. */ #define AT_PAGESIZESLEN 21 /* Number of pagesizes. */ +#define AT_TIMEKEEP 22 /* Pointer to timehands. */ #define AT_STACKPROT 23 /* Initial stack protection. */ #define AT_COUNT 24 /* Count of defined aux entry types. */ Modified: stable/9/sys/mips/include/elf.h ============================================================================== --- stable/9/sys/mips/include/elf.h Fri Jun 29 09:17:49 2012 (r237752) +++ stable/9/sys/mips/include/elf.h Fri Jun 29 09:41:09 2012 (r237753) @@ -257,6 +257,7 @@ __ElfType(Auxinfo); #define AT_NCPUS 19 /* Number of CPUs. */ #define AT_PAGESIZES 20 /* Pagesizes. */ #define AT_PAGESIZESLEN 21 /* Number of pagesizes. */ +#define AT_TIMEKEEP 22 /* Pointer to timehands. */ #define AT_STACKPROT 23 /* Initial stack protection. */ #define AT_COUNT 24 /* Count of defined aux entry types. */ Modified: stable/9/sys/powerpc/include/elf.h ============================================================================== --- stable/9/sys/powerpc/include/elf.h Fri Jun 29 09:17:49 2012 (r237752) +++ stable/9/sys/powerpc/include/elf.h Fri Jun 29 09:41:09 2012 (r237753) @@ -106,8 +106,9 @@ __ElfType(Auxinfo); #define AT_PAGESIZES 18 /* Pagesizes. */ #define AT_PAGESIZESLEN 19 /* Number of pagesizes. */ #define AT_STACKPROT 21 /* Initial stack protection. */ +#define AT_TIMEKEEP 22 /* Pointer to timehands. */ -#define AT_COUNT 22 /* Count of defined aux entry types. */ +#define AT_COUNT 23 /* Count of defined aux entry types. */ /* * Relocation types. Modified: stable/9/sys/sparc64/include/elf.h ============================================================================== --- stable/9/sys/sparc64/include/elf.h Fri Jun 29 09:17:49 2012 (r237752) +++ stable/9/sys/sparc64/include/elf.h Fri Jun 29 09:41:09 2012 (r237753) @@ -90,6 +90,7 @@ __ElfType(Auxinfo); #define AT_NCPUS 19 /* Number of CPUs. */ #define AT_PAGESIZES 20 /* Pagesizes. */ #define AT_PAGESIZESLEN 21 /* Number of pagesizes. */ +#define AT_TIMEKEEP 22 /* Pointer to timehands. */ #define AT_STACKPROT 23 /* Initial stack protection. */ #define AT_COUNT 24 /* Count of defined aux entry types. */ From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 10:01:57 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4F0A61065672; Fri, 29 Jun 2012 10:01:57 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3787D8FC0A; Fri, 29 Jun 2012 10:01:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5TA1vgU032703; Fri, 29 Jun 2012 10:01:57 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5TA1uBd032693; Fri, 29 Jun 2012 10:01:56 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201206291001.q5TA1uBd032693@svn.freebsd.org> From: Andriy Gapon Date: Fri, 29 Jun 2012 10:01:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237756 - in stable/9/sys/boot/i386: btx/btx btx/btxldr btx/lib common loader zfsboot X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 10:01:57 -0000 Author: avg Date: Fri Jun 29 10:01:56 2012 New Revision: 237756 URL: http://svn.freebsd.org/changeset/base/237756 Log: MFC r235154,r235158: btxldr: future-proof argument passing from boot1/2-ish to loader Added: stable/9/sys/boot/i386/btx/lib/btxcsu.S - copied unchanged from r235154, head/sys/boot/i386/btx/lib/btxcsu.S stable/9/sys/boot/i386/common/bootargs.h - copied unchanged from r235154, head/sys/boot/i386/common/bootargs.h Deleted: stable/9/sys/boot/i386/btx/lib/btxcsu.s Modified: stable/9/sys/boot/i386/btx/btx/Makefile stable/9/sys/boot/i386/btx/btx/btx.S stable/9/sys/boot/i386/btx/btxldr/Makefile stable/9/sys/boot/i386/btx/btxldr/btxldr.S stable/9/sys/boot/i386/btx/lib/Makefile stable/9/sys/boot/i386/loader/main.c stable/9/sys/boot/i386/zfsboot/zfsboot.c Directory Properties: stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) Modified: stable/9/sys/boot/i386/btx/btx/Makefile ============================================================================== --- stable/9/sys/boot/i386/btx/btx/Makefile Fri Jun 29 10:01:52 2012 (r237755) +++ stable/9/sys/boot/i386/btx/btx/Makefile Fri Jun 29 10:01:56 2012 (r237756) @@ -12,6 +12,7 @@ BOOT_BTX_FLAGS=0x0 .endif CFLAGS+=-DBTX_FLAGS=${BOOT_BTX_FLAGS} +CFLAGS+=-I${.CURDIR}/../../common .if defined(BTX_SERIAL) BOOT_COMCONSOLE_PORT?= 0x3f8 Modified: stable/9/sys/boot/i386/btx/btx/btx.S ============================================================================== --- stable/9/sys/boot/i386/btx/btx/btx.S Fri Jun 29 10:01:52 2012 (r237755) +++ stable/9/sys/boot/i386/btx/btx/btx.S Fri Jun 29 10:01:56 2012 (r237756) @@ -15,6 +15,8 @@ * $FreeBSD$ */ +#include + /* * Memory layout. */ @@ -205,7 +207,7 @@ init.8: xorl %ecx,%ecx # Zero movl $MEM_USR,%edx # User base address movzwl %ss:BDA_MEM,%eax # Get free memory shll $0xa,%eax # To bytes - subl $0x1000,%eax # Less arg space + subl $ARGSPACE,%eax # Less arg space subl %edx,%eax # Less base movb $SEL_UDATA,%cl # User data selector pushl %ecx # Set SS Modified: stable/9/sys/boot/i386/btx/btxldr/Makefile ============================================================================== --- stable/9/sys/boot/i386/btx/btxldr/Makefile Fri Jun 29 10:01:52 2012 (r237755) +++ stable/9/sys/boot/i386/btx/btxldr/Makefile Fri Jun 29 10:01:56 2012 (r237756) @@ -6,6 +6,7 @@ NO_MAN= SRCS= btxldr.S CFLAGS+=-DLOADER_ADDRESS=${LOADER_ADDRESS} +CFLAGS+=-I${.CURDIR}/../../common .if defined(BTXLDR_VERBOSE) CFLAGS+=-DBTXLDR_VERBOSE Modified: stable/9/sys/boot/i386/btx/btxldr/btxldr.S ============================================================================== --- stable/9/sys/boot/i386/btx/btxldr/btxldr.S Fri Jun 29 10:01:52 2012 (r237755) +++ stable/9/sys/boot/i386/btx/btxldr/btxldr.S Fri Jun 29 10:01:56 2012 (r237756) @@ -15,6 +15,8 @@ * $FreeBSD$ */ +#include + #define RBX_MUTE 0x10 /* -m */ #define OPT_SET(opt) (1 << (opt)) @@ -89,7 +91,7 @@ start: cld # String ops inc call hexout # stack call putstr # pointer movl $m_args,%esi # Format string - leal 0x4(%esp,1),%ebx # First argument + leal 0x4(%esp),%ebx # First argument movl $0x6,%ecx # Count start.1: movl (%ebx),%eax # Get argument and addl $0x4,%ebx # bump pointer @@ -97,24 +99,28 @@ start.1: movl (%ebx),%eax # Get argumen loop start.1 # Till done call putstr # End message #endif - movl $0x48,%ecx # Allocate space - subl %ecx,%ebp # for bootinfo - movl 0x18(%esp,1),%esi # Source: bootinfo + movl BA_BOOTINFO+4(%esp),%esi # Source: bootinfo cmpl $0x0, %esi # If the bootinfo pointer je start_null_bi # is null, don't copy it + movl BI_SIZE(%esi),%ecx # Allocate space + subl %ecx,%ebp # for bootinfo movl %ebp,%edi # Destination rep # Copy movsb # it - movl %ebp,0x18(%esp,1) # Update pointer + movl %ebp,BA_BOOTINFO+4(%esp) # Update pointer + movl %edi,%ebp # Restore base pointer #ifdef BTXLDR_VERBOSE movl $m_rel_bi,%esi # Display movl %ebp,%eax # bootinfo call hexout # relocation call putstr # message #endif -start_null_bi: movl $0x18,%ecx # Allocate space - subl %ecx,%ebp # for arguments - leal 0x4(%esp,1),%esi # Source +start_null_bi: movl $BOOTARGS_SIZE,%ecx # Fixed size of arguments + testl $KARGS_FLAGS_EXTARG, BA_BOOTFLAGS+4(%esp) # Check for extra data + jz start_fixed # Skip if the flag is not set + addl BOOTARGS_SIZE+4(%esp),%ecx # Add size of variable args +start_fixed: subl $ARGOFF,%ebp # Place args at fixed offset + leal 0x4(%esp),%esi # Source movl %ebp,%edi # Destination rep # Copy movsb # them Modified: stable/9/sys/boot/i386/btx/lib/Makefile ============================================================================== --- stable/9/sys/boot/i386/btx/lib/Makefile Fri Jun 29 10:01:52 2012 (r237755) +++ stable/9/sys/boot/i386/btx/lib/Makefile Fri Jun 29 10:01:56 2012 (r237756) @@ -3,7 +3,8 @@ PROG= crt0.o INTERNALPROG= NO_MAN= -SRCS= btxcsu.s btxsys.s btxv86.s +SRCS= btxcsu.S btxsys.s btxv86.s +CFLAGS+=-I${.CURDIR}/../../common LDFLAGS=-Wl,-r .include Copied: stable/9/sys/boot/i386/btx/lib/btxcsu.S (from r235154, head/sys/boot/i386/btx/lib/btxcsu.S) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/9/sys/boot/i386/btx/lib/btxcsu.S Fri Jun 29 10:01:56 2012 (r237756, copy of r235154, head/sys/boot/i386/btx/lib/btxcsu.S) @@ -0,0 +1,49 @@ +# +# Copyright (c) 1998 Robert Nordier +# All rights reserved. +# +# Redistribution and use in source and binary forms are freely +# permitted provided that the above copyright notice and this +# paragraph and the following disclaimer are duplicated in all +# such forms. +# +# This software is provided "AS IS" and without any express or +# implied warranties, including, without limitation, the implied +# warranties of merchantability and fitness for a particular +# purpose. +# + +# $FreeBSD$ + +#include + +# +# BTX C startup code (ELF). +# + +# +# Globals. +# + .global _start +# +# Client entry point. +# +_start: cld + pushl %eax + movl $_edata,%edi + movl $_end,%ecx + subl %edi, %ecx + xorb %al, %al + rep + stosb + popl __base + movl %esp,%eax # Set + addl $ARGADJ,%eax # argument + movl %eax,__args # pointer + call main # Invoke client main() + call exit # Invoke client exit() +# +# Data. +# + .comm __base,4 # Client base address + .comm __args,4 # Client arguments Copied: stable/9/sys/boot/i386/common/bootargs.h (from r235154, head/sys/boot/i386/common/bootargs.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/9/sys/boot/i386/common/bootargs.h Fri Jun 29 10:01:56 2012 (r237756, copy of r235154, head/sys/boot/i386/common/bootargs.h) @@ -0,0 +1,69 @@ +/*- + * Copyright (c) 2012 Andriy Gapon + * All rights reserved. + * + * Redistribution and use in source and binary forms are freely + * permitted provided that the above copyright notice and this + * paragraph and the following disclaimer are duplicated in all + * such forms. + * + * This software is provided "AS IS" and without any express or + * implied warranties, including, without limitation, the implied + * warranties of merchantability and fitness for a particular + * purpose. + * + * $FreeBSD$ + */ + +#ifndef _BOOT_I386_ARGS_H_ +#define _BOOT_I386_ARGS_H_ + +#define KARGS_FLAGS_CD 0x1 +#define KARGS_FLAGS_PXE 0x2 +#define KARGS_FLAGS_ZFS 0x4 +#define KARGS_FLAGS_EXTARG 0x8 /* variably sized extended argument */ + +#define BOOTARGS_SIZE 24 /* sizeof(struct bootargs) */ +#define BA_BOOTFLAGS 8 /* offsetof(struct bootargs, bootflags) */ +#define BA_BOOTINFO 20 /* offsetof(struct bootargs, bootinfo) */ +#define BI_SIZE 48 /* offsetof(struct bootinfo, bi_size) */ + +/* + * We reserve some space above BTX allocated stack for the arguments + * and certain data that could hang off them. Currently only struct bootinfo + * is supported in that category. The bootinfo is placed at the top + * of the arguments area and the actual arguments are placed at ARGOFF offset + * from the top and grow towards the top. Hopefully we have enough space + * for bootinfo and the arguments to not run into each other. + * Arguments area below ARGOFF is reserved for future use. + */ +#define ARGSPACE 0x1000 /* total size of the BTX args area */ +#define ARGOFF 0x800 /* actual args offset within the args area */ +#define ARGADJ (ARGSPACE - ARGOFF) + +#ifndef __ASSEMBLER__ + +struct bootargs +{ + uint32_t howto; + uint32_t bootdev; + uint32_t bootflags; + union { + struct { + uint32_t pxeinfo; + uint32_t reserved; + }; + uint64_t zfspool; + }; + uint32_t bootinfo; + + /* + * If KARGS_FLAGS_EXTARG is set in bootflags, then the above fields + * are followed by a uint32_t field that specifies a size of the + * extended arguments (including the size field). + */ +}; + +#endif /*__ASSEMBLER__*/ + +#endif /* !_BOOT_I386_ARGS_H_ */ Modified: stable/9/sys/boot/i386/loader/main.c ============================================================================== --- stable/9/sys/boot/i386/loader/main.c Fri Jun 29 10:01:52 2012 (r237755) +++ stable/9/sys/boot/i386/loader/main.c Fri Jun 29 10:01:56 2012 (r237756) @@ -33,34 +33,24 @@ __FBSDID("$FreeBSD$"); */ #include +#include #include #include #include #include #include "bootstrap.h" +#include "common/bootargs.h" #include "libi386/libi386.h" #include "btxv86.h" -#define KARGS_FLAGS_CD 0x1 -#define KARGS_FLAGS_PXE 0x2 -#define KARGS_FLAGS_ZFS 0x4 +CTASSERT(sizeof(struct bootargs) == BOOTARGS_SIZE); +CTASSERT(offsetof(struct bootargs, bootinfo) == BA_BOOTINFO); +CTASSERT(offsetof(struct bootargs, bootflags) == BA_BOOTFLAGS); +CTASSERT(offsetof(struct bootinfo, bi_size) == BI_SIZE); /* Arguments passed in from the boot1/boot2 loader */ -static struct -{ - u_int32_t howto; - u_int32_t bootdev; - u_int32_t bootflags; - union { - struct { - u_int32_t pxeinfo; - u_int32_t res2; - }; - uint64_t zfspool; - }; - u_int32_t bootinfo; -} *kargs; +static struct bootargs *kargs; static u_int32_t initial_howto; static u_int32_t initial_bootdev; Modified: stable/9/sys/boot/i386/zfsboot/zfsboot.c ============================================================================== --- stable/9/sys/boot/i386/zfsboot/zfsboot.c Fri Jun 29 10:01:52 2012 (r237755) +++ stable/9/sys/boot/i386/zfsboot/zfsboot.c Fri Jun 29 10:01:56 2012 (r237756) @@ -41,9 +41,7 @@ __FBSDID("$FreeBSD$"); #include "drv.h" #include "util.h" #include "cons.h" - -/* Hint to loader that we came from ZFS */ -#define KARGS_FLAGS_ZFS 0x4 +#include "bootargs.h" #define PATH_DOTCONFIG "/boot.config" #define PATH_CONFIG "/boot/config" From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 10:06:37 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E2ED91065679; Fri, 29 Jun 2012 10:06:37 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CCC1B8FC1B; Fri, 29 Jun 2012 10:06:37 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5TA6bPJ033026; Fri, 29 Jun 2012 10:06:37 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5TA6bO9033020; Fri, 29 Jun 2012 10:06:37 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201206291006.q5TA6bO9033020@svn.freebsd.org> From: Andriy Gapon Date: Fri, 29 Jun 2012 10:06:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237758 - in stable/9/sys/boot: i386/libi386 i386/zfsboot pc98/libpc98 X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 10:06:38 -0000 Author: avg Date: Fri Jun 29 10:06:37 2012 New Revision: 237758 URL: http://svn.freebsd.org/changeset/base/237758 Log: MFC r235155: i386 boot: consolidate MAXBDDEV definition Modified: stable/9/sys/boot/i386/libi386/biosdisk.c stable/9/sys/boot/i386/libi386/libi386.h stable/9/sys/boot/i386/zfsboot/zfsboot.c stable/9/sys/boot/pc98/libpc98/biosdisk.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/dev/isp/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/modules/ (props changed) Modified: stable/9/sys/boot/i386/libi386/biosdisk.c ============================================================================== --- stable/9/sys/boot/i386/libi386/biosdisk.c Fri Jun 29 10:04:23 2012 (r237757) +++ stable/9/sys/boot/i386/libi386/biosdisk.c Fri Jun 29 10:06:37 2012 (r237758) @@ -55,7 +55,6 @@ __FBSDID("$FreeBSD$"); #define BIOS_NUMDRIVES 0x475 #define BIOSDISK_SECSIZE 512 #define BUFSIZE (1 * BIOSDISK_SECSIZE) -#define MAXBDDEV MAXDEV #define DT_ATAPI 0x10 /* disk type for ATAPI floppies */ #define WDMAJOR 0 /* major numbers for devices we frontend for */ Modified: stable/9/sys/boot/i386/libi386/libi386.h ============================================================================== --- stable/9/sys/boot/i386/libi386/libi386.h Fri Jun 29 10:04:23 2012 (r237757) +++ stable/9/sys/boot/i386/libi386/libi386.h Fri Jun 29 10:06:37 2012 (r237758) @@ -58,7 +58,8 @@ int i386_setcurrdev(struct env_var *ev, extern struct devdesc currdev; /* our current device */ -#define MAXDEV 31 /* maximum number of distinct devices */ +#define MAXDEV 31 /* maximum number of distinct devices */ +#define MAXBDDEV MAXDEV /* exported devices XXX rename? */ extern struct devsw bioscd; Modified: stable/9/sys/boot/i386/zfsboot/zfsboot.c ============================================================================== --- stable/9/sys/boot/i386/zfsboot/zfsboot.c Fri Jun 29 10:04:23 2012 (r237757) +++ stable/9/sys/boot/i386/zfsboot/zfsboot.c Fri Jun 29 10:06:37 2012 (r237758) @@ -61,8 +61,6 @@ __FBSDID("$FreeBSD$"); #define TYPE_MAXHARD TYPE_DA #define TYPE_FD 2 -#define MAXBDDEV 31 - extern uint32_t _end; #ifdef GPT Modified: stable/9/sys/boot/pc98/libpc98/biosdisk.c ============================================================================== --- stable/9/sys/boot/pc98/libpc98/biosdisk.c Fri Jun 29 10:04:23 2012 (r237757) +++ stable/9/sys/boot/pc98/libpc98/biosdisk.c Fri Jun 29 10:06:37 2012 (r237758) @@ -52,7 +52,6 @@ __FBSDID("$FreeBSD$"); #define BIOS_NUMDRIVES 0x475 #define BIOSDISK_SECSIZE 512 #define BUFSIZE (1 * BIOSDISK_SECSIZE) -#define MAXBDDEV MAXDEV #define DT_ATAPI 0x10 /* disk type for ATAPI floppies */ #define WDMAJOR 0 /* major numbers for devices we frontend for */ From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 10:08:32 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 2172D1065670; Fri, 29 Jun 2012 10:08:32 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E70088FC08; Fri, 29 Jun 2012 10:08:31 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5TA8Vbr033189; Fri, 29 Jun 2012 10:08:31 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5TA8VeD033187; Fri, 29 Jun 2012 10:08:31 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201206291008.q5TA8VeD033187@svn.freebsd.org> From: Andriy Gapon Date: Fri, 29 Jun 2012 10:08:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237760 - stable/9/sys/boot/i386/loader X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 10:08:32 -0000 Author: avg Date: Fri Jun 29 10:08:31 2012 New Revision: 237760 URL: http://svn.freebsd.org/changeset/base/237760 Log: MFC r235156: i386 zfsloader: rename LIBZFS to LIBZFSBOOT Modified: stable/9/sys/boot/i386/loader/Makefile Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/dev/isp/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/modules/ (props changed) Modified: stable/9/sys/boot/i386/loader/Makefile ============================================================================== --- stable/9/sys/boot/i386/loader/Makefile Fri Jun 29 10:07:16 2012 (r237759) +++ stable/9/sys/boot/i386/loader/Makefile Fri Jun 29 10:08:31 2012 (r237760) @@ -20,9 +20,7 @@ LIBFIREWIRE= ${.OBJDIR}/../libfirewire/l # Set by zfsloader Makefile .if defined(LOADER_ZFS_SUPPORT) CFLAGS+= -DLOADER_ZFS_SUPPORT -LIBZFS= ${.OBJDIR}/../../zfs/libzfsboot.a -.else -LIBZFS= +LIBZFSBOOT= ${.OBJDIR}/../../zfs/libzfsboot.a .endif # Enable PXE TFTP or NFS support, not both. @@ -119,8 +117,8 @@ FILES+= menu.rc # XXX crt0.o needs to be first for pxeboot(8) to work OBJS= ${BTXCRT} -DPADD= ${LIBFICL} ${LIBFIREWIRE} ${LIBZFS} ${LIBI386} ${LIBSTAND} -LDADD= ${LIBFICL} ${LIBFIREWIRE} ${LIBZFS} ${LIBI386} ${LIBSTAND} +DPADD= ${LIBFICL} ${LIBFIREWIRE} ${LIBZFSBOOT} ${LIBI386} ${LIBSTAND} +LDADD= ${LIBFICL} ${LIBFIREWIRE} ${LIBZFSBOOT} ${LIBI386} ${LIBSTAND} .include From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 10:10:17 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 84539106566C; Fri, 29 Jun 2012 10:10:17 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6DAFC8FC15; Fri, 29 Jun 2012 10:10:17 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5TAAHbS033465; Fri, 29 Jun 2012 10:10:17 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5TAAH0F033457; Fri, 29 Jun 2012 10:10:17 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201206291010.q5TAAH0F033457@svn.freebsd.org> From: Andriy Gapon Date: Fri, 29 Jun 2012 10:10:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237761 - in stable/9/sys/boot/i386: cdboot pxeldr X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 10:10:17 -0000 Author: avg Date: Fri Jun 29 10:10:16 2012 New Revision: 237761 URL: http://svn.freebsd.org/changeset/base/237761 Log: MFC r235219: cdboot, pxeldr: make use of bootargs.h instead of redefining flag constants Added: stable/9/sys/boot/i386/cdboot/cdboot.S - copied unchanged from r235219, head/sys/boot/i386/cdboot/cdboot.S Deleted: stable/9/sys/boot/i386/cdboot/cdboot.s Modified: stable/9/sys/boot/i386/cdboot/Makefile stable/9/sys/boot/i386/pxeldr/Makefile stable/9/sys/boot/i386/pxeldr/pxeldr.S Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/dev/isp/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/modules/ (props changed) Modified: stable/9/sys/boot/i386/cdboot/Makefile ============================================================================== --- stable/9/sys/boot/i386/cdboot/Makefile Fri Jun 29 10:08:31 2012 (r237760) +++ stable/9/sys/boot/i386/cdboot/Makefile Fri Jun 29 10:10:16 2012 (r237761) @@ -4,7 +4,9 @@ PROG= cdboot STRIP= BINMODE=${NOBINMODE} NO_MAN= -SRCS= ${PROG}.s +SRCS= ${PROG}.S + +CFLAGS+=-I${.CURDIR}/../common ORG= 0x7c00 Copied: stable/9/sys/boot/i386/cdboot/cdboot.S (from r235219, head/sys/boot/i386/cdboot/cdboot.S) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/9/sys/boot/i386/cdboot/cdboot.S Fri Jun 29 10:10:16 2012 (r237761, copy of r235219, head/sys/boot/i386/cdboot/cdboot.S) @@ -0,0 +1,597 @@ +# +# Copyright (c) 2001 John Baldwin +# 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. +# 3. Neither the name of the author nor the names of any co-contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# 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$ + +# +# This program is a freestanding boot program to load an a.out binary +# from a CD-ROM booted with no emulation mode as described by the El +# Torito standard. Due to broken BIOSen that do not load the desired +# number of sectors, we try to fit this in as small a space as possible. +# +# Basically, we first create a set of boot arguments to pass to the loaded +# binary. Then we attempt to load /boot/loader from the CD we were booted +# off of. +# + +#include + +# +# Memory locations. +# + .set MEM_PAGE_SIZE,0x1000 # memory page size, 4k + .set MEM_ARG,0x900 # Arguments at start + .set MEM_ARG_BTX,0xa100 # Where we move them to so the + # BTX client can see them + .set MEM_ARG_SIZE,0x18 # Size of the arguments + .set MEM_BTX_ADDRESS,0x9000 # where BTX lives + .set MEM_BTX_ENTRY,0x9010 # where BTX starts to execute + .set MEM_BTX_OFFSET,MEM_PAGE_SIZE # offset of BTX in the loader + .set MEM_BTX_CLIENT,0xa000 # where BTX clients live +# +# a.out header fields +# + .set AOUT_TEXT,0x04 # text segment size + .set AOUT_DATA,0x08 # data segment size + .set AOUT_BSS,0x0c # zero'd BSS size + .set AOUT_SYMBOLS,0x10 # symbol table + .set AOUT_ENTRY,0x14 # entry point + .set AOUT_HEADER,MEM_PAGE_SIZE # size of the a.out header +# +# Segment selectors. +# + .set SEL_SDATA,0x8 # Supervisor data + .set SEL_RDATA,0x10 # Real mode data + .set SEL_SCODE,0x18 # PM-32 code + .set SEL_SCODE16,0x20 # PM-16 code +# +# BTX constants +# + .set INT_SYS,0x30 # BTX syscall interrupt +# +# Constants for reading from the CD. +# + .set ERROR_TIMEOUT,0x80 # BIOS timeout on read + .set NUM_RETRIES,3 # Num times to retry + .set SECTOR_SIZE,0x800 # size of a sector + .set SECTOR_SHIFT,11 # number of place to shift + .set BUFFER_LEN,0x100 # number of sectors in buffer + .set MAX_READ,0x10000 # max we can read at a time + .set MAX_READ_SEC,MAX_READ >> SECTOR_SHIFT + .set MEM_READ_BUFFER,0x9000 # buffer to read from CD + .set MEM_VOLDESC,MEM_READ_BUFFER # volume descriptor + .set MEM_DIR,MEM_VOLDESC+SECTOR_SIZE # Lookup buffer + .set VOLDESC_LBA,0x10 # LBA of vol descriptor + .set VD_PRIMARY,1 # Primary VD + .set VD_END,255 # VD Terminator + .set VD_ROOTDIR,156 # Offset of Root Dir Record + .set DIR_LEN,0 # Offset of Dir Record length + .set DIR_EA_LEN,1 # Offset of EA length + .set DIR_EXTENT,2 # Offset of 64-bit LBA + .set DIR_SIZE,10 # Offset of 64-bit length + .set DIR_NAMELEN,32 # Offset of 8-bit name len + .set DIR_NAME,33 # Offset of dir name +# +# We expect to be loaded by the BIOS at 0x7c00 (standard boot loader entry +# point) +# + .code16 + .globl start + .org 0x0, 0x0 +# +# Program start. +# +start: cld # string ops inc + xor %ax,%ax # zero %ax + mov %ax,%ss # setup the + mov $start,%sp # stack + mov %ax,%ds # setup the + mov %ax,%es # data segments + mov %dl,drive # Save BIOS boot device + mov $msg_welcome,%si # %ds:(%si) -> welcome message + call putstr # display the welcome message +# +# Setup the arguments that the loader is expecting from boot[12] +# + mov $msg_bootinfo,%si # %ds:(%si) -> boot args message + call putstr # display the message + mov $MEM_ARG,%bx # %ds:(%bx) -> boot args + mov %bx,%di # %es:(%di) -> boot args + xor %eax,%eax # zero %eax + mov $(MEM_ARG_SIZE/4),%cx # Size of arguments in 32-bit + # dwords + rep # Clear the arguments + stosl # to zero + mov drive,%dl # Store BIOS boot device + mov %dl,0x4(%bx) # in kargs->bootdev + or $KARGS_FLAGS_CD,0x8(%bx) # kargs->bootflags |= + # KARGS_FLAGS_CD +# +# Load Volume Descriptor +# + mov $VOLDESC_LBA,%eax # Set LBA of first VD +load_vd: push %eax # Save %eax + mov $1,%dh # One sector + mov $MEM_VOLDESC,%ebx # Destination + call read # Read it in + cmpb $VD_PRIMARY,(%bx) # Primary VD? + je have_vd # Yes + pop %eax # Prepare to + inc %eax # try next + cmpb $VD_END,(%bx) # Last VD? + jne load_vd # No, read next + mov $msg_novd,%si # No VD + jmp error # Halt +have_vd: # Have Primary VD +# +# Try to look up the loader binary using the paths in the loader_paths +# array. +# + mov $loader_paths,%si # Point to start of array +lookup_path: push %si # Save file name pointer + call lookup # Try to find file + pop %di # Restore file name pointer + jnc lookup_found # Found this file + xor %al,%al # Look for next + mov $0xffff,%cx # path name by + repnz # scanning for + scasb # nul char + mov %di,%si # Point %si at next path + mov (%si),%al # Get first char of next path + or %al,%al # Is it double nul? + jnz lookup_path # No, try it. + mov $msg_failed,%si # Failed message + jmp error # Halt +lookup_found: # Found a loader file +# +# Load the binary into the buffer. Due to real mode addressing limitations +# we have to read it in 64k chunks. +# + mov DIR_SIZE(%bx),%eax # Read file length + add $SECTOR_SIZE-1,%eax # Convert length to sectors + shr $SECTOR_SHIFT,%eax + cmp $BUFFER_LEN,%eax + jbe load_sizeok + mov $msg_load2big,%si # Error message + call error +load_sizeok: movzbw %al,%cx # Num sectors to read + mov DIR_EXTENT(%bx),%eax # Load extent + xor %edx,%edx + mov DIR_EA_LEN(%bx),%dl + add %edx,%eax # Skip extended + mov $MEM_READ_BUFFER,%ebx # Read into the buffer +load_loop: mov %cl,%dh + cmp $MAX_READ_SEC,%cl # Truncate to max read size + jbe load_notrunc + mov $MAX_READ_SEC,%dh +load_notrunc: sub %dh,%cl # Update count + push %eax # Save + call read # Read it in + pop %eax # Restore + add $MAX_READ_SEC,%eax # Update LBA + add $MAX_READ,%ebx # Update dest addr + jcxz load_done # Done? + jmp load_loop # Keep going +load_done: +# +# Turn on the A20 address line +# + call seta20 # Turn A20 on +# +# Relocate the loader and BTX using a very lazy protected mode +# + mov $msg_relocate,%si # Display the + call putstr # relocation message + mov MEM_READ_BUFFER+AOUT_ENTRY,%edi # %edi is the destination + mov $(MEM_READ_BUFFER+AOUT_HEADER),%esi # %esi is + # the start of the text + # segment + mov MEM_READ_BUFFER+AOUT_TEXT,%ecx # %ecx = length of the text + # segment + push %edi # Save entry point for later + lgdt gdtdesc # setup our own gdt + cli # turn off interrupts + mov %cr0,%eax # Turn on + or $0x1,%al # protected + mov %eax,%cr0 # mode + ljmp $SEL_SCODE,$pm_start # long jump to clear the + # instruction pre-fetch queue + .code32 +pm_start: mov $SEL_SDATA,%ax # Initialize + mov %ax,%ds # %ds and + mov %ax,%es # %es to a flat selector + rep # Relocate the + movsb # text segment + add $(MEM_PAGE_SIZE - 1),%edi # pad %edi out to a new page + and $~(MEM_PAGE_SIZE - 1),%edi # for the data segment + mov MEM_READ_BUFFER+AOUT_DATA,%ecx # size of the data segment + rep # Relocate the + movsb # data segment + mov MEM_READ_BUFFER+AOUT_BSS,%ecx # size of the bss + xor %eax,%eax # zero %eax + add $3,%cl # round %ecx up to + shr $2,%ecx # a multiple of 4 + rep # zero the + stosl # bss + mov MEM_READ_BUFFER+AOUT_ENTRY,%esi # %esi -> relocated loader + add $MEM_BTX_OFFSET,%esi # %esi -> BTX in the loader + mov $MEM_BTX_ADDRESS,%edi # %edi -> where BTX needs to go + movzwl 0xa(%esi),%ecx # %ecx -> length of BTX + rep # Relocate + movsb # BTX + ljmp $SEL_SCODE16,$pm_16 # Jump to 16-bit PM + .code16 +pm_16: mov $SEL_RDATA,%ax # Initialize + mov %ax,%ds # %ds and + mov %ax,%es # %es to a real mode selector + mov %cr0,%eax # Turn off + and $~0x1,%al # protected + mov %eax,%cr0 # mode + ljmp $0,$pm_end # Long jump to clear the + # instruction pre-fetch queue +pm_end: sti # Turn interrupts back on now +# +# Copy the BTX client to MEM_BTX_CLIENT +# + xor %ax,%ax # zero %ax and set + mov %ax,%ds # %ds and %es + mov %ax,%es # to segment 0 + mov $MEM_BTX_CLIENT,%di # Prepare to relocate + mov $btx_client,%si # the simple btx client + mov $(btx_client_end-btx_client),%cx # length of btx client + rep # Relocate the + movsb # simple BTX client +# +# Copy the boot[12] args to where the BTX client can see them +# + mov $MEM_ARG,%si # where the args are at now + mov $MEM_ARG_BTX,%di # where the args are moving to + mov $(MEM_ARG_SIZE/4),%cx # size of the arguments in longs + rep # Relocate + movsl # the words +# +# Save the entry point so the client can get to it later on +# + pop %eax # Restore saved entry point + stosl # and add it to the end of + # the arguments +# +# Now we just start up BTX and let it do the rest +# + mov $msg_jump,%si # Display the + call putstr # jump message + ljmp $0,$MEM_BTX_ENTRY # Jump to the BTX entry point + +# +# Lookup the file in the path at [SI] from the root directory. +# +# Trashes: All but BX +# Returns: CF = 0 (success), BX = pointer to record +# CF = 1 (not found) +# +lookup: mov $VD_ROOTDIR+MEM_VOLDESC,%bx # Root directory record + push %si + mov $msg_lookup,%si # Display lookup message + call putstr + pop %si + push %si + call putstr + mov $msg_lookup2,%si + call putstr + pop %si +lookup_dir: lodsb # Get first char of path + cmp $0,%al # Are we done? + je lookup_done # Yes + cmp $'/',%al # Skip path separator. + je lookup_dir + dec %si # Undo lodsb side effect + call find_file # Lookup first path item + jnc lookup_dir # Try next component + mov $msg_lookupfail,%si # Not found message + call putstr + stc # Set carry + ret + jmp error +lookup_done: mov $msg_lookupok,%si # Success message + call putstr + clc # Clear carry + ret + +# +# Lookup file at [SI] in directory whose record is at [BX]. +# +# Trashes: All but returns +# Returns: CF = 0 (success), BX = pointer to record, SI = next path item +# CF = 1 (not found), SI = preserved +# +find_file: mov DIR_EXTENT(%bx),%eax # Load extent + xor %edx,%edx + mov DIR_EA_LEN(%bx),%dl + add %edx,%eax # Skip extended attributes + mov %eax,rec_lba # Save LBA + mov DIR_SIZE(%bx),%eax # Save size + mov %eax,rec_size + xor %cl,%cl # Zero length + push %si # Save +ff.namelen: inc %cl # Update length + lodsb # Read char + cmp $0,%al # Nul? + je ff.namedone # Yes + cmp $'/',%al # Path separator? + jnz ff.namelen # No, keep going +ff.namedone: dec %cl # Adjust length and save + mov %cl,name_len + pop %si # Restore +ff.load: mov rec_lba,%eax # Load LBA + mov $MEM_DIR,%ebx # Address buffer + mov $1,%dh # One sector + call read # Read directory block + incl rec_lba # Update LBA to next block +ff.scan: mov %ebx,%edx # Check for EOF + sub $MEM_DIR,%edx + cmp %edx,rec_size + ja ff.scan.1 + stc # EOF reached + ret +ff.scan.1: cmpb $0,DIR_LEN(%bx) # Last record in block? + je ff.nextblock + push %si # Save + movzbw DIR_NAMELEN(%bx),%si # Find end of string +ff.checkver: cmpb $'0',DIR_NAME-1(%bx,%si) # Less than '0'? + jb ff.checkver.1 + cmpb $'9',DIR_NAME-1(%bx,%si) # Greater than '9'? + ja ff.checkver.1 + dec %si # Next char + jnz ff.checkver + jmp ff.checklen # All numbers in name, so + # no version +ff.checkver.1: movzbw DIR_NAMELEN(%bx),%cx + cmp %cx,%si # Did we find any digits? + je ff.checkdot # No + cmpb $';',DIR_NAME-1(%bx,%si) # Check for semicolon + jne ff.checkver.2 + dec %si # Skip semicolon + mov %si,%cx + mov %cl,DIR_NAMELEN(%bx) # Adjust length + jmp ff.checkdot +ff.checkver.2: mov %cx,%si # Restore %si to end of string +ff.checkdot: cmpb $'.',DIR_NAME-1(%bx,%si) # Trailing dot? + jne ff.checklen # No + decb DIR_NAMELEN(%bx) # Adjust length +ff.checklen: pop %si # Restore + movzbw name_len,%cx # Load length of name + cmp %cl,DIR_NAMELEN(%bx) # Does length match? + je ff.checkname # Yes, check name +ff.nextrec: add DIR_LEN(%bx),%bl # Next record + adc $0,%bh + jmp ff.scan +ff.nextblock: subl $SECTOR_SIZE,rec_size # Adjust size + jnc ff.load # If subtract ok, keep going + ret # End of file, so not found +ff.checkname: lea DIR_NAME(%bx),%di # Address name in record + push %si # Save + repe cmpsb # Compare name + je ff.match # We have a winner! + pop %si # Restore + jmp ff.nextrec # Keep looking. +ff.match: add $2,%sp # Discard saved %si + clc # Clear carry + ret + +# +# Load DH sectors starting at LBA EAX into [EBX]. +# +# Trashes: EAX +# +read: push %si # Save + push %cx # Save since some BIOSs trash + mov %eax,edd_lba # LBA to read from + mov %ebx,%eax # Convert address + shr $4,%eax # to segment + mov %ax,edd_addr+0x2 # and store +read.retry: call twiddle # Entertain the user + push %dx # Save + mov $edd_packet,%si # Address Packet + mov %dh,edd_len # Set length + mov drive,%dl # BIOS Device + mov $0x42,%ah # BIOS: Extended Read + int $0x13 # Call BIOS + pop %dx # Restore + jc read.fail # Worked? + pop %cx # Restore + pop %si + ret # Return +read.fail: cmp $ERROR_TIMEOUT,%ah # Timeout? + je read.retry # Yes, Retry. +read.error: mov %ah,%al # Save error + mov $hex_error,%di # Format it + call hex8 # as hex + mov $msg_badread,%si # Display Read error message + +# +# Display error message at [SI] and halt. +# +error: call putstr # Display message +halt: hlt + jmp halt # Spin + +# +# Display a null-terminated string. +# +# Trashes: AX, SI +# +putstr: push %bx # Save +putstr.load: lodsb # load %al from %ds:(%si) + test %al,%al # stop at null + jnz putstr.putc # if the char != null, output it + pop %bx # Restore + ret # return when null is hit +putstr.putc: call putc # output char + jmp putstr.load # next char + +# +# Display a single char. +# +putc: mov $0x7,%bx # attribute for output + mov $0xe,%ah # BIOS: put_char + int $0x10 # call BIOS, print char in %al + ret # Return to caller + +# +# Output the "twiddle" +# +twiddle: push %ax # Save + push %bx # Save + mov twiddle_index,%al # Load index + mov $twiddle_chars,%bx # Address table + inc %al # Next + and $3,%al # char + mov %al,twiddle_index # Save index for next call + xlat # Get char + call putc # Output it + mov $8,%al # Backspace + call putc # Output it + pop %bx # Restore + pop %ax # Restore + ret + +# +# Enable A20. Put an upper limit on the amount of time we wait for the +# keyboard controller to get ready (65K x ISA access time). If +# we wait more than that amount, the hardware is probably +# legacy-free and simply doesn't have a keyboard controller. +# Thus, the A20 line is already enabled. +# +seta20: cli # Disable interrupts + xor %cx,%cx # Clear +seta20.1: inc %cx # Increment, overflow? + jz seta20.3 # Yes + in $0x64,%al # Get status + test $0x2,%al # Busy? + jnz seta20.1 # Yes + mov $0xd1,%al # Command: Write + out %al,$0x64 # output port +seta20.2: in $0x64,%al # Get status + test $0x2,%al # Busy? + jnz seta20.2 # Yes + mov $0xdf,%al # Enable + out %al,$0x60 # A20 +seta20.3: sti # Enable interrupts + ret # To caller + +# +# Convert AL to hex, saving the result to [EDI]. +# +hex8: pushl %eax # Save + shrb $0x4,%al # Do upper + call hex8.1 # 4 + popl %eax # Restore +hex8.1: andb $0xf,%al # Get lower 4 + cmpb $0xa,%al # Convert + sbbb $0x69,%al # to hex + das # digit + orb $0x20,%al # To lower case + stosb # Save char + ret # (Recursive) + +# +# BTX client to start btxldr +# + .code32 +btx_client: mov $(MEM_ARG_BTX-MEM_BTX_CLIENT+MEM_ARG_SIZE-4), %esi + # %ds:(%esi) -> end + # of boot[12] args + mov $(MEM_ARG_SIZE/4),%ecx # Number of words to push + std # Go backwards +push_arg: lodsl # Read argument + push %eax # Push it onto the stack + loop push_arg # Push all of the arguments + cld # In case anyone depends on this + pushl MEM_ARG_BTX-MEM_BTX_CLIENT+MEM_ARG_SIZE # Entry point of + # the loader + push %eax # Emulate a near call + mov $0x1,%eax # 'exec' system call + int $INT_SYS # BTX system call +btx_client_end: + .code16 + + .p2align 4 +# +# Global descriptor table. +# +gdt: .word 0x0,0x0,0x0,0x0 # Null entry + .word 0xffff,0x0,0x9200,0xcf # SEL_SDATA + .word 0xffff,0x0,0x9200,0x0 # SEL_RDATA + .word 0xffff,0x0,0x9a00,0xcf # SEL_SCODE (32-bit) + .word 0xffff,0x0,0x9a00,0x8f # SEL_SCODE16 (16-bit) +gdt.1: +# +# Pseudo-descriptors. +# +gdtdesc: .word gdt.1-gdt-1 # Limit + .long gdt # Base +# +# EDD Packet +# +edd_packet: .byte 0x10 # Length + .byte 0 # Reserved +edd_len: .byte 0x0 # Num to read + .byte 0 # Reserved +edd_addr: .word 0x0,0x0 # Seg:Off +edd_lba: .quad 0x0 # LBA + +drive: .byte 0 + +# +# State for searching dir +# +rec_lba: .long 0x0 # LBA (adjusted for EA) +rec_size: .long 0x0 # File size +name_len: .byte 0x0 # Length of current name + +twiddle_index: .byte 0x0 + +msg_welcome: .asciz "CD Loader 1.2\r\n\n" +msg_bootinfo: .asciz "Building the boot loader arguments\r\n" +msg_relocate: .asciz "Relocating the loader and the BTX\r\n" +msg_jump: .asciz "Starting the BTX loader\r\n" +msg_badread: .ascii "Read Error: 0x" +hex_error: .asciz "00\r\n" +msg_novd: .asciz "Could not find Primary Volume Descriptor\r\n" +msg_lookup: .asciz "Looking up " +msg_lookup2: .asciz "... " +msg_lookupok: .asciz "Found\r\n" +msg_lookupfail: .asciz "File not found\r\n" +msg_load2big: .asciz "File too big\r\n" +msg_failed: .asciz "Boot failed\r\n" +twiddle_chars: .ascii "|/-\\" +loader_paths: .asciz "/BOOT/LOADER" + .asciz "/boot/loader" + .byte 0 + Modified: stable/9/sys/boot/i386/pxeldr/Makefile ============================================================================== --- stable/9/sys/boot/i386/pxeldr/Makefile Fri Jun 29 10:08:31 2012 (r237760) +++ stable/9/sys/boot/i386/pxeldr/Makefile Fri Jun 29 10:10:16 2012 (r237761) @@ -23,6 +23,8 @@ CFLAGS+=-DPROBE_KEYBOARD CFLAGS+=-DALWAYS_SERIAL .endif +CFLAGS+=-I${.CURDIR}/../common + LOADERBIN= ${.OBJDIR}/../loader/loader.bin CLEANFILES+= ${BOOT}.tmp Modified: stable/9/sys/boot/i386/pxeldr/pxeldr.S ============================================================================== --- stable/9/sys/boot/i386/pxeldr/pxeldr.S Fri Jun 29 10:08:31 2012 (r237760) +++ stable/9/sys/boot/i386/pxeldr/pxeldr.S Fri Jun 29 10:10:16 2012 (r237761) @@ -26,6 +26,7 @@ */ #include +#include /* * Memory locations. @@ -50,11 +51,6 @@ .set AOUT_ENTRY,0x14 # entry point .set AOUT_HEADER,MEM_PAGE_SIZE # size of the a.out header /* - * Flags for kargs->bootflags - */ - .set KARGS_FLAGS_PXE,0x2 # flag to indicate booting from - # PXE loader -/* * Segment selectors. */ .set SEL_SDATA,0x8 # Supervisor data From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 10:12:18 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DF28A1065673; Fri, 29 Jun 2012 10:12:18 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C63498FC18; Fri, 29 Jun 2012 10:12:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5TACI6x038842; Fri, 29 Jun 2012 10:12:18 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5TACIxk038832; Fri, 29 Jun 2012 10:12:18 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201206291012.q5TACIxk038832@svn.freebsd.org> From: Andriy Gapon Date: Fri, 29 Jun 2012 10:12:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237763 - in stable/9/sys/boot/pc98: btx/btx btx/btxldr btx/lib cdboot loader X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 10:12:19 -0000 Author: avg Date: Fri Jun 29 10:12:18 2012 New Revision: 237763 URL: http://svn.freebsd.org/changeset/base/237763 Log: MFC r235264: MFi386: improve argument passing via btxldr Added: stable/9/sys/boot/pc98/btx/lib/btxcsu.S - copied unchanged from r235264, head/sys/boot/pc98/btx/lib/btxcsu.S stable/9/sys/boot/pc98/cdboot/cdboot.S - copied unchanged from r235264, head/sys/boot/pc98/cdboot/cdboot.S Deleted: stable/9/sys/boot/pc98/btx/lib/btxcsu.s stable/9/sys/boot/pc98/cdboot/cdboot.s Modified: stable/9/sys/boot/pc98/btx/btx/Makefile stable/9/sys/boot/pc98/btx/btx/btx.S stable/9/sys/boot/pc98/btx/btxldr/Makefile stable/9/sys/boot/pc98/btx/btxldr/btxldr.S stable/9/sys/boot/pc98/btx/lib/Makefile stable/9/sys/boot/pc98/cdboot/Makefile stable/9/sys/boot/pc98/loader/main.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/dev/isp/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/modules/ (props changed) Modified: stable/9/sys/boot/pc98/btx/btx/Makefile ============================================================================== --- stable/9/sys/boot/pc98/btx/btx/Makefile Fri Jun 29 10:10:43 2012 (r237762) +++ stable/9/sys/boot/pc98/btx/btx/Makefile Fri Jun 29 10:12:18 2012 (r237763) @@ -12,6 +12,7 @@ BOOT_BTX_FLAGS=0x0 .endif CFLAGS+=-DBTX_FLAGS=${BOOT_BTX_FLAGS} +CFLAGS+=-I${.CURDIR}/../../../i386/common .if defined(BTX_SERIAL) BOOT_COMCONSOLE_PORT?= 0x238 Modified: stable/9/sys/boot/pc98/btx/btx/btx.S ============================================================================== --- stable/9/sys/boot/pc98/btx/btx/btx.S Fri Jun 29 10:10:43 2012 (r237762) +++ stable/9/sys/boot/pc98/btx/btx/btx.S Fri Jun 29 10:12:18 2012 (r237763) @@ -15,6 +15,8 @@ * $FreeBSD$ */ +#include + /* * Memory layout. */ @@ -205,7 +207,7 @@ init.8: xorl %ecx,%ecx # Zero andl $0x7,%eax incl %eax shll $0x11,%eax # To bytes - subl $0x1000,%eax # Less arg space + subl $ARGSPACE,%eax # Less arg space subl %edx,%eax # Less base movb $SEL_UDATA,%cl # User data selector pushl %ecx # Set SS Modified: stable/9/sys/boot/pc98/btx/btxldr/Makefile ============================================================================== --- stable/9/sys/boot/pc98/btx/btxldr/Makefile Fri Jun 29 10:10:43 2012 (r237762) +++ stable/9/sys/boot/pc98/btx/btxldr/Makefile Fri Jun 29 10:12:18 2012 (r237763) @@ -6,6 +6,7 @@ NO_MAN= SRCS= btxldr.S CFLAGS+=-DLOADER_ADDRESS=${LOADER_ADDRESS} +CFLAGS+=-I${.CURDIR}/../../../i386/common .if defined(BTXLDR_VERBOSE) CFLAGS+=-DBTXLDR_VERBOSE Modified: stable/9/sys/boot/pc98/btx/btxldr/btxldr.S ============================================================================== --- stable/9/sys/boot/pc98/btx/btxldr/btxldr.S Fri Jun 29 10:10:43 2012 (r237762) +++ stable/9/sys/boot/pc98/btx/btxldr/btxldr.S Fri Jun 29 10:12:18 2012 (r237763) @@ -20,6 +20,8 @@ * real thing should probably be more flexible, and in C. */ +#include + /* * Memory locations. */ @@ -105,7 +107,7 @@ gdcwait.2: inb $0x60,%al call hexout # stack call putstr # pointer movl $m_args,%esi # Format string - leal 0x4(%esp,1),%ebx # First argument + leal 0x4(%esp),%ebx # First argument movl $0x6,%ecx # Count start.1: movl (%ebx),%eax # Get argument and addl $0x4,%ebx # bump pointer @@ -113,24 +115,28 @@ start.1: movl (%ebx),%eax # Get argumen loop start.1 # Till done call putstr # End message #endif - movl $0x48,%ecx # Allocate space - subl %ecx,%ebp # for bootinfo - movl 0x18(%esp,1),%esi # Source: bootinfo + movl BA_BOOTINFO+4(%esp),%esi # Source: bootinfo cmpl $0x0, %esi # If the bootinfo pointer je start_null_bi # is null, don't copy it + movl BI_SIZE(%esi),%ecx # Allocate space + subl %ecx,%ebp # for bootinfo movl %ebp,%edi # Destination rep # Copy movsb # it - movl %ebp,0x18(%esp,1) # Update pointer + movl %ebp,BA_BOOTINFO+4(%esp) # Update pointer + movl %edi,%ebp # Restore base pointer #ifdef BTXLDR_VERBOSE movl $m_rel_bi,%esi # Display movl %ebp,%eax # bootinfo call hexout # relocation call putstr # message #endif -start_null_bi: movl $0x18,%ecx # Allocate space - subl %ecx,%ebp # for arguments - leal 0x4(%esp,1),%esi # Source +start_null_bi: movl $BOOTARGS_SIZE,%ecx # Fixed size of arguments + testl $KARGS_FLAGS_EXTARG, BA_BOOTFLAGS+4(%esp) # Check for extra data + jz start_fixed # Skip if the flag is not set + addl BOOTARGS_SIZE+4(%esp),%ecx # Add size of variable args +start_fixed: subl $ARGOFF,%ebp # Place args at fixed offset + leal 0x4(%esp),%esi # Source movl %ebp,%edi # Destination rep # Copy movsb # them Modified: stable/9/sys/boot/pc98/btx/lib/Makefile ============================================================================== --- stable/9/sys/boot/pc98/btx/lib/Makefile Fri Jun 29 10:10:43 2012 (r237762) +++ stable/9/sys/boot/pc98/btx/lib/Makefile Fri Jun 29 10:12:18 2012 (r237763) @@ -3,7 +3,8 @@ PROG= crt0.o INTERNALPROG= NO_MAN= -SRCS= btxcsu.s btxsys.s btxv86.s +SRCS= btxcsu.S btxsys.s btxv86.s +CFLAGS+=-I${.CURDIR}/../../../i386/common LDFLAGS=-Wl,-r .include Copied: stable/9/sys/boot/pc98/btx/lib/btxcsu.S (from r235264, head/sys/boot/pc98/btx/lib/btxcsu.S) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/9/sys/boot/pc98/btx/lib/btxcsu.S Fri Jun 29 10:12:18 2012 (r237763, copy of r235264, head/sys/boot/pc98/btx/lib/btxcsu.S) @@ -0,0 +1,49 @@ +# +# Copyright (c) 1998 Robert Nordier +# All rights reserved. +# +# Redistribution and use in source and binary forms are freely +# permitted provided that the above copyright notice and this +# paragraph and the following disclaimer are duplicated in all +# such forms. +# +# This software is provided "AS IS" and without any express or +# implied warranties, including, without limitation, the implied +# warranties of merchantability and fitness for a particular +# purpose. +# + +# $FreeBSD$ + +# +# BTX C startup code (ELF). +# + +#include + +# +# Globals. +# + .global _start +# +# Client entry point. +# +_start: cld + pushl %eax + movl $_edata,%edi + movl $_end,%ecx + subl %edi, %ecx + xorb %al, %al + rep + stosb + popl __base + movl %esp,%eax # Set + addl $ARGADJ,%eax # argument + movl %eax,__args # pointer + call main # Invoke client main() + call exit # Invoke client exit() +# +# Data. +# + .comm __base,4 # Client base address + .comm __args,4 # Client arguments Modified: stable/9/sys/boot/pc98/cdboot/Makefile ============================================================================== --- stable/9/sys/boot/pc98/cdboot/Makefile Fri Jun 29 10:10:43 2012 (r237762) +++ stable/9/sys/boot/pc98/cdboot/Makefile Fri Jun 29 10:12:18 2012 (r237763) @@ -4,7 +4,9 @@ PROG= cdboot STRIP= BINMODE=${NOBINMODE} NO_MAN= -SRCS= ${PROG}.s +SRCS= ${PROG}.S + +CFLAGS+=-I${.CURDIR}/../../i386/common ORG= 0x0000 Copied: stable/9/sys/boot/pc98/cdboot/cdboot.S (from r235264, head/sys/boot/pc98/cdboot/cdboot.S) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/9/sys/boot/pc98/cdboot/cdboot.S Fri Jun 29 10:12:18 2012 (r237763, copy of r235264, head/sys/boot/pc98/cdboot/cdboot.S) @@ -0,0 +1,808 @@ +# +# Copyright (c) 2006 TAKAHASHI Yoshihiro +# Copyright (c) 2001 John Baldwin +# 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. +# 3. Neither the name of the author nor the names of any co-contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# 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$ + +#include + +# +# Basically, we first create a set of boot arguments to pass to the loaded +# binary. Then we attempt to load /boot/loader from the CD we were booted +# off of. +# + +# +# Memory locations. +# + .set STACK_OFF,0x6000 # Stack offset + .set LOAD_SEG,0x0700 # Load segment + .set LOAD_SIZE,2048 # Load size + .set DAUA,0x0584 # DA/UA + + .set MEM_PAGE_SIZE,0x1000 # memory page size, 4k + .set MEM_ARG,0x900 # Arguments at start + .set MEM_ARG_BTX,0xa100 # Where we move them to so the + # BTX client can see them + .set MEM_ARG_SIZE,0x18 # Size of the arguments + .set MEM_BTX_ADDRESS,0x9000 # where BTX lives + .set MEM_BTX_ENTRY,0x9010 # where BTX starts to execute + .set MEM_BTX_OFFSET,MEM_PAGE_SIZE # offset of BTX in the loader + .set MEM_BTX_CLIENT,0xa000 # where BTX clients live +# +# PC98 machine type from sys/pc98/pc98/pc98_machdep.h +# + .set MEM_SYS, 0xa100 # System common area segment + .set PC98_MACHINE_TYPE, 0x0620 # PC98 machine type + .set EPSON_ID, 0x0624 # EPSON machine id + + .set M_NEC_PC98, 0x0001 + .set M_EPSON_PC98, 0x0002 + .set M_NOT_H98, 0x0010 + .set M_H98, 0x0020 + .set M_NOTE, 0x0040 + .set M_NORMAL, 0x1000 + .set M_8M, 0x8000 +# +# Signature Constants +# + .set SIG1_OFF,0x1fe # Signature offset + .set SIG2_OFF,0x7fe # Signature offset +# +# a.out header fields +# + .set AOUT_TEXT,0x04 # text segment size + .set AOUT_DATA,0x08 # data segment size + .set AOUT_BSS,0x0c # zero'd BSS size + .set AOUT_SYMBOLS,0x10 # symbol table + .set AOUT_ENTRY,0x14 # entry point + .set AOUT_HEADER,MEM_PAGE_SIZE # size of the a.out header +# +# Segment selectors. +# + .set SEL_SDATA,0x8 # Supervisor data + .set SEL_RDATA,0x10 # Real mode data + .set SEL_SCODE,0x18 # PM-32 code + .set SEL_SCODE16,0x20 # PM-16 code +# +# BTX constants +# + .set INT_SYS,0x30 # BTX syscall interrupt +# +# Constants for reading from the CD. +# + .set ERROR_TIMEOUT,0x90 # BIOS timeout on read + .set NUM_RETRIES,3 # Num times to retry + .set SECTOR_SIZE,0x800 # size of a sector + .set SECTOR_SHIFT,11 # number of place to shift + .set BUFFER_LEN,0x100 # number of sectors in buffer + .set MAX_READ,0xf800 # max we can read at a time + .set MAX_READ_SEC,MAX_READ >> SECTOR_SHIFT + .set MEM_READ_BUFFER,0x9000 # buffer to read from CD + .set MEM_VOLDESC,MEM_READ_BUFFER # volume descriptor + .set MEM_DIR,MEM_VOLDESC+SECTOR_SIZE # Lookup buffer + .set VOLDESC_LBA,0x10 # LBA of vol descriptor + .set VD_PRIMARY,1 # Primary VD + .set VD_END,255 # VD Terminator + .set VD_ROOTDIR,156 # Offset of Root Dir Record + .set DIR_LEN,0 # Offset of Dir Record length + .set DIR_EA_LEN,1 # Offset of EA length + .set DIR_EXTENT,2 # Offset of 64-bit LBA + .set DIR_SIZE,10 # Offset of 64-bit length + .set DIR_NAMELEN,32 # Offset of 8-bit name len + .set DIR_NAME,33 # Offset of dir name + +# +# Program start. +# + .code16 + .globl start + +start: jmp main + + .org 4 + .ascii "IPL1 " + +main: cld + + /* Setup the stack */ + xor %ax,%ax + mov %ax,%ss + mov $STACK_OFF,%sp + + push %ecx + + /* Setup graphic screen */ + mov $0x42,%ah # 640x400 + mov $0xc0,%ch + int $0x18 + mov $0x40,%ah # graph on + int $0x18 + + /* Setup text screen */ + mov $0x0a00,%ax # 80x25 + int $0x18 + mov $0x0c,%ah # text on + int $0x18 + mov $0x13,%ah # cursor home + xor %dx,%dx + int $0x18 + mov $0x11,%ah # cursor on + int $0x18 + + /* Setup keyboard */ + mov $0x03,%ah + int $0x18 + + /* Transfer PC-9801 system common area */ + xor %ax,%ax + mov %ax,%si + mov %ax,%ds + mov %ax,%di + mov $MEM_SYS,%ax + mov %ax,%es + mov $0x0600,%cx + rep + movsb + + /* Transfer EPSON machine type */ + mov $0xfd00,%ax + mov %ax,%ds + mov (0x804),%eax + and $0x00ffffff,%eax + mov %eax,%es:(EPSON_ID) + + /* Set machine type to PC98_SYSTEM_PARAMETER */ + call machine_check + + /* Load cdboot */ + xor %ax,%ax + mov %ax,%ds + mov $0x06,%ah /* Read data */ + mov (DAUA),%al /* Read drive */ + pop %ecx /* cylinder */ + xor %dx,%dx /* head / sector */ + mov $LOAD_SEG,%bx /* Load address */ + mov %bx,%es + xor %bp,%bp + mov $LOAD_SIZE,%bx /* Load size */ + int $0x1b + mov $msg_readerr,%si + jc error + + /* Jump to cdboot */ + ljmp $LOAD_SEG,$cdboot + +# +# Set machine type to PC98_SYSTEM_PARAMETER. +# +machine_check: xor %edx,%edx + mov %dx,%ds + mov $MEM_SYS,%ax + mov %ax,%es + + /* Wait V-SYNC */ +vsync.1: inb $0x60,%al + test $0x20,%al + jnz vsync.1 +vsync.2: inb $0x60,%al + test $0x20,%al + jz vsync.2 + + /* ANK 'A' font */ + xor %al,%al + outb %al,$0xa1 + mov $0x41,%al + outb %al,$0xa3 + + /* Get 'A' font from CG window */ + push %ds + mov $0xa400,%ax + mov %ax,%ds + xor %eax,%eax + xor %bx,%bx + mov $4,%cx +font.1: add (%bx),%eax + add $4,%bx + loop font.1 + pop %ds + cmp $0x6efc58fc,%eax + jnz m_epson + +m_pc98: or $M_NEC_PC98,%edx + mov $0x0458,%bx + mov (%bx),%al + test $0x80,%al + jz m_not_h98 + or $M_H98,%edx + jmp 1f +m_epson: or $M_EPSON_PC98,%edx +m_not_h98: or $M_NOT_H98,%edx + +1: inb $0x42,%al + test $0x20,%al + jz 1f + or $M_8M,%edx + +1: mov $0x0400,%bx + mov (%bx),%al + test $0x80,%al + jz 1f + or $M_NOTE,%edx + +1: mov $PC98_MACHINE_TYPE,%bx + mov %edx,%es:(%bx) + ret + +# +# Print out the error message at [SI], wait for a keypress, and then +# reboot the machine. +# +error: call putstr + mov $msg_keypress,%si + call putstr + xor %ax,%ax # Get keypress + int $0x18 + xor %ax,%ax # CPU reset + outb %al,$0xf0 +halt: hlt + jmp halt # Spin + +# +# Display a null-terminated string at [SI]. +# +# Trashes: AX, BX, CX, DX, SI, DI +# +putstr: push %ds + push %es + mov %cs,%ax + mov %ax,%ds + mov $0xa000,%ax + mov %ax,%es + mov cursor,%di + mov $0x00e1,%bx # Attribute + mov $160,%cx +putstr.0: lodsb + testb %al,%al + jz putstr.done + cmp $0x0d,%al + jz putstr.cr + cmp $0x0a,%al + jz putstr.lf + mov %bl,%es:0x2000(%di) + stosb + inc %di + jmp putstr.move +putstr.cr: xor %dx,%dx + mov %di,%ax + div %cx + sub %dx,%di + jmp putstr.move +putstr.lf: add %cx,%di +putstr.move: mov %di,%dx + mov $0x13,%ah # Move cursor + int $0x18 + jmp putstr.0 +putstr.done: mov %di,cursor + pop %es + pop %ds + ret + +# +# Display a single char at [AL], but don't move a cursor. +# +putc: push %es + push %di + push %bx + mov $0xa000,%bx + mov %bx,%es + mov cursor,%di + mov $0xe1,%bl # Attribute + mov %bl,%es:0x2000(%di) + stosb + pop %bx + pop %di + pop %es + ret + +msg_readerr: .asciz "Read Error\r\n" +msg_keypress: .asciz "\r\nPress any key to reboot\r\n" + +/* Boot signature */ + + .org SIG1_OFF,0x90 + + .word 0xaa55 # Magic number + +# +# cdboot +# +cdboot: mov %cs,%ax + mov %ax,%ds + xor %ax,%ax + mov %ax,%es + mov %es:(DAUA),%al # Save BIOS boot device + mov %al,drive + mov %cx,cylinder # Save BIOS boot cylinder + + mov $msg_welcome,%si # %ds:(%si) -> welcome message + call putstr # display the welcome message +# +# Setup the arguments that the loader is expecting from boot[12] +# + mov $msg_bootinfo,%si # %ds:(%si) -> boot args message + call putstr # display the message + mov $MEM_ARG,%bx # %ds:(%bx) -> boot args + mov %bx,%di # %es:(%di) -> boot args + xor %eax,%eax # zero %eax + mov $(MEM_ARG_SIZE/4),%cx # Size of arguments in 32-bit + # dwords + rep # Clear the arguments + stosl # to zero + mov drive,%dl # Store BIOS boot device + mov %dl,%es:0x4(%bx) # in kargs->bootdev + or $KARGS_FLAGS_CD,%es:0x8(%bx) # kargs->bootflags |= + # KARGS_FLAGS_CD +# +# Load Volume Descriptor +# + mov $VOLDESC_LBA,%eax # Set LBA of first VD +load_vd: push %eax # Save %eax + mov $1,%dh # One sector + mov $MEM_VOLDESC,%ebx # Destination + call read # Read it in + cmpb $VD_PRIMARY,%es:(%bx) # Primary VD? + je have_vd # Yes + pop %eax # Prepare to + inc %eax # try next + cmpb $VD_END,%es:(%bx) # Last VD? + jne load_vd # No, read next + mov $msg_novd,%si # No VD + jmp error # Halt +have_vd: # Have Primary VD +# +# Try to look up the loader binary using the paths in the loader_paths +# array. +# + mov $loader_paths,%si # Point to start of array +lookup_path: push %si # Save file name pointer + call lookup # Try to find file + pop %di # Restore file name pointer + jnc lookup_found # Found this file + push %es + mov %cs,%ax + mov %ax,%es + xor %al,%al # Look for next + mov $0xffff,%cx # path name by + repnz # scanning for + scasb # nul char + pop %es + mov %di,%si # Point %si at next path + mov (%si),%al # Get first char of next path + or %al,%al # Is it double nul? + jnz lookup_path # No, try it. + mov $msg_failed,%si # Failed message + jmp error # Halt +lookup_found: # Found a loader file +# +# Load the binary into the buffer. Due to real mode addressing limitations +# we have to read it in 64k chunks. +# + mov %es:DIR_SIZE(%bx),%eax # Read file length + add $SECTOR_SIZE-1,%eax # Convert length to sectors + shr $SECTOR_SHIFT,%eax + cmp $BUFFER_LEN,%eax + jbe load_sizeok + mov $msg_load2big,%si # Error message + jmp error +load_sizeok: movzbw %al,%cx # Num sectors to read + mov %es:DIR_EXTENT(%bx),%eax # Load extent + xor %edx,%edx + mov %es:DIR_EA_LEN(%bx),%dl + add %edx,%eax # Skip extended + mov $MEM_READ_BUFFER,%ebx # Read into the buffer +load_loop: mov %cl,%dh + cmp $MAX_READ_SEC,%cl # Truncate to max read size + jbe load_notrunc + mov $MAX_READ_SEC,%dh +load_notrunc: sub %dh,%cl # Update count + push %eax # Save + call read # Read it in + pop %eax # Restore + add $MAX_READ_SEC,%eax # Update LBA + add $MAX_READ,%ebx # Update dest addr + jcxz load_done # Done? + jmp load_loop # Keep going +load_done: +# +# Turn on the A20 address line +# + xor %ax,%ax # Turn A20 on + outb %al,$0xf2 + mov $0x02,%al + outb %al,$0xf6 +# +# Relocate the loader and BTX using a very lazy protected mode +# + mov $msg_relocate,%si # Display the + call putstr # relocation message + mov %es:(MEM_READ_BUFFER+AOUT_ENTRY),%edi # %edi is the destination + mov $(MEM_READ_BUFFER+AOUT_HEADER),%esi # %esi is + # the start of the text + # segment + mov %es:(MEM_READ_BUFFER+AOUT_TEXT),%ecx # %ecx = length of the text + # segment + push %edi # Save entry point for later + lgdt gdtdesc # setup our own gdt + cli # turn off interrupts + mov %cr0,%eax # Turn on + or $0x1,%al # protected + mov %eax,%cr0 # mode + ljmp $SEL_SCODE,$pm_start # long jump to clear the + # instruction pre-fetch queue + .code32 +pm_start: mov $SEL_SDATA,%ax # Initialize + mov %ax,%ds # %ds and + mov %ax,%es # %es to a flat selector + rep # Relocate the + movsb # text segment + add $(MEM_PAGE_SIZE - 1),%edi # pad %edi out to a new page + and $~(MEM_PAGE_SIZE - 1),%edi # for the data segment + mov MEM_READ_BUFFER+AOUT_DATA,%ecx # size of the data segment + rep # Relocate the + movsb # data segment + mov MEM_READ_BUFFER+AOUT_BSS,%ecx # size of the bss + xor %eax,%eax # zero %eax + add $3,%cl # round %ecx up to + shr $2,%ecx # a multiple of 4 + rep # zero the + stosl # bss + mov MEM_READ_BUFFER+AOUT_ENTRY,%esi # %esi -> relocated loader + add $MEM_BTX_OFFSET,%esi # %esi -> BTX in the loader + mov $MEM_BTX_ADDRESS,%edi # %edi -> where BTX needs to go + movzwl 0xa(%esi),%ecx # %ecx -> length of BTX + rep # Relocate + movsb # BTX + ljmp $SEL_SCODE16,$pm_16 # Jump to 16-bit PM + .code16 +pm_16: mov $SEL_RDATA,%ax # Initialize + mov %ax,%ds # %ds and + mov %ax,%es # %es to a real mode selector + mov %cr0,%eax # Turn off + and $~0x1,%al # protected + mov %eax,%cr0 # mode + ljmp $LOAD_SEG,$pm_end # Long jump to clear the + # instruction pre-fetch queue +pm_end: sti # Turn interrupts back on now +# +# Copy the BTX client to MEM_BTX_CLIENT +# + mov %cs,%ax + mov %ax,%ds + xor %ax,%ax + mov %ax,%es + mov $MEM_BTX_CLIENT,%di # Prepare to relocate + mov $btx_client,%si # the simple btx client + mov $(btx_client_end-btx_client),%cx # length of btx client + rep # Relocate the + movsb # simple BTX client +# +# Copy the boot[12] args to where the BTX client can see them +# + xor %ax,%ax + mov %ax,%ds + mov $MEM_ARG,%si # where the args are at now + mov $MEM_ARG_BTX,%di # where the args are moving to + mov $(MEM_ARG_SIZE/4),%cx # size of the arguments in longs + rep # Relocate + movsl # the words +# +# Save the entry point so the client can get to it later on +# + pop %eax # Restore saved entry point + stosl # and add it to the end of + # the arguments +# +# Now we just start up BTX and let it do the rest +# + mov $msg_jump,%si # Display the + call putstr # jump message + ljmp $0,$MEM_BTX_ENTRY # Jump to the BTX entry point + +# +# Lookup the file in the path at [SI] from the root directory. +# +# Trashes: All but BX +# Returns: CF = 0 (success), BX = pointer to record +# CF = 1 (not found) +# +lookup: mov $VD_ROOTDIR+MEM_VOLDESC,%bx # Root directory record + push %bx + push %si + mov $msg_lookup,%si # Display lookup message + call putstr + pop %si + push %si + call putstr + mov $msg_lookup2,%si + call putstr + pop %si + pop %bx +lookup_dir: lodsb # Get first char of path + cmp $0,%al # Are we done? + je lookup_done # Yes + cmp $'/',%al # Skip path separator. + je lookup_dir + dec %si # Undo lodsb side effect + call find_file # Lookup first path item + jnc lookup_dir # Try next component + mov $msg_lookupfail,%si # Not found message + push %bx + call putstr + pop %bx + stc # Set carry + ret +lookup_done: mov $msg_lookupok,%si # Success message + push %bx + call putstr + pop %bx + clc # Clear carry + ret + +# +# Lookup file at [SI] in directory whose record is at [BX]. +# +# Trashes: All but returns +# Returns: CF = 0 (success), BX = pointer to record, SI = next path item +# CF = 1 (not found), SI = preserved +# +find_file: mov %es:DIR_EXTENT(%bx),%eax # Load extent + xor %edx,%edx + mov %es:DIR_EA_LEN(%bx),%dl + add %edx,%eax # Skip extended attributes + mov %eax,rec_lba # Save LBA + mov %es:DIR_SIZE(%bx),%eax # Save size + mov %eax,rec_size + xor %cl,%cl # Zero length + push %si # Save +ff.namelen: inc %cl # Update length + lodsb # Read char + cmp $0,%al # Nul? + je ff.namedone # Yes + cmp $'/',%al # Path separator? + jnz ff.namelen # No, keep going +ff.namedone: dec %cl # Adjust length and save + mov %cl,name_len + pop %si # Restore +ff.load: mov rec_lba,%eax # Load LBA + mov $MEM_DIR,%ebx # Address buffer + mov $1,%dh # One sector + call read # Read directory block + incl rec_lba # Update LBA to next block +ff.scan: mov %ebx,%edx # Check for EOF + sub $MEM_DIR,%edx + cmp %edx,rec_size + ja ff.scan.1 + stc # EOF reached + ret +ff.scan.1: cmpb $0,%es:DIR_LEN(%bx) # Last record in block? + je ff.nextblock + push %si # Save + movzbw %es:DIR_NAMELEN(%bx),%si # Find end of string +ff.checkver: cmpb $'0',%es:DIR_NAME-1(%bx,%si) # Less than '0'? + jb ff.checkver.1 + cmpb $'9',%es:DIR_NAME-1(%bx,%si) # Greater than '9'? + ja ff.checkver.1 + dec %si # Next char + jnz ff.checkver + jmp ff.checklen # All numbers in name, so + # no version +ff.checkver.1: movzbw %es:DIR_NAMELEN(%bx),%cx + cmp %cx,%si # Did we find any digits? + je ff.checkdot # No + cmpb $';',%es:DIR_NAME-1(%bx,%si) # Check for semicolon + jne ff.checkver.2 + dec %si # Skip semicolon + mov %si,%cx + mov %cl,%es:DIR_NAMELEN(%bx) # Adjust length + jmp ff.checkdot +ff.checkver.2: mov %cx,%si # Restore %si to end of string +ff.checkdot: cmpb $'.',%es:DIR_NAME-1(%bx,%si) # Trailing dot? + jne ff.checklen # No + decb %es:DIR_NAMELEN(%bx) # Adjust length +ff.checklen: pop %si # Restore + movzbw name_len,%cx # Load length of name + cmp %cl,%es:DIR_NAMELEN(%bx) # Does length match? + je ff.checkname # Yes, check name +ff.nextrec: add %es:DIR_LEN(%bx),%bl # Next record + adc $0,%bh + jmp ff.scan +ff.nextblock: subl $SECTOR_SIZE,rec_size # Adjust size + jnc ff.load # If subtract ok, keep going + ret # End of file, so not found +ff.checkname: lea DIR_NAME(%bx),%di # Address name in record + push %si # Save + repe cmpsb # Compare name + je ff.match # We have a winner! + pop %si # Restore + jmp ff.nextrec # Keep looking. +ff.match: add $2,%sp # Discard saved %si + clc # Clear carry + ret + +# +# Load DH sectors starting at LBA EAX into [EBX]. +# +# Trashes: EAX +# +read: push %es # Save + push %bp + push %dx + push %cx + push %ebx + mov %bx,%bp # Set destination address + and $0x000f,%bp + shr $4,%ebx + mov %bx,%es + xor %bx,%bx # Set read bytes + mov %dh,%bl + shl $SECTOR_SHIFT,%bx # 2048 bytes/sec + mov %ax,%cx # Set LBA + shr $16,%eax + mov %ax,%dx +read.retry: mov $0x06,%ah # BIOS device read + mov drive,%al + and $0x7f,%al + call twiddle # Entertain the user + int $0x1b # Call BIOS + jc read.fail # Worked? + pop %ebx # Restore + pop %cx + pop %dx + pop %bp + pop %es + ret # Return +read.fail: cmp $ERROR_TIMEOUT,%ah # Timeout? + je read.retry # Yes, Retry. +read.error: mov %ah,%al # Save error + mov $hex_error,%di # Format it + call hex8 # as hex + mov $msg_badread,%si # Display Read error message + jmp error + +# +# Output the "twiddle" +# +twiddle: push %ax # Save + push %bx # Save + mov twiddle_index,%al # Load index + mov $twiddle_chars,%bx # Address table + inc %al # Next + and $3,%al # char + mov %al,twiddle_index # Save index for next call + xlat # Get char + call putc # Output it + pop %bx # Restore + pop %ax # Restore + ret + +# +# Convert AL to hex, saving the result to [EDI]. +# +hex8: pushl %eax # Save + shrb $0x4,%al # Do upper + call hex8.1 # 4 + popl %eax # Restore +hex8.1: andb $0xf,%al # Get lower 4 + cmpb $0xa,%al # Convert + sbbb $0x69,%al # to hex + das # digit + orb $0x20,%al # To lower case + mov %al,(%di) # Save char + inc %di + ret # (Recursive) + +# +# BTX client to start btxldr +# + .code32 +btx_client: mov $(MEM_ARG_BTX-MEM_BTX_CLIENT+MEM_ARG_SIZE-4), %esi + # %ds:(%esi) -> end + # of boot[12] args + mov $(MEM_ARG_SIZE/4),%ecx # Number of words to push + std # Go backwards +push_arg: lodsl # Read argument + push %eax # Push it onto the stack + loop push_arg # Push all of the arguments + cld # In case anyone depends on this + pushl MEM_ARG_BTX-MEM_BTX_CLIENT+MEM_ARG_SIZE # Entry point of + # the loader + push %eax # Emulate a near call + mov $0x1,%eax # 'exec' system call + int $INT_SYS # BTX system call +btx_client_end: + .code16 + + .p2align 4 +# +# Global descriptor table. +# +gdt: .word 0x0,0x0,0x0,0x0 # Null entry + .word 0xffff,0x0000,0x9200,0x00cf # SEL_SDATA + .word 0xffff,0x0000,0x9200,0x0000 # SEL_RDATA + .word 0xffff,LOAD_SEG<<4,0x9a00,0x00cf # SEL_SCODE (32-bit) + .word 0xffff,LOAD_SEG<<4,0x9a00,0x008f # SEL_SCODE16 (16-bit) +gdt.1: +# +# Pseudo-descriptors. +# +gdtdesc: .word gdt.1-gdt-1 # Limit + .long LOAD_SEG<<4 + gdt # Base + +# +# BOOT device +# +drive: .byte 0 +cylinder: .word 0 + +# +# State for searching dir +# +rec_lba: .long 0x0 # LBA (adjusted for EA) +rec_size: .long 0x0 # File size +name_len: .byte 0x0 # Length of current name + +cursor: .word 0 +twiddle_index: .byte 0x0 + +msg_welcome: .asciz "CD Loader 1.2\r\n\n" +msg_bootinfo: .asciz "Building the boot loader arguments\r\n" +msg_relocate: .asciz "Relocating the loader and the BTX\r\n" +msg_jump: .asciz "Starting the BTX loader\r\n" +msg_badread: .ascii "Read Error: 0x" +hex_error: .asciz "00\r\n" +msg_novd: .asciz "Could not find Primary Volume Descriptor\r\n" +msg_lookup: .asciz "Looking up " +msg_lookup2: .asciz "... " +msg_lookupok: .asciz "Found\r\n" +msg_lookupfail: .asciz "File not found\r\n" +msg_load2big: .asciz "File too big\r\n" +msg_failed: .asciz "Boot failed\r\n" +twiddle_chars: .ascii "|/-\\" +loader_paths: .asciz "/BOOT.PC98/LOADER" + .asciz "/boot.pc98/loader" + .asciz "/BOOT/LOADER" + .asciz "/boot/loader" + .byte 0 + +/* Boot signature */ + + .org SIG2_OFF,0x90 + + .word 0xaa55 # Magic number Modified: stable/9/sys/boot/pc98/loader/main.c ============================================================================== --- stable/9/sys/boot/pc98/loader/main.c Fri Jun 29 10:10:43 2012 (r237762) +++ stable/9/sys/boot/pc98/loader/main.c Fri Jun 29 10:12:18 2012 (r237763) @@ -33,29 +33,25 @@ __FBSDID("$FreeBSD$"); */ #include +#include #include #include #include #include #include "bootstrap.h" +#include "common/bootargs.h" #include "libi386/libi386.h" #include "libpc98/libpc98.h" *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 10:19:16 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0333B1065672; Fri, 29 Jun 2012 10:19:16 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DE8498FC0A; Fri, 29 Jun 2012 10:19:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5TAJFbZ039415; Fri, 29 Jun 2012 10:19:15 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5TAJF75039397; Fri, 29 Jun 2012 10:19:15 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201206291019.q5TAJF75039397@svn.freebsd.org> From: Andriy Gapon Date: Fri, 29 Jun 2012 10:19:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237766 - in stable/9/sys: boot boot/common boot/i386/libi386 boot/i386/loader boot/i386/zfsboot boot/ofw/libofw boot/sparc64/loader boot/zfs cddl/boot/zfs X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 10:19:16 -0000 Author: avg Date: Fri Jun 29 10:19:15 2012 New Revision: 237766 URL: http://svn.freebsd.org/changeset/base/237766 Log: MFC r235329,235343,235361,235364: zfsboot/zfsloader: support accessing filesystems within a pool Added: stable/9/sys/boot/zfs/devicename_stubs.c - copied unchanged from r235329, head/sys/boot/zfs/devicename_stubs.c stable/9/sys/boot/zfs/libzfs.h - copied unchanged from r235329, head/sys/boot/zfs/libzfs.h Modified: stable/9/sys/boot/Makefile.sparc64 stable/9/sys/boot/common/bootstrap.h stable/9/sys/boot/i386/libi386/Makefile stable/9/sys/boot/i386/libi386/devicename.c stable/9/sys/boot/i386/libi386/libi386.h stable/9/sys/boot/i386/loader/conf.c stable/9/sys/boot/i386/loader/main.c stable/9/sys/boot/i386/zfsboot/zfsboot.c stable/9/sys/boot/ofw/libofw/Makefile stable/9/sys/boot/ofw/libofw/devicename.c stable/9/sys/boot/ofw/libofw/libofw.h stable/9/sys/boot/sparc64/loader/Makefile stable/9/sys/boot/sparc64/loader/main.c stable/9/sys/boot/zfs/zfs.c stable/9/sys/boot/zfs/zfsimpl.c stable/9/sys/cddl/boot/zfs/zfsimpl.h Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/dev/isp/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/modules/ (props changed) Modified: stable/9/sys/boot/Makefile.sparc64 ============================================================================== --- stable/9/sys/boot/Makefile.sparc64 Fri Jun 29 10:18:36 2012 (r237765) +++ stable/9/sys/boot/Makefile.sparc64 Fri Jun 29 10:19:15 2012 (r237766) @@ -1,3 +1,4 @@ # $FreeBSD$ SUBDIR+= ofw +SUBDIR+= zfs Modified: stable/9/sys/boot/common/bootstrap.h ============================================================================== --- stable/9/sys/boot/common/bootstrap.h Fri Jun 29 10:18:36 2012 (r237765) +++ stable/9/sys/boot/common/bootstrap.h Fri Jun 29 10:19:15 2012 (r237766) @@ -317,6 +317,9 @@ struct arch_switch #else void (*arch_loadseg)(void *eh, void *ph, uint64_t delta); #endif + + /* Probe ZFS pool(s), if needed. */ + void (*arch_zfs_probe)(void); }; extern struct arch_switch archsw; Modified: stable/9/sys/boot/i386/libi386/Makefile ============================================================================== --- stable/9/sys/boot/i386/libi386/Makefile Fri Jun 29 10:18:36 2012 (r237765) +++ stable/9/sys/boot/i386/libi386/Makefile Fri Jun 29 10:19:15 2012 (r237766) @@ -9,6 +9,8 @@ SRCS= biosacpi.c bioscd.c biosdisk.c bio elf64_freebsd.c \ i386_copy.c i386_module.c nullconsole.c pxe.c pxetramp.s \ smbios.c time.c vidconsole.c amd64_tramp.S spinconsole.c +.PATH: ${.CURDIR}/../../zfs +SRCS+= devicename_stubs.c # Enable PXE TFTP or NFS support, not both. .if defined(LOADER_TFTP_SUPPORT) Modified: stable/9/sys/boot/i386/libi386/devicename.c ============================================================================== --- stable/9/sys/boot/i386/libi386/devicename.c Fri Jun 29 10:18:36 2012 (r237765) +++ stable/9/sys/boot/i386/libi386/devicename.c Fri Jun 29 10:19:15 2012 (r237766) @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include #include "bootstrap.h" #include "libi386.h" +#include "../zfs/libzfs.h" static int i386_parsedev(struct i386_devdesc **dev, const char *devspec, const char **path); @@ -171,7 +172,6 @@ i386_parsedev(struct i386_devdesc **dev, case DEVT_CD: case DEVT_NET: - case DEVT_ZFS: unit = 0; if (*np && (*np != ':')) { @@ -192,7 +192,11 @@ i386_parsedev(struct i386_devdesc **dev, if (path != NULL) *path = (*cp == 0) ? cp : cp + 1; break; - + case DEVT_ZFS: + err = zfs_parsedev((struct zfs_devdesc *)idev, np, path); + if (err != 0) + goto fail; + break; default: err = EINVAL; goto fail; @@ -247,9 +251,10 @@ i386_fmtdev(void *vdev) break; case DEVT_NET: - case DEVT_ZFS: sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit); break; + case DEVT_ZFS: + return(zfs_fmtdev(vdev)); } return(buf); } Modified: stable/9/sys/boot/i386/libi386/libi386.h ============================================================================== --- stable/9/sys/boot/i386/libi386/libi386.h Fri Jun 29 10:18:36 2012 (r237765) +++ stable/9/sys/boot/i386/libi386/libi386.h Fri Jun 29 10:19:15 2012 (r237766) @@ -30,7 +30,8 @@ /* * i386 fully-qualified device descriptor. * Note, this must match the 'struct devdesc' declaration - * in bootstrap.h. + * in bootstrap.h and also with struct zfs_devdesc for zfs + * support. */ struct i386_devdesc { @@ -49,6 +50,12 @@ struct i386_devdesc { void *data; } bioscd; + struct + { + void *data; + uint64_t pool_guid; + uint64_t root_guid; + } zfs; } d_kind; }; Modified: stable/9/sys/boot/i386/loader/conf.c ============================================================================== --- stable/9/sys/boot/i386/loader/conf.c Fri Jun 29 10:18:36 2012 (r237765) +++ stable/9/sys/boot/i386/loader/conf.c Fri Jun 29 10:19:15 2012 (r237766) @@ -30,6 +30,9 @@ __FBSDID("$FreeBSD$"); #include #include #include "libi386/libi386.h" +#if defined(LOADER_ZFS_SUPPORT) +#include "../zfs/libzfs.h" +#endif /* * We could use linker sets for some or all of these, but @@ -50,10 +53,6 @@ __FBSDID("$FreeBSD$"); extern struct devsw fwohci; #endif -#if defined(LOADER_ZFS_SUPPORT) -extern struct devsw zfs_dev; -#endif - /* Exported for libstand */ struct devsw *devsw[] = { &bioscd, @@ -70,10 +69,6 @@ struct devsw *devsw[] = { NULL }; -#if defined(LOADER_ZFS_SUPPORT) -extern struct fs_ops zfs_fsops; -#endif - struct fs_ops *file_system[] = { &ufs_fsops, &ext2fs_fsops, Modified: stable/9/sys/boot/i386/loader/main.c ============================================================================== --- stable/9/sys/boot/i386/loader/main.c Fri Jun 29 10:18:36 2012 (r237765) +++ stable/9/sys/boot/i386/loader/main.c Fri Jun 29 10:19:15 2012 (r237766) @@ -44,6 +44,10 @@ __FBSDID("$FreeBSD$"); #include "libi386/libi386.h" #include "btxv86.h" +#ifdef LOADER_ZFS_SUPPORT +#include "../zfs/libzfs.h" +#endif + CTASSERT(sizeof(struct bootargs) == BOOTARGS_SIZE); CTASSERT(offsetof(struct bootargs, bootinfo) == BA_BOOTINFO); CTASSERT(offsetof(struct bootargs, bootflags) == BA_BOOTFLAGS); @@ -62,6 +66,9 @@ static void extract_currdev(void); static int isa_inb(int port); static void isa_outb(int port, int value); void exit(int code); +#ifdef LOADER_ZFS_SUPPORT +static void i386_zfs_probe(void); +#endif /* from vers.c */ extern char bootprog_name[], bootprog_rev[], bootprog_date[], bootprog_maker[]; @@ -153,6 +160,9 @@ main(void) archsw.arch_readin = i386_readin; archsw.arch_isainb = isa_inb; archsw.arch_isaoutb = isa_outb; +#ifdef LOADER_ZFS_SUPPORT + archsw.arch_zfs_probe = i386_zfs_probe; +#endif /* * March through the device switch probing for things. @@ -196,8 +206,11 @@ main(void) static void extract_currdev(void) { - struct i386_devdesc new_currdev; - int biosdev = -1; + struct i386_devdesc new_currdev; +#ifdef LOADER_ZFS_SUPPORT + struct zfs_boot_args *zargs; +#endif + int biosdev = -1; /* Assume we are booting from a BIOS disk by default */ new_currdev.d_dev = &biosdisk; @@ -218,6 +231,24 @@ extract_currdev(void) new_currdev.d_kind.biosdisk.partition = 0; biosdev = -1; } +#ifdef LOADER_ZFS_SUPPORT + } else if ((kargs->bootflags & KARGS_FLAGS_ZFS) != 0) { + zargs = NULL; + /* check for new style extended argument */ + if ((kargs->bootflags & KARGS_FLAGS_EXTARG) != 0) + zargs = (struct zfs_boot_args *)(kargs + 1); + + if (zargs != NULL && zargs->size >= sizeof(*zargs)) { + /* sufficient data is provided */ + new_currdev.d_kind.zfs.pool_guid = zargs->pool; + new_currdev.d_kind.zfs.root_guid = zargs->root; + } else { + /* old style zfsboot block */ + new_currdev.d_kind.zfs.pool_guid = kargs->zfspool; + new_currdev.d_kind.zfs.root_guid = 0; + } + new_currdev.d_dev = &zfs_dev; +#endif } else if ((initial_bootdev & B_MAGICMASK) != B_DEVMAGIC) { /* The passed-in boot device is bad */ new_currdev.d_kind.biosdisk.slice = -1; @@ -238,7 +269,7 @@ extract_currdev(void) biosdev = 0x80 + B_UNIT(initial_bootdev); /* assume harddisk */ } new_currdev.d_type = new_currdev.d_dev->dv_type; - + /* * If we are booting off of a BIOS disk and we didn't succeed in determining * which one we booted off of, just use disk0: as a reasonable default. @@ -249,33 +280,11 @@ extract_currdev(void) "Guessed BIOS device 0x%x not found by probes, defaulting to disk0:\n", biosdev); new_currdev.d_unit = 0; } + env_setenv("currdev", EV_VOLATILE, i386_fmtdev(&new_currdev), i386_setcurrdev, env_nounset); env_setenv("loaddev", EV_VOLATILE, i386_fmtdev(&new_currdev), env_noset, env_nounset); - -#ifdef LOADER_ZFS_SUPPORT - /* - * If we were started from a ZFS-aware boot2, we can work out - * which ZFS pool we are booting from. - */ - if (kargs->bootflags & KARGS_FLAGS_ZFS) { - /* - * Dig out the pool guid and convert it to a 'unit number' - */ - uint64_t guid; - int unit; - char devname[32]; - extern int zfs_guid_to_unit(uint64_t); - - guid = kargs->zfspool; - unit = zfs_guid_to_unit(guid); - if (unit >= 0) { - sprintf(devname, "zfs%d", unit); - setenv("currdev", devname, 1); - } - } -#endif } COMMAND_SET(reboot, "reboot", "reboot the system", command_reboot); @@ -342,3 +351,30 @@ isa_outb(int port, int value) } } +#ifdef LOADER_ZFS_SUPPORT +static void +i386_zfs_probe(void) +{ + char devname[32]; + int unit, slice; + + /* + * Open all the disks we can find and see if we can reconstruct + * ZFS pools from them. Bogusly assumes that the disks are named + * diskN, diskNpM or diskNsM. + */ + for (unit = 0; unit < MAXBDDEV; unit++) { + sprintf(devname, "disk%d:", unit); + if (zfs_probe_dev(devname, NULL) == ENXIO) + continue; + for (slice = 1; slice <= 128; slice++) { + sprintf(devname, "disk%dp%d:", unit, slice); + zfs_probe_dev(devname, NULL); + } + for (slice = 1; slice <= 4; slice++) { + sprintf(devname, "disk%ds%d:", unit, slice); + zfs_probe_dev(devname, NULL); + } + } +} +#endif Modified: stable/9/sys/boot/i386/zfsboot/zfsboot.c ============================================================================== --- stable/9/sys/boot/i386/zfsboot/zfsboot.c Fri Jun 29 10:18:36 2012 (r237765) +++ stable/9/sys/boot/i386/zfsboot/zfsboot.c Fri Jun 29 10:19:15 2012 (r237766) @@ -43,6 +43,8 @@ __FBSDID("$FreeBSD$"); #include "cons.h" #include "bootargs.h" +#include "libzfs.h" + #define PATH_DOTCONFIG "/boot.config" #define PATH_CONFIG "/boot/config" #define PATH_BOOT3 "/boot/zfsloader" @@ -91,9 +93,12 @@ static const unsigned char dev_maj[NDEV] static char cmd[512]; static char cmddup[512]; static char kname[1024]; +static char rootname[256]; static int comspeed = SIOSPD; static struct bootinfo bootinfo; static uint32_t bootdev; +static struct zfs_boot_args zfsargs; +static struct zfsmount zfsmount; vm_offset_t high_heap_base; uint32_t bios_basemem, bios_extmem, high_heap_size; @@ -170,7 +175,7 @@ zfs_read(spa_t *spa, const dnode_phys_t /* * Current ZFS pool */ -spa_t *spa; +static spa_t *spa; /* * A wrapper for dskread that doesn't have to worry about whether the @@ -209,7 +214,7 @@ static int xfsread(const dnode_phys_t *dnode, off_t *offp, void *buf, size_t nbyte) { if ((size_t)zfs_read(spa, dnode, offp, buf, nbyte) != nbyte) { - printf("Invalid %s\n", "format"); + printf("Invalid format\n"); return -1; } return 0; @@ -529,10 +534,12 @@ main(void) } } - zfs_mount_pool(spa); - - if (zfs_lookup(spa, PATH_CONFIG, &dn) == 0 || - zfs_lookup(spa, PATH_DOTCONFIG, &dn) == 0) { + if (zfs_spa_init(spa) != 0 || zfs_mount(spa, 0, &zfsmount) != 0) { + printf("%s: failed to mount default pool %s\n", + BOOTPROG, spa->spa_name); + autoboot = 0; + } else if (zfs_lookup(&zfsmount, PATH_CONFIG, &dn) == 0 || + zfs_lookup(&zfsmount, PATH_DOTCONFIG, &dn) == 0) { off = 0; zfs_read(spa, &dn, &off, cmd, sizeof(cmd)); } @@ -567,11 +574,17 @@ main(void) /* Present the user with the boot2 prompt. */ for (;;) { - if (!autoboot || !OPT_CHECK(RBX_QUIET)) - printf("\nFreeBSD/x86 boot\n" - "Default: %s:%s\n" - "boot: ", - spa->spa_name, kname); + if (!autoboot || !OPT_CHECK(RBX_QUIET)) { + printf("\nFreeBSD/x86 boot\n"); + if (zfs_rlookup(spa, zfsmount.rootobj, rootname) != 0) + printf("Default: %s:<0x%llx>:%s\n" + "boot: ", + spa->spa_name, zfsmount.rootobj, kname); + else + printf("Default: %s:%s:%s\n" + "boot: ", + spa->spa_name, rootname, kname); + } if (ioctrl & IO_SERIAL) sio_flush(); if (!autoboot || keyhit(5)) @@ -607,7 +620,8 @@ load(void) uint32_t addr, x; int fmt, i, j; - if (zfs_lookup(spa, kname, &dn)) { + if (zfs_lookup(&zfsmount, kname, &dn)) { + printf("\nCan't find %s\n", kname); return; } off = 0; @@ -681,12 +695,16 @@ load(void) } bootinfo.bi_esymtab = VTOP(p); bootinfo.bi_kernelname = VTOP(kname); + zfsargs.size = sizeof(zfsargs); + zfsargs.pool = zfsmount.spa->spa_guid; + zfsargs.root = zfsmount.rootobj; __exec((caddr_t)addr, RB_BOOTINFO | (opts & RBX_MASK), bootdev, - KARGS_FLAGS_ZFS, + KARGS_FLAGS_ZFS | KARGS_FLAGS_EXTARG, (uint32_t) spa->spa_guid, (uint32_t) (spa->spa_guid >> 32), - VTOP(&bootinfo)); + VTOP(&bootinfo), + zfsargs); } static int @@ -738,7 +756,7 @@ parse(void) } if (c == '?') { dnode_phys_t dn; - if (zfs_lookup(spa, arg, &dn) == 0) { + if (zfs_lookup(&zfsmount, arg, &dn) == 0) { zap_list(spa, &dn); } return -1; @@ -760,17 +778,32 @@ parse(void) q = (char *) strchr(arg, ':'); if (q) { spa_t *newspa; + uint64_t newroot; *q++ = 0; newspa = spa_find_by_name(arg); if (newspa) { + arg = q; spa = newspa; - zfs_mount_pool(spa); + newroot = 0; + q = (char *) strchr(arg, ':'); + if (q) { + *q++ = 0; + if (zfs_lookup_dataset(spa, arg, &newroot)) { + printf("\nCan't find dataset %s in ZFS pool %s\n", + arg, spa->spa_name); + return -1; + } + arg = q; + } + if (zfs_mount(spa, newroot, &zfsmount)) { + printf("\nCan't mount ZFS dataset\n"); + return -1; + } } else { printf("\nCan't find ZFS pool %s\n", arg); return -1; } - arg = q; } if ((i = ep - arg)) { if ((size_t)i >= sizeof(kname)) Modified: stable/9/sys/boot/ofw/libofw/Makefile ============================================================================== --- stable/9/sys/boot/ofw/libofw/Makefile Fri Jun 29 10:18:36 2012 (r237765) +++ stable/9/sys/boot/ofw/libofw/Makefile Fri Jun 29 10:19:15 2012 (r237766) @@ -6,6 +6,8 @@ INTERNALLIB= SRCS= devicename.c elf_freebsd.c ofw_console.c ofw_copy.c ofw_disk.c \ ofw_memory.c ofw_module.c ofw_net.c ofw_reboot.c \ ofw_time.c openfirm.c +.PATH: ${.CURDIR}/../../zfs +SRCS+= devicename_stubs.c CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/ Modified: stable/9/sys/boot/ofw/libofw/devicename.c ============================================================================== --- stable/9/sys/boot/ofw/libofw/devicename.c Fri Jun 29 10:18:36 2012 (r237765) +++ stable/9/sys/boot/ofw/libofw/devicename.c Fri Jun 29 10:19:15 2012 (r237766) @@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$"); #include "bootstrap.h" #include "libofw.h" +#include "../zfs/libzfs.h" static int ofw_parsedev(struct ofw_devdesc **, const char *, const char **); @@ -81,6 +82,7 @@ ofw_parsedev(struct ofw_devdesc **dev, c char *ep; char name[256]; char type[64]; + int err; int len; int i; @@ -114,14 +116,11 @@ found: idev->d_dev = dv; idev->d_type = dv->dv_type; if (idev->d_type == DEVT_ZFS) { - idev->d_unit = 0; - p = name + strlen(dv->dv_name); - if (*p && (*p != ':')) { - idev->d_unit = strtol(p, &ep, 0); - if (ep == p) { - free(idev); - return (EUNIT); - } + p = devspec + strlen(dv->dv_name); + err = zfs_parsedev((struct zfs_devdesc *)idev, p, path); + if (err != 0) { + free(idev); + return (err); } } Modified: stable/9/sys/boot/ofw/libofw/libofw.h ============================================================================== --- stable/9/sys/boot/ofw/libofw/libofw.h Fri Jun 29 10:18:36 2012 (r237765) +++ stable/9/sys/boot/ofw/libofw/libofw.h Fri Jun 29 10:19:15 2012 (r237766) @@ -33,7 +33,13 @@ struct ofw_devdesc { int d_type; int d_unit; ihandle_t d_handle; - char d_path[256]; + union { + char d_path[256]; + struct { + uint64_t pool_guid; + uint64_t root_guid; + }; + }; }; extern int ofw_getdev(void **vdev, const char *devspec, const char **path); Modified: stable/9/sys/boot/sparc64/loader/Makefile ============================================================================== --- stable/9/sys/boot/sparc64/loader/Makefile Fri Jun 29 10:18:36 2012 (r237765) +++ stable/9/sys/boot/sparc64/loader/Makefile Fri Jun 29 10:19:15 2012 (r237766) @@ -37,6 +37,7 @@ CFLAGS+= -DLOADER_CD9660_SUPPORT CFLAGS+= -DLOADER_ZFS_SUPPORT CFLAGS+= -I${.CURDIR}/../../zfs CFLAGS+= -I${.CURDIR}/../../../cddl/boot/zfs +LIBZFSBOOT= ${.OBJDIR}/../../zfs/libzfsboot.a .endif .if ${LOADER_GZIP_SUPPORT} == "yes" CFLAGS+= -DLOADER_GZIP_SUPPORT @@ -83,8 +84,8 @@ CFLAGS+= -I${.CURDIR}/../../ofw/libofw/ # where to get libstand from CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/ -DPADD= ${LIBFICL} ${LIBOFW} ${LIBSTAND} -LDADD= ${LIBFICL} ${LIBOFW} -lstand +DPADD= ${LIBFICL} ${LIBZFSBOOT} ${LIBOFW} ${LIBSTAND} +LDADD= ${LIBFICL} ${LIBZFSBOOT} ${LIBOFW} -lstand vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/../loader/version sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/../loader/version \ Modified: stable/9/sys/boot/sparc64/loader/main.c ============================================================================== --- stable/9/sys/boot/sparc64/loader/main.c Fri Jun 29 10:18:36 2012 (r237765) +++ stable/9/sys/boot/sparc64/loader/main.c Fri Jun 29 10:19:15 2012 (r237766) @@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$"); #include #ifdef LOADER_ZFS_SUPPORT #include +#include "../zfs/libzfs.h" #endif #include @@ -74,6 +75,8 @@ __FBSDID("$FreeBSD$"); #include "libofw.h" #include "dev_net.h" +#define MAXDEV 31 + extern char bootprog_name[], bootprog_rev[], bootprog_date[], bootprog_maker[]; enum { @@ -140,11 +143,6 @@ static vm_offset_t heapva; static phandle_t root; -#ifdef LOADER_ZFS_SUPPORT -static int zfs_dev_init(void); -#include "zfs.c" -#endif - /* * Machine dependent structures that the machine independent * loader part uses. @@ -731,39 +729,20 @@ tlb_init_sun4u(void) } #ifdef LOADER_ZFS_SUPPORT - -static int -zfs_dev_init(void) +static void +sparc64_zfs_probe(void) { struct vtoc8 vtoc; - char devname[512]; - spa_t *spa; - vdev_t *vdev; + struct zfs_devdesc zfs_currdev; + char devname[32]; uint64_t guid; int fd, part, unit; - zfs_init(); - - guid = 0; /* Get the GUID of the ZFS pool on the boot device. */ - fd = open(getenv("currdev"), O_RDONLY); - if (fd != -1) { - if (vdev_probe(vdev_read, (void *)(uintptr_t) fd, &spa) == 0) - guid = spa->spa_guid; - close(fd); - } - - /* Clean up the environment to let ZFS work. */ - while ((vdev = STAILQ_FIRST(&zfs_vdevs)) != NULL) { - STAILQ_REMOVE_HEAD(&zfs_vdevs, v_alllink); - free(vdev); - } - while ((spa = STAILQ_FIRST(&zfs_pools)) != NULL) { - STAILQ_REMOVE_HEAD(&zfs_pools, spa_link); - free(spa); - } + guid = 0; + zfs_probe_dev(getenv("currdev"), &guid); - for (unit = 0; unit < MAXBDDEV; unit++) { + for (unit = 0; unit < MAXDEV; unit++) { /* Find freebsd-zfs slices in the VTOC. */ sprintf(devname, "disk%d:", unit); fd = open(devname, O_RDONLY); @@ -781,29 +760,23 @@ zfs_dev_init(void) VTOC_TAG_FREEBSD_ZFS) continue; sprintf(devname, "disk%d:%c", unit, part + 'a'); - fd = open(devname, O_RDONLY); - if (fd == -1) + if (zfs_probe_dev(devname, NULL) == ENXIO) break; - - if (vdev_probe(vdev_read, (void*)(uintptr_t) fd, 0)) - close(fd); } } if (guid != 0) { - unit = zfs_guid_to_unit(guid); - if (unit >= 0) { - /* Update the environment for ZFS. */ - sprintf(devname, "zfs%d", unit); - env_setenv("currdev", EV_VOLATILE, devname, - ofw_setcurrdev, env_nounset); - env_setenv("loaddev", EV_VOLATILE, devname, - env_noset, env_nounset); - } + zfs_currdev.pool_guid = guid; + zfs_currdev.root_guid = 0; + zfs_currdev.d_dev = &zfs_dev; + zfs_currdev.d_type = zfs_currdev.d_dev->dv_type; + /* Update the environment for ZFS. */ + env_setenv("currdev", EV_VOLATILE, zfs_fmtdev(&zfs_currdev), + ofw_setcurrdev, env_nounset); + env_setenv("loaddev", EV_VOLATILE, zfs_fmtdev(&zfs_currdev), + env_noset, env_nounset); } - return (0); } - #endif /* LOADER_ZFS_SUPPORT */ int @@ -823,6 +796,9 @@ main(int (*openfirm)(void *)) archsw.arch_copyout = ofw_copyout; archsw.arch_readin = sparc64_readin; archsw.arch_autoload = sparc64_autoload; +#ifdef LOADER_ZFS_SUPPORT + archsw.arch_zfs_probe = sparc64_zfs_probe; +#endif if (init_heap() == (vm_offset_t)-1) OF_exit(); Copied: stable/9/sys/boot/zfs/devicename_stubs.c (from r235329, head/sys/boot/zfs/devicename_stubs.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/9/sys/boot/zfs/devicename_stubs.c Fri Jun 29 10:19:15 2012 (r237766, copy of r235329, head/sys/boot/zfs/devicename_stubs.c) @@ -0,0 +1,47 @@ +/*- + * Copyright (c) 2012 Andriy Gapon + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include "libzfs.h" + +__attribute__((weak)) +int +zfs_parsedev(struct zfs_devdesc *dev, const char *devspec, const char **path) +{ + return (EINVAL); +} + +__attribute__((weak)) +char * +zfs_fmtdev(void *vdev) +{ + static char buf[128]; + + return (buf); +} Copied: stable/9/sys/boot/zfs/libzfs.h (from r235329, head/sys/boot/zfs/libzfs.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/9/sys/boot/zfs/libzfs.h Fri Jun 29 10:19:15 2012 (r237766, copy of r235329, head/sys/boot/zfs/libzfs.h) @@ -0,0 +1,66 @@ +/*- + * Copyright (c) 2012 Andriy Gapon + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _BOOT_LIBZFS_H_ +#define _BOOT_LIBZFS_H_ + +#define ZFS_MAXNAMELEN 256 + +/* + * ZFS fully-qualified device descriptor. + * Note, this must match the 'struct devdesc' declaration in bootstrap.h. + * Arch-specific device descriptors should be binary compatible with this + * structure if they are to support ZFS. + */ +struct zfs_devdesc +{ + struct devsw *d_dev; + int d_type; + int d_unit; + void *d_opendata; + uint64_t pool_guid; + uint64_t root_guid; +}; + +struct zfs_boot_args +{ + uint32_t size; + uint32_t reserved; + uint64_t pool; + uint64_t root; +}; + +int zfs_parsedev(struct zfs_devdesc *dev, const char *devspec, + const char **path); +char *zfs_fmtdev(void *vdev); +int zfs_probe_dev(const char *devname, uint64_t *pool_guid); + +extern struct devsw zfs_dev; +extern struct fs_ops zfs_fsops; + +#endif /*_BOOT_LIBZFS_H_*/ Modified: stable/9/sys/boot/zfs/zfs.c ============================================================================== --- stable/9/sys/boot/zfs/zfs.c Fri Jun 29 10:18:36 2012 (r237765) +++ stable/9/sys/boot/zfs/zfs.c Fri Jun 29 10:19:15 2012 (r237766) @@ -43,9 +43,9 @@ __FBSDID("$FreeBSD$"); #include #include -#include "zfsimpl.c" +#include "libzfs.h" -#define MAXBDDEV 31 +#include "zfsimpl.c" static int zfs_open(const char *path, struct open_file *f); static int zfs_write(struct open_file *f, void *buf, size_t size, size_t *resid); @@ -56,6 +56,7 @@ static int zfs_stat(struct open_file *f, static int zfs_readdir(struct open_file *f, struct dirent *d); struct devsw zfs_dev; +struct devsw zfs_dev_compat; struct fs_ops zfs_fsops = { "zfs", @@ -85,35 +86,20 @@ struct file { static int zfs_open(const char *upath, struct open_file *f) { - spa_t *spa = (spa_t *) f->f_devdata; + struct zfsmount *mount = (struct zfsmount *)f->f_devdata; struct file *fp; int rc; - if (f->f_dev != &zfs_dev) + if (f->f_dev != &zfs_dev && f->f_dev != &zfs_dev_compat) return (EINVAL); - rc = zfs_mount_pool(spa); - if (rc) - return (rc); - /* allocate file system specific data structure */ fp = malloc(sizeof(struct file)); bzero(fp, sizeof(struct file)); f->f_fsdata = (void *)fp; - if (spa->spa_root_objset.os_type != DMU_OST_ZFS) { - printf("Unexpected object set type %llu\n", - spa->spa_root_objset.os_type); - rc = EIO; - goto out; - } - - rc = zfs_lookup(spa, upath, &fp->f_dnode); - if (rc) - goto out; - + rc = zfs_lookup(mount, upath, &fp->f_dnode); fp->f_seekp = 0; -out: if (rc) { f->f_fsdata = NULL; free(fp); @@ -142,7 +128,7 @@ zfs_close(struct open_file *f) static int zfs_read(struct open_file *f, void *start, size_t size, size_t *resid /* out */) { - spa_t *spa = (spa_t *) f->f_devdata; + spa_t *spa = ((struct zfsmount *)f->f_devdata)->spa; struct file *fp = (struct file *)f->f_fsdata; struct stat sb; size_t n; @@ -216,7 +202,7 @@ zfs_seek(struct open_file *f, off_t offs static int zfs_stat(struct open_file *f, struct stat *sb) { - spa_t *spa = (spa_t *) f->f_devdata; + spa_t *spa = ((struct zfsmount *)f->f_devdata)->spa; struct file *fp = (struct file *)f->f_fsdata; return (zfs_dnode_stat(spa, &fp->f_dnode, sb)); @@ -225,7 +211,7 @@ zfs_stat(struct open_file *f, struct sta static int zfs_readdir(struct open_file *f, struct dirent *d) { - spa_t *spa = (spa_t *) f->f_devdata; + spa_t *spa = ((struct zfsmount *)f->f_devdata)->spa; struct file *fp = (struct file *)f->f_fsdata; mzap_ent_phys_t mze; struct stat sb; @@ -381,68 +367,33 @@ vdev_read(vdev_t *vdev, void *priv, off_ } } -/* - * Convert a pool guid to a 'unit number' suitable for use with zfs_dev_open. - */ -int -zfs_guid_to_unit(uint64_t guid) +static int +zfs_dev_init(void) { - spa_t *spa; - int unit; - - unit = 0; - STAILQ_FOREACH(spa, &zfs_pools, spa_link) { - if (spa->spa_guid == guid) - return unit; - unit++; - } - return (-1); + zfs_init(); + if (archsw.arch_zfs_probe == NULL) + return (ENXIO); + archsw.arch_zfs_probe(); + return (0); } -#if defined(__amd64__) || defined(__i386__) -static int -zfs_dev_init(void) +int +zfs_probe_dev(const char *devname, uint64_t *pool_guid) { - char devname[512]; - int unit, slice; + spa_t *spa; int fd; + int ret; - /* - * Open all the disks we can find and see if we can reconstruct - * ZFS pools from them. Bogusly assumes that the disks are named - * diskN, diskNpM or diskNsM. - */ - zfs_init(); - for (unit = 0; unit < MAXBDDEV; unit++) { - sprintf(devname, "disk%d:", unit); - fd = open(devname, O_RDONLY); - if (fd == -1) - continue; - - /* - * If we find a vdev, the zfs code will eat the fd, otherwise - * we close it. - */ - if (vdev_probe(vdev_read, (void*) (uintptr_t) fd, 0)) - close(fd); - - for (slice = 1; slice <= 128; slice++) { - sprintf(devname, "disk%dp%d:", unit, slice); - fd = open(devname, O_RDONLY); - if (fd == -1) { - sprintf(devname, "disk%ds%d:", unit, slice); - fd = open(devname, O_RDONLY); - if (fd == -1) - continue; - } - if (vdev_probe(vdev_read, (void*) (uintptr_t) fd, 0)) - close(fd); - } - } - + fd = open(devname, O_RDONLY); + if (fd == -1) + return (ENXIO); + ret = vdev_probe(vdev_read, (void *)(uintptr_t)fd, &spa); + if (ret != 0) + close(fd); + else if (pool_guid != NULL) + *pool_guid = spa->spa_guid; return (0); } -#endif /* * Print information about ZFS pools @@ -452,54 +403,52 @@ zfs_dev_print(int verbose) { spa_t *spa; char line[80]; - int unit; if (verbose) { spa_all_status(); return; } - unit = 0; STAILQ_FOREACH(spa, &zfs_pools, spa_link) { - sprintf(line, " zfs%d: %s\n", unit, spa->spa_name); + sprintf(line, " zfs:%s\n", spa->spa_name); pager_output(line); - unit++; } } /* * Attempt to open the pool described by (dev) for use by (f). */ -static int +static int zfs_dev_open(struct open_file *f, ...) { va_list args; - struct devdesc *dev; - int unit, i; + struct zfs_devdesc *dev; + struct zfsmount *mount; spa_t *spa; + int rv; va_start(args, f); - dev = va_arg(args, struct devdesc*); + dev = va_arg(args, struct zfs_devdesc *); va_end(args); - /* - * We mostly ignore the stuff that devopen sends us. For now, - * use the unit to find a pool - later we will override the - * devname parsing so that we can name a pool and a fs within - * the pool. - */ - unit = dev->d_unit; - - i = 0; - STAILQ_FOREACH(spa, &zfs_pools, spa_link) { - if (i == unit) - break; - i++; - } - if (!spa) { + spa = spa_find_by_guid(dev->pool_guid); + if (!spa) *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 10:22:21 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3C016106566B; Fri, 29 Jun 2012 10:22:21 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0D5CB8FC1E; Fri, 29 Jun 2012 10:22:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5TAMKKp039615; Fri, 29 Jun 2012 10:22:20 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5TAMKpf039613; Fri, 29 Jun 2012 10:22:20 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201206291022.q5TAMKpf039613@svn.freebsd.org> From: Andriy Gapon Date: Fri, 29 Jun 2012 10:22:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237767 - stable/9/sys/boot/common X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 10:22:21 -0000 Author: avg Date: Fri Jun 29 10:22:20 2012 New Revision: 237767 URL: http://svn.freebsd.org/changeset/base/237767 Log: MFC r235330: zfs boot: try to set vfs.root.mountfrom from currdev as a fallback Modified: stable/9/sys/boot/common/boot.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/dev/isp/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/modules/ (props changed) Modified: stable/9/sys/boot/common/boot.c ============================================================================== --- stable/9/sys/boot/common/boot.c Fri Jun 29 10:19:15 2012 (r237766) +++ stable/9/sys/boot/common/boot.c Fri Jun 29 10:22:20 2012 (r237767) @@ -311,12 +311,12 @@ getrootmount(char *rootdev) if (getenv("vfs.root.mountfrom") != NULL) return(0); + error = 1; sprintf(lbuf, "%s/etc/fstab", rootdev); if ((fd = open(lbuf, O_RDONLY)) < 0) - return(1); + goto notfound; /* loop reading lines from /etc/fstab What was that about sscanf again? */ - error = 1; while (fgetstr(lbuf, sizeof(lbuf), fd) >= 0) { if ((lbuf[0] == 0) || (lbuf[0] == '#')) continue; @@ -377,6 +377,20 @@ getrootmount(char *rootdev) break; } close(fd); + +notfound: + if (error) { + const char *currdev; + + currdev = getenv("currdev"); + if (currdev != NULL && strncmp("zfs:", currdev, 4) == 0) { + cp = strdup(currdev); + cp[strlen(cp) - 1] = '\0'; + setenv("vfs.root.mountfrom", cp, 0); + error = 0; + } + } + return(error); } From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 10:28:46 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 959A41065672; Fri, 29 Jun 2012 10:28:46 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7FF638FC15; Fri, 29 Jun 2012 10:28:46 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5TASk0h040071; Fri, 29 Jun 2012 10:28:46 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5TASkef040066; Fri, 29 Jun 2012 10:28:46 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201206291028.q5TASkef040066@svn.freebsd.org> From: Andriy Gapon Date: Fri, 29 Jun 2012 10:28:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237770 - in stable/9: sys/boot/pc98/libpc98 sys/boot/zfs tools/tools/zfsboottest X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 10:28:46 -0000 Author: avg Date: Fri Jun 29 10:28:46 2012 New Revision: 237770 URL: http://svn.freebsd.org/changeset/base/237770 Log: MFC r235392,235394,235395: fixes and cleanups for zfs boot MFC Modified: stable/9/sys/boot/pc98/libpc98/Makefile stable/9/sys/boot/zfs/zfs.c stable/9/tools/tools/zfsboottest/zfsboottest.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/dev/isp/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/modules/ (props changed) stable/9/tools/tools/ (props changed) stable/9/tools/tools/ath/ (props changed) stable/9/tools/tools/ether_reflect/ (props changed) stable/9/tools/tools/nanobsd/ (props changed) stable/9/tools/tools/syscall_timing/ (props changed) stable/9/tools/tools/vimage/ (props changed) stable/9/tools/tools/zfsboottest/ (props changed) Modified: stable/9/sys/boot/pc98/libpc98/Makefile ============================================================================== --- stable/9/sys/boot/pc98/libpc98/Makefile Fri Jun 29 10:28:40 2012 (r237769) +++ stable/9/sys/boot/pc98/libpc98/Makefile Fri Jun 29 10:28:46 2012 (r237770) @@ -10,6 +10,8 @@ SRCS= bioscd.c biosdisk.c biosmem.c bios comconsole.c devicename.c elf32_freebsd.c \ i386_copy.c i386_module.c nullconsole.c pc98_sys.c pxe.c pxetramp.s \ time.c vidconsole.c +.PATH: ${.CURDIR}/../../zfs +SRCS+= devicename_stubs.c # Enable PXE TFTP or NFS support, not both. .if defined(LOADER_TFTP_SUPPORT) Modified: stable/9/sys/boot/zfs/zfs.c ============================================================================== --- stable/9/sys/boot/zfs/zfs.c Fri Jun 29 10:28:40 2012 (r237769) +++ stable/9/sys/boot/zfs/zfs.c Fri Jun 29 10:28:46 2012 (r237770) @@ -56,7 +56,6 @@ static int zfs_stat(struct open_file *f, static int zfs_readdir(struct open_file *f, struct dirent *d); struct devsw zfs_dev; -struct devsw zfs_dev_compat; struct fs_ops zfs_fsops = { "zfs", @@ -90,7 +89,7 @@ zfs_open(const char *upath, struct open_ struct file *fp; int rc; - if (f->f_dev != &zfs_dev && f->f_dev != &zfs_dev_compat) + if (f->f_dev != &zfs_dev) return (EINVAL); /* allocate file system specific data structure */ Modified: stable/9/tools/tools/zfsboottest/zfsboottest.c ============================================================================== --- stable/9/tools/tools/zfsboottest/zfsboottest.c Fri Jun 29 10:28:40 2012 (r237769) +++ stable/9/tools/tools/zfsboottest/zfsboottest.c Fri Jun 29 10:28:46 2012 (r237770) @@ -89,7 +89,11 @@ main(int argc, char** argv) char buf[512], hash[33]; MD5_CTX ctx; struct stat sb; + struct zfsmount zfsmnt; dnode_phys_t dn; +#if 0 + uint64_t rootobj; +#endif spa_t *spa; off_t off; ssize_t n; @@ -138,14 +142,28 @@ main(int argc, char** argv) exit(1); } - if (zfs_mount_pool(spa)) { - fprintf(stderr, "can't mount pool\n"); + if (zfs_spa_init(spa)) { + fprintf(stderr, "can't init pool\n"); exit(1); } +#if 0 + if (zfs_get_root(spa, &rootobj)) { + fprintf(stderr, "can't get root\n"); + exit(1); + } + + if (zfs_mount(spa, rootobj, &zfsmnt)) { +#else + if (zfs_mount(spa, 0, &zfsmnt)) { + fprintf(stderr, "can't mount\n"); + exit(1); + } +#endif + printf("\n"); for (++i, failures = 0; i < argc; i++) { - if (zfs_lookup(spa, argv[i], &dn)) { + if (zfs_lookup(&zfsmnt, argv[i], &dn)) { fprintf(stderr, "%s: can't lookup\n", argv[i]); failures++; continue; From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 10:31:00 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 424C6106566B; Fri, 29 Jun 2012 10:31:00 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1ECD88FC0A; Fri, 29 Jun 2012 10:31:00 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5TAUxT1040238; Fri, 29 Jun 2012 10:30:59 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5TAUxbE040235; Fri, 29 Jun 2012 10:30:59 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201206291030.q5TAUxbE040235@svn.freebsd.org> From: Andriy Gapon Date: Fri, 29 Jun 2012 10:30:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237771 - stable/9/sys/boot/zfs X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 10:31:00 -0000 Author: avg Date: Fri Jun 29 10:30:59 2012 New Revision: 237771 URL: http://svn.freebsd.org/changeset/base/237771 Log: MFC r235390: zfs boot code: mark spa_t arguments as const where they are used as such Modified: stable/9/sys/boot/zfs/zfs.c stable/9/sys/boot/zfs/zfsimpl.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/dev/isp/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/modules/ (props changed) Modified: stable/9/sys/boot/zfs/zfs.c ============================================================================== --- stable/9/sys/boot/zfs/zfs.c Fri Jun 29 10:28:46 2012 (r237770) +++ stable/9/sys/boot/zfs/zfs.c Fri Jun 29 10:30:59 2012 (r237771) @@ -127,7 +127,7 @@ zfs_close(struct open_file *f) static int zfs_read(struct open_file *f, void *start, size_t size, size_t *resid /* out */) { - spa_t *spa = ((struct zfsmount *)f->f_devdata)->spa; + const spa_t *spa = ((struct zfsmount *)f->f_devdata)->spa; struct file *fp = (struct file *)f->f_fsdata; struct stat sb; size_t n; @@ -201,7 +201,7 @@ zfs_seek(struct open_file *f, off_t offs static int zfs_stat(struct open_file *f, struct stat *sb) { - spa_t *spa = ((struct zfsmount *)f->f_devdata)->spa; + const spa_t *spa = ((struct zfsmount *)f->f_devdata)->spa; struct file *fp = (struct file *)f->f_fsdata; return (zfs_dnode_stat(spa, &fp->f_dnode, sb)); @@ -210,7 +210,7 @@ zfs_stat(struct open_file *f, struct sta static int zfs_readdir(struct open_file *f, struct dirent *d) { - spa_t *spa = ((struct zfsmount *)f->f_devdata)->spa; + const spa_t *spa = ((struct zfsmount *)f->f_devdata)->spa; struct file *fp = (struct file *)f->f_fsdata; mzap_ent_phys_t mze; struct stat sb; Modified: stable/9/sys/boot/zfs/zfsimpl.c ============================================================================== --- stable/9/sys/boot/zfs/zfsimpl.c Fri Jun 29 10:28:46 2012 (r237770) +++ stable/9/sys/boot/zfs/zfsimpl.c Fri Jun 29 10:30:59 2012 (r237771) @@ -39,7 +39,7 @@ __FBSDID("$FreeBSD$"); struct zfsmount { - spa_t *spa; + const spa_t *spa; objset_phys_t objset; uint64_t rootobj; }; @@ -63,7 +63,7 @@ static char *zfs_temp_buf, *zfs_temp_end #define TEMP_SIZE (1024 * 1024) -static int zio_read(spa_t *spa, const blkptr_t *bp, void *buf); +static int zio_read(const spa_t *spa, const blkptr_t *bp, void *buf); static void zfs_init(void) @@ -981,7 +981,7 @@ ilog2(int n) } static int -zio_read_gang(spa_t *spa, const blkptr_t *bp, void *buf) +zio_read_gang(const spa_t *spa, const blkptr_t *bp, void *buf) { blkptr_t gbh_bp; zio_gbh_phys_t zio_gb; @@ -1018,7 +1018,7 @@ zio_read_gang(spa_t *spa, const blkptr_t } static int -zio_read(spa_t *spa, const blkptr_t *bp, void *buf) +zio_read(const spa_t *spa, const blkptr_t *bp, void *buf) { int cpfunc = BP_GET_COMPRESS(bp); uint64_t align, size; @@ -1078,7 +1078,7 @@ zio_read(spa_t *spa, const blkptr_t *bp, } static int -dnode_read(spa_t *spa, const dnode_phys_t *dnode, off_t offset, void *buf, size_t buflen) +dnode_read(const spa_t *spa, const dnode_phys_t *dnode, off_t offset, void *buf, size_t buflen) { int ibshift = dnode->dn_indblkshift - SPA_BLKPTRSHIFT; int bsize = dnode->dn_datablkszsec << SPA_MINBLOCKSHIFT; @@ -1141,7 +1141,7 @@ dnode_read(spa_t *spa, const dnode_phys_ * scratch buffer contains the directory contents. */ static int -mzap_lookup(spa_t *spa, const dnode_phys_t *dnode, const char *name, uint64_t *value) +mzap_lookup(const dnode_phys_t *dnode, const char *name, uint64_t *value) { const mzap_phys_t *mz; const mzap_ent_phys_t *mze; @@ -1222,7 +1222,7 @@ fzap_leaf_value(const zap_leaf_t *zl, co * buffer contains the directory header. */ static int -fzap_lookup(spa_t *spa, const dnode_phys_t *dnode, const char *name, uint64_t *value) +fzap_lookup(const spa_t *spa, const dnode_phys_t *dnode, const char *name, uint64_t *value) { int bsize = dnode->dn_datablkszsec << SPA_MINBLOCKSHIFT; zap_phys_t zh = *(zap_phys_t *) zap_scratch; @@ -1300,7 +1300,7 @@ fzap_lookup(spa_t *spa, const dnode_phys * Lookup a name in a zap object and return its value as a uint64_t. */ static int -zap_lookup(spa_t *spa, const dnode_phys_t *dnode, const char *name, uint64_t *value) +zap_lookup(const spa_t *spa, const dnode_phys_t *dnode, const char *name, uint64_t *value) { int rc; uint64_t zap_type; @@ -1312,7 +1312,7 @@ zap_lookup(spa_t *spa, const dnode_phys_ zap_type = *(uint64_t *) zap_scratch; if (zap_type == ZBT_MICRO) - return mzap_lookup(spa, dnode, name, value); + return mzap_lookup(dnode, name, value); else if (zap_type == ZBT_HEADER) return fzap_lookup(spa, dnode, name, value); printf("ZFS: invalid zap_type=%d\n", (int)zap_type); @@ -1326,7 +1326,7 @@ zap_lookup(spa_t *spa, const dnode_phys_ * the directory contents. */ static int -mzap_list(spa_t *spa, const dnode_phys_t *dnode) +mzap_list(const dnode_phys_t *dnode) { const mzap_phys_t *mz; const mzap_ent_phys_t *mze; @@ -1356,7 +1356,7 @@ mzap_list(spa_t *spa, const dnode_phys_t * the directory header. */ static int -fzap_list(spa_t *spa, const dnode_phys_t *dnode) +fzap_list(const spa_t *spa, const dnode_phys_t *dnode) { int bsize = dnode->dn_datablkszsec << SPA_MINBLOCKSHIFT; zap_phys_t zh = *(zap_phys_t *) zap_scratch; @@ -1395,7 +1395,7 @@ fzap_list(spa_t *spa, const dnode_phys_t namelen = zc->l_entry.le_name_length; if (namelen > sizeof(name)) namelen = sizeof(name); - + /* * Paste the name back together. */ @@ -1429,7 +1429,7 @@ fzap_list(spa_t *spa, const dnode_phys_t * List a zap directory. */ static int -zap_list(spa_t *spa, const dnode_phys_t *dnode) +zap_list(const spa_t *spa, const dnode_phys_t *dnode) { uint64_t zap_type; size_t size = dnode->dn_datablkszsec * 512; @@ -1439,7 +1439,7 @@ zap_list(spa_t *spa, const dnode_phys_t zap_type = *(uint64_t *) zap_scratch; if (zap_type == ZBT_MICRO) - return mzap_list(spa, dnode); + return mzap_list(dnode); else return fzap_list(spa, dnode); } @@ -1447,7 +1447,7 @@ zap_list(spa_t *spa, const dnode_phys_t #endif static int -objset_get_dnode(spa_t *spa, const objset_phys_t *os, uint64_t objnum, dnode_phys_t *dnode) +objset_get_dnode(const spa_t *spa, const objset_phys_t *os, uint64_t objnum, dnode_phys_t *dnode) { off_t offset; @@ -1457,7 +1457,7 @@ objset_get_dnode(spa_t *spa, const objse } static int -mzap_rlookup(spa_t *spa, const dnode_phys_t *dnode, char *name, uint64_t value) +mzap_rlookup(const spa_t *spa, const dnode_phys_t *dnode, char *name, uint64_t value) { const mzap_phys_t *mz; const mzap_ent_phys_t *mze; @@ -1510,7 +1510,7 @@ fzap_name_copy(const zap_leaf_t *zl, con } static int -fzap_rlookup(spa_t *spa, const dnode_phys_t *dnode, char *name, uint64_t value) +fzap_rlookup(const spa_t *spa, const dnode_phys_t *dnode, char *name, uint64_t value) { int bsize = dnode->dn_datablkszsec << SPA_MINBLOCKSHIFT; zap_phys_t zh = *(zap_phys_t *) zap_scratch; @@ -1585,7 +1585,7 @@ fzap_rlookup(spa_t *spa, const dnode_phy } static int -zap_rlookup(spa_t *spa, const dnode_phys_t *dnode, char *name, uint64_t value) +zap_rlookup(const spa_t *spa, const dnode_phys_t *dnode, char *name, uint64_t value) { int rc; uint64_t zap_type; @@ -1603,7 +1603,7 @@ zap_rlookup(spa_t *spa, const dnode_phys } static int -zfs_rlookup(spa_t *spa, uint64_t objnum, char *result) +zfs_rlookup(const spa_t *spa, uint64_t objnum, char *result) { char name[256]; char component[256]; @@ -1661,7 +1661,7 @@ zfs_rlookup(spa_t *spa, uint64_t objnum, } static int -zfs_lookup_dataset(spa_t *spa, const char *name, uint64_t *objnum) +zfs_lookup_dataset(const spa_t *spa, const char *name, uint64_t *objnum) { char element[256]; uint64_t dir_obj, child_dir_zapobj; @@ -1714,7 +1714,7 @@ zfs_lookup_dataset(spa_t *spa, const cha * and return its details in *objset */ static int -zfs_mount_dataset(spa_t *spa, uint64_t objnum, objset_phys_t *objset) +zfs_mount_dataset(const spa_t *spa, uint64_t objnum, objset_phys_t *objset) { dnode_phys_t dataset; dsl_dataset_phys_t *ds; @@ -1739,7 +1739,7 @@ zfs_mount_dataset(spa_t *spa, uint64_t o * dataset if there is none and return its details in *objset */ static int -zfs_get_root(spa_t *spa, uint64_t *objid) +zfs_get_root(const spa_t *spa, uint64_t *objid) { dnode_phys_t dir, propdir; uint64_t props, bootfs, root; @@ -1784,7 +1784,7 @@ zfs_get_root(spa_t *spa, uint64_t *objid } static int -zfs_mount(spa_t *spa, uint64_t rootobj, struct zfsmount *mount) +zfs_mount(const spa_t *spa, uint64_t rootobj, struct zfsmount *mount) { mount->spa = spa; @@ -1822,7 +1822,7 @@ zfs_spa_init(spa_t *spa) } static int -zfs_dnode_stat(spa_t *spa, dnode_phys_t *dn, struct stat *sb) +zfs_dnode_stat(const spa_t *spa, dnode_phys_t *dn, struct stat *sb) { if (dn->dn_bonustype != DMU_OT_SA) { @@ -1881,7 +1881,7 @@ zfs_lookup(const struct zfsmount *mount, { int rc; uint64_t objnum, rootnum, parentnum; - spa_t *spa; + const spa_t *spa; dnode_phys_t dn; const char *p, *q; char element[256]; From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 10:39:43 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2B119106566B; Fri, 29 Jun 2012 10:39:43 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 158DA8FC0A; Fri, 29 Jun 2012 10:39:43 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5TAdg7G040674; Fri, 29 Jun 2012 10:39:42 GMT (envelope-from jhibbits@svn.freebsd.org) Received: (from jhibbits@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5TAdgbA040672; Fri, 29 Jun 2012 10:39:42 GMT (envelope-from jhibbits@svn.freebsd.org) Message-Id: <201206291039.q5TAdgbA040672@svn.freebsd.org> From: Justin Hibbits Date: Fri, 29 Jun 2012 10:39:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237773 - stable/9/sys/dev/adb X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 10:39:43 -0000 Author: jhibbits Date: Fri Jun 29 10:39:42 2012 New Revision: 237773 URL: http://svn.freebsd.org/changeset/base/237773 Log: MFC r237480 Release the ADB keyboard mutex when handling the power button press/release. Found by WITNESS. Approved by: nwhitehorn (mentor) Modified: stable/9/sys/dev/adb/adb_kbd.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/adb/adb_kbd.c ============================================================================== --- stable/9/sys/dev/adb/adb_kbd.c Fri Jun 29 10:31:26 2012 (r237772) +++ stable/9/sys/dev/adb/adb_kbd.c Fri Jun 29 10:39:42 2012 (r237773) @@ -426,8 +426,10 @@ adb_kbd_receive_packet(device_t dev, u_c /* 0x7f is always the power button */ if (data[0] == 0x7f && devctl_process_running()) { devctl_notify("PMU", "Button", "pressed", NULL); + mtx_unlock(&sc->sc_mutex); return (0); } else if (data[0] == 0xff) { + mtx_unlock(&sc->sc_mutex); return (0); /* Ignore power button release. */ } if ((data[0] & 0x7f) == 57 && sc->buffers < 7) { From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 12:05:20 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 2413F1065675; Fri, 29 Jun 2012 12:05:20 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0E73D8FC28; Fri, 29 Jun 2012 12:05:20 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5TC5JIj044474; Fri, 29 Jun 2012 12:05:19 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5TC5JIt044472; Fri, 29 Jun 2012 12:05:19 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201206291205.q5TC5JIt044472@svn.freebsd.org> From: Gleb Smirnoff Date: Fri, 29 Jun 2012 12:05:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237774 - stable/9/usr.sbin/arp X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 12:05:20 -0000 Author: glebius Date: Fri Jun 29 12:05:19 2012 New Revision: 237774 URL: http://svn.freebsd.org/changeset/base/237774 Log: Merge r233773 from head: Historically arp(8) did a route lookup for the entry it is about to add, and failed if it exist and had invalid data link type. Later on, in r201282, this check morphed to other code, but message "proxy entry exists for non 802 device" still left, and now it is printed in a case if route prefix found is equal to current address being added. In other words, when we are trying to add ARP entry for a network address. The message is absolutely unrelated and disappointing in this case. I don't see anything bad with setting ARP entries for network addresses. While useless in usual network, in a /31 RFC3021 it may be necessary. This, remove this code. Modified: stable/9/usr.sbin/arp/arp.c Directory Properties: stable/9/usr.sbin/arp/ (props changed) Modified: stable/9/usr.sbin/arp/arp.c ============================================================================== --- stable/9/usr.sbin/arp/arp.c Fri Jun 29 10:39:42 2012 (r237773) +++ stable/9/usr.sbin/arp/arp.c Fri Jun 29 12:05:19 2012 (r237774) @@ -387,10 +387,6 @@ set(int argc, char **argv) } addr = (struct sockaddr_inarp *)(rtm + 1); sdl = (struct sockaddr_dl *)(SA_SIZE(addr) + (char *)addr); - if (addr->sin_addr.s_addr == dst->sin_addr.s_addr) { - printf("set: proxy entry exists for non 802 device\n"); - return (1); - } if ((sdl->sdl_family != AF_LINK) || (rtm->rtm_flags & RTF_GATEWAY) || From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 12:08:27 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A09E91065676; Fri, 29 Jun 2012 12:08:27 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 81A658FC15; Fri, 29 Jun 2012 12:08:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5TC8RVf044640; Fri, 29 Jun 2012 12:08:27 GMT (envelope-from pho@svn.freebsd.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5TC8Rac044638; Fri, 29 Jun 2012 12:08:27 GMT (envelope-from pho@svn.freebsd.org) Message-Id: <201206291208.q5TC8Rac044638@svn.freebsd.org> From: Peter Holm Date: Fri, 29 Jun 2012 12:08:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237775 - stable/9/sys/kern X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 12:08:27 -0000 Author: pho Date: Fri Jun 29 12:08:26 2012 New Revision: 237775 URL: http://svn.freebsd.org/changeset/base/237775 Log: MFC: r237219 In tty_makedev() the following construction: dev = make_dev_cred(); dev->si_drv1 = tp; leaves a small window where the newly created device may be opened and si_drv1 is NULL. As this is a vary rare situation, using a lock to close the window seems overkill. Instead just wait for the assignment of si_drv1. Modified: stable/9/sys/kern/tty.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/kern/tty.c ============================================================================== --- stable/9/sys/kern/tty.c Fri Jun 29 12:05:19 2012 (r237774) +++ stable/9/sys/kern/tty.c Fri Jun 29 12:08:26 2012 (r237775) @@ -219,9 +219,15 @@ ttydev_leave(struct tty *tp) static int ttydev_open(struct cdev *dev, int oflags, int devtype, struct thread *td) { - struct tty *tp = dev->si_drv1; + struct tty *tp; int error = 0; + while ((tp = dev->si_drv1) == NULL) { + error = tsleep(&dev->si_drv1, PCATCH, "ttdrv1", 1); + if (error != EWOULDBLOCK) + return (error); + } + tty_lock(tp); if (tty_gone(tp)) { /* Device is already gone. */ @@ -738,9 +744,14 @@ static struct cdevsw ttydev_cdevsw = { static int ttyil_open(struct cdev *dev, int oflags, int devtype, struct thread *td) { - struct tty *tp = dev->si_drv1; + struct tty *tp; int error = 0; + while ((tp = dev->si_drv1) == NULL) { + error = tsleep(&dev->si_drv1, PCATCH, "ttdrv1", 1); + if (error != EWOULDBLOCK) + return (error); + } tty_lock(tp); if (tty_gone(tp)) error = ENODEV; @@ -1203,6 +1214,7 @@ tty_makedev(struct tty *tp, struct ucred dev = make_dev_cred(&ttydev_cdevsw, 0, cred, uid, gid, mode, "%s%s", prefix, name); dev->si_drv1 = tp; + wakeup(&dev->si_drv1); tp->t_dev = dev; /* Slave call-in devices. */ @@ -1211,12 +1223,14 @@ tty_makedev(struct tty *tp, struct ucred uid, gid, mode, "%s%s.init", prefix, name); dev_depends(tp->t_dev, dev); dev->si_drv1 = tp; + wakeup(&dev->si_drv1); dev->si_drv2 = &tp->t_termios_init_in; dev = make_dev_cred(&ttyil_cdevsw, TTYUNIT_LOCK, cred, uid, gid, mode, "%s%s.lock", prefix, name); dev_depends(tp->t_dev, dev); dev->si_drv1 = tp; + wakeup(&dev->si_drv1); dev->si_drv2 = &tp->t_termios_lock_in; } @@ -1226,6 +1240,7 @@ tty_makedev(struct tty *tp, struct ucred UID_UUCP, GID_DIALER, 0660, "cua%s", name); dev_depends(tp->t_dev, dev); dev->si_drv1 = tp; + wakeup(&dev->si_drv1); /* Slave call-out devices. */ if (tp->t_flags & TF_INITLOCK) { @@ -1234,6 +1249,7 @@ tty_makedev(struct tty *tp, struct ucred UID_UUCP, GID_DIALER, 0660, "cua%s.init", name); dev_depends(tp->t_dev, dev); dev->si_drv1 = tp; + wakeup(&dev->si_drv1); dev->si_drv2 = &tp->t_termios_init_out; dev = make_dev_cred(&ttyil_cdevsw, @@ -1241,6 +1257,7 @@ tty_makedev(struct tty *tp, struct ucred UID_UUCP, GID_DIALER, 0660, "cua%s.lock", name); dev_depends(tp->t_dev, dev); dev->si_drv1 = tp; + wakeup(&dev->si_drv1); dev->si_drv2 = &tp->t_termios_lock_out; } } From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 12:11:32 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AD403106564A; Fri, 29 Jun 2012 12:11:32 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8F5F58FC1A; Fri, 29 Jun 2012 12:11:32 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5TCBWmF044845; Fri, 29 Jun 2012 12:11:32 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5TCBWom044841; Fri, 29 Jun 2012 12:11:32 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201206291211.q5TCBWom044841@svn.freebsd.org> From: Gleb Smirnoff Date: Fri, 29 Jun 2012 12:11:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237776 - stable/9/sys/contrib/pf/net X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 12:11:32 -0000 Author: glebius Date: Fri Jun 29 12:11:31 2012 New Revision: 237776 URL: http://svn.freebsd.org/changeset/base/237776 Log: Merge r236364 from head by eri@: Correct table counter functionality to not panic. This was caused by not proper initialization of necessary parameters. PR: 168200 Reviewed by: bz@, glebius@ MFC after: 1 week Modified: stable/9/sys/contrib/pf/net/pf_ioctl.c stable/9/sys/contrib/pf/net/pf_table.c stable/9/sys/contrib/pf/net/pfvar.h Directory Properties: stable/9/sys/ (props changed) stable/9/sys/contrib/pf/ (props changed) Modified: stable/9/sys/contrib/pf/net/pf_ioctl.c ============================================================================== --- stable/9/sys/contrib/pf/net/pf_ioctl.c Fri Jun 29 12:08:26 2012 (r237775) +++ stable/9/sys/contrib/pf/net/pf_ioctl.c Fri Jun 29 12:11:31 2012 (r237776) @@ -298,7 +298,7 @@ init_zone_var(void) V_pf_altq_pl = V_pf_pooladdr_pl = NULL; V_pf_frent_pl = V_pf_frag_pl = V_pf_cache_pl = V_pf_cent_pl = NULL; V_pf_state_scrub_pl = NULL; - V_pfr_ktable_pl = V_pfr_kentry_pl = NULL; + V_pfr_ktable_pl = V_pfr_kentry_pl = V_pfr_kcounters_pl = NULL; } void @@ -317,6 +317,7 @@ cleanup_pf_zone(void) UMA_DESTROY(V_pf_cent_pl); UMA_DESTROY(V_pfr_ktable_pl); UMA_DESTROY(V_pfr_kentry_pl); + UMA_DESTROY(V_pfr_kcounters_pl); UMA_DESTROY(V_pf_state_scrub_pl); UMA_DESTROY(V_pfi_addr_pl); } @@ -337,6 +338,7 @@ pfattach(void) UMA_CREATE(V_pf_pooladdr_pl, struct pf_pooladdr, "pfpooladdrpl"); UMA_CREATE(V_pfr_ktable_pl, struct pfr_ktable, "pfrktable"); UMA_CREATE(V_pfr_kentry_pl, struct pfr_kentry, "pfrkentry"); + UMA_CREATE(V_pfr_kcounters_pl, struct pfr_kcounters, "pfrkcounters"); UMA_CREATE(V_pf_frent_pl, struct pf_frent, "pffrent"); UMA_CREATE(V_pf_frag_pl, struct pf_fragment, "pffrag"); UMA_CREATE(V_pf_cache_pl, struct pf_fragment, "pffrcache"); Modified: stable/9/sys/contrib/pf/net/pf_table.c ============================================================================== --- stable/9/sys/contrib/pf/net/pf_table.c Fri Jun 29 12:08:26 2012 (r237775) +++ stable/9/sys/contrib/pf/net/pf_table.c Fri Jun 29 12:11:31 2012 (r237776) @@ -179,7 +179,6 @@ struct pfr_walktree { VNET_DEFINE(uma_zone_t, pfr_ktable_pl); VNET_DEFINE(uma_zone_t, pfr_kentry_pl); VNET_DEFINE(uma_zone_t, pfr_kcounters_pl); -#define V_pfr_kcounters_pl VNET(pfr_kcounters_pl) VNET_DEFINE(struct sockaddr_in, pfr_sin); #define V_pfr_sin VNET(pfr_sin) VNET_DEFINE(struct sockaddr_in6, pfr_sin6); Modified: stable/9/sys/contrib/pf/net/pfvar.h ============================================================================== --- stable/9/sys/contrib/pf/net/pfvar.h Fri Jun 29 12:08:26 2012 (r237775) +++ stable/9/sys/contrib/pf/net/pfvar.h Fri Jun 29 12:11:31 2012 (r237776) @@ -1868,6 +1868,8 @@ VNET_DECLARE(uma_zone_t, pfr_ktable_pl #define V_pfr_ktable_pl VNET(pfr_ktable_pl) VNET_DECLARE(uma_zone_t, pfr_kentry_pl); #define V_pfr_kentry_pl VNET(pfr_kentry_pl) +VNET_DECLARE(uma_zone_t, pfr_kcounters_pl); +#define V_pfr_kcounters_pl VNET(pfr_kcounters_pl) VNET_DECLARE(uma_zone_t, pf_cache_pl); #define V_pf_cache_pl VNET(pf_cache_pl) VNET_DECLARE(uma_zone_t, pf_cent_pl); From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 13:00:29 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7C156106564A; Fri, 29 Jun 2012 13:00:29 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 664018FC0A; Fri, 29 Jun 2012 13:00:29 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5TD0TnV047040; Fri, 29 Jun 2012 13:00:29 GMT (envelope-from bapt@svn.freebsd.org) Received: (from bapt@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5TD0Tlg047038; Fri, 29 Jun 2012 13:00:29 GMT (envelope-from bapt@svn.freebsd.org) Message-Id: <201206291300.q5TD0Tlg047038@svn.freebsd.org> From: Baptiste Daroussin Date: Fri, 29 Jun 2012 13:00:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237778 - stable/9/lib/libutil X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 13:00:29 -0000 Author: bapt Date: Fri Jun 29 13:00:28 2012 New Revision: 237778 URL: http://svn.freebsd.org/changeset/base/237778 Log: MFC: r237268 early MFC to get this important bugfix into 9.1 Revert user comparison back to user names as some user can share uids (root/toor for example) get the username information from old_pw structures to still allow renaming of a user. Reported by: Claude Buisson Approved by: des (mentor) Modified: stable/9/lib/libutil/pw_util.c Directory Properties: stable/9/lib/libutil/ (props changed) Modified: stable/9/lib/libutil/pw_util.c ============================================================================== --- stable/9/lib/libutil/pw_util.c Fri Jun 29 12:55:36 2012 (r237777) +++ stable/9/lib/libutil/pw_util.c Fri Jun 29 13:00:28 2012 (r237778) @@ -436,14 +436,21 @@ pw_copy(int ffd, int tfd, const struct p size_t len; int eof, readlen; - spw = pw; + if (old_pw == NULL && pw == NULL) + return (-1); + + spw = old_pw; + /* deleting a user */ if (pw == NULL) { line = NULL; - if (old_pw == NULL) + } else { + if ((line = pw_make(pw)) == NULL) return (-1); - spw = old_pw; - } else if ((line = pw_make(pw)) == NULL) - return (-1); + } + + /* adding a user */ + if (spw == NULL) + spw = pw; eof = 0; len = 0; @@ -510,7 +517,7 @@ pw_copy(int ffd, int tfd, const struct p */ *q = t; - if (fpw == NULL || fpw->pw_uid != spw->pw_uid) { + if (fpw == NULL || strcmp(fpw->pw_name, spw->pw_name) != 0) { /* nope */ if (fpw != NULL) free(fpw); From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 15:24:47 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7D38C1065672; Fri, 29 Jun 2012 15:24:47 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4DF738FC0C; Fri, 29 Jun 2012 15:24:47 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5TFOl8a053466; Fri, 29 Jun 2012 15:24:47 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5TFOllL053463; Fri, 29 Jun 2012 15:24:47 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201206291524.q5TFOllL053463@svn.freebsd.org> From: John Baldwin Date: Fri, 29 Jun 2012 15:24:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237789 - stable/9/usr.bin/kdump X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 15:24:47 -0000 Author: jhb Date: Fri Jun 29 15:24:46 2012 New Revision: 237789 URL: http://svn.freebsd.org/changeset/base/237789 Log: MFC 236577: Allow the -p argument to kdump to accept either a PID or a thread ID. Modified: stable/9/usr.bin/kdump/kdump.1 stable/9/usr.bin/kdump/kdump.c Directory Properties: stable/9/usr.bin/kdump/ (props changed) Modified: stable/9/usr.bin/kdump/kdump.1 ============================================================================== --- stable/9/usr.bin/kdump/kdump.1 Fri Jun 29 15:24:42 2012 (r237788) +++ stable/9/usr.bin/kdump/kdump.1 Fri Jun 29 15:24:46 2012 (r237789) @@ -28,7 +28,7 @@ .\" @(#)kdump.1 8.1 (Berkeley) 6/6/93 .\" $FreeBSD$ .\" -.Dd April 20, 2012 +.Dd June 4, 2012 .Dt KDUMP 1 .Os .Sh NAME @@ -86,9 +86,9 @@ string. Suppressing this feature yields a more consistent output format and is easily amenable to further processing. .It Fl p Ar pid -Display only trace events that correspond to the process +Display only trace events that correspond to the process or thread .Ar pid . -This may be useful when there are multiple processes recorded in the +This may be useful when there are multiple processes or threads recorded in the same trace file. .It Fl R Display relative timestamps (time since previous entry). Modified: stable/9/usr.bin/kdump/kdump.c ============================================================================== --- stable/9/usr.bin/kdump/kdump.c Fri Jun 29 15:24:42 2012 (r237788) +++ stable/9/usr.bin/kdump/kdump.c Fri Jun 29 15:24:46 2012 (r237789) @@ -249,7 +249,8 @@ main(int argc, char *argv[]) } } if (trpoints & (1< Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 648C0106564A; Fri, 29 Jun 2012 15:30:15 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4EBBF8FC14; Fri, 29 Jun 2012 15:30:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5TFUFV4053814; Fri, 29 Jun 2012 15:30:15 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5TFUFNh053812; Fri, 29 Jun 2012 15:30:15 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201206291530.q5TFUFNh053812@svn.freebsd.org> From: John Baldwin Date: Fri, 29 Jun 2012 15:30:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237792 - stable/9/lib/libprocstat X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 15:30:15 -0000 Author: jhb Date: Fri Jun 29 15:30:14 2012 New Revision: 237792 URL: http://svn.freebsd.org/changeset/base/237792 Log: MFC 236717: Teach procstat_get_shm_info_kvm() how to fetch the pathname of a SHM file descriptor from a core and set it in fts->fs_path. Modified: stable/9/lib/libprocstat/libprocstat.c Directory Properties: stable/9/lib/libprocstat/ (props changed) Modified: stable/9/lib/libprocstat/libprocstat.c ============================================================================== --- stable/9/lib/libprocstat/libprocstat.c Fri Jun 29 15:27:17 2012 (r237791) +++ stable/9/lib/libprocstat/libprocstat.c Fri Jun 29 15:30:14 2012 (r237792) @@ -881,6 +881,8 @@ procstat_get_shm_info_kvm(kvm_t *kd, str { struct shmfd shmfd; void *shmfdp; + char *path; + int i; assert(kd); assert(shm); @@ -896,6 +898,21 @@ procstat_get_shm_info_kvm(kvm_t *kd, str } shm->mode = S_IFREG | shmfd.shm_mode; shm->size = shmfd.shm_size; + if (fst->fs_path == NULL && shmfd.shm_path != NULL) { + path = malloc(MAXPATHLEN); + for (i = 0; i < MAXPATHLEN - 1; i++) { + if (!kvm_read_all(kd, (unsigned long)shmfd.shm_path + i, + path + i, 1)) + break; + if (path[i] == '\0') + break; + } + path[i] = '\0'; + if (i == 0) + free(path); + else + fst->fs_path = path; + } return (0); fail: From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 15:57:25 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C3F941065710; Fri, 29 Jun 2012 15:57:25 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A89028FC18; Fri, 29 Jun 2012 15:57:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5TFvP91055063; Fri, 29 Jun 2012 15:57:25 GMT (envelope-from obrien@svn.freebsd.org) Received: (from obrien@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5TFvPLb055057; Fri, 29 Jun 2012 15:57:25 GMT (envelope-from obrien@svn.freebsd.org) Message-Id: <201206291557.q5TFvPLb055057@svn.freebsd.org> From: "David E. O'Brien" Date: Fri, 29 Jun 2012 15:57:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237795 - in stable/9: share/man/man4 sys/dev/filemon sys/modules sys/modules/filemon tools/regression/filemon X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 15:57:26 -0000 Author: obrien Date: Fri Jun 29 15:57:25 2012 New Revision: 237795 URL: http://svn.freebsd.org/changeset/base/237795 Log: MFC: r236592 r236593 r236594 r236620 r236621 r236622 r236637 r237794: filemon(4) Added: stable/9/share/man/man4/filemon.4 - copied, changed from r236593, head/share/man/man4/filemon.4 stable/9/sys/dev/filemon/ - copied from r236592, head/sys/dev/filemon/ stable/9/sys/modules/filemon/ - copied from r236592, head/sys/modules/filemon/ stable/9/tools/regression/filemon/ - copied from r236594, head/tools/regression/filemon/ Modified: stable/9/share/man/man4/Makefile stable/9/sys/modules/Makefile stable/9/tools/regression/filemon/Makefile stable/9/tools/regression/filemon/filemontest.c Directory Properties: stable/9/ (props changed) stable/9/share/ (props changed) stable/9/share/man/ (props changed) stable/9/share/man/man4/ (props changed) stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/modules/ (props changed) stable/9/tools/ (props changed) Modified: stable/9/share/man/man4/Makefile ============================================================================== --- stable/9/share/man/man4/Makefile Fri Jun 29 15:54:07 2012 (r237794) +++ stable/9/share/man/man4/Makefile Fri Jun 29 15:57:25 2012 (r237795) @@ -126,6 +126,7 @@ MAN= aac.4 \ fdc.4 \ fdt.4 \ fdtbus.4 \ + filemon.4 \ firewire.4 \ fpa.4 \ fwe.4 \ Copied and modified: stable/9/share/man/man4/filemon.4 (from r236593, head/share/man/man4/filemon.4) ============================================================================== --- head/share/man/man4/filemon.4 Mon Jun 4 22:59:06 2012 (r236593, copy source) +++ stable/9/share/man/man4/filemon.4 Fri Jun 29 15:57:25 2012 (r237795) @@ -50,63 +50,74 @@ responds to two calls. .Pp System calls are denoted using the following single letters: +.Pp .Bl -tag -width indent -compact -.It Dq Li C +.It Ql C .Xr chdir 2 -.It Dq Li D +.It Ql D .Xr unlink 2 -.It Dq Li E +.It Ql E .Xr exec 2 -.It Dq Li F +.It Ql F .Xr fork 2 , .Xr vfork 2 -.It Dq Li L +.It Ql L .Xr link 2 , .Xr linkat 2 , .Xr symlink 2 , .Xr symlinkat 2 -.It Dq Li M +.It Ql M .Xr rename 2 -.It Dq Li R +.It Ql R .Xr open 2 for read -.It Dq Li S +.It Ql S .Xr stat 2 -.It Dq Li W +.It Ql W .Xr open 2 for write -.It Dq Li X +.It Ql X .Xr _exit 2 .El .Pp Note that -.Dq R +.Ql R following -.Dq W +.Ql W records can represent a single .Xr open 2 for R/W, or two seperate .Xr open 2 calls, one for -R +.Ql R and one for -W. +.Ql W . .Sh IOCTLS -User mode programs communicate with the filemon driver through a -number of ioctls which are described below. +User mode programs communicate with the +.Nm +driver through a number of ioctls which are described below. Each takes a single argument. -.Bl -tag -width FILEMON_SET_PID +.Bl -tag -width ".Dv FILEMON_SET_PID" .It Dv FILEMON_SET_FD Write the internal tracing buffer to the supplied open file descriptor. -.It Dv FILEMON_SET_PID . +.It Dv FILEMON_SET_PID Child process ID to trace. .El -.Pp .Sh RETURN VALUES -The ioctl returns zero on success and non-zero on failure. +.\" .Rv -std ioctl +The +.Fn ioctl +function returns the value 0 if successful; +otherwise the value \-1 is returned and the global variable +.Va errno +is set to indicate the error. +.Sh FILES +.Bl -tag -width ".Pa /dev/filemon" +.It Pa /dev/filemon +.El .Sh EXAMPLES -.Bd -literal -offset indent +.Bd -literal #include #include #include @@ -122,23 +133,24 @@ open_filemon(void) int fm_fd, fm_log; if ((fm_fd = open("/dev/filemon", O_RDWR)) == -1) - err(1, "open(\"/dev/filemon\", O_RDWR)"); + err(1, "open(\e"/dev/filemon\e", O_RDWR)"); if ((fm_log = open("filemon.out", O_CREAT | O_WRONLY | O_TRUNC, DEFFILEMODE)) == -1) err(1, "open(filemon.out)"); - if (ioctl(fm_fd, FILEMON_SET_FD, &fm_log) < 0) + if (ioctl(fm_fd, FILEMON_SET_FD, &fm_log) == -1) err(1, "Cannot set filemon log file descriptor"); /* Set up these two fd's to close on exec. */ (void)fcntl(fm_fd, F_SETFD, FD_CLOEXEC); (void)fcntl(fm_log, F_SETFD, FD_CLOEXEC); if ((child = fork()) == 0) { + child = getpid(); + if (ioctl(fm_fd, FILEMON_SET_PID, &child) == -1) + err(1, "Cannot set filemon PID"); /* Do something here. */ return 0; } else { - if (ioctl(fm_fd, FILEMON_SET_PID, &child) < 0) - err(1, "Cannot set filemon PID"); wait(&child); close(fm_fd); } @@ -150,11 +162,9 @@ Creates a file named .Pa filemon.out and configures the .Nm -device to write the filemon buffer contents to it. -.Sh FILES -.Bl -tag -width /dev/zero -.It Pa /dev/filemon -.El +device to write the +.Nm +buffer contents to it. .Sh SEE ALSO .Xr dtrace 1 , .Xr ktrace 1 , Modified: stable/9/sys/modules/Makefile ============================================================================== --- stable/9/sys/modules/Makefile Fri Jun 29 15:54:07 2012 (r237794) +++ stable/9/sys/modules/Makefile Fri Jun 29 15:57:25 2012 (r237795) @@ -5,7 +5,8 @@ # Modules that include binary-only blobs of microcode should be selectable by # MK_SOURCELESS_UCODE option (see below). -SUBDIR= ${_3dfx} \ +SUBDIR= \ + ${_3dfx} \ ${_3dfx_linux} \ ${_aac} \ accf_data \ @@ -102,6 +103,7 @@ SUBDIR= ${_3dfx} \ fdc \ fdescfs \ ${_fe} \ + ${_filemon} \ firewire \ firmware \ ${_fxp} \ @@ -352,6 +354,10 @@ SUBDIR= ${_3dfx} \ ${_zfs} \ zlib \ +.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" +_filemon= filemon +.endif + .if ${MACHINE_CPUARCH} != "powerpc" && ${MACHINE_CPUARCH} != "arm" && \ ${MACHINE_CPUARCH} != "mips" _syscons= syscons Modified: stable/9/tools/regression/filemon/Makefile ============================================================================== --- head/tools/regression/filemon/Makefile Mon Jun 4 22:59:33 2012 (r236594) +++ stable/9/tools/regression/filemon/Makefile Fri Jun 29 15:57:25 2012 (r237795) @@ -9,16 +9,18 @@ CFLAGS+= -I${.CURDIR}/../../../sys # Cannot use .OBJDIR -- 'filemontest' expects 'test_script.sh' in . test: ${PROG} clean-test +.for BIN in ${PROG} ${PROG}32 cd ${.CURDIR} ; \ for A in 1 2 3 4 5 6 7 8 9 0; do \ for B in 1 2 3 4 5 6 7 8 9 0; do \ for C in 1 2 3 4 5 6 7 8 9 0; do \ - ${.OBJDIR}/${PROG} ;\ + test -x ${BIN} && ${.OBJDIR}/${BIN} ;\ done ;\ done ;\ done @cd ${.CURDIR} ; set +e ; egrep '(Start|Stop) .*\.' filemon_log.* | \ grep -q -v '\.[0-9][0-9][0-9][0-9][0-9][0-9]$$' || echo "Time stamp format OK" +.endfor clean-test: cd ${.CURDIR} ; rm -f filemon_log.* Modified: stable/9/tools/regression/filemon/filemontest.c ============================================================================== --- head/tools/regression/filemon/filemontest.c Mon Jun 4 22:59:33 2012 (r236594) +++ stable/9/tools/regression/filemon/filemontest.c Fri Jun 29 15:57:25 2012 (r237795) @@ -54,22 +54,27 @@ main(void) { if ((fm_log = mkstemp(log_name)) == -1) err(1, "mkstemp(%s)", log_name); - if (ioctl(fm_fd, FILEMON_SET_FD, &fm_log) < 0) + if (ioctl(fm_fd, FILEMON_SET_FD, &fm_log) == -1) err(1, "Cannot set filemon log file descriptor"); /* Set up these two fd's to close on exec. */ (void)fcntl(fm_fd, F_SETFD, FD_CLOEXEC); (void)fcntl(fm_log, F_SETFD, FD_CLOEXEC); - if ((child = fork()) == 0) { + switch (child = fork()) { + case 0: + child = getpid(); + if (ioctl(fm_fd, FILEMON_SET_PID, &child) == -1) + err(1, "Cannot set filemon PID to %d", child); system("./test_script.sh"); - return 0; - } else { - if (ioctl(fm_fd, FILEMON_SET_PID, &child) < 0) - err(1, "Cannot set filemon PID"); + break; + case -1: + err(1, "Cannot fork"); + default: wait(&child); close(fm_fd); // printf("Results in %s\n", log_name); + break; } return 0; } From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 16:29:38 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9C9A6106566B; Fri, 29 Jun 2012 16:29:38 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7D6EE8FC0C; Fri, 29 Jun 2012 16:29:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5TGTcCb056431; Fri, 29 Jun 2012 16:29:38 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5TGTcGc056429; Fri, 29 Jun 2012 16:29:38 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201206291629.q5TGTcGc056429@svn.freebsd.org> From: John Baldwin Date: Fri, 29 Jun 2012 16:29:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237797 - stable/9/sys/dev/pci X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 16:29:38 -0000 Author: jhb Date: Fri Jun 29 16:29:38 2012 New Revision: 237797 URL: http://svn.freebsd.org/changeset/base/237797 Log: MFC 237008,237271,237272,237673: - Fix a couple of bugs that prevented windows in PCI-PCI bridges from growing "downward" (moving the start address down). First, an off by one error caused the end address to be moved down an extra alignment chunk unnecessarily. Second, when aligning the new candidate starting address, the wrong bits were masked off. - Add a 'wmask' variable to hold the expression '(1ul << w->step) - 1' in pcib_grow_window(). - For subtractively decoding bridges, don't try to grow windows but pass the request up the tree in order to be on the safe side. Growing windows in this case would mean to switch resources to positive decoding and it's unclear how to correctly handle this. At least with ALi/ULi M5249 PCI-PCI bridges, this also just doesn't work out of the box. Modified: stable/9/sys/dev/pci/pci_pci.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/dev/isp/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/modules/ (props changed) Modified: stable/9/sys/dev/pci/pci_pci.c ============================================================================== --- stable/9/sys/dev/pci/pci_pci.c Fri Jun 29 16:06:06 2012 (r237796) +++ stable/9/sys/dev/pci/pci_pci.c Fri Jun 29 16:29:38 2012 (r237797) @@ -815,7 +815,7 @@ static int pcib_grow_window(struct pcib_softc *sc, struct pcib_window *w, int type, u_long start, u_long end, u_long count, u_int flags) { - u_long align, start_free, end_free, front, back; + u_long align, start_free, end_free, front, back, wmask; int error, rid; /* @@ -828,6 +828,7 @@ pcib_grow_window(struct pcib_softc *sc, end = w->rman.rm_end; if (start + count - 1 > end || start + count < start) return (EINVAL); + wmask = (1ul << w->step) - 1; /* * If there is no resource at all, just try to allocate enough @@ -838,8 +839,8 @@ pcib_grow_window(struct pcib_softc *sc, flags &= ~RF_ALIGNMENT_MASK; flags |= RF_ALIGNMENT_LOG2(w->step); } - start &= ~((1ul << w->step) - 1); - end |= ((1ul << w->step) - 1); + start &= ~wmask; + end |= wmask; count = roundup2(count, 1ul << w->step); rid = w->reg; w->res = bus_alloc_resource(sc->dev, type, &rid, start, end, @@ -893,9 +894,9 @@ pcib_grow_window(struct pcib_softc *sc, if (start < rman_get_start(w->res)) { if (rman_first_free_region(&w->rman, &start_free, &end_free) != 0 || start_free != rman_get_start(w->res)) - end_free = rman_get_start(w->res) - 1; + end_free = rman_get_start(w->res); if (end_free > end) - end_free = end; + end_free = end + 1; /* Move end_free down until it is properly aligned. */ end_free &= ~(align - 1); @@ -913,7 +914,7 @@ pcib_grow_window(struct pcib_softc *sc, if (bootverbose) printf("\tfront candidate range: %#lx-%#lx\n", front, end_free); - front &= (1ul << w->step) - 1; + front &= ~wmask; front = rman_get_start(w->res) - front; } else front = 0; @@ -941,7 +942,7 @@ pcib_grow_window(struct pcib_softc *sc, if (bootverbose) printf("\tback candidate range: %#lx-%#lx\n", start_free, back); - back = roundup2(back + 1, 1ul << w->step) - 1; + back |= wmask; back -= rman_get_end(w->res); } else back = 0; @@ -1000,10 +1001,8 @@ updatewin: /* Save the new window. */ w->base = rman_get_start(w->res); w->limit = rman_get_end(w->res); - KASSERT((w->base & ((1ul << w->step) - 1)) == 0, - ("start address is not aligned")); - KASSERT((w->limit & ((1ul << w->step) - 1)) == (1ul << w->step) - 1, - ("end address is not aligned")); + KASSERT((w->base & wmask) == 0, ("start address is not aligned")); + KASSERT((w->limit & wmask) == wmask, ("end address is not aligned")); pcib_write_windows(sc, w->mask); return (0); } @@ -1039,7 +1038,7 @@ pcib_alloc_resource(device_t dev, device case SYS_RES_IOPORT: r = pcib_suballoc_resource(sc, &sc->io, child, type, rid, start, end, count, flags); - if (r != NULL) + if (r != NULL || (sc->flags & PCIB_SUBTRACTIVE) != 0) break; if (pcib_grow_window(sc, &sc->io, type, start, end, count, flags) == 0) @@ -1063,7 +1062,7 @@ pcib_alloc_resource(device_t dev, device } r = pcib_suballoc_resource(sc, &sc->mem, child, type, rid, start, end, count, flags); - if (r != NULL) + if (r != NULL || (sc->flags & PCIB_SUBTRACTIVE) != 0) break; if (flags & RF_PREFETCHABLE) { if (pcib_grow_window(sc, &sc->pmem, type, start, end, From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 17:12:04 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AC32D106564A; Fri, 29 Jun 2012 17:12:04 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7D72C8FC0C; Fri, 29 Jun 2012 17:12:04 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5THC4Kn058452; Fri, 29 Jun 2012 17:12:04 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5THC4sk058450; Fri, 29 Jun 2012 17:12:04 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201206291712.q5THC4sk058450@svn.freebsd.org> From: John Baldwin Date: Fri, 29 Jun 2012 17:12:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237803 - stable/9/sys/vm X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 17:12:04 -0000 Author: jhb Date: Fri Jun 29 17:12:03 2012 New Revision: 237803 URL: http://svn.freebsd.org/changeset/base/237803 Log: MFC 237334: Move the per-thread deferred user map entries list into a private list in vm_map_process_deferred() which is then iterated to release map entries. This avoids having a nested vm map unlock operation called from the loop body attempt to recuse into vm_map_process_deferred(). This can happen if the vm_map_remove() triggers the OOM killer. Modified: stable/9/sys/vm/vm_map.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/dev/isp/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/modules/ (props changed) Modified: stable/9/sys/vm/vm_map.c ============================================================================== --- stable/9/sys/vm/vm_map.c Fri Jun 29 17:05:13 2012 (r237802) +++ stable/9/sys/vm/vm_map.c Fri Jun 29 17:12:03 2012 (r237803) @@ -475,12 +475,14 @@ static void vm_map_process_deferred(void) { struct thread *td; - vm_map_entry_t entry; + vm_map_entry_t entry, next; vm_object_t object; td = curthread; - while ((entry = td->td_map_def_user) != NULL) { - td->td_map_def_user = entry->next; + entry = td->td_map_def_user; + td->td_map_def_user = NULL; + while (entry != NULL) { + next = entry->next; if ((entry->eflags & MAP_ENTRY_VN_WRITECNT) != 0) { /* * Decrement the object's writemappings and @@ -494,6 +496,7 @@ vm_map_process_deferred(void) entry->end); } vm_map_entry_deallocate(entry, FALSE); + entry = next; } } From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 17:21:20 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3D2571065672; Fri, 29 Jun 2012 17:21:20 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1E9D88FC18; Fri, 29 Jun 2012 17:21:20 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5THLJmI058919; Fri, 29 Jun 2012 17:21:19 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5THLJ37058915; Fri, 29 Jun 2012 17:21:19 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201206291721.q5THLJ37058915@svn.freebsd.org> From: John Baldwin Date: Fri, 29 Jun 2012 17:21:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237805 - stable/9/sys/vm X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 17:21:20 -0000 Author: jhb Date: Fri Jun 29 17:21:19 2012 New Revision: 237805 URL: http://svn.freebsd.org/changeset/base/237805 Log: MFC 233191: Fix madvise(MADV_WILLNEED) to properly handle individual mappings larger than 4GB. Specifically, the inlined version of 'ptoa' of the the 'int' count of pages overflowed on 64-bit platforms. While here, change vm_object_madvise() to accept two vm_pindex_t parameters (start and end) rather than a (start, count) tuple to match other VM APIs as suggested by alc@. Modified: stable/9/sys/vm/vm_map.c stable/9/sys/vm/vm_object.c stable/9/sys/vm/vm_object.h Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/dev/isp/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/modules/ (props changed) Modified: stable/9/sys/vm/vm_map.c ============================================================================== --- stable/9/sys/vm/vm_map.c Fri Jun 29 17:12:26 2012 (r237804) +++ stable/9/sys/vm/vm_map.c Fri Jun 29 17:21:19 2012 (r237805) @@ -2105,8 +2105,7 @@ vm_map_madvise( } vm_map_unlock(map); } else { - vm_pindex_t pindex; - int count; + vm_pindex_t pstart, pend; /* * madvise behaviors that are implemented in the underlying @@ -2124,30 +2123,29 @@ vm_map_madvise( if (current->eflags & MAP_ENTRY_IS_SUB_MAP) continue; - pindex = OFF_TO_IDX(current->offset); - count = atop(current->end - current->start); + pstart = OFF_TO_IDX(current->offset); + pend = pstart + atop(current->end - current->start); useStart = current->start; if (current->start < start) { - pindex += atop(start - current->start); - count -= atop(start - current->start); + pstart += atop(start - current->start); useStart = start; } if (current->end > end) - count -= atop(current->end - end); + pend -= atop(current->end - end); - if (count <= 0) + if (pstart >= pend) continue; - vm_object_madvise(current->object.vm_object, - pindex, count, behav); + vm_object_madvise(current->object.vm_object, pstart, + pend, behav); if (behav == MADV_WILLNEED) { vm_map_pmap_enter(map, useStart, current->protection, current->object.vm_object, - pindex, - (count << PAGE_SHIFT), + pstart, + ptoa(pend - pstart), MAP_PREFAULT_MADVISE ); } Modified: stable/9/sys/vm/vm_object.c ============================================================================== --- stable/9/sys/vm/vm_object.c Fri Jun 29 17:12:26 2012 (r237804) +++ stable/9/sys/vm/vm_object.c Fri Jun 29 17:21:19 2012 (r237805) @@ -1064,16 +1064,16 @@ vm_object_sync(vm_object_t object, vm_oo * without I/O. */ void -vm_object_madvise(vm_object_t object, vm_pindex_t pindex, int count, int advise) +vm_object_madvise(vm_object_t object, vm_pindex_t pindex, vm_pindex_t end, + int advise) { - vm_pindex_t end, tpindex; + vm_pindex_t tpindex; vm_object_t backing_object, tobject; vm_page_t m; if (object == NULL) return; VM_OBJECT_LOCK(object); - end = pindex + count; /* * Locate and adjust resident pages */ Modified: stable/9/sys/vm/vm_object.h ============================================================================== --- stable/9/sys/vm/vm_object.h Fri Jun 29 17:12:26 2012 (r237804) +++ stable/9/sys/vm/vm_object.h Fri Jun 29 17:21:19 2012 (r237805) @@ -226,6 +226,7 @@ void vm_object_destroy (vm_object_t); void vm_object_terminate (vm_object_t); void vm_object_set_writeable_dirty (vm_object_t); void vm_object_init (void); +void vm_object_madvise(vm_object_t, vm_pindex_t, vm_pindex_t, int); void vm_object_page_cache(vm_object_t object, vm_pindex_t start, vm_pindex_t end); boolean_t vm_object_page_clean(vm_object_t object, vm_ooffset_t start, @@ -241,7 +242,6 @@ void vm_object_shadow (vm_object_t *, vm void vm_object_split(vm_map_entry_t); boolean_t vm_object_sync(vm_object_t, vm_ooffset_t, vm_size_t, boolean_t, boolean_t); -void vm_object_madvise (vm_object_t, vm_pindex_t, int, int); #endif /* _KERNEL */ #endif /* _VM_OBJECT_ */ From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 17:28:49 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7E37B106564A; Fri, 29 Jun 2012 17:28:49 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 681758FC0C; Fri, 29 Jun 2012 17:28:49 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5THSn8r059457; Fri, 29 Jun 2012 17:28:49 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5THSnWi059455; Fri, 29 Jun 2012 17:28:49 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201206291728.q5THSnWi059455@svn.freebsd.org> From: John Baldwin Date: Fri, 29 Jun 2012 17:28:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237809 - stable/9/etc/periodic/daily X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 17:28:49 -0000 Author: jhb Date: Fri Jun 29 17:28:48 2012 New Revision: 237809 URL: http://svn.freebsd.org/changeset/base/237809 Log: MFC 237337: Only output a list of file systems that need to be dumped if the system has a non-empty dumpdates file. Modified: stable/9/etc/periodic/daily/400.status-disks Directory Properties: stable/9/etc/ (props changed) Modified: stable/9/etc/periodic/daily/400.status-disks ============================================================================== --- stable/9/etc/periodic/daily/400.status-disks Fri Jun 29 17:28:03 2012 (r237808) +++ stable/9/etc/periodic/daily/400.status-disks Fri Jun 29 17:28:48 2012 (r237809) @@ -19,12 +19,15 @@ case "$daily_status_disks_enable" in df $daily_status_disks_df_flags && rc=1 || rc=3 # display which filesystems need backing up - if ! [ -f /etc/fstab ]; then - export PATH_FSTAB=/dev/null - fi + if [ -s /etc/dumpdates ]; then + if ! [ -f /etc/fstab ]; then + export PATH_FSTAB=/dev/null + fi - echo "" - dump W || rc=3;; + echo "" + dump W || rc=3 + fi + ;; *) rc=0;; esac From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 18:09:39 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DE1B41065670; Fri, 29 Jun 2012 18:09:39 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C7A9A8FC12; Fri, 29 Jun 2012 18:09:39 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5TI9d8O062065; Fri, 29 Jun 2012 18:09:39 GMT (envelope-from dim@svn.freebsd.org) Received: (from dim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5TI9dk1062063; Fri, 29 Jun 2012 18:09:39 GMT (envelope-from dim@svn.freebsd.org) Message-Id: <201206291809.q5TI9dk1062063@svn.freebsd.org> From: Dimitry Andric Date: Fri, 29 Jun 2012 18:09:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237812 - stable/9/sys/boot/i386/cdboot X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 18:09:40 -0000 Author: dim Date: Fri Jun 29 18:09:39 2012 New Revision: 237812 URL: http://svn.freebsd.org/changeset/base/237812 Log: MFC r235281: Fix sys/boot/i386/cdboot/cdboot.S compilation with clang after r235219. This file uses .code16 directives, which are not yet supported by clang's integrated assembler. Modified: stable/9/sys/boot/i386/cdboot/Makefile Directory Properties: stable/9/sys/ (props changed) stable/9/sys/boot/ (props changed) Modified: stable/9/sys/boot/i386/cdboot/Makefile ============================================================================== --- stable/9/sys/boot/i386/cdboot/Makefile Fri Jun 29 17:39:40 2012 (r237811) +++ stable/9/sys/boot/i386/cdboot/Makefile Fri Jun 29 18:09:39 2012 (r237812) @@ -13,3 +13,7 @@ ORG= 0x7c00 LDFLAGS=-e start -Ttext ${ORG} -Wl,-N,-S,--oformat,binary .include + +# XXX: clang integrated-as doesn't grok .codeNN directives yet +CFLAGS.cdboot.S= ${CLANG_NO_IAS} +CFLAGS+= ${CFLAGS.${.IMPSRC:T}} From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 18:18:51 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C4F631065677; Fri, 29 Jun 2012 18:18:51 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AF2EE8FC16; Fri, 29 Jun 2012 18:18:51 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5TIIp2X063014; Fri, 29 Jun 2012 18:18:51 GMT (envelope-from dim@svn.freebsd.org) Received: (from dim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5TIIp6H063012; Fri, 29 Jun 2012 18:18:51 GMT (envelope-from dim@svn.freebsd.org) Message-Id: <201206291818.q5TIIp6H063012@svn.freebsd.org> From: Dimitry Andric Date: Fri, 29 Jun 2012 18:18:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237814 - stable/9/share/mk X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 18:18:51 -0000 Author: dim Date: Fri Jun 29 18:18:51 2012 New Revision: 237814 URL: http://svn.freebsd.org/changeset/base/237814 Log: MFC r236810: Amend r227797 by also passing ${STATIC_CXXFLAGS} for the other supported C++ file extensions. Modified: stable/9/share/mk/bsd.lib.mk Directory Properties: stable/9/share/mk/ (props changed) Modified: stable/9/share/mk/bsd.lib.mk ============================================================================== --- stable/9/share/mk/bsd.lib.mk Fri Jun 29 18:15:56 2012 (r237813) +++ stable/9/share/mk/bsd.lib.mk Fri Jun 29 18:18:51 2012 (r237814) @@ -85,7 +85,7 @@ PO_FLAG=-pg (${ECHO} ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} && \ ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}) -.cc.o: +.cc.o .C.o .cpp.o .cxx.o: ${CXX} ${STATIC_CXXFLAGS} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET} .cc.po .C.po .cpp.po .cxx.po: From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 18:39:23 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7E73B1065670; Fri, 29 Jun 2012 18:39:23 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 68A7E8FC0C; Fri, 29 Jun 2012 18:39:23 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5TIdN3G063898; Fri, 29 Jun 2012 18:39:23 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5TIdN1G063896; Fri, 29 Jun 2012 18:39:23 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201206291839.q5TIdN1G063896@svn.freebsd.org> From: Marius Strobl Date: Fri, 29 Jun 2012 18:39:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237815 - stable/9/sys/boot/sparc64/loader X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 18:39:23 -0000 Author: marius Date: Fri Jun 29 18:39:22 2012 New Revision: 237815 URL: http://svn.freebsd.org/changeset/base/237815 Log: MFC: r236581 The loaddev environment variable is not modifiable once set, so it is not update for ZFS. It seems that this does not really affect anything except the help command. Nevertheless, rearrange things so loaddev is set only once in all cases in order to get it right. Pointed out by: avg Modified: stable/9/sys/boot/sparc64/loader/main.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/dev/isp/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/modules/ (props changed) Modified: stable/9/sys/boot/sparc64/loader/main.c ============================================================================== --- stable/9/sys/boot/sparc64/loader/main.c Fri Jun 29 18:18:51 2012 (r237814) +++ stable/9/sys/boot/sparc64/loader/main.c Fri Jun 29 18:39:22 2012 (r237815) @@ -141,6 +141,7 @@ static u_int tlb_locked; static vm_offset_t curkva = 0; static vm_offset_t heapva; +static char bootpath[64]; static phandle_t root; /* @@ -740,7 +741,7 @@ sparc64_zfs_probe(void) /* Get the GUID of the ZFS pool on the boot device. */ guid = 0; - zfs_probe_dev(getenv("currdev"), &guid); + zfs_probe_dev(bootpath, &guid); for (unit = 0; unit < MAXDEV; unit++) { /* Find freebsd-zfs slices in the VTOC. */ @@ -757,7 +758,7 @@ sparc64_zfs_probe(void) for (part = 0; part < 8; part++) { if (part == 2 || vtoc.part[part].tag != - VTOC_TAG_FREEBSD_ZFS) + VTOC_TAG_FREEBSD_ZFS) continue; sprintf(devname, "disk%d:%c", unit, part + 'a'); if (zfs_probe_dev(devname, NULL) == ENXIO) @@ -770,11 +771,9 @@ sparc64_zfs_probe(void) zfs_currdev.root_guid = 0; zfs_currdev.d_dev = &zfs_dev; zfs_currdev.d_type = zfs_currdev.d_dev->dv_type; - /* Update the environment for ZFS. */ - env_setenv("currdev", EV_VOLATILE, zfs_fmtdev(&zfs_currdev), - ofw_setcurrdev, env_nounset); - env_setenv("loaddev", EV_VOLATILE, zfs_fmtdev(&zfs_currdev), - env_noset, env_nounset); + (void)strncpy(bootpath, zfs_fmtdev(&zfs_currdev), + sizeof(bootpath) - 1); + bootpath[sizeof(bootpath) - 1] = '\0'; } } #endif /* LOADER_ZFS_SUPPORT */ @@ -782,7 +781,6 @@ sparc64_zfs_probe(void) int main(int (*openfirm)(void *)) { - char bootpath[64]; char compatible[32]; struct devsw **dp; @@ -834,16 +832,11 @@ main(int (*openfirm)(void *)) */ if (bootpath[strlen(bootpath) - 2] == ':' && bootpath[strlen(bootpath) - 1] == 'f' && - strstr(bootpath, "cdrom")) { + strstr(bootpath, "cdrom") != NULL) { bootpath[strlen(bootpath) - 1] = 'a'; printf("Boot path set to %s\n", bootpath); } - env_setenv("currdev", EV_VOLATILE, bootpath, - ofw_setcurrdev, env_nounset); - env_setenv("loaddev", EV_VOLATILE, bootpath, - env_noset, env_nounset); - /* * Initialize devices. */ @@ -851,6 +844,15 @@ main(int (*openfirm)(void *)) if ((*dp)->dv_init != 0) (*dp)->dv_init(); + /* + * Now that sparc64_zfs_probe() might have altered bootpath, + * export it. + */ + env_setenv("currdev", EV_VOLATILE, bootpath, + ofw_setcurrdev, env_nounset); + env_setenv("loaddev", EV_VOLATILE, bootpath, + env_noset, env_nounset); + printf("\n"); printf("%s, Revision %s\n", bootprog_name, bootprog_rev); printf("(%s, %s)\n", bootprog_maker, bootprog_date); From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 19:48:05 2012 Return-Path: Delivered-To: svn-src-stable-9@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5F618106566B; Fri, 29 Jun 2012 19:48:05 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id DDBE48FC08; Fri, 29 Jun 2012 19:48:03 +0000 (UTC) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id WAA10174; Fri, 29 Jun 2012 22:48:02 +0300 (EEST) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1SkhAg-0005Bo-0L; Fri, 29 Jun 2012 22:48:02 +0300 Message-ID: <4FEE0670.6000306@FreeBSD.org> Date: Fri, 29 Jun 2012 22:48:00 +0300 From: Andriy Gapon User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:13.0) Gecko/20120620 Thunderbird/13.0.1 MIME-Version: 1.0 To: Dimitry Andric References: <201206291809.q5TI9dk1062063@svn.freebsd.org> In-Reply-To: <201206291809.q5TI9dk1062063@svn.freebsd.org> X-Enigmail-Version: 1.4.2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: svn-src-stable@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, svn-src-stable-9@FreeBSD.org Subject: Re: svn commit: r237812 - stable/9/sys/boot/i386/cdboot X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 19:48:05 -0000 on 29/06/2012 21:09 Dimitry Andric said the following: > Author: dim > Date: Fri Jun 29 18:09:39 2012 > New Revision: 237812 > URL: http://svn.freebsd.org/changeset/base/237812 > > Log: > MFC r235281: > > Fix sys/boot/i386/cdboot/cdboot.S compilation with clang after r235219. > This file uses .code16 directives, which are not yet supported by > clang's integrated assembler. Sorry and thank you again. I should have remembered this problem and this fix, but MFC timeout was too long for my memory. > Modified: > stable/9/sys/boot/i386/cdboot/Makefile > Directory Properties: > stable/9/sys/ (props changed) > stable/9/sys/boot/ (props changed) > > Modified: stable/9/sys/boot/i386/cdboot/Makefile > ============================================================================== > --- stable/9/sys/boot/i386/cdboot/Makefile Fri Jun 29 17:39:40 2012 (r237811) > +++ stable/9/sys/boot/i386/cdboot/Makefile Fri Jun 29 18:09:39 2012 (r237812) > @@ -13,3 +13,7 @@ ORG= 0x7c00 > LDFLAGS=-e start -Ttext ${ORG} -Wl,-N,-S,--oformat,binary > > .include > + > +# XXX: clang integrated-as doesn't grok .codeNN directives yet > +CFLAGS.cdboot.S= ${CLANG_NO_IAS} > +CFLAGS+= ${CFLAGS.${.IMPSRC:T}} > -- Andriy Gapon From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 21:19:25 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7E0C2106564A; Fri, 29 Jun 2012 21:19:25 +0000 (UTC) (envelope-from ken@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 669F18FC15; Fri, 29 Jun 2012 21:19:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5TLJP5r070696; Fri, 29 Jun 2012 21:19:25 GMT (envelope-from ken@svn.freebsd.org) Received: (from ken@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5TLJPrA070685; Fri, 29 Jun 2012 21:19:25 GMT (envelope-from ken@svn.freebsd.org) Message-Id: <201206292119.q5TLJPrA070685@svn.freebsd.org> From: "Kenneth D. Merry" Date: Fri, 29 Jun 2012 21:19:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237821 - in stable/9: sys/cam/ctl usr.sbin/ctladm X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 21:19:25 -0000 Author: ken Date: Fri Jun 29 21:19:24 2012 New Revision: 237821 URL: http://svn.freebsd.org/changeset/base/237821 Log: MFC r232604: r232604 | trasz | 2012-03-06 06:43:57 -0700 (Tue, 06 Mar 2012) | 6 lines Add LUN resizing to CTL. Also make it possible to explicitly set size when creating file-backed or device-backed LUN. Reviewed by: ken (earlier version) Sponsored by: The FreeBSD Foundation Modified: stable/9/sys/cam/ctl/ctl.c stable/9/sys/cam/ctl/ctl.h stable/9/sys/cam/ctl/ctl_backend.h stable/9/sys/cam/ctl/ctl_backend_block.c stable/9/sys/cam/ctl/ctl_backend_ramdisk.c stable/9/sys/cam/ctl/ctl_error.c stable/9/sys/cam/ctl/ctl_ioctl.h stable/9/usr.sbin/ctladm/Makefile stable/9/usr.sbin/ctladm/ctladm.8 stable/9/usr.sbin/ctladm/ctladm.c Directory Properties: stable/9/sys/ (props changed) stable/9/usr.sbin/ctladm/ (props changed) Modified: stable/9/sys/cam/ctl/ctl.c ============================================================================== --- stable/9/sys/cam/ctl/ctl.c Fri Jun 29 20:15:00 2012 (r237820) +++ stable/9/sys/cam/ctl/ctl.c Fri Jun 29 21:19:24 2012 (r237821) @@ -1,7 +1,11 @@ /*- * Copyright (c) 2003-2009 Silicon Graphics International Corp. + * Copyright (c) 2012 The FreeBSD Foundation * All rights reserved. * + * Portions of this software were developed by Edward Tomasz Napierala + * under sponsorship from the FreeBSD Foundation. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -4797,6 +4801,25 @@ ctl_lun_power_lock(struct ctl_be_lun *be return (0); } +void +ctl_lun_capacity_changed(struct ctl_be_lun *be_lun) +{ + struct ctl_lun *lun; + struct ctl_softc *softc; + int i; + + softc = control_softc; + + mtx_lock(&softc->ctl_lock); + + lun = (struct ctl_lun *)be_lun->ctl_lun; + + for (i = 0; i < CTL_MAX_INITIATORS; i++) + lun->pending_sense[i].ua_pending |= CTL_UA_CAPACITY_CHANGED; + + mtx_unlock(&softc->ctl_lock); +} + /* * Backend "memory move is complete" callback for requests that never * make it down to say RAIDCore's configuration code. Modified: stable/9/sys/cam/ctl/ctl.h ============================================================================== --- stable/9/sys/cam/ctl/ctl.h Fri Jun 29 20:15:00 2012 (r237820) +++ stable/9/sys/cam/ctl/ctl.h Fri Jun 29 21:19:24 2012 (r237821) @@ -120,7 +120,8 @@ typedef enum { CTL_UA_RES_PREEMPT = 0x0200, CTL_UA_RES_RELEASE = 0x0400, CTL_UA_REG_PREEMPT = 0x0800, - CTL_UA_ASYM_ACC_CHANGE = 0x1000 + CTL_UA_ASYM_ACC_CHANGE = 0x1000, + CTL_UA_CAPACITY_CHANGED = 0x2000 } ctl_ua_type; #ifdef _KERNEL Modified: stable/9/sys/cam/ctl/ctl_backend.h ============================================================================== --- stable/9/sys/cam/ctl/ctl_backend.h Fri Jun 29 20:15:00 2012 (r237820) +++ stable/9/sys/cam/ctl/ctl_backend.h Fri Jun 29 21:19:24 2012 (r237821) @@ -280,6 +280,11 @@ int ctl_lun_power_lock(struct ctl_be_lun int ctl_lun_offline(struct ctl_be_lun *be_lun); int ctl_lun_online(struct ctl_be_lun *be_lun); +/* + * Let the backend notify the initiator about changed capacity. + */ +void ctl_lun_capacity_changed(struct ctl_be_lun *be_lun); + #endif /* _KERNEL */ #endif /* _CTL_BACKEND_H_ */ Modified: stable/9/sys/cam/ctl/ctl_backend_block.c ============================================================================== --- stable/9/sys/cam/ctl/ctl_backend_block.c Fri Jun 29 20:15:00 2012 (r237820) +++ stable/9/sys/cam/ctl/ctl_backend_block.c Fri Jun 29 21:19:24 2012 (r237821) @@ -1,8 +1,12 @@ /*- * Copyright (c) 2003 Silicon Graphics International Corp. * Copyright (c) 2009-2011 Spectra Logic Corporation + * Copyright (c) 2012 The FreeBSD Foundation * All rights reserved. * + * Portions of this software were developed by Edward Tomasz Napierala + * under sponsorship from the FreeBSD Foundation. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -250,6 +254,12 @@ static int ctl_be_block_create(struct ct struct ctl_lun_req *req); static int ctl_be_block_rm(struct ctl_be_block_softc *softc, struct ctl_lun_req *req); +static int ctl_be_block_modify_file(struct ctl_be_block_lun *be_lun, + struct ctl_lun_req *req); +static int ctl_be_block_modify_dev(struct ctl_be_block_lun *be_lun, + struct ctl_lun_req *req); +static int ctl_be_block_modify(struct ctl_be_block_softc *softc, + struct ctl_lun_req *req); static void ctl_be_block_lun_shutdown(void *be_lun); static void ctl_be_block_lun_config_status(void *be_lun, ctl_lun_config_status status); @@ -1263,6 +1273,9 @@ ctl_be_block_ioctl(struct cdev *dev, u_l case CTL_LUNREQ_RM: error = ctl_be_block_rm(softc, lun_req); break; + case CTL_LUNREQ_MODIFY: + error = ctl_be_block_modify(softc, lun_req); + break; default: lun_req->status = CTL_LUN_ERROR; snprintf(lun_req->error_str, sizeof(lun_req->error_str), @@ -1321,7 +1334,10 @@ ctl_be_block_open_file(struct ctl_be_blo file_data->cred = crhold(curthread->td_ucred); - be_lun->size_bytes = vattr.va_size; + if (params->lun_size_bytes != 0) + be_lun->size_bytes = params->lun_size_bytes; + else + be_lun->size_bytes = vattr.va_size; /* * We set the multi thread flag for file operations because all * filesystems (in theory) are capable of allowing multiple readers @@ -1446,15 +1462,27 @@ ctl_be_block_open_dev(struct ctl_be_bloc curthread); if (error) { snprintf(req->error_str, sizeof(req->error_str), - "%s: error %d returned for DIOCGMEDIASIZE ioctl " - "on %s!", __func__, error, be_lun->dev_path); + "%s: error %d returned for DIOCGMEDIASIZE " + " ioctl on %s!", __func__, error, + be_lun->dev_path); return (error); } - return (0); + if (params->lun_size_bytes != 0) { + if (params->lun_size_bytes > be_lun->size_bytes) { + snprintf(req->error_str, sizeof(req->error_str), + "%s: requested LUN size %ju > backing device " + "size %ju", __func__, + (uintmax_t)params->lun_size_bytes, + (uintmax_t)be_lun->size_bytes); + return (EINVAL); + } -} + be_lun->size_bytes = params->lun_size_bytes; + } + return (0); +} static int ctl_be_block_close(struct ctl_be_block_lun *be_lun) @@ -1599,7 +1627,6 @@ ctl_be_block_open(struct ctl_be_block_so be_lun->size_blocks = be_lun->size_bytes >> be_lun->blocksize_shift; return (0); - } static int @@ -2007,6 +2034,155 @@ bailout_error: return (0); } +static int +ctl_be_block_modify_file(struct ctl_be_block_lun *be_lun, + struct ctl_lun_req *req) +{ + struct vattr vattr; + int error; + struct ctl_lun_modify_params *params; + + params = &req->reqdata.modify; + + if (params->lun_size_bytes != 0) { + be_lun->size_bytes = params->lun_size_bytes; + } else { + error = VOP_GETATTR(be_lun->vn, &vattr, curthread->td_ucred); + if (error != 0) { + snprintf(req->error_str, sizeof(req->error_str), + "error calling VOP_GETATTR() for file %s", + be_lun->dev_path); + return (error); + } + + be_lun->size_bytes = vattr.va_size; + } + + return (0); +} + +static int +ctl_be_block_modify_dev(struct ctl_be_block_lun *be_lun, + struct ctl_lun_req *req) +{ + struct cdev *dev; + struct cdevsw *devsw; + int error; + struct ctl_lun_modify_params *params; + uint64_t size_bytes; + + params = &req->reqdata.modify; + + dev = be_lun->vn->v_rdev; + devsw = dev->si_devsw; + if (!devsw->d_ioctl) { + snprintf(req->error_str, sizeof(req->error_str), + "%s: no d_ioctl for device %s!", __func__, + be_lun->dev_path); + return (ENODEV); + } + + error = devsw->d_ioctl(dev, DIOCGMEDIASIZE, + (caddr_t)&size_bytes, FREAD, + curthread); + if (error) { + snprintf(req->error_str, sizeof(req->error_str), + "%s: error %d returned for DIOCGMEDIASIZE ioctl " + "on %s!", __func__, error, be_lun->dev_path); + return (error); + } + + if (params->lun_size_bytes != 0) { + if (params->lun_size_bytes > size_bytes) { + snprintf(req->error_str, sizeof(req->error_str), + "%s: requested LUN size %ju > backing device " + "size %ju", __func__, + (uintmax_t)params->lun_size_bytes, + (uintmax_t)size_bytes); + return (EINVAL); + } + + be_lun->size_bytes = params->lun_size_bytes; + } else { + be_lun->size_bytes = size_bytes; + } + + return (0); +} + +static int +ctl_be_block_modify(struct ctl_be_block_softc *softc, struct ctl_lun_req *req) +{ + struct ctl_lun_modify_params *params; + struct ctl_be_block_lun *be_lun; + int vfs_is_locked, error; + + params = &req->reqdata.modify; + + mtx_lock(&softc->lock); + + be_lun = NULL; + + STAILQ_FOREACH(be_lun, &softc->lun_list, links) { + if (be_lun->ctl_be_lun.lun_id == params->lun_id) + break; + } + mtx_unlock(&softc->lock); + + if (be_lun == NULL) { + snprintf(req->error_str, sizeof(req->error_str), + "%s: LUN %u is not managed by the block backend", + __func__, params->lun_id); + goto bailout_error; + } + + if (params->lun_size_bytes != 0) { + if (params->lun_size_bytes < be_lun->blocksize) { + snprintf(req->error_str, sizeof(req->error_str), + "%s: LUN size %ju < blocksize %u", __func__, + params->lun_size_bytes, be_lun->blocksize); + goto bailout_error; + } + } + + vfs_is_locked = VFS_LOCK_GIANT(be_lun->vn->v_mount); + vn_lock(be_lun->vn, LK_SHARED | LK_RETRY); + + if (be_lun->vn->v_type == VREG) + error = ctl_be_block_modify_file(be_lun, req); + else + error = ctl_be_block_modify_dev(be_lun, req); + + VOP_UNLOCK(be_lun->vn, 0); + VFS_UNLOCK_GIANT(vfs_is_locked); + + if (error != 0) + goto bailout_error; + + be_lun->size_blocks = be_lun->size_bytes >> be_lun->blocksize_shift; + + /* + * The maximum LBA is the size - 1. + * + * XXX: Note that this field is being updated without locking, + * which might cause problems on 32-bit architectures. + */ + be_lun->ctl_be_lun.maxlba = be_lun->size_blocks - 1; + ctl_lun_capacity_changed(&be_lun->ctl_be_lun); + + /* Tell the user the exact size we ended up using */ + params->lun_size_bytes = be_lun->size_bytes; + + req->status = CTL_LUN_OK; + + return (0); + +bailout_error: + req->status = CTL_LUN_ERROR; + + return (0); +} + static void ctl_be_block_lun_shutdown(void *be_lun) { Modified: stable/9/sys/cam/ctl/ctl_backend_ramdisk.c ============================================================================== --- stable/9/sys/cam/ctl/ctl_backend_ramdisk.c Fri Jun 29 20:15:00 2012 (r237820) +++ stable/9/sys/cam/ctl/ctl_backend_ramdisk.c Fri Jun 29 21:19:24 2012 (r237821) @@ -1,7 +1,11 @@ /*- * Copyright (c) 2003, 2008 Silicon Graphics International Corp. + * Copyright (c) 2012 The FreeBSD Foundation * All rights reserved. * + * Portions of this software were developed by Edward Tomasz Napierala + * under sponsorship from the FreeBSD Foundation. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -102,6 +106,8 @@ static int ctl_backend_ramdisk_rm(struct struct ctl_lun_req *req); static int ctl_backend_ramdisk_create(struct ctl_be_ramdisk_softc *softc, struct ctl_lun_req *req, int do_wait); +static int ctl_backend_ramdisk_modify(struct ctl_be_ramdisk_softc *softc, + struct ctl_lun_req *req); static void ctl_backend_ramdisk_lun_shutdown(void *be_lun); static void ctl_backend_ramdisk_lun_config_status(void *be_lun, ctl_lun_config_status status); @@ -376,6 +382,9 @@ ctl_backend_ramdisk_ioctl(struct cdev *d case CTL_LUNREQ_RM: retval = ctl_backend_ramdisk_rm(softc, lun_req); break; + case CTL_LUNREQ_MODIFY: + retval = ctl_backend_ramdisk_modify(softc, lun_req); + break; default: lun_req->status = CTL_LUN_ERROR; snprintf(lun_req->error_str, sizeof(lun_req->error_str), @@ -666,6 +675,73 @@ bailout_error: return (retval); } +static int +ctl_backend_ramdisk_modify(struct ctl_be_ramdisk_softc *softc, + struct ctl_lun_req *req) +{ + struct ctl_be_ramdisk_lun *be_lun; + struct ctl_lun_modify_params *params; + uint32_t blocksize; + + params = &req->reqdata.modify; + + be_lun = NULL; + + mtx_lock(&softc->lock); + STAILQ_FOREACH(be_lun, &softc->lun_list, links) { + if (be_lun->ctl_be_lun.lun_id == params->lun_id) + break; + } + mtx_unlock(&softc->lock); + + if (be_lun == NULL) { + snprintf(req->error_str, sizeof(req->error_str), + "%s: LUN %u is not managed by the ramdisk backend", + __func__, params->lun_id); + goto bailout_error; + } + + if (params->lun_size_bytes == 0) { + snprintf(req->error_str, sizeof(req->error_str), + "%s: LUN size \"auto\" not supported " + "by the ramdisk backend", __func__); + goto bailout_error; + } + + blocksize = be_lun->ctl_be_lun.blocksize; + + if (params->lun_size_bytes < blocksize) { + snprintf(req->error_str, sizeof(req->error_str), + "%s: LUN size %ju < blocksize %u", __func__, + params->lun_size_bytes, blocksize); + goto bailout_error; + } + + be_lun->size_blocks = params->lun_size_bytes / blocksize; + be_lun->size_bytes = be_lun->size_blocks * blocksize; + + /* + * The maximum LBA is the size - 1. + * + * XXX: Note that this field is being updated without locking, + * which might cause problems on 32-bit architectures. + */ + be_lun->ctl_be_lun.maxlba = be_lun->size_blocks - 1; + ctl_lun_capacity_changed(&be_lun->ctl_be_lun); + + /* Tell the user the exact size we ended up using */ + params->lun_size_bytes = be_lun->size_bytes; + + req->status = CTL_LUN_OK; + + return (0); + +bailout_error: + req->status = CTL_LUN_ERROR; + + return (0); +} + static void ctl_backend_ramdisk_lun_shutdown(void *be_lun) { Modified: stable/9/sys/cam/ctl/ctl_error.c ============================================================================== --- stable/9/sys/cam/ctl/ctl_error.c Fri Jun 29 20:15:00 2012 (r237820) +++ stable/9/sys/cam/ctl/ctl_error.c Fri Jun 29 21:19:24 2012 (r237821) @@ -454,6 +454,11 @@ ctl_build_ua(ctl_ua_type ua_type, struct asc = 0x2A; ascq = 0x06; break; + case CTL_UA_CAPACITY_CHANGED: + /* 2Ah/09n CAPACITY DATA HAS CHANGED */ + asc = 0x2A; + ascq = 0x09; + break; default: ua_to_build = CTL_UA_NONE; return (ua_to_build); Modified: stable/9/sys/cam/ctl/ctl_ioctl.h ============================================================================== --- stable/9/sys/cam/ctl/ctl_ioctl.h Fri Jun 29 20:15:00 2012 (r237820) +++ stable/9/sys/cam/ctl/ctl_ioctl.h Fri Jun 29 21:19:24 2012 (r237821) @@ -397,7 +397,8 @@ struct ctl_be_arg { typedef enum { CTL_LUNREQ_CREATE, - CTL_LUNREQ_RM + CTL_LUNREQ_RM, + CTL_LUNREQ_MODIFY, } ctl_lunreq_type; @@ -471,12 +472,27 @@ struct ctl_lun_rm_params { }; /* + * LUN modification parameters: + * + * lun_id: The number of the LUN to modify. This must be set. + * The LUN must be backed by the given backend. + * + * lun_size_bytes: The size of the LUN in bytes. If zero, update + * the size using the backing file size, if possible. + */ +struct ctl_lun_modify_params { + uint32_t lun_id; + uint64_t lun_size_bytes; +}; + +/* * Union of request type data. Fill in the appropriate union member for * the request type. */ union ctl_lunreq_data { struct ctl_lun_create_params create; struct ctl_lun_rm_params rm; + struct ctl_lun_modify_params modify; }; /* Modified: stable/9/usr.sbin/ctladm/Makefile ============================================================================== --- stable/9/usr.sbin/ctladm/Makefile Fri Jun 29 20:15:00 2012 (r237820) +++ stable/9/usr.sbin/ctladm/Makefile Fri Jun 29 21:19:24 2012 (r237821) @@ -14,8 +14,8 @@ CFLAGS+= -I${SDIR} WARNS?= 3 .endif -DPADD= ${LIBCAM} ${LIBSBUF} -LDADD= -lcam -lsbuf -lbsdxml +DPADD= ${LIBCAM} ${LIBSBUF} ${LIBBSDXML} ${LIBUTIL} +LDADD= -lcam -lsbuf -lbsdxml -lutil MAN= ctladm.8 .include Modified: stable/9/usr.sbin/ctladm/ctladm.8 ============================================================================== --- stable/9/usr.sbin/ctladm/ctladm.8 Fri Jun 29 20:15:00 2012 (r237820) +++ stable/9/usr.sbin/ctladm/ctladm.8 Fri Jun 29 21:19:24 2012 (r237821) @@ -34,7 +34,7 @@ .\" $Id: //depot/users/kenm/FreeBSD-test2/usr.sbin/ctladm/ctladm.8#3 $ .\" $FreeBSD$ .\" -.Dd July 8, 2011 +.Dd March 6, 2012 .Dt CTLADM 8 .Os .Sh NAME @@ -173,6 +173,11 @@ .Aq Fl l Ar lun_id .Op Fl o Ar name=value .Nm +.Ic modify +.Aq Fl b Ar backend +.Aq Fl l Ar lun_id +.Aq Fl s Ar size_bytes +.Nm .Ic devlist .Op Fl b Ar backend .Op Fl v @@ -830,6 +835,27 @@ Multiple arguments may be specified. Refer to the backend documentation for arguments that may be used. .El +.It Ic modify +Modify a LUN size. +The backend, the LUN number, and the size must be specified. +.Bl -tag -width 14n +.It Fl b Ar backend +Specify the backend that owns the LUN to be removed. +Examples are +.Dq ramdisk +and +.Dq block . +.It Fl l Ar lun_id +Specify the LUN number to remove. +.It Fl s Ar size_bytes +Specify the size of the LUN in bytes. +For the +.Dq block +backend, an +.Dq auto +keyword may be passed instead; this will make CTL use the size of backing +file or device. +.El .It Ic devlist Get a list of all configured LUNs. This also includes the LUN size and blocksize, serial number and device ID. Modified: stable/9/usr.sbin/ctladm/ctladm.c ============================================================================== --- stable/9/usr.sbin/ctladm/ctladm.c Fri Jun 29 20:15:00 2012 (r237820) +++ stable/9/usr.sbin/ctladm/ctladm.c Fri Jun 29 21:19:24 2012 (r237821) @@ -1,8 +1,12 @@ /*- * Copyright (c) 2003, 2004 Silicon Graphics International Corp. * Copyright (c) 1997-2007 Kenneth D. Merry + * Copyright (c) 2012 The FreeBSD Foundation * All rights reserved. * + * Portions of this software were developed by Edward Tomasz Napierala + * under sponsorship from the FreeBSD Foundation. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -68,6 +72,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include "ctladm.h" #ifdef min @@ -110,7 +115,8 @@ typedef enum { CTLADM_CMD_PRES_IN, CTLADM_CMD_PRES_OUT, CTLADM_CMD_INQ_VPD_DEVID, - CTLADM_CMD_RTPG + CTLADM_CMD_RTPG, + CTLADM_CMD_MODIFY } ctladm_cmdfunction; typedef enum { @@ -175,6 +181,7 @@ struct ctladm_opts option_table[] = { {"inquiry", CTLADM_CMD_INQUIRY, CTLADM_ARG_NEED_TL, NULL}, {"lunlist", CTLADM_CMD_LUNLIST, CTLADM_ARG_NONE, NULL}, {"modesense", CTLADM_CMD_MODESENSE, CTLADM_ARG_NEED_TL, "P:S:dlm:c:"}, + {"modify", CTLADM_CMD_MODIFY, CTLADM_ARG_NONE, "b:l:s:"}, {"port", CTLADM_CMD_PORT, CTLADM_ARG_NONE, "lo:p:qt:w:W:x"}, {"prin", CTLADM_CMD_PRES_IN, CTLADM_ARG_NEED_TL, "a:"}, {"prout", CTLADM_CMD_PRES_OUT, CTLADM_ARG_NEED_TL, "a:k:r:s:"}, @@ -249,6 +256,7 @@ static int cctl_create_lun(int fd, int a static int cctl_inquiry_vpd_devid(int fd, int target, int lun, int initiator); static int cctl_report_target_port_group(int fd, int target, int lun, int initiator); +static int cctl_modify_lun(int fd, int argc, char **argv, char *combinedopt); ctladm_optret getoption(struct ctladm_opts *table, char *arg, uint32_t *cmdnum, @@ -3043,7 +3051,15 @@ cctl_create_lun(int fd, int argc, char * break; } case 's': - lun_size = strtoull(optarg, NULL, 0); + if (strcasecmp(optarg, "auto") != 0) { + retval = expand_number(optarg, &lun_size); + if (retval != 0) { + warn("%s: invalid -s argument", + __func__); + retval = 1; + goto bailout; + } + } lun_size_set = 1; break; case 'S': @@ -3287,12 +3303,12 @@ cctl_rm_lun(int fd, int argc, char **arg } if (req.status == CTL_LUN_ERROR) { - warnx("%s: error returned from LUN creation request:\n%s", + warnx("%s: error returned from LUN removal request:\n%s", __func__, req.error_str); retval = 1; goto bailout; } else if (req.status != CTL_LUN_OK) { - warnx("%s: unknown LUN creation request status %d", + warnx("%s: unknown LUN removal request status %d", __func__, req.status); retval = 1; goto bailout; @@ -3304,6 +3320,84 @@ bailout: return (retval); } +static int +cctl_modify_lun(int fd, int argc, char **argv, char *combinedopt) +{ + struct ctl_lun_req req; + uint64_t lun_size = 0; + uint32_t lun_id = 0; + int lun_id_set = 0, lun_size_set = 0; + char *backend_name = NULL; + int retval = 0, c; + + while ((c = getopt(argc, argv, combinedopt)) != -1) { + switch (c) { + case 'b': + backend_name = strdup(optarg); + break; + case 'l': + lun_id = strtoul(optarg, NULL, 0); + lun_id_set = 1; + break; + case 's': + if (strcasecmp(optarg, "auto") != 0) { + retval = expand_number(optarg, &lun_size); + if (retval != 0) { + warn("%s: invalid -s argument", + __func__); + retval = 1; + goto bailout; + } + } + lun_size_set = 1; + break; + default: + break; + } + } + + if (backend_name == NULL) + errx(1, "%s: backend name (-b) must be specified", __func__); + + if (lun_id_set == 0) + errx(1, "%s: LUN id (-l) must be specified", __func__); + + if (lun_size_set == 0) + errx(1, "%s: size (-s) must be specified", __func__); + + bzero(&req, sizeof(req)); + + strlcpy(req.backend, backend_name, sizeof(req.backend)); + req.reqtype = CTL_LUNREQ_MODIFY; + + req.reqdata.modify.lun_id = lun_id; + req.reqdata.modify.lun_size_bytes = lun_size; + + if (ioctl(fd, CTL_LUN_REQ, &req) == -1) { + warn("%s: error issuing CTL_LUN_REQ ioctl", __func__); + retval = 1; + goto bailout; + } + + if (req.status == CTL_LUN_ERROR) { + warnx("%s: error returned from LUN modification request:\n%s", + __func__, req.error_str); + retval = 1; + goto bailout; + } else if (req.status != CTL_LUN_OK) { + warnx("%s: unknown LUN modification request status %d", + __func__, req.status); + retval = 1; + goto bailout; + } + + printf("LUN %d modified successfully\n", lun_id); + +bailout: + return (retval); +} + + /* * Name/value pair used for per-LUN attributes. */ @@ -3599,6 +3693,7 @@ usage(int error) " [-l lun_id] [-o name=value] [-s size_bytes]\n" " [-S serial_num] [-t dev_type]\n" " ctladm remove <-b backend> <-l lun_id> [-o name=value]\n" +" ctladm modify <-b backend> <-l lun_id> <-s size_bytes>\n" " ctladm devlist [-b][-v][-x]\n" " ctladm shutdown\n" " ctladm startup\n" @@ -3983,6 +4078,9 @@ main(int argc, char **argv) case CTLADM_CMD_RTPG: retval = cctl_report_target_port_group(fd, target, lun, initid); break; + case CTLADM_CMD_MODIFY: + retval = cctl_modify_lun(fd, argc, argv, combinedopt); + break; case CTLADM_CMD_HELP: default: usage(retval); From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 21:24:57 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8F869106566C; Fri, 29 Jun 2012 21:24:57 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 76C7B8FC16; Fri, 29 Jun 2012 21:24:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5TLOv01071047; Fri, 29 Jun 2012 21:24:57 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5TLOvtW071039; Fri, 29 Jun 2012 21:24:57 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201206292124.q5TLOvtW071039@svn.freebsd.org> From: John Baldwin Date: Fri, 29 Jun 2012 21:24:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237822 - in stable/9: share/man/man4 sys/amd64/acpica sys/dev/acpica sys/i386/acpica X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 21:24:57 -0000 Author: jhb Date: Fri Jun 29 21:24:56 2012 New Revision: 237822 URL: http://svn.freebsd.org/changeset/base/237822 Log: MFC 235024,235029,235556,235834,235845: Use MADT to match ACPI Processor objects to CPUs. MADT and DSDT/SSDTs may list CPUs in different orders, especially for disabled logical cores. Now we match ACPI IDs from the MADT with Processor objects, strictly order CPUs accordingly, and ignore disabled cores. This prevents us from executing methods for other CPUs, e. g., _PSS for disabled logical core, which may not exist. Unfortunately, it is known that there are a few systems with buggy BIOSes that do not have unique ACPI IDs for MADT and Processor objects. To work around these problems, 'debug.acpi.cpu_unordered' tunable is added. Set this to a non-zero value to restore the old behavior. Modified: stable/9/share/man/man4/acpi.4 stable/9/sys/amd64/acpica/acpi_machdep.c stable/9/sys/dev/acpica/acpi_cpu.c stable/9/sys/dev/acpica/acpi_ec.c stable/9/sys/dev/acpica/acpi_smbat.c stable/9/sys/dev/acpica/acpivar.h stable/9/sys/i386/acpica/acpi_machdep.c Directory Properties: stable/9/share/man/man4/ (props changed) stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/dev/isp/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/modules/ (props changed) Modified: stable/9/share/man/man4/acpi.4 ============================================================================== --- stable/9/share/man/man4/acpi.4 Fri Jun 29 21:19:24 2012 (r237821) +++ stable/9/share/man/man4/acpi.4 Fri Jun 29 21:24:56 2012 (r237822) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 22, 2012 +.Dd May 4, 2012 .Dt ACPI 4 .Os .Sh NAME @@ -198,6 +198,11 @@ entry for access after boot. Enables loading of a custom ACPI DSDT. .It Va acpi_dsdt_name Name of the DSDT table to load, if loading is enabled. +.It Va debug.acpi.cpu_unordered +Do not use the MADT to match ACPI Processor objects to CPUs. +This is needed on a few systems with a buggy BIOS that does not use +consistent processor IDs. +Default is 0 (disabled). .It Va debug.acpi.disabled Selectively disables portions of ACPI for debugging purposes. .It Va debug.acpi.interpreter_slack Modified: stable/9/sys/amd64/acpica/acpi_machdep.c ============================================================================== --- stable/9/sys/amd64/acpica/acpi_machdep.c Fri Jun 29 21:19:24 2012 (r237821) +++ stable/9/sys/amd64/acpica/acpi_machdep.c Fri Jun 29 21:24:56 2012 (r237822) @@ -44,8 +44,6 @@ __FBSDID("$FreeBSD$"); #include -SYSCTL_DECL(_debug_acpi); - int acpi_resume_beep; TUNABLE_INT("debug.acpi.resume_beep", &acpi_resume_beep); SYSCTL_INT(_debug_acpi, OID_AUTO, resume_beep, CTLFLAG_RW, &acpi_resume_beep, Modified: stable/9/sys/dev/acpica/acpi_cpu.c ============================================================================== --- stable/9/sys/dev/acpica/acpi_cpu.c Fri Jun 29 21:19:24 2012 (r237821) +++ stable/9/sys/dev/acpica/acpi_cpu.c Fri Jun 29 21:24:56 2012 (r237822) @@ -124,6 +124,13 @@ struct acpi_cpu_device { #define PIIX4_STOP_BREAK_MASK (PIIX4_BRLD_EN_IRQ0 | PIIX4_BRLD_EN_IRQ | PIIX4_BRLD_EN_IRQ8) #define PIIX4_PCNTRL_BST_EN (1<<10) +/* Allow users to ignore processor orders in MADT. */ +static int cpu_unordered; +TUNABLE_INT("debug.acpi.cpu_unordered", &cpu_unordered); +SYSCTL_INT(_debug_acpi, OID_AUTO, cpu_unordered, CTLFLAG_RDTUN, + &cpu_unordered, 0, + "Do not use the MADT to match ACPI Processor objects to CPUs."); + /* Platform hardware resource information. */ static uint32_t cpu_smi_cmd; /* Value to write to SMI_CMD. */ static uint8_t cpu_cst_cnt; /* Indicate we are _CST aware. */ @@ -148,7 +155,7 @@ static int acpi_cpu_probe(device_t dev); static int acpi_cpu_attach(device_t dev); static int acpi_cpu_suspend(device_t dev); static int acpi_cpu_resume(device_t dev); -static int acpi_pcpu_get_id(uint32_t idx, uint32_t *acpi_id, +static int acpi_pcpu_get_id(device_t dev, uint32_t *acpi_id, uint32_t *cpu_id); static struct resource_list *acpi_cpu_get_rlist(device_t dev, device_t child); static device_t acpi_cpu_add_child(device_t dev, u_int order, const char *name, @@ -245,7 +252,7 @@ acpi_cpu_probe(device_t dev) */ acpi_id = obj->Processor.ProcId; AcpiOsFree(obj); - if (acpi_pcpu_get_id(device_get_unit(dev), &acpi_id, &cpu_id) != 0) + if (acpi_pcpu_get_id(dev, &acpi_id, &cpu_id) != 0) return (ENXIO); /* @@ -436,36 +443,66 @@ acpi_cpu_resume(device_t dev) } /* - * Find the nth present CPU and return its pc_cpuid as well as set the - * pc_acpi_id from the most reliable source. + * Find the processor associated with a given ACPI ID. By default, + * use the MADT to map ACPI IDs to APIC IDs and use that to locate a + * processor. Some systems have inconsistent ASL and MADT however. + * For these systems the cpu_unordered tunable can be set in which + * case we assume that Processor objects are listed in the same order + * in both the MADT and ASL. */ static int -acpi_pcpu_get_id(uint32_t idx, uint32_t *acpi_id, uint32_t *cpu_id) +acpi_pcpu_get_id(device_t dev, uint32_t *acpi_id, uint32_t *cpu_id) { - struct pcpu *pcpu_data; - uint32_t i; + struct pcpu *pc; + uint32_t i, idx; KASSERT(acpi_id != NULL, ("Null acpi_id")); KASSERT(cpu_id != NULL, ("Null cpu_id")); + idx = device_get_unit(dev); + + /* + * If pc_acpi_id for CPU 0 is not initialized (e.g. a non-APIC + * UP box) use the ACPI ID from the first processor we find. + */ + if (idx == 0 && mp_ncpus == 1) { + pc = pcpu_find(0); + if (pc->pc_acpi_id == 0xffffffff) + pc->pc_acpi_id = *acpi_id; + *cpu_id = 0; + return (0); + } + CPU_FOREACH(i) { - pcpu_data = pcpu_find(i); - KASSERT(pcpu_data != NULL, ("no pcpu data for %d", i)); - if (idx-- == 0) { - /* - * If pc_acpi_id was not initialized (e.g., a non-APIC UP box) - * override it with the value from the ASL. Otherwise, if the - * two don't match, prefer the MADT-derived value. Finally, - * return the pc_cpuid to reference this processor. - */ - if (pcpu_data->pc_acpi_id == 0xffffffff) - pcpu_data->pc_acpi_id = *acpi_id; - else if (pcpu_data->pc_acpi_id != *acpi_id) - *acpi_id = pcpu_data->pc_acpi_id; - *cpu_id = pcpu_data->pc_cpuid; - return (0); + pc = pcpu_find(i); + KASSERT(pc != NULL, ("no pcpu data for %d", i)); + if (cpu_unordered) { + if (idx-- == 0) { + /* + * If pc_acpi_id doesn't match the ACPI ID from the + * ASL, prefer the MADT-derived value. + */ + if (pc->pc_acpi_id != *acpi_id) + *acpi_id = pc->pc_acpi_id; + *cpu_id = pc->pc_cpuid; + return (0); + } + } else { + if (pc->pc_acpi_id == *acpi_id) { + if (bootverbose) + device_printf(dev, + "Processor %s (ACPI ID %u) -> APIC ID %d\n", + acpi_name(acpi_get_handle(dev)), *acpi_id, + pc->pc_cpuid); + *cpu_id = pc->pc_cpuid; + return (0); + } } } + if (bootverbose) + printf("ACPI: Processor %s (ACPI ID %u) ignored\n", + acpi_name(acpi_get_handle(dev)), *acpi_id); + return (ESRCH); } Modified: stable/9/sys/dev/acpica/acpi_ec.c ============================================================================== --- stable/9/sys/dev/acpica/acpi_ec.c Fri Jun 29 21:19:24 2012 (r237821) +++ stable/9/sys/dev/acpica/acpi_ec.c Fri Jun 29 21:24:56 2012 (r237822) @@ -178,7 +178,6 @@ struct acpi_ec_softc { ACPI_SERIAL_DECL(ec, "ACPI embedded controller"); -SYSCTL_DECL(_debug_acpi); SYSCTL_NODE(_debug_acpi, OID_AUTO, ec, CTLFLAG_RD, NULL, "EC debugging"); static int ec_burst_mode; Modified: stable/9/sys/dev/acpica/acpi_smbat.c ============================================================================== --- stable/9/sys/dev/acpica/acpi_smbat.c Fri Jun 29 21:19:24 2012 (r237821) +++ stable/9/sys/dev/acpica/acpi_smbat.c Fri Jun 29 21:24:56 2012 (r237822) @@ -62,7 +62,6 @@ static int acpi_smbat_get_bst(device_t d ACPI_SERIAL_DECL(smbat, "ACPI Smart Battery"); -SYSCTL_DECL(_debug_acpi); SYSCTL_NODE(_debug_acpi, OID_AUTO, batt, CTLFLAG_RD, NULL, "Battery debugging"); /* On some laptops with smart batteries, enabling battery monitoring Modified: stable/9/sys/dev/acpica/acpivar.h ============================================================================== --- stable/9/sys/dev/acpica/acpivar.h Fri Jun 29 21:19:24 2012 (r237821) +++ stable/9/sys/dev/acpica/acpivar.h Fri Jun 29 21:24:56 2012 (r237822) @@ -487,5 +487,7 @@ ACPI_HANDLE acpi_GetReference(ACPI_HANDL /* Use the device logging level for ktr(4). */ #define KTR_ACPI KTR_DEV +SYSCTL_DECL(_debug_acpi); + #endif /* _KERNEL */ #endif /* !_ACPIVAR_H_ */ Modified: stable/9/sys/i386/acpica/acpi_machdep.c ============================================================================== --- stable/9/sys/i386/acpica/acpi_machdep.c Fri Jun 29 21:19:24 2012 (r237821) +++ stable/9/sys/i386/acpica/acpi_machdep.c Fri Jun 29 21:24:56 2012 (r237822) @@ -44,8 +44,6 @@ __FBSDID("$FreeBSD$"); #include -SYSCTL_DECL(_debug_acpi); - uint32_t acpi_resume_beep; TUNABLE_INT("debug.acpi.resume_beep", &acpi_resume_beep); SYSCTL_UINT(_debug_acpi, OID_AUTO, resume_beep, CTLFLAG_RW, &acpi_resume_beep, From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 21:27:38 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8A7FC106566C; Fri, 29 Jun 2012 21:27:38 +0000 (UTC) (envelope-from ken@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 739F28FC0A; Fri, 29 Jun 2012 21:27:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5TLRcR8071250; Fri, 29 Jun 2012 21:27:38 GMT (envelope-from ken@svn.freebsd.org) Received: (from ken@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5TLRcUN071241; Fri, 29 Jun 2012 21:27:38 GMT (envelope-from ken@svn.freebsd.org) Message-Id: <201206292127.q5TLRcUN071241@svn.freebsd.org> From: "Kenneth D. Merry" Date: Fri, 29 Jun 2012 21:27:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237824 - stable/9/sys/cam/ctl X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 21:27:38 -0000 Author: ken Date: Fri Jun 29 21:27:37 2012 New Revision: 237824 URL: http://svn.freebsd.org/changeset/base/237824 Log: MFC r233963: r233963 | ken | 2012-04-06 16:23:13 -0600 (Fri, 06 Apr 2012) | 27 lines Change the SCSI INQUIRY peripheral qualifier that CTL reports for LUNs that don't exist. Anecdotal evidence indicates that it is better to return 011b (bad LUN) than 001b (LUN offline). However, this change also gives the user a sysctl/tunable, kern.cam.ctl.inquiry_pq_no_lun, to override the change and return to the previous behavior. (The previous behavior was to return 001b, or LUN offline.) ctl.c: Change the default inquiry peripheral qualifier to 011b, and add a sysctl and tunable to allow the user to change it back to 001b if needed. Don't insert a Copan copyright statement in the inquiry data. The copyright statements on the files are sufficient. ctl_private.h:Add sysctl variable context to the CTL softc. ctl_cmd_table.c, ctl_frontend_internal.c, ctl_frontend.c, ctl_backend.c, ctl_error.c: Include sys/sysctl.h. Modified: stable/9/sys/cam/ctl/ctl.c stable/9/sys/cam/ctl/ctl_backend.c stable/9/sys/cam/ctl/ctl_cmd_table.c stable/9/sys/cam/ctl/ctl_error.c stable/9/sys/cam/ctl/ctl_frontend.c stable/9/sys/cam/ctl/ctl_frontend_internal.c stable/9/sys/cam/ctl/ctl_private.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/cam/ctl/ctl.c ============================================================================== --- stable/9/sys/cam/ctl/ctl.c Fri Jun 29 21:25:24 2012 (r237823) +++ stable/9/sys/cam/ctl/ctl.c Fri Jun 29 21:27:37 2012 (r237824) @@ -959,6 +959,33 @@ ctl_init(void) softc->dev->si_drv1 = softc; + /* + * By default, return a "bad LUN" peripheral qualifier for unknown + * LUNs. The user can override this default using the tunable or + * sysctl. See the comment in ctl_inquiry_std() for more details. + */ + softc->inquiry_pq_no_lun = 1; + TUNABLE_INT_FETCH("kern.cam.ctl.inquiry_pq_no_lun", + &softc->inquiry_pq_no_lun); + sysctl_ctx_init(&softc->sysctl_ctx); + softc->sysctl_tree = SYSCTL_ADD_NODE(&softc->sysctl_ctx, + SYSCTL_STATIC_CHILDREN(_kern_cam), OID_AUTO, "ctl", + CTLFLAG_RD, 0, "CAM Target Layer"); + + if (softc->sysctl_tree == NULL) { + printf("%s: unable to allocate sysctl tree\n", __func__); + destroy_dev(softc->dev); + free(control_softc, M_DEVBUF); + control_softc = NULL; + return; + } + + SYSCTL_ADD_INT(&softc->sysctl_ctx, + SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, + "inquiry_pq_no_lun", CTLFLAG_RW, + &softc->inquiry_pq_no_lun, 0, + "Report no lun possible for invalid LUNs"); + mtx_init(&softc->ctl_lock, "CTL mutex", NULL, MTX_DEF); softc->open_count = 0; @@ -1150,6 +1177,11 @@ ctl_shutdown(void) destroy_dev(softc->dev); + sysctl_ctx_free(&softc->sysctl_ctx); + + free(control_softc, M_DEVBUF); + control_softc = NULL; + printf("ctl: CAM Target Layer unloaded\n"); } @@ -9369,15 +9401,55 @@ ctl_inquiry_std(struct ctl_scsiio *ctsio memset(inq_ptr, 0, sizeof(*inq_ptr)); /* - * The control device is always connected. The disk device, on the - * other hand, may not be online all the time. If we don't have a - * LUN mapping, we'll just say it's offline. + * If we have a LUN configured, report it as connected. Otherwise, + * report that it is offline or no device is supported, depending + * on the value of inquiry_pq_no_lun. + * + * According to the spec (SPC-4 r34), the peripheral qualifier + * SID_QUAL_LU_OFFLINE (001b) is used in the following scenario: + * + * "A peripheral device having the specified peripheral device type + * is not connected to this logical unit. However, the device + * server is capable of supporting the specified peripheral device + * type on this logical unit." + * + * According to the same spec, the peripheral qualifier + * SID_QUAL_BAD_LU (011b) is used in this scenario: + * + * "The device server is not capable of supporting a peripheral + * device on this logical unit. For this peripheral qualifier the + * peripheral device type shall be set to 1Fh. All other peripheral + * device type values are reserved for this peripheral qualifier." + * + * Given the text, it would seem that we probably want to report that + * the LUN is offline here. There is no LUN connected, but we can + * support a LUN at the given LUN number. + * + * In the real world, though, it sounds like things are a little + * different: + * + * - Linux, when presented with a LUN with the offline peripheral + * qualifier, will create an sg driver instance for it. So when + * you attach it to CTL, you wind up with a ton of sg driver + * instances. (One for every LUN that Linux bothered to probe.) + * Linux does this despite the fact that it issues a REPORT LUNs + * to LUN 0 to get the inventory of supported LUNs. + * + * - There is other anecdotal evidence (from Emulex folks) about + * arrays that use the offline peripheral qualifier for LUNs that + * are on the "passive" path in an active/passive array. + * + * So the solution is provide a hopefully reasonable default + * (return bad/no LUN) and allow the user to change the behavior + * with a tunable/sysctl variable. */ if (lun != NULL) inq_ptr->device = (SID_QUAL_LU_CONNECTED << 5) | lun->be_lun->lun_type; - else + else if (ctl_softc->inquiry_pq_no_lun == 0) inq_ptr->device = (SID_QUAL_LU_OFFLINE << 5) | T_DIRECT; + else + inq_ptr->device = (SID_QUAL_BAD_LU << 5) | T_NODEVICE; /* RMB in byte 2 is 0 */ inq_ptr->version = SCSI_REV_SPC3; @@ -9491,8 +9563,6 @@ ctl_inquiry_std(struct ctl_scsiio *ctsio break; } } - sprintf((char *)inq_ptr->vendor_specific1, "Copyright (C) 2004, COPAN " - "Systems, Inc. All Rights Reserved."); ctsio->scsi_status = SCSI_STATUS_OK; if (ctsio->kern_data_len > 0) { Modified: stable/9/sys/cam/ctl/ctl_backend.c ============================================================================== --- stable/9/sys/cam/ctl/ctl_backend.c Fri Jun 29 21:25:24 2012 (r237823) +++ stable/9/sys/cam/ctl/ctl_backend.c Fri Jun 29 21:27:37 2012 (r237824) @@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include Modified: stable/9/sys/cam/ctl/ctl_cmd_table.c ============================================================================== --- stable/9/sys/cam/ctl/ctl_cmd_table.c Fri Jun 29 21:25:24 2012 (r237823) +++ stable/9/sys/cam/ctl/ctl_cmd_table.c Fri Jun 29 21:27:37 2012 (r237824) @@ -44,6 +44,7 @@ #include #include #include +#include #include #include Modified: stable/9/sys/cam/ctl/ctl_error.c ============================================================================== --- stable/9/sys/cam/ctl/ctl_error.c Fri Jun 29 21:25:24 2012 (r237823) +++ stable/9/sys/cam/ctl/ctl_error.c Fri Jun 29 21:27:37 2012 (r237824) @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include Modified: stable/9/sys/cam/ctl/ctl_frontend.c ============================================================================== --- stable/9/sys/cam/ctl/ctl_frontend.c Fri Jun 29 21:25:24 2012 (r237823) +++ stable/9/sys/cam/ctl/ctl_frontend.c Fri Jun 29 21:27:37 2012 (r237824) @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include Modified: stable/9/sys/cam/ctl/ctl_frontend_internal.c ============================================================================== --- stable/9/sys/cam/ctl/ctl_frontend_internal.c Fri Jun 29 21:25:24 2012 (r237823) +++ stable/9/sys/cam/ctl/ctl_frontend_internal.c Fri Jun 29 21:27:37 2012 (r237824) @@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include Modified: stable/9/sys/cam/ctl/ctl_private.h ============================================================================== --- stable/9/sys/cam/ctl/ctl_private.h Fri Jun 29 21:25:24 2012 (r237823) +++ stable/9/sys/cam/ctl/ctl_private.h Fri Jun 29 21:27:37 2012 (r237824) @@ -421,6 +421,9 @@ struct ctl_softc { int num_luns; ctl_gen_flags flags; ctl_ha_mode ha_mode; + int inquiry_pq_no_lun; + struct sysctl_ctx_list sysctl_ctx; + struct sysctl_oid *sysctl_tree; struct ctl_ioctl_info ioctl_info; struct ctl_lun lun; struct ctl_io_pool *internal_pool; From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 21:33:37 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4FEA61065676; Fri, 29 Jun 2012 21:33:37 +0000 (UTC) (envelope-from ken@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 377C58FC1E; Fri, 29 Jun 2012 21:33:37 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5TLXbGo071576; Fri, 29 Jun 2012 21:33:37 GMT (envelope-from ken@svn.freebsd.org) Received: (from ken@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5TLXaP1071567; Fri, 29 Jun 2012 21:33:36 GMT (envelope-from ken@svn.freebsd.org) Message-Id: <201206292133.q5TLXaP1071567@svn.freebsd.org> From: "Kenneth D. Merry" Date: Fri, 29 Jun 2012 21:33:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237825 - in stable/9: share/examples/scsi_target sys/cam/ctl sys/dev/aic7xxx sys/dev/firewire sys/dev/mpt X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 21:33:37 -0000 Author: ken Date: Fri Jun 29 21:33:36 2012 New Revision: 237825 URL: http://svn.freebsd.org/changeset/base/237825 Log: MFC r237601: r237601 | ken | 2012-06-26 08:51:35 -0600 (Tue, 26 Jun 2012) | 38 lines Fix an issue that caused the kernel to panic inside CTL when trying to attach to target capable HBAs that implement the old immediate notify (XPT_IMMED_NOTIFY) and notify acknowledge (XPT_NOTIFY_ACK) CCBs. The new API has been in place since SVN change 196008 in 2009. The solution is two-fold: fix CTL to handle the responses from the HBAs, and convert the HBA drivers in question to use the new API. These drivers have not been tested with CTL, so how well they will interoperate with CTL is unknown. scsi_target.c:Update the userland target example code to use the new immediate notify API. scsi_ctl.c: Detect when an immediate notify CCB is returned with CAM_REQ_INVALID or CAM_PROVIDE_FAIL status, and just free it. Fix a duplicate assignment. aic79xx.c, aic79xx_osm.c:Update the aic79xx driver to use the new API. Target mode is not enabled on for this driver, so the changes will have no practical effect. aic7xxx.c, aic7xxx_osm.c:Update the aic7xxx driver to use the new API. sbp_targ.c: Update the firewire target code to work with the new API. mpt_cam.c: Update the mpt(4) driver to work with the new API. Target mode is only enabled for Fibre Channel mpt(4) devices. Modified: stable/9/share/examples/scsi_target/scsi_target.c stable/9/sys/cam/ctl/scsi_ctl.c stable/9/sys/dev/aic7xxx/aic79xx.c stable/9/sys/dev/aic7xxx/aic79xx_osm.c stable/9/sys/dev/aic7xxx/aic7xxx.c stable/9/sys/dev/aic7xxx/aic7xxx_osm.c stable/9/sys/dev/firewire/sbp_targ.c stable/9/sys/dev/mpt/mpt_cam.c Directory Properties: stable/9/share/examples/scsi_target/ (props changed) stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/share/examples/scsi_target/scsi_target.c ============================================================================== --- stable/9/share/examples/scsi_target/scsi_target.c Fri Jun 29 21:27:37 2012 (r237824) +++ stable/9/share/examples/scsi_target/scsi_target.c Fri Jun 29 21:33:36 2012 (r237825) @@ -88,7 +88,7 @@ static void handle_read(void); /* static int work_atio(struct ccb_accept_tio *); */ static void queue_io(struct ccb_scsiio *); static int run_queue(struct ccb_accept_tio *); -static int work_inot(struct ccb_immed_notify *); +static int work_inot(struct ccb_immediate_notify *); static struct ccb_scsiio * get_ctio(void); /* static void free_ccb(union ccb *); */ @@ -393,7 +393,7 @@ init_ccbs() warn("malloc INOT"); return (-1); } - inot->ccb_h.func_code = XPT_IMMED_NOTIFY; + inot->ccb_h.func_code = XPT_IMMEDIATE_NOTIFY; send_ccb((union ccb *)inot, /*priority*/1); } @@ -501,8 +501,8 @@ request_loop() /* Start one more transfer. */ retval = work_atio(&ccb->atio); break; - case XPT_IMMED_NOTIFY: - retval = work_inot(&ccb->cin); + case XPT_IMMEDIATE_NOTIFY: + retval = work_inot(&ccb->cin1); break; default: warnx("Unhandled ccb type %#x on workq", @@ -657,7 +657,7 @@ work_atio(struct ccb_accept_tio *atio) warnx("ATIO with %u bytes sense received", atio->sense_len); } - sense = &atio->sense_data; + sense = (struct scsi_sense_data_fixed *)&atio->sense_data; tcmd_sense(ctio->init_id, ctio, sense->flags, sense->add_sense_code, sense->add_sense_code_qual); send_ccb((union ccb *)ctio, /*priority*/1); @@ -778,16 +778,14 @@ run_queue(struct ccb_accept_tio *atio) } static int -work_inot(struct ccb_immed_notify *inot) +work_inot(struct ccb_immediate_notify *inot) { cam_status status; - int sense; if (debug) warnx("Working on INOT %p", inot); status = inot->ccb_h.status; - sense = (status & CAM_AUTOSNS_VALID) != 0; status &= CAM_STATUS_MASK; switch (status) { @@ -800,7 +798,7 @@ work_inot(struct ccb_immed_notify *inot) abort_all_pending(); break; case CAM_MESSAGE_RECV: - switch (inot->message_args[0]) { + switch (inot->arg) { case MSG_TASK_COMPLETE: case MSG_INITIATOR_DET_ERR: case MSG_ABORT_TASK_SET: @@ -811,7 +809,7 @@ work_inot(struct ccb_immed_notify *inot) case MSG_ABORT_TASK: case MSG_CLEAR_TASK_SET: default: - warnx("INOT message %#x", inot->message_args[0]); + warnx("INOT message %#x", inot->arg); break; } break; @@ -823,17 +821,6 @@ work_inot(struct ccb_immed_notify *inot) break; } - /* If there is sense data, use it */ - if (sense != 0) { - struct scsi_sense_data_fixed *sense; - - sense = (struct scsi_sense_data_fixed *)&inot->sense_data; - tcmd_sense(inot->initiator_id, NULL, sense->flags, - sense->add_sense_code, sense->add_sense_code_qual); - if (debug) - warnx("INOT has sense: %#x", sense->flags); - } - /* Requeue on SIM */ TAILQ_REMOVE(&work_queue, &inot->ccb_h, periph_links.tqe); send_ccb((union ccb *)inot, /*priority*/1); Modified: stable/9/sys/cam/ctl/scsi_ctl.c ============================================================================== --- stable/9/sys/cam/ctl/scsi_ctl.c Fri Jun 29 21:27:37 2012 (r237824) +++ stable/9/sys/cam/ctl/scsi_ctl.c Fri Jun 29 21:33:36 2012 (r237825) @@ -558,7 +558,6 @@ ctlferegister(struct cam_periph *periph, TAILQ_INIT(&softc->work_queue); softc->periph = periph; - softc->parent_softc = bus_softc; callout_init_mtx(&softc->dma_callout, sim->mtx, /*flags*/ 0); periph->softc = softc; @@ -628,12 +627,22 @@ ctlferegister(struct cam_periph *periph, xpt_action(new_ccb); softc->inots_sent++; status = new_ccb->ccb_h.status; - if (status != CAM_REQ_INPROG) { - free(new_ccb, M_CTLFE); + if ((status & CAM_STATUS_MASK) != CAM_REQ_INPROG) { + /* + * Note that we don't free the CCB here. If the + * status is not CAM_REQ_INPROG, then we're + * probably talking to a SIM that says it is + * target-capable but doesn't support the + * XPT_IMMEDIATE_NOTIFY CCB. i.e. it supports the + * older API. In that case, it'll call xpt_done() + * on the CCB, and we need to free it in our done + * routine as a result. + */ break; } } - if (i == 0) { + if ((i == 0) + || (status != CAM_REQ_INPROG)) { xpt_print(periph->path, "%s: could not allocate immediate " "notify CCBs, status 0x%x\n", __func__, status); return (CAM_REQ_CMP_ERR); @@ -1460,12 +1469,29 @@ ctlfedone(struct cam_periph *periph, uni */ send_ctl_io = 0; break; + case CAM_REQ_INVALID: + case CAM_PROVIDE_FAIL: default: - xpt_print(periph->path, "%s: " - "unsupported CAM status 0x%x\n", - __func__, status); - send_ctl_io = 0; - break; + /* + * We should only get here if we're talking + * to a talking to a SIM that is target + * capable but supports the old API. In + * that case, we need to just free the CCB. + * If we actually send a notify acknowledge, + * it will send that back with an error as + * well. + */ + + if ((status != CAM_REQ_INVALID) + && (status != CAM_PROVIDE_FAIL)) + xpt_print(periph->path, "%s: " + "unsupported CAM status " + "0x%x\n", __func__, status); + + ctl_free_io(io); + ctlfe_free_ccb(periph, done_ccb); + + return; } if (send_ctl_io != 0) { ctl_queue(io); Modified: stable/9/sys/dev/aic7xxx/aic79xx.c ============================================================================== --- stable/9/sys/dev/aic7xxx/aic79xx.c Fri Jun 29 21:27:37 2012 (r237824) +++ stable/9/sys/dev/aic7xxx/aic79xx.c Fri Jun 29 21:33:36 2012 (r237825) @@ -8561,7 +8561,7 @@ void ahd_send_lstate_events(struct ahd_softc *ahd, struct ahd_tmode_lstate *lstate) { struct ccb_hdr *ccbh; - struct ccb_immed_notify *inot; + struct ccb_immediate_notify *inot; while (lstate->event_r_idx != lstate->event_w_idx && (ccbh = SLIST_FIRST(&lstate->immed_notifies)) != NULL) { @@ -8569,19 +8569,18 @@ ahd_send_lstate_events(struct ahd_softc event = &lstate->event_buffer[lstate->event_r_idx]; SLIST_REMOVE_HEAD(&lstate->immed_notifies, sim_links.sle); - inot = (struct ccb_immed_notify *)ccbh; + inot = (struct ccb_immediate_notify *)ccbh; switch (event->event_type) { case EVENT_TYPE_BUS_RESET: ccbh->status = CAM_SCSI_BUS_RESET|CAM_DEV_QFRZN; break; default: ccbh->status = CAM_MESSAGE_RECV|CAM_DEV_QFRZN; - inot->message_args[0] = event->event_type; - inot->message_args[1] = event->event_arg; + inot->arg = event->event_type; + inot->seq_id = event->event_arg; break; } inot->initiator_id = event->initiator_id; - inot->sense_len = 0; xpt_done((union ccb *)inot); lstate->event_r_idx++; if (lstate->event_r_idx == AHD_TMODE_EVENT_BUFFER_SIZE) Modified: stable/9/sys/dev/aic7xxx/aic79xx_osm.c ============================================================================== --- stable/9/sys/dev/aic7xxx/aic79xx_osm.c Fri Jun 29 21:27:37 2012 (r237824) +++ stable/9/sys/dev/aic7xxx/aic79xx_osm.c Fri Jun 29 21:33:36 2012 (r237825) @@ -601,8 +601,8 @@ ahd_action(struct cam_sim *sim, union cc break; } #ifdef AHD_TARGET_MODE - case XPT_NOTIFY_ACK: - case XPT_IMMED_NOTIFY: + case XPT_NOTIFY_ACKNOWLEDGE: + case XPT_IMMEDIATE_NOTIFY: { struct ahd_tmode_tstate *tstate; struct ahd_tmode_lstate *lstate; @@ -1189,7 +1189,7 @@ ahd_abort_ccb(struct ahd_softc *ahd, str switch (abort_ccb->ccb_h.func_code) { #ifdef AHD_TARGET_MODE case XPT_ACCEPT_TARGET_IO: - case XPT_IMMED_NOTIFY: + case XPT_IMMEDIATE_NOTIFY: case XPT_CONT_TARGET_IO: { struct ahd_tmode_tstate *tstate; @@ -1207,7 +1207,7 @@ ahd_abort_ccb(struct ahd_softc *ahd, str if (abort_ccb->ccb_h.func_code == XPT_ACCEPT_TARGET_IO) list = &lstate->accept_tios; - else if (abort_ccb->ccb_h.func_code == XPT_IMMED_NOTIFY) + else if (abort_ccb->ccb_h.func_code == XPT_IMMEDIATE_NOTIFY) list = &lstate->immed_notifies; else list = NULL; Modified: stable/9/sys/dev/aic7xxx/aic7xxx.c ============================================================================== --- stable/9/sys/dev/aic7xxx/aic7xxx.c Fri Jun 29 21:27:37 2012 (r237824) +++ stable/9/sys/dev/aic7xxx/aic7xxx.c Fri Jun 29 21:33:36 2012 (r237825) @@ -6368,7 +6368,7 @@ void ahc_send_lstate_events(struct ahc_softc *ahc, struct ahc_tmode_lstate *lstate) { struct ccb_hdr *ccbh; - struct ccb_immed_notify *inot; + struct ccb_immediate_notify *inot; while (lstate->event_r_idx != lstate->event_w_idx && (ccbh = SLIST_FIRST(&lstate->immed_notifies)) != NULL) { @@ -6376,19 +6376,18 @@ ahc_send_lstate_events(struct ahc_softc event = &lstate->event_buffer[lstate->event_r_idx]; SLIST_REMOVE_HEAD(&lstate->immed_notifies, sim_links.sle); - inot = (struct ccb_immed_notify *)ccbh; + inot = (struct ccb_immediate_notify *)ccbh; switch (event->event_type) { case EVENT_TYPE_BUS_RESET: ccbh->status = CAM_SCSI_BUS_RESET|CAM_DEV_QFRZN; break; default: ccbh->status = CAM_MESSAGE_RECV|CAM_DEV_QFRZN; - inot->message_args[0] = event->event_type; - inot->message_args[1] = event->event_arg; + inot->arg = event->event_type; + inot->seq_id = event->event_arg; break; } inot->initiator_id = event->initiator_id; - inot->sense_len = 0; xpt_done((union ccb *)inot); lstate->event_r_idx++; if (lstate->event_r_idx == AHC_TMODE_EVENT_BUFFER_SIZE) Modified: stable/9/sys/dev/aic7xxx/aic7xxx_osm.c ============================================================================== --- stable/9/sys/dev/aic7xxx/aic7xxx_osm.c Fri Jun 29 21:27:37 2012 (r237824) +++ stable/9/sys/dev/aic7xxx/aic7xxx_osm.c Fri Jun 29 21:33:36 2012 (r237825) @@ -568,8 +568,8 @@ ahc_action(struct cam_sim *sim, union cc } break; } - case XPT_NOTIFY_ACK: - case XPT_IMMED_NOTIFY: + case XPT_NOTIFY_ACKNOWLEDGE: + case XPT_IMMEDIATE_NOTIFY: { struct ahc_tmode_tstate *tstate; struct ahc_tmode_lstate *lstate; @@ -1248,7 +1248,7 @@ ahc_abort_ccb(struct ahc_softc *ahc, str abort_ccb = ccb->cab.abort_ccb; switch (abort_ccb->ccb_h.func_code) { case XPT_ACCEPT_TARGET_IO: - case XPT_IMMED_NOTIFY: + case XPT_IMMEDIATE_NOTIFY: case XPT_CONT_TARGET_IO: { struct ahc_tmode_tstate *tstate; @@ -1266,7 +1266,7 @@ ahc_abort_ccb(struct ahc_softc *ahc, str if (abort_ccb->ccb_h.func_code == XPT_ACCEPT_TARGET_IO) list = &lstate->accept_tios; - else if (abort_ccb->ccb_h.func_code == XPT_IMMED_NOTIFY) + else if (abort_ccb->ccb_h.func_code == XPT_IMMEDIATE_NOTIFY) list = &lstate->immed_notifies; else list = NULL; Modified: stable/9/sys/dev/firewire/sbp_targ.c ============================================================================== --- stable/9/sys/dev/firewire/sbp_targ.c Fri Jun 29 21:27:37 2012 (r237824) +++ stable/9/sys/dev/firewire/sbp_targ.c Fri Jun 29 21:33:36 2012 (r237825) @@ -488,7 +488,7 @@ sbp_targ_send_lstate_events(struct sbp_t { #if 0 struct ccb_hdr *ccbh; - struct ccb_immed_notify *inot; + struct ccb_immediate_notify *inot; printf("%s: not implemented yet\n", __func__); #endif @@ -822,7 +822,7 @@ sbp_targ_abort_ccb(struct sbp_targ_softc if (accb->ccb_h.func_code == XPT_ACCEPT_TARGET_IO) list = &lstate->accept_tios; - else if (accb->ccb_h.func_code == XPT_IMMED_NOTIFY) + else if (accb->ccb_h.func_code == XPT_IMMEDIATE_NOTIFY) list = &lstate->immed_notifies; else return (CAM_UA_ABORT); @@ -1100,8 +1100,8 @@ sbp_targ_action1(struct cam_sim *sim, un } } break; - case XPT_NOTIFY_ACK: /* recycle notify ack */ - case XPT_IMMED_NOTIFY: /* Add Immediate Notify Resource */ + case XPT_NOTIFY_ACKNOWLEDGE: /* recycle notify ack */ + case XPT_IMMEDIATE_NOTIFY: /* Add Immediate Notify Resource */ if (status != CAM_REQ_CMP) { ccb->ccb_h.status = status; xpt_done(ccb); @@ -1147,7 +1147,7 @@ sbp_targ_action1(struct cam_sim *sim, un switch (accb->ccb_h.func_code) { case XPT_ACCEPT_TARGET_IO: - case XPT_IMMED_NOTIFY: + case XPT_IMMEDIATE_NOTIFY: ccb->ccb_h.status = sbp_targ_abort_ccb(sc, ccb); break; case XPT_CONT_TARGET_IO: Modified: stable/9/sys/dev/mpt/mpt_cam.c ============================================================================== --- stable/9/sys/dev/mpt/mpt_cam.c Fri Jun 29 21:27:37 2012 (r237824) +++ stable/9/sys/dev/mpt/mpt_cam.c Fri Jun 29 21:33:36 2012 (r237825) @@ -3411,7 +3411,7 @@ mpt_action(struct cam_sim *sim, union cc CAMLOCK_2_MPTLOCK(mpt); switch (accb->ccb_h.func_code) { case XPT_ACCEPT_TARGET_IO: - case XPT_IMMED_NOTIFY: + case XPT_IMMEDIATE_NOTIFY: ccb->ccb_h.status = mpt_abort_target_ccb(mpt, ccb); break; case XPT_CONT_TARGET_IO: @@ -3785,8 +3785,8 @@ mpt_action(struct cam_sim *sim, union cc } break; } - case XPT_NOTIFY_ACK: /* recycle notify ack */ - case XPT_IMMED_NOTIFY: /* Add Immediate Notify Resource */ + case XPT_NOTIFY_ACKNOWLEDGE: /* recycle notify ack */ + case XPT_IMMEDIATE_NOTIFY: /* Add Immediate Notify Resource */ case XPT_ACCEPT_TARGET_IO: /* Add Accept Target IO Resource */ { tgt_resource_t *trtp; @@ -3813,7 +3813,7 @@ mpt_action(struct cam_sim *sim, union cc "Put FREE ATIO %p lun %d\n", ccb, lun); STAILQ_INSERT_TAIL(&trtp->atios, &ccb->ccb_h, sim_links.stqe); - } else if (ccb->ccb_h.func_code == XPT_IMMED_NOTIFY) { + } else if (ccb->ccb_h.func_code == XPT_IMMEDIATE_NOTIFY) { mpt_lprt(mpt, MPT_PRT_DEBUG1, "Put FREE INOT lun %d\n", lun); STAILQ_INSERT_TAIL(&trtp->inots, &ccb->ccb_h, @@ -4822,7 +4822,7 @@ mpt_abort_target_ccb(struct mpt_softc *m if (accb->ccb_h.func_code == XPT_ACCEPT_TARGET_IO) { lp = &trtp->atios; - } else if (accb->ccb_h.func_code == XPT_IMMED_NOTIFY) { + } else if (accb->ccb_h.func_code == XPT_IMMEDIATE_NOTIFY) { lp = &trtp->inots; } else { return (CAM_REQ_INVALID); @@ -5043,11 +5043,11 @@ static void mpt_scsi_tgt_tsk_mgmt(struct mpt_softc *mpt, request_t *req, mpt_task_mgmt_t fc, tgt_resource_t *trtp, int init_id) { - struct ccb_immed_notify *inot; + struct ccb_immediate_notify *inot; mpt_tgt_state_t *tgt; tgt = MPT_TGT_STATE(mpt, req); - inot = (struct ccb_immed_notify *) STAILQ_FIRST(&trtp->inots); + inot = (struct ccb_immediate_notify *) STAILQ_FIRST(&trtp->inots); if (inot == NULL) { mpt_lprt(mpt, MPT_PRT_WARN, "no INOTSs- sending back BSY\n"); mpt_scsi_tgt_status(mpt, NULL, req, SCSI_STATUS_BUSY, NULL); @@ -5057,35 +5057,35 @@ mpt_scsi_tgt_tsk_mgmt(struct mpt_softc * mpt_lprt(mpt, MPT_PRT_DEBUG1, "Get FREE INOT %p lun %d\n", inot, inot->ccb_h.target_lun); - memset(&inot->sense_data, 0, sizeof (inot->sense_data)); - inot->sense_len = 0; - memset(inot->message_args, 0, sizeof (inot->message_args)); inot->initiator_id = init_id; /* XXX */ - /* * This is a somewhat grotesque attempt to map from task management * to old style SCSI messages. God help us all. */ switch (fc) { case MPT_ABORT_TASK_SET: - inot->message_args[0] = MSG_ABORT_TAG; + inot->arg = MSG_ABORT_TAG; break; case MPT_CLEAR_TASK_SET: - inot->message_args[0] = MSG_CLEAR_TASK_SET; + inot->arg = MSG_CLEAR_TASK_SET; break; case MPT_TARGET_RESET: - inot->message_args[0] = MSG_TARGET_RESET; + inot->arg = MSG_TARGET_RESET; break; case MPT_CLEAR_ACA: - inot->message_args[0] = MSG_CLEAR_ACA; + inot->arg = MSG_CLEAR_ACA; break; case MPT_TERMINATE_TASK: - inot->message_args[0] = MSG_ABORT_TAG; + inot->arg = MSG_ABORT_TAG; break; default: - inot->message_args[0] = MSG_NOOP; + inot->arg = MSG_NOOP; break; } + /* + * XXX KDM we need the sequence/tag number for the target of the + * task management operation, especially if it is an abort. + */ tgt->ccb = (union ccb *) inot; inot->ccb_h.status = CAM_MESSAGE_RECV|CAM_DEV_QFRZN; MPTLOCK_2_CAMLOCK(mpt); From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 22:00:30 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E6D8B106566C; Fri, 29 Jun 2012 22:00:30 +0000 (UTC) (envelope-from ken@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CFF4E8FC14; Fri, 29 Jun 2012 22:00:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5TM0Us0072726; Fri, 29 Jun 2012 22:00:30 GMT (envelope-from ken@svn.freebsd.org) Received: (from ken@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5TM0Ub4072721; Fri, 29 Jun 2012 22:00:30 GMT (envelope-from ken@svn.freebsd.org) Message-Id: <201206292200.q5TM0Ub4072721@svn.freebsd.org> From: "Kenneth D. Merry" Date: Fri, 29 Jun 2012 22:00:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237826 - stable/9/sys/cam/scsi X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 22:00:31 -0000 Author: ken Date: Fri Jun 29 22:00:30 2012 New Revision: 237826 URL: http://svn.freebsd.org/changeset/base/237826 Log: MFC r236138, with the exception of scsi_enc.c: r236138 | ken | 2012-05-27 00:11:09 -0600 (Sun, 27 May 2012) | 64 lines Work around a race condition in devfs by changing the way closes are handled in most CAM peripheral drivers that are not handled by GEOM's disk class. The usual character driver open and close semantics are that the driver gets N open calls, but only one close, when the last caller closes the device. CAM peripheral drivers expect that behavior to be honored to the letter, and the CAM peripheral driver code (specifically cam_periph_release_locked_busses()) panics if it is done incorrectly. Since devfs has to drop its locks while it calls a driver's close routine, and it does not have a way to delay or prevent open calls while it is calling the close routine, there is a race. The sequence of events, simplified a bit, is: - devfs acquires a lock - devfs checks the reference count, and if it is 1, continues to close. - devfs releases the lock - 2nd process open call on the device happens here - devfs calls the driver's close routine - devfs acquires a lock - devfs decrements the reference count - devfs releases the lock - 2nd process close call on the device happens here At the second close, we get a panic in cam_periph_release_locked_busses(), complaining that peripheral has been released when the reference count is already 0. This is because we have gotten two closes in a row, which should not happen. The fix is to add the D_TRACKCLOSE flag to the driver's cdevsw, so that we get a close() call for each open(). That does happen reliably, so we can make sure that our reference counts are correct. Note that the sa(4) and pt(4) drivers only allow one context through the open routine. So these drivers aren't exposed to the same race condition. scsi_ch.c, scsi_enc.c, scsi_enc_internal.h, scsi_pass.c, scsi_sg.c: For these drivers, change the open() routine to increment the reference count for every open, and just decrement the reference count in the close. Call cam_periph_release_locked() in some scenarios to avoid additional lock and unlock calls. scsi_pt.c: Call cam_periph_release_locked() in some scenarios to avoid additional lock and unlock calls. Modified: stable/9/sys/cam/scsi/scsi_ch.c stable/9/sys/cam/scsi/scsi_pass.c stable/9/sys/cam/scsi/scsi_pt.c stable/9/sys/cam/scsi/scsi_sg.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/cam/scsi/scsi_ch.c ============================================================================== --- stable/9/sys/cam/scsi/scsi_ch.c Fri Jun 29 21:33:36 2012 (r237825) +++ stable/9/sys/cam/scsi/scsi_ch.c Fri Jun 29 22:00:30 2012 (r237826) @@ -107,8 +107,7 @@ static const u_int32_t CH_TIMEOUT_SEND_V static const u_int32_t CH_TIMEOUT_INITIALIZE_ELEMENT_STATUS = 500000; typedef enum { - CH_FLAG_INVALID = 0x001, - CH_FLAG_OPEN = 0x002 + CH_FLAG_INVALID = 0x001 } ch_flags; typedef enum { @@ -211,7 +210,7 @@ PERIPHDRIVER_DECLARE(ch, chdriver); static struct cdevsw ch_cdevsw = { .d_version = D_VERSION, - .d_flags = 0, + .d_flags = D_TRACKCLOSE, .d_open = chopen, .d_close = chclose, .d_ioctl = chioctl, @@ -404,16 +403,11 @@ chopen(struct cdev *dev, int flags, int cam_periph_lock(periph); if (softc->flags & CH_FLAG_INVALID) { + cam_periph_release_locked(periph); cam_periph_unlock(periph); - cam_periph_release(periph); return(ENXIO); } - if ((softc->flags & CH_FLAG_OPEN) == 0) - softc->flags |= CH_FLAG_OPEN; - else - cam_periph_release(periph); - if ((error = cam_periph_hold(periph, PRIBIO | PCATCH)) != 0) { cam_periph_unlock(periph); cam_periph_release(periph); @@ -424,9 +418,8 @@ chopen(struct cdev *dev, int flags, int * Load information about this changer device into the softc. */ if ((error = chgetparams(periph)) != 0) { - softc->flags &= ~CH_FLAG_OPEN; + cam_periph_release_locked(periph); cam_periph_unlock(periph); - cam_periph_release(periph); return(error); } @@ -451,11 +444,6 @@ chclose(struct cdev *dev, int flag, int softc = (struct ch_softc *)periph->softc; - cam_periph_lock(periph); - - softc->flags &= ~CH_FLAG_OPEN; - - cam_periph_unlock(periph); cam_periph_release(periph); return(0); Modified: stable/9/sys/cam/scsi/scsi_pass.c ============================================================================== --- stable/9/sys/cam/scsi/scsi_pass.c Fri Jun 29 21:33:36 2012 (r237825) +++ stable/9/sys/cam/scsi/scsi_pass.c Fri Jun 29 22:00:30 2012 (r237826) @@ -111,7 +111,7 @@ PERIPHDRIVER_DECLARE(pass, passdriver); static struct cdevsw pass_cdevsw = { .d_version = D_VERSION, - .d_flags = 0, + .d_flags = D_TRACKCLOSE, .d_open = passopen, .d_close = passclose, .d_ioctl = passioctl, @@ -377,8 +377,8 @@ passopen(struct cdev *dev, int flags, in softc = (struct pass_softc *)periph->softc; if (softc->flags & PASS_FLAG_INVALID) { + cam_periph_release_locked(periph); cam_periph_unlock(periph); - cam_periph_release(periph); return(ENXIO); } @@ -387,8 +387,8 @@ passopen(struct cdev *dev, int flags, in */ error = securelevel_gt(td->td_ucred, 1); if (error) { + cam_periph_release_locked(periph); cam_periph_unlock(periph); - cam_periph_release(periph); return(error); } @@ -396,8 +396,8 @@ passopen(struct cdev *dev, int flags, in * Only allow read-write access. */ if (((flags & FWRITE) == 0) || ((flags & FREAD) == 0)) { + cam_periph_release_locked(periph); cam_periph_unlock(periph); - cam_periph_release(periph); return(EPERM); } @@ -406,19 +406,12 @@ passopen(struct cdev *dev, int flags, in */ if ((flags & O_NONBLOCK) != 0) { xpt_print(periph->path, "can't do nonblocking access\n"); + cam_periph_release_locked(periph); cam_periph_unlock(periph); - cam_periph_release(periph); return(EINVAL); } - if ((softc->flags & PASS_FLAG_OPEN) == 0) { - softc->flags |= PASS_FLAG_OPEN; - cam_periph_unlock(periph); - } else { - /* Device closes aren't symmertical, so fix up the refcount */ - cam_periph_unlock(periph); - cam_periph_release(periph); - } + cam_periph_unlock(periph); return (error); } @@ -427,18 +420,11 @@ static int passclose(struct cdev *dev, int flag, int fmt, struct thread *td) { struct cam_periph *periph; - struct pass_softc *softc; periph = (struct cam_periph *)dev->si_drv1; if (periph == NULL) return (ENXIO); - cam_periph_lock(periph); - - softc = (struct pass_softc *)periph->softc; - softc->flags &= ~PASS_FLAG_OPEN; - - cam_periph_unlock(periph); cam_periph_release(periph); return (0); Modified: stable/9/sys/cam/scsi/scsi_pt.c ============================================================================== --- stable/9/sys/cam/scsi/scsi_pt.c Fri Jun 29 21:33:36 2012 (r237825) +++ stable/9/sys/cam/scsi/scsi_pt.c Fri Jun 29 22:00:30 2012 (r237826) @@ -148,8 +148,8 @@ ptopen(struct cdev *dev, int flags, int cam_periph_lock(periph); if (softc->flags & PT_FLAG_DEVICE_INVALID) { + cam_periph_release_locked(periph); cam_periph_unlock(periph); - cam_periph_release(periph); return(ENXIO); } @@ -182,8 +182,8 @@ ptclose(struct cdev *dev, int flag, int cam_periph_lock(periph); softc->flags &= ~PT_FLAG_OPEN; + cam_periph_release_locked(periph); cam_periph_unlock(periph); - cam_periph_release(periph); return (0); } Modified: stable/9/sys/cam/scsi/scsi_sg.c ============================================================================== --- stable/9/sys/cam/scsi/scsi_sg.c Fri Jun 29 21:33:36 2012 (r237825) +++ stable/9/sys/cam/scsi/scsi_sg.c Fri Jun 29 22:00:30 2012 (r237826) @@ -61,9 +61,8 @@ __FBSDID("$FreeBSD$"); #include typedef enum { - SG_FLAG_OPEN = 0x01, - SG_FLAG_LOCKED = 0x02, - SG_FLAG_INVALID = 0x04 + SG_FLAG_LOCKED = 0x01, + SG_FLAG_INVALID = 0x02 } sg_flags; typedef enum { @@ -141,7 +140,7 @@ PERIPHDRIVER_DECLARE(sg, sgdriver); static struct cdevsw sg_cdevsw = { .d_version = D_VERSION, - .d_flags = D_NEEDGIANT, + .d_flags = D_NEEDGIANT | D_TRACKCLOSE, .d_open = sgopen, .d_close = sgclose, .d_ioctl = sgioctl, @@ -415,19 +414,12 @@ sgopen(struct cdev *dev, int flags, int softc = (struct sg_softc *)periph->softc; if (softc->flags & SG_FLAG_INVALID) { + cam_periph_release_locked(periph); cam_periph_unlock(periph); - cam_periph_release(periph); return (ENXIO); } - if ((softc->flags & SG_FLAG_OPEN) == 0) { - softc->flags |= SG_FLAG_OPEN; - cam_periph_unlock(periph); - } else { - /* Device closes aren't symmetrical, fix up the refcount. */ - cam_periph_unlock(periph); - cam_periph_release(periph); - } + cam_periph_unlock(periph); return (error); } @@ -436,18 +428,11 @@ static int sgclose(struct cdev *dev, int flag, int fmt, struct thread *td) { struct cam_periph *periph; - struct sg_softc *softc; periph = (struct cam_periph *)dev->si_drv1; if (periph == NULL) return (ENXIO); - cam_periph_lock(periph); - - softc = (struct sg_softc *)periph->softc; - softc->flags &= ~SG_FLAG_OPEN; - - cam_periph_unlock(periph); cam_periph_release(periph); return (0); From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 22:28:31 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B985D106564A; Fri, 29 Jun 2012 22:28:31 +0000 (UTC) (envelope-from ken@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A1D288FC16; Fri, 29 Jun 2012 22:28:31 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5TMSVtd074098; Fri, 29 Jun 2012 22:28:31 GMT (envelope-from ken@svn.freebsd.org) Received: (from ken@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5TMSV7j074093; Fri, 29 Jun 2012 22:28:31 GMT (envelope-from ken@svn.freebsd.org) Message-Id: <201206292228.q5TMSV7j074093@svn.freebsd.org> From: "Kenneth D. Merry" Date: Fri, 29 Jun 2012 22:28:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237827 - in stable/9/sys/cam: . scsi X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 22:28:31 -0000 Author: ken Date: Fri Jun 29 22:28:31 2012 New Revision: 237827 URL: http://svn.freebsd.org/changeset/base/237827 Log: MFC r237328, except for the scsi_enc.c changes: r237328 | ken | 2012-06-20 11:08:00 -0600 (Wed, 20 Jun 2012) | 69 lines Fix several reference counting and object lifetime issues between the pass(4) and enc(4) drivers and devfs. The pass(4) driver uses the destroy_dev_sched() routine to schedule its device node for destruction in a separate thread context. It does this because the passcleanup() routine can get called indirectly from the passclose() routine, and that would cause a deadlock if the close routine tried to destroy its own device node. In any case, once a particular passthrough driver number, e.g. pass3, is destroyed, CAM considers that unit number (3 in this case) available for reuse. The problem is that devfs may not be done cleaning up the previous instance of pass3, and will panic if isn't done cleaning up the previous instance. The solution is to get a callback from devfs when the device node is removed, and make sure we hold a reference to the peripheral until that happens. Testing exposed some other cases where we have reference counting issues, and those were also fixed in the pass(4) driver. cam_periph.c: In camperiphfree(), reorder some of the operations. The peripheral destructor needs to be called before the peripheral is removed from the peripheral is removed from the list. This is because once we remove the peripheral from the list, and drop the topology lock, the peripheral number may be reused. But if the destructor hasn't been called yet, there may still be resources hanging around (like devfs nodes) that haven't been fully cleaned up. cam_xpt.c: Add an argument to xpt_remove_periph() to indicate whether the topology lock is already held. scsi_enc.c: Acquire an extra reference to the peripheral during registration, and release it once we get a callback from devfs indicating that the device node is gone. Call destroy_dev_sched_cb() in enc_oninvalidate() instead of calling destroy_dev() in the cleanup routine. scsi_pass.c: Add reference counting to handle peripheral and devfs object lifetime issues. Add a reference to the peripheral and the devfs node in the peripheral registration. Don't attempt to add a physical path alias if the peripheral has been marked invalid. Release the devfs reference once the initial physical path alias taskqueue run has completed. Schedule devfs node destruction in the passoninvalidate(), and release our peripheral reference in a new routine, passdevgonecb() once the devfs node is gone. This allows the peripheral to fully go away, and the peripheral destructor, passcleanup(), will get called. Sponsored by: Spectra Logic Modified: stable/9/sys/cam/cam_periph.c stable/9/sys/cam/cam_xpt.c stable/9/sys/cam/cam_xpt_periph.h stable/9/sys/cam/scsi/scsi_pass.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/cam/cam_periph.c ============================================================================== --- stable/9/sys/cam/cam_periph.c Fri Jun 29 22:00:30 2012 (r237826) +++ stable/9/sys/cam/cam_periph.c Fri Jun 29 22:28:31 2012 (r237827) @@ -258,7 +258,7 @@ failure: break; case 3: CAM_DEBUG(periph->path, CAM_DEBUG_INFO, ("Periph destroyed\n")); - xpt_remove_periph(periph); + xpt_remove_periph(periph, /*topology_lock_held*/ 0); /* FALLTHROUGH */ case 2: xpt_lock_buses(); @@ -614,13 +614,38 @@ camperiphfree(struct cam_periph *periph) return; } - TAILQ_REMOVE(&(*p_drv)->units, periph, unit_links); - (*p_drv)->generation++; + /* + * The peripheral destructor semantics dictate calling with only the + * SIM mutex held. Since it might sleep, it should not be called + * with the topology lock held. + */ xpt_unlock_buses(); + /* + * We need to call the peripheral destructor prior to removing the + * peripheral from the list. Otherwise, we risk running into a + * scenario where the peripheral unit number may get reused + * (because it has been removed from the list), but some resources + * used by the peripheral are still hanging around. In particular, + * the devfs nodes used by some peripherals like the pass(4) driver + * aren't fully cleaned up until the destructor is run. If the + * unit number is reused before the devfs instance is fully gone, + * devfs will panic. + */ if (periph->periph_dtor != NULL) periph->periph_dtor(periph); - xpt_remove_periph(periph); + + /* + * The peripheral list is protected by the topology lock. + */ + xpt_lock_buses(); + + TAILQ_REMOVE(&(*p_drv)->units, periph, unit_links); + (*p_drv)->generation++; + + xpt_remove_periph(periph, /*topology_lock_held*/ 1); + + xpt_unlock_buses(); CAM_DEBUG(periph->path, CAM_DEBUG_INFO, ("Periph destroyed\n")); if (periph->flags & CAM_PERIPH_NEW_DEV_FOUND) { Modified: stable/9/sys/cam/cam_xpt.c ============================================================================== --- stable/9/sys/cam/cam_xpt.c Fri Jun 29 22:00:30 2012 (r237826) +++ stable/9/sys/cam/cam_xpt.c Fri Jun 29 22:28:31 2012 (r237827) @@ -1026,7 +1026,7 @@ xpt_add_periph(struct cam_periph *periph } void -xpt_remove_periph(struct cam_periph *periph) +xpt_remove_periph(struct cam_periph *periph, int topology_lock_held) { struct cam_ed *device; @@ -1047,9 +1047,13 @@ xpt_remove_periph(struct cam_periph *per SLIST_REMOVE(periph_head, periph, cam_periph, periph_links); } - mtx_lock(&xsoftc.xpt_topo_lock); + if (topology_lock_held == 0) + mtx_lock(&xsoftc.xpt_topo_lock); + xsoftc.xpt_generation++; - mtx_unlock(&xsoftc.xpt_topo_lock); + + if (topology_lock_held == 0) + mtx_unlock(&xsoftc.xpt_topo_lock); } Modified: stable/9/sys/cam/cam_xpt_periph.h ============================================================================== --- stable/9/sys/cam/cam_xpt_periph.h Fri Jun 29 22:00:30 2012 (r237826) +++ stable/9/sys/cam/cam_xpt_periph.h Fri Jun 29 22:28:31 2012 (r237827) @@ -42,7 +42,8 @@ void xpt_polled_action(union ccb *ccb); void xpt_release_ccb(union ccb *released_ccb); void xpt_schedule(struct cam_periph *perph, u_int32_t new_priority); int32_t xpt_add_periph(struct cam_periph *periph); -void xpt_remove_periph(struct cam_periph *periph); +void xpt_remove_periph(struct cam_periph *periph, + int topology_lock_held); void xpt_announce_periph(struct cam_periph *periph, char *announce_string); #endif Modified: stable/9/sys/cam/scsi/scsi_pass.c ============================================================================== --- stable/9/sys/cam/scsi/scsi_pass.c Fri Jun 29 22:00:30 2012 (r237826) +++ stable/9/sys/cam/scsi/scsi_pass.c Fri Jun 29 22:28:31 2012 (r237827) @@ -55,7 +55,8 @@ __FBSDID("$FreeBSD$"); typedef enum { PASS_FLAG_OPEN = 0x01, PASS_FLAG_LOCKED = 0x02, - PASS_FLAG_INVALID = 0x04 + PASS_FLAG_INVALID = 0x04, + PASS_FLAG_INITIAL_PHYSPATH = 0x08 } pass_flags; typedef enum { @@ -133,7 +134,18 @@ passinit(void) printf("pass: Failed to attach master async callback " "due to status 0x%x!\n", status); } - + +} + +static void +passdevgonecb(void *arg) +{ + struct cam_periph *periph; + + periph = (struct cam_periph *)arg; + + xpt_print(periph->path, "%s: devfs entry is gone\n", __func__); + cam_periph_release(periph); } static void @@ -151,6 +163,12 @@ passoninvalidate(struct cam_periph *peri softc->flags |= PASS_FLAG_INVALID; /* + * Tell devfs this device has gone away, and ask for a callback + * when it has cleaned up its state. + */ + destroy_dev_sched_cb(softc->dev, passdevgonecb, periph); + + /* * XXX Return all queued I/O with ENXIO. * XXX Handle any transactions queued to the card * with XPT_ABORT_CCB. @@ -176,11 +194,6 @@ passcleanup(struct cam_periph *periph) cam_periph_unlock(periph); taskqueue_drain(taskqueue_thread, &softc->add_physpath_task); - /* - * passcleanup() is indirectly a d_close method via passclose, - * so using destroy_dev(9) directly can result in deadlock. - */ - destroy_dev_sched(softc->dev); cam_periph_lock(periph); free(softc, M_DEVBUF); @@ -199,6 +212,12 @@ pass_add_physpath(void *context, int pen */ periph = context; softc = periph->softc; + cam_periph_lock(periph); + if (periph->flags & CAM_PERIPH_INVALID) { + cam_periph_unlock(periph); + return; + } + cam_periph_unlock(periph); physpath = malloc(MAXPATHLEN, M_DEVBUF, M_WAITOK); if (xpt_getattr(physpath, MAXPATHLEN, "GEOM::physpath", periph->path) == 0 @@ -208,6 +227,19 @@ pass_add_physpath(void *context, int pen softc->dev, softc->alias_dev, physpath); } free(physpath, M_DEVBUF); + + /* + * Now that we've made our alias, we no longer have to have a + * reference to the device. + */ + cam_periph_lock(periph); + if ((softc->flags & PASS_FLAG_INITIAL_PHYSPATH) == 0) { + softc->flags |= PASS_FLAG_INITIAL_PHYSPATH; + cam_periph_unlock(periph); + dev_rel(softc->dev); + } + else + cam_periph_unlock(periph); } static void @@ -281,12 +313,12 @@ passregister(struct cam_periph *periph, cgd = (struct ccb_getdev *)arg; if (periph == NULL) { - printf("passregister: periph was NULL!!\n"); + printf("%s: periph was NULL!!\n", __func__); return(CAM_REQ_CMP_ERR); } if (cgd == NULL) { - printf("passregister: no getdev CCB, can't register device\n"); + printf("%s: no getdev CCB, can't register device\n", __func__); return(CAM_REQ_CMP_ERR); } @@ -294,8 +326,8 @@ passregister(struct cam_periph *periph, M_DEVBUF, M_NOWAIT); if (softc == NULL) { - printf("passregister: Unable to probe new device. " - "Unable to allocate softc\n"); + printf("%s: Unable to probe new device. " + "Unable to allocate softc\n", __func__); return(CAM_REQ_CMP_ERR); } @@ -331,10 +363,31 @@ passregister(struct cam_periph *periph, DEVSTAT_TYPE_PASS, DEVSTAT_PRIORITY_PASS); + /* + * Acquire a reference to the periph before we create the devfs + * instance for it. We'll release this reference once the devfs + * instance has been freed. + */ + if (cam_periph_acquire(periph) != CAM_REQ_CMP) { + xpt_print(periph->path, "%s: lost periph during " + "registration!\n", __func__); + mtx_lock(periph->sim->mtx); + return (CAM_REQ_CMP_ERR); + } + /* Register the device */ softc->dev = make_dev(&pass_cdevsw, periph->unit_number, UID_ROOT, GID_OPERATOR, 0600, "%s%d", periph->periph_name, periph->unit_number); + + /* + * Now that we have made the devfs instance, hold a reference to it + * until the task queue has run to setup the physical path alias. + * That way devfs won't get rid of the device before we add our + * alias. + */ + dev_ref(softc->dev); + mtx_lock(periph->sim->mtx); softc->dev->si_drv1 = periph; From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 22:33:48 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D3D73106564A; Fri, 29 Jun 2012 22:33:48 +0000 (UTC) (envelope-from ken@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BCC588FC17; Fri, 29 Jun 2012 22:33:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5TMXmTS074390; Fri, 29 Jun 2012 22:33:48 GMT (envelope-from ken@svn.freebsd.org) Received: (from ken@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5TMXm0c074386; Fri, 29 Jun 2012 22:33:48 GMT (envelope-from ken@svn.freebsd.org) Message-Id: <201206292233.q5TMXm0c074386@svn.freebsd.org> From: "Kenneth D. Merry" Date: Fri, 29 Jun 2012 22:33:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237828 - in stable/9: sbin/camcontrol sys/cam/scsi X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 22:33:48 -0000 Author: ken Date: Fri Jun 29 22:33:48 2012 New Revision: 237828 URL: http://svn.freebsd.org/changeset/base/237828 Log: MFC r237452: r237452 | ken | 2012-06-22 12:57:06 -0600 (Fri, 22 Jun 2012) | 25 lines Change 'camcontrol defects' to first probe a drive to find out how much defect information it has before grabbing the full defect list. This works around a bug with some Hitachi drives that generate data overrun errors when they are asked for more defect data than they have. The change is done in a spec-compliant way, so it should have no negative impact on drives that don't have this issue. This is based on work originally done at Sandvine. scsi_da.h: Add a define for the maximum amount of data that can be contained in a defect list. camcontrol.c: Update the readdefects() function to issue an initial command to determine the length of the defect list, and then use that length in the request for the full defect list. camcontrol.8: Add a note that some drives will report 0 defects available if you don't request either the PLIST or GLIST. Submitted by: Mark Johnston (original version) Modified: stable/9/sbin/camcontrol/camcontrol.8 stable/9/sbin/camcontrol/camcontrol.c stable/9/sys/cam/scsi/scsi_da.h Directory Properties: stable/9/sbin/camcontrol/ (props changed) stable/9/sys/ (props changed) Modified: stable/9/sbin/camcontrol/camcontrol.8 ============================================================================== --- stable/9/sbin/camcontrol/camcontrol.8 Fri Jun 29 22:28:31 2012 (r237827) +++ stable/9/sbin/camcontrol/camcontrol.8 Fri Jun 29 22:33:48 2012 (r237828) @@ -497,6 +497,8 @@ is specified, .Nm will print out the number of defects given in the READ DEFECT DATA header returned from the drive. +Some drives will report 0 defects if neither the primary or grown defect +lists are requested. .It Ic modepage Allows the user to display and optionally edit a SCSI mode page. The mode Modified: stable/9/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/9/sbin/camcontrol/camcontrol.c Fri Jun 29 22:28:31 2012 (r237827) +++ stable/9/sbin/camcontrol/camcontrol.c Fri Jun 29 22:33:48 2012 (r237828) @@ -1799,13 +1799,14 @@ readdefects(struct cam_device *device, i union ccb *ccb = NULL; struct scsi_read_defect_data_10 *rdd_cdb; u_int8_t *defect_list = NULL; - u_int32_t dlist_length = 65000; + u_int32_t max_dlist_length = SRDD10_MAX_LENGTH, dlist_length = 0; u_int32_t returned_length = 0; u_int32_t num_returned = 0; u_int8_t returned_format; unsigned int i; int c, error = 0; - int lists_specified = 0; + int lists_specified; + int get_length = 1; while ((c = getopt(argc, argv, combinedopt)) != -1) { switch(c){ @@ -1842,20 +1843,33 @@ readdefects(struct cam_device *device, i ccb = cam_getccb(device); /* - * Hopefully 65000 bytes is enough to hold the defect list. If it - * isn't, the disk is probably dead already. We'd have to go with - * 12 byte command (i.e. alloc_length is 32 bits instead of 16) - * to hold them all. + * Eventually we should probably support the 12 byte READ DEFECT + * DATA command. It supports a longer parameter list, which may be + * necessary on newer drives with lots of defects. According to + * the SBC-3 spec, drives are supposed to return an illegal request + * if they have more defect data than will fit in 64K. */ - defect_list = malloc(dlist_length); + defect_list = malloc(max_dlist_length); if (defect_list == NULL) { warnx("can't malloc memory for defect list"); error = 1; goto defect_bailout; } + /* + * We start off asking for just the header to determine how much + * defect data is available. Some Hitachi drives return an error + * if you ask for more data than the drive has. Once we know the + * length, we retry the command with the returned length. + */ + dlist_length = sizeof(struct scsi_read_defect_data_hdr_10); + rdd_cdb =(struct scsi_read_defect_data_10 *)&ccb->csio.cdb_io.cdb_bytes; +retry: + + lists_specified = 0; + /* * cam_getccb() zeros the CCB header only. So we need to zero the * payload portion of the ccb. @@ -1917,6 +1931,51 @@ readdefects(struct cam_device *device, i returned_length = scsi_2btoul(((struct scsi_read_defect_data_hdr_10 *)defect_list)->length); + if (get_length != 0) { + get_length = 0; + + if ((ccb->ccb_h.status & CAM_STATUS_MASK) == + CAM_SCSI_STATUS_ERROR) { + struct scsi_sense_data *sense; + int error_code, sense_key, asc, ascq; + + sense = &ccb->csio.sense_data; + scsi_extract_sense_len(sense, ccb->csio.sense_len - + ccb->csio.sense_resid, &error_code, &sense_key, + &asc, &ascq, /*show_errors*/ 1); + + /* + * If the drive is reporting that it just doesn't + * support the defect list format, go ahead and use + * the length it reported. Otherwise, the length + * may not be valid, so use the maximum. + */ + if ((sense_key == SSD_KEY_RECOVERED_ERROR) + && (asc == 0x1c) && (ascq == 0x00) + && (returned_length > 0)) { + dlist_length = returned_length + + sizeof(struct scsi_read_defect_data_hdr_10); + dlist_length = min(dlist_length, + SRDD10_MAX_LENGTH); + } else + dlist_length = max_dlist_length; + } else if ((ccb->ccb_h.status & CAM_STATUS_MASK) != + CAM_REQ_CMP){ + error = 1; + warnx("Error reading defect header"); + if (arglist & CAM_ARG_VERBOSE) + cam_error_print(device, ccb, CAM_ESF_ALL, + CAM_EPF_ALL, stderr); + goto defect_bailout; + } else { + dlist_length = returned_length + + sizeof(struct scsi_read_defect_data_hdr_10); + dlist_length = min(dlist_length, SRDD10_MAX_LENGTH); + } + + goto retry; + } + returned_format = ((struct scsi_read_defect_data_hdr_10 *) defect_list)->format; Modified: stable/9/sys/cam/scsi/scsi_da.h ============================================================================== --- stable/9/sys/cam/scsi/scsi_da.h Fri Jun 29 22:28:31 2012 (r237827) +++ stable/9/sys/cam/scsi/scsi_da.h Fri Jun 29 22:33:48 2012 (r237828) @@ -111,6 +111,7 @@ struct scsi_read_defect_data_10 u_int8_t reserved[4]; u_int8_t alloc_length[2]; +#define SRDD10_MAX_LENGTH 0xffff u_int8_t control; }; From owner-svn-src-stable-9@FreeBSD.ORG Sat Jun 30 14:05:36 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5C33910656D1; Sat, 30 Jun 2012 14:05:36 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4564B8FC0C; Sat, 30 Jun 2012 14:05:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5UE5aPW022914; Sat, 30 Jun 2012 14:05:36 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5UE5aF7022912; Sat, 30 Jun 2012 14:05:36 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201206301405.q5UE5aF7022912@svn.freebsd.org> From: Andriy Gapon Date: Sat, 30 Jun 2012 14:05:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237837 - stable/9/usr.sbin/cpucontrol X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Jun 2012 14:05:36 -0000 Author: avg Date: Sat Jun 30 14:05:35 2012 New Revision: 237837 URL: http://svn.freebsd.org/changeset/base/237837 Log: MFC r236504: cpucontrol: use CPUCTL_UPDATE ioctl on correct file descriptor (in amd case) Modified: stable/9/usr.sbin/cpucontrol/amd.c Directory Properties: stable/9/usr.sbin/cpucontrol/ (props changed) Modified: stable/9/usr.sbin/cpucontrol/amd.c ============================================================================== --- stable/9/usr.sbin/cpucontrol/amd.c Sat Jun 30 13:17:21 2012 (r237836) +++ stable/9/usr.sbin/cpucontrol/amd.c Sat Jun 30 14:05:35 2012 (r237837) @@ -160,7 +160,7 @@ amd_update(const char *dev, const char * args.data = fw_image; args.size = st.st_size; - error = ioctl(fd, CPUCTL_UPDATE, &args); + error = ioctl(devfd, CPUCTL_UPDATE, &args); if (error < 0) { fprintf(stderr, "failed.\n"); warn("ioctl()"); From owner-svn-src-stable-9@FreeBSD.ORG Sat Jun 30 14:18:00 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 97BD5106566C; Sat, 30 Jun 2012 14:18:00 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 77B748FC0A; Sat, 30 Jun 2012 14:18:00 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5UEI0VB023610; Sat, 30 Jun 2012 14:18:00 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5UEI06V023604; Sat, 30 Jun 2012 14:18:00 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201206301418.q5UEI06V023604@svn.freebsd.org> From: Andriy Gapon Date: Sat, 30 Jun 2012 14:18:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237839 - in stable/9/sys: amd64/amd64 i386/i386 kern x86/x86 X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Jun 2012 14:18:00 -0000 Author: avg Date: Sat Jun 30 14:17:59 2012 New Revision: 237839 URL: http://svn.freebsd.org/changeset/base/237839 Log: MFC r236503: free wdog_kern_pat calls in post-panic paths from under SW_WATCHDOG Modified: stable/9/sys/amd64/amd64/minidump_machdep.c stable/9/sys/i386/i386/minidump_machdep.c stable/9/sys/kern/kern_shutdown.c stable/9/sys/kern/vfs_subr.c stable/9/sys/x86/x86/dump_machdep.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/dev/isp/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/modules/ (props changed) Modified: stable/9/sys/amd64/amd64/minidump_machdep.c ============================================================================== --- stable/9/sys/amd64/amd64/minidump_machdep.c Sat Jun 30 14:06:17 2012 (r237838) +++ stable/9/sys/amd64/amd64/minidump_machdep.c Sat Jun 30 14:17:59 2012 (r237839) @@ -37,9 +37,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#ifdef SW_WATCHDOG #include -#endif #include #include #include @@ -177,9 +175,9 @@ blk_write(struct dumperinfo *di, char *p report_progress(progress, dumpsize); counter &= (1<<24) - 1; } -#ifdef SW_WATCHDOG + wdog_kern_pat(WD_LASTVAL); -#endif + if (ptr) { error = dump_write(di, ptr, 0, dumplo, len); if (error) Modified: stable/9/sys/i386/i386/minidump_machdep.c ============================================================================== --- stable/9/sys/i386/i386/minidump_machdep.c Sat Jun 30 14:06:17 2012 (r237838) +++ stable/9/sys/i386/i386/minidump_machdep.c Sat Jun 30 14:17:59 2012 (r237839) @@ -36,9 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#ifdef SW_WATCHDOG #include -#endif #include #include #include @@ -143,9 +141,9 @@ blk_write(struct dumperinfo *di, char *p printf(" %lld", PG2MB(progress >> PAGE_SHIFT)); counter &= (1<<24) - 1; } -#ifdef SW_WATCHDOG + wdog_kern_pat(WD_LASTVAL); -#endif + if (ptr) { error = dump_write(di, ptr, 0, dumplo, len); if (error) Modified: stable/9/sys/kern/kern_shutdown.c ============================================================================== --- stable/9/sys/kern/kern_shutdown.c Sat Jun 30 14:06:17 2012 (r237838) +++ stable/9/sys/kern/kern_shutdown.c Sat Jun 30 14:17:59 2012 (r237839) @@ -66,9 +66,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#ifdef SW_WATCHDOG #include -#endif #include @@ -331,9 +329,7 @@ kern_reboot(int howto) waittime = 0; -#ifdef SW_WATCHDOG wdog_kern_pat(WD_LASTVAL); -#endif sys_sync(curthread, NULL); /* @@ -359,9 +355,8 @@ kern_reboot(int howto) if (nbusy < pbusy) iter = 0; pbusy = nbusy; -#ifdef SW_WATCHDOG + wdog_kern_pat(WD_LASTVAL); -#endif sys_sync(curthread, NULL); #ifdef PREEMPTION Modified: stable/9/sys/kern/vfs_subr.c ============================================================================== --- stable/9/sys/kern/vfs_subr.c Sat Jun 30 14:06:17 2012 (r237838) +++ stable/9/sys/kern/vfs_subr.c Sat Jun 30 14:17:59 2012 (r237839) @@ -73,9 +73,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#ifdef SW_WATCHDOG #include -#endif #include @@ -1869,10 +1867,10 @@ sched_sync(void) LIST_INSERT_HEAD(next, bo, bo_synclist); continue; } -#ifdef SW_WATCHDOG + if (first_printf == 0) wdog_kern_pat(WD_LASTVAL); -#endif + } if (!LIST_EMPTY(gslp)) { mtx_unlock(&sync_mtx); Modified: stable/9/sys/x86/x86/dump_machdep.c ============================================================================== --- stable/9/sys/x86/x86/dump_machdep.c Sat Jun 30 14:06:17 2012 (r237838) +++ stable/9/sys/x86/x86/dump_machdep.c Sat Jun 30 14:17:59 2012 (r237839) @@ -36,9 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#ifdef SW_WATCHDOG #include -#endif #include #include #include @@ -198,9 +196,9 @@ cb_dumpdata(struct md_pa *mdp, int seqnr a = pa + i * PAGE_SIZE; va = pmap_kenter_temporary(trunc_page(a), i); } -#ifdef SW_WATCHDOG + wdog_kern_pat(WD_LASTVAL); -#endif + error = dump_write(di, va, 0, dumplo, sz); if (error) break; From owner-svn-src-stable-9@FreeBSD.ORG Sat Jun 30 18:57:55 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id CE1551065672; Sat, 30 Jun 2012 18:57:55 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B7E7C8FC0C; Sat, 30 Jun 2012 18:57:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5UIvt2m036017; Sat, 30 Jun 2012 18:57:55 GMT (envelope-from thompsa@svn.freebsd.org) Received: (from thompsa@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5UIvtPe036014; Sat, 30 Jun 2012 18:57:55 GMT (envelope-from thompsa@svn.freebsd.org) Message-Id: <201206301857.q5UIvtPe036014@svn.freebsd.org> From: Andrew Thompson Date: Sat, 30 Jun 2012 18:57:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237850 - stable/9/usr.bin/sockstat X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Jun 2012 18:57:55 -0000 Author: thompsa Date: Sat Jun 30 18:57:55 2012 New Revision: 237850 URL: http://svn.freebsd.org/changeset/base/237850 Log: MFC r237674 Update the usage with the new jail option. Modified: stable/9/usr.bin/sockstat/sockstat.c Directory Properties: stable/9/usr.bin/sockstat/ (props changed) Modified: stable/9/usr.bin/sockstat/sockstat.c ============================================================================== --- stable/9/usr.bin/sockstat/sockstat.c Sat Jun 30 18:56:08 2012 (r237849) +++ stable/9/usr.bin/sockstat/sockstat.c Sat Jun 30 18:57:55 2012 (r237850) @@ -732,7 +732,7 @@ static void usage(void) { fprintf(stderr, - "Usage: sockstat [-46cLlu] [-p ports] [-P protocols]\n"); + "Usage: sockstat [-46cLlu] [-j jid] [-p ports] [-P protocols]\n"); exit(1); } From owner-svn-src-stable-9@FreeBSD.ORG Sat Jun 30 20:22:21 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0566C106566B; Sat, 30 Jun 2012 20:22:21 +0000 (UTC) (envelope-from gavin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E14498FC1D; Sat, 30 Jun 2012 20:22:20 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5UKMKVg039694; Sat, 30 Jun 2012 20:22:20 GMT (envelope-from gavin@svn.freebsd.org) Received: (from gavin@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5UKMK2T039692; Sat, 30 Jun 2012 20:22:20 GMT (envelope-from gavin@svn.freebsd.org) Message-Id: <201206302022.q5UKMK2T039692@svn.freebsd.org> From: Gavin Atkinson Date: Sat, 30 Jun 2012 20:22:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237853 - stable/9/sbin/mdconfig X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Jun 2012 20:22:21 -0000 Author: gavin Date: Sat Jun 30 20:22:20 2012 New Revision: 237853 URL: http://svn.freebsd.org/changeset/base/237853 Log: Merge r237645 from head: The -S option, to specify the sector size, has been usable on all types of memory disks since r135340. Update the man page to reflect this. Noticed by: avg Modified: stable/9/sbin/mdconfig/mdconfig.8 Directory Properties: stable/9/sbin/mdconfig/ (props changed) Modified: stable/9/sbin/mdconfig/mdconfig.8 ============================================================================== --- stable/9/sbin/mdconfig/mdconfig.8 Sat Jun 30 19:09:02 2012 (r237852) +++ stable/9/sbin/mdconfig/mdconfig.8 Sat Jun 30 20:22:20 2012 (r237853) @@ -41,7 +41,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 21, 2008 +.Dd June 27, 2012 .Dt MDCONFIG 8 .Os .Sh NAME @@ -143,7 +143,7 @@ and .Fl t Ar swap are implied if not specified. .It Fl S Ar sectorsize -Sectorsize to use for malloc backed device. +Sectorsize to use for the memory disk, in bytes. .It Fl x Ar sectors/track See the description of the .Fl y