From owner-svn-src-projects@FreeBSD.ORG Tue Jan 27 19:40:15 2015 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id AF260530; Tue, 27 Jan 2015 19:40:15 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 97B2AB6C; Tue, 27 Jan 2015 19:40:15 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t0RJeFqA016203; Tue, 27 Jan 2015 19:40:15 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t0RJe93T016161; Tue, 27 Jan 2015 19:40:09 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201501271940.t0RJe93T016161@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Tue, 27 Jan 2015 19:40:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r277809 - in projects/clang360-import: bin/expr contrib/sendmail/cf/m4 contrib/tcpdump etc/sendmail lib/libthread_db/arch/i386 sbin/geom/class/mountver share/man/man9 sys/dev/acpica sys... X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Jan 2015 19:40:15 -0000 Author: dim Date: Tue Jan 27 19:40:08 2015 New Revision: 277809 URL: https://svnweb.freebsd.org/changeset/base/277809 Log: Merging ^/head r277777 through r277803. Modified: projects/clang360-import/bin/expr/expr.y projects/clang360-import/contrib/sendmail/cf/m4/cfhead.m4 projects/clang360-import/contrib/tcpdump/print-ip.c projects/clang360-import/contrib/tcpdump/print-sl.c projects/clang360-import/etc/sendmail/Makefile projects/clang360-import/lib/libthread_db/arch/i386/libpthread_md.c projects/clang360-import/sbin/geom/class/mountver/gmountver.8 projects/clang360-import/share/man/man9/pmap_enter.9 projects/clang360-import/sys/dev/acpica/acpi.c projects/clang360-import/sys/dev/fb/fbd.c projects/clang360-import/sys/dev/syscons/syscons.c projects/clang360-import/sys/dev/virtio/block/virtio_blk.c projects/clang360-import/sys/dev/vt/hw/fb/vt_fb.c projects/clang360-import/sys/dev/vt/hw/fb/vt_fb.h projects/clang360-import/sys/dev/vt/vt.h projects/clang360-import/sys/dev/vt/vt_core.c projects/clang360-import/sys/netipsec/key.c projects/clang360-import/sys/powerpc/pseries/plpar_iommu.c projects/clang360-import/sys/sys/eventhandler.h projects/clang360-import/sys/ufs/ufs/ufs_quota.c projects/clang360-import/sys/ufs/ufs/ufs_vfsops.c projects/clang360-import/usr.bin/sed/main.c projects/clang360-import/usr.bin/sed/process.c projects/clang360-import/usr.sbin/pmcstudy/pmcstudy.c Directory Properties: projects/clang360-import/ (props changed) projects/clang360-import/contrib/sendmail/ (props changed) projects/clang360-import/contrib/tcpdump/ (props changed) projects/clang360-import/etc/ (props changed) projects/clang360-import/sbin/ (props changed) projects/clang360-import/share/ (props changed) projects/clang360-import/sys/ (props changed) Modified: projects/clang360-import/bin/expr/expr.y ============================================================================== --- projects/clang360-import/bin/expr/expr.y Tue Jan 27 19:37:02 2015 (r277808) +++ projects/clang360-import/bin/expr/expr.y Tue Jan 27 19:40:08 2015 (r277809) @@ -444,14 +444,26 @@ op_minus(struct val *a, struct val *b) return (r); } +/* + * We depend on undefined behaviour giving a result (in r). + * To test this result, pass it as volatile. This prevents + * optimizing away of the test based on the undefined behaviour. + */ void -assert_times(intmax_t a, intmax_t b, intmax_t r) +assert_times(intmax_t a, intmax_t b, volatile intmax_t r) { /* - * if first operand is 0, no overflow is possible, - * else result of division test must match second operand + * If the first operand is 0, no overflow is possible, + * else the result of the division test must match the + * second operand. + * + * Be careful to avoid overflow in the overflow test, as + * in assert_div(). Overflow in division would kill us + * with a SIGFPE before getting the test wrong. In old + * buggy versions, optimization used to give a null test + * instead of a SIGFPE. */ - if (a != 0 && r / a != b) + if ((a == -1 && b == INTMAX_MIN) || (a != 0 && r / a != b)) errx(ERR_EXIT, "overflow"); } Modified: projects/clang360-import/contrib/sendmail/cf/m4/cfhead.m4 ============================================================================== --- projects/clang360-import/contrib/sendmail/cf/m4/cfhead.m4 Tue Jan 27 19:37:02 2015 (r277808) +++ projects/clang360-import/contrib/sendmail/cf/m4/cfhead.m4 Tue Jan 27 19:40:08 2015 (r277809) @@ -20,7 +20,7 @@ ifdef(`__win32__', `dnl', `dnl ifdef(`TEMPFILE', `dnl', `define(`TEMPFILE', maketemp(/tmp/cfXXXXXX))dnl syscmd(sh _CF_DIR_`'sh/makeinfo.sh _CF_DIR_ > TEMPFILE)dnl -include(TEMPFILE)dnl +ifdef(`_NO_MAKEINFO_',, `include(TEMPFILE)')dnl syscmd(rm -f TEMPFILE)dnl')') ##### ###################################################################### Modified: projects/clang360-import/contrib/tcpdump/print-ip.c ============================================================================== --- projects/clang360-import/contrib/tcpdump/print-ip.c Tue Jan 27 19:37:02 2015 (r277808) +++ projects/clang360-import/contrib/tcpdump/print-ip.c Tue Jan 27 19:40:08 2015 (r277809) @@ -537,6 +537,7 @@ ip_print(netdissect_options *ndo, struct protoent *proto; ipds->ip = (const struct ip *)bp; + ND_TCHECK(ipds->ip->ip_vhl); if (IP_V(ipds->ip) != 4) { /* print version if != 4 */ ND_PRINT((ndo, "IP%u ", IP_V(ipds->ip))); if (IP_V(ipds->ip) == 6) @@ -545,10 +546,7 @@ ip_print(netdissect_options *ndo, else if (!ndo->ndo_eflag) ND_PRINT((ndo, "IP ")); - if ((u_char *)(ipds->ip + 1) > ndo->ndo_snapend) { - ND_PRINT((ndo, "%s", tstr)); - return; - } + ND_TCHECK(*ipds->ip); if (length < sizeof (struct ip)) { ND_PRINT((ndo, "truncated-ip %u", length)); return; @@ -677,6 +675,11 @@ ip_print(netdissect_options *ndo, ND_PRINT((ndo, " ip-proto-%d", ipds->ip->ip_p)); } } + return; + +trunc: + ND_PRINT((ndo, "%s", tstr)); + return; } void Modified: projects/clang360-import/contrib/tcpdump/print-sl.c ============================================================================== --- projects/clang360-import/contrib/tcpdump/print-sl.c Tue Jan 27 19:37:02 2015 (r277808) +++ projects/clang360-import/contrib/tcpdump/print-sl.c Tue Jan 27 19:40:08 2015 (r277809) @@ -64,7 +64,7 @@ sl_if_print(netdissect_options *ndo, register u_int length = h->len; register const struct ip *ip; - if (caplen < SLIP_HDRLEN) { + if (caplen < SLIP_HDRLEN || length < SLIP_HDRLEN) { ND_PRINT((ndo, "%s", tstr)); return (caplen); } Modified: projects/clang360-import/etc/sendmail/Makefile ============================================================================== --- projects/clang360-import/etc/sendmail/Makefile Tue Jan 27 19:37:02 2015 (r277808) +++ projects/clang360-import/etc/sendmail/Makefile Tue Jan 27 19:40:08 2015 (r277809) @@ -17,7 +17,8 @@ M4FILES!= find ${SENDMAIL_CF_DIR} -type .mc.cf: ${M4FILES} ${RM} ${.TARGET} - ${M4} -D_CF_DIR_=${SENDMAIL_CF_DIR}/ ${SENDMAIL_M4_FLAGS} \ + ${M4} -D_CF_DIR_=${SENDMAIL_CF_DIR}/ -D_NO_MAKEINFO_ \ + ${SENDMAIL_M4_FLAGS} \ ${SENDMAIL_CF_DIR}/m4/cf.m4 ${.IMPSRC} > ${.TARGET} ${CHMOD} ${ROMODE} ${.TARGET} Modified: projects/clang360-import/lib/libthread_db/arch/i386/libpthread_md.c ============================================================================== --- projects/clang360-import/lib/libthread_db/arch/i386/libpthread_md.c Tue Jan 27 19:37:02 2015 (r277808) +++ projects/clang360-import/lib/libthread_db/arch/i386/libpthread_md.c Tue Jan 27 19:40:08 2015 (r277809) @@ -72,7 +72,7 @@ pt_ucontext_to_fpreg(const ucontext_t *u memcpy(r, &uc->uc_mcontext.mc_fpstate, sizeof(struct save87)); else { int i; - struct savexmm *sx = (struct savexmm *)&uc->uc_mcontext.mc_fpstate; + const struct savexmm *sx = (const struct savexmm *)&uc->uc_mcontext.mc_fpstate; memcpy(&r->fpr_env, &sx->sv_env, sizeof(r->fpr_env)); for (i = 0; i < 8; ++i) memcpy(&r->fpr_acc[i], &sx->sv_fp[i].fp_acc, 10); Modified: projects/clang360-import/sbin/geom/class/mountver/gmountver.8 ============================================================================== --- projects/clang360-import/sbin/geom/class/mountver/gmountver.8 Tue Jan 27 19:37:02 2015 (r277808) +++ projects/clang360-import/sbin/geom/class/mountver/gmountver.8 Tue Jan 27 19:40:08 2015 (r277809) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 14, 2010 +.Dd January 27, 2015 .Dt GMOUNTVER 8 .Os .Sh NAME @@ -110,7 +110,7 @@ GEOM class. This can be set to a number between 0 and 3 inclusive. If set to 0 minimal debug information is printed, and if set to 3 the maximum amount of debug information is printed. -.It Va kern.geom.mountver.check.check_ident : No 1 +.It Va kern.geom.mountver.check_ident : No 1 This can be set to 0 or 1. If set to 0, .Nm Modified: projects/clang360-import/share/man/man9/pmap_enter.9 ============================================================================== --- projects/clang360-import/share/man/man9/pmap_enter.9 Tue Jan 27 19:37:02 2015 (r277808) +++ projects/clang360-import/share/man/man9/pmap_enter.9 Tue Jan 27 19:40:08 2015 (r277809) @@ -1,5 +1,6 @@ .\" .\" Copyright (c) 2003 Bruce M Simpson +.\" Copyright (c) 2014 The FreeBSD Foundation .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -25,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 21, 2003 +.Dd January 27, 2015 .Dt PMAP_ENTER 9 .Os .Sh NAME @@ -35,34 +36,129 @@ .In sys/param.h .In vm/vm.h .In vm/pmap.h -.Ft void +.Ft int .Fo pmap_enter -.Fa "pmap_t pmap" "vm_offset_t va" "vm_page_t p" "vm_prot_t prot" -.Fa "boolean_t wired" +.Fa "pmap_t pmap" "vm_offset_t va" "vm_page_t m" "vm_prot_t prot" +.Fa "u_int flags" "int8_t psind" .Fc .Sh DESCRIPTION The .Fn pmap_enter -function inserts the given physical page -.Fa p , -into the physical map -.Fa pmap , -at the virtual address -.Fa va , +function creates a mapping in the physical map +.Fa pmap +from the virtual address +.Fa va +to the physical page +.Fa m with the protection .Fa prot . -If -.Fa wired -is -.Dv TRUE , -then increment the wired count for the page as soon as the mapping -is inserted into -.Fa pmap . -.Sh IMPLEMENTATION NOTES -This routine MAY NOT lazy-evaluate the entry; it is required by -specification to make the requested entry at the time it is called. +Any previous mapping at the virtual address +.Fa va +is destroyed. +.Pp +The +.Fa flags +argument may have the following values: +.Bl -tag -width ".Dv PMAP_ENTER_NOSLEEP" +.It Dv VM_PROT_READ +A read access to the given virtual address triggered the call. +.It Dv VM_PROT_WRITE +A write access to the given virtual address triggered the call. +.It Dv VM_PROT_EXECUTE +An execute access to the given virtual address triggered the call. +.It Dv PMAP_ENTER_WIRED +The mapping should be marked as wired. +.It Dv PMAP_ENTER_NOSLEEP +This function may not sleep during creation of the mapping. +If the mapping cannot be created without sleeping, an appropriate +Mach VM error is returned. +.El +If the +.Dv PMAP_ENTER_NOSLEEP +flag is not specified, this function must create the requested mapping +before returning. +It may not fail. +In order to create the requested mapping, this function may destroy +any non-wired mapping in any pmap. +.Pp +The +.Fa psind +parameter specifies the page size that should be used by the mapping. +The supported page sizes are described by the global array +.Dv pagesizes[] . +The desired page size is specified by passing the index of the array +element that equals the desired page size. +.Pp +When the +.Fn pmap_enter +function destroys or updates a managed mapping, including an existing +mapping at virtual address +.Fa va , +it updates the +.Ft vm_page +structure corresponding to the previously mapped physical page. +If the physical page was accessed through the managed mapping, +then the +.Ft vm_page +structure's +.Dv PGA_REFERENCED +aflag is set. +If the physical page was modified through the managed mapping, then the +.Fn vm_page_dirty +function is called on the +.Ft vm_page +structure. +.Pp +The +.Dv PGA_WRITEABLE +aflag must be set for the page +.Fa m +if the new mapping is managed and writeable. +It is advised to clear +.Dv PGA_WRITEABLE +for destroyed mappings if the implementation can ensure +that no other writeable managed mappings for the previously +mapped pages exist. +.Pp +If the page +.Fa m +is managed, the page must be busied by the caller +or the owning object must be locked. +In the later case, the +.Dv PMAP_ENTER_NOSLEEP +must be specified by the caller. +.Pp +The +.Fn pmap_enter +function must handle the multiprocessor TLB consistency for the +given address. +.Sh NOTES +On amd64, arm and i386 architectures the existing implementation +of the +.Nm +function is incomplete, only value 0 for +.Fa psind +is supported. +Other supported architectures have +.Dv pagesizes[] +array of size 1. +.Sh RETURN VALUES +If successful, the +.Fn pmap_enter +function returns +.Er KERN_SUCCESS . +If the +.Dv PMAP_ENTER_NOSLEEP +flag was specified and the resources required for the mapping cannot +be acquired without sleeping, +.Dv KERN_RESOURCE_SHORTAGE +is returned. .Sh SEE ALSO .Xr pmap 9 .Sh AUTHORS -This manual page was written by -.An Bruce M Simpson Aq Mt bms@spc.org . +This manual page was first written by +.An Bruce M Simpson Aq Mt bms@spc.org +and then rewritten by +.An Alan Cox Aq Mt alc@FreeBSD.org +and +.An Konstantin Belousov Aq Mt kib@FreeBSD.org . Modified: projects/clang360-import/sys/dev/acpica/acpi.c ============================================================================== --- projects/clang360-import/sys/dev/acpica/acpi.c Tue Jan 27 19:37:02 2015 (r277808) +++ projects/clang360-import/sys/dev/acpica/acpi.c Tue Jan 27 19:40:08 2015 (r277809) @@ -2749,6 +2749,8 @@ acpi_EnterSleepState(struct acpi_softc * return_ACPI_STATUS (AE_OK); } + EVENTHANDLER_INVOKE(power_suspend_early); + stop_all_proc(); EVENTHANDLER_INVOKE(power_suspend); if (smp_started) { @@ -2892,6 +2894,8 @@ backout: thread_unlock(curthread); } + resume_all_proc(); + EVENTHANDLER_INVOKE(power_resume); /* Allow another sleep request after a while. */ Modified: projects/clang360-import/sys/dev/fb/fbd.c ============================================================================== --- projects/clang360-import/sys/dev/fb/fbd.c Tue Jan 27 19:37:02 2015 (r277808) +++ projects/clang360-import/sys/dev/fb/fbd.c Tue Jan 27 19:40:08 2015 (r277809) @@ -332,22 +332,6 @@ fbd_detach(device_t dev) return (err); } -static int -fbd_suspend(device_t dev) -{ - - vt_fb_suspend(); - return (bus_generic_suspend(dev)); -} - -static int -fbd_resume(device_t dev) -{ - - vt_fb_resume(); - return (bus_generic_resume(dev)); -} - static device_method_t fbd_methods[] = { /* Device interface */ DEVMETHOD(device_probe, fbd_probe), @@ -355,8 +339,6 @@ static device_method_t fbd_methods[] = { DEVMETHOD(device_detach, fbd_detach), DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD(device_suspend, fbd_suspend), - DEVMETHOD(device_resume, fbd_resume), { 0, 0 } }; Modified: projects/clang360-import/sys/dev/syscons/syscons.c ============================================================================== --- projects/clang360-import/sys/dev/syscons/syscons.c Tue Jan 27 19:37:02 2015 (r277808) +++ projects/clang360-import/sys/dev/syscons/syscons.c Tue Jan 27 19:40:08 2015 (r277809) @@ -549,7 +549,7 @@ sc_attach_unit(int unit, int flags) /* Register suspend/resume/shutdown callbacks for the kernel console. */ if (sc_console_unit == unit) { - EVENTHANDLER_REGISTER(power_suspend, scsuspend, NULL, + EVENTHANDLER_REGISTER(power_suspend_early, scsuspend, NULL, EVENTHANDLER_PRI_ANY); EVENTHANDLER_REGISTER(power_resume, scresume, NULL, EVENTHANDLER_PRI_ANY); Modified: projects/clang360-import/sys/dev/virtio/block/virtio_blk.c ============================================================================== --- projects/clang360-import/sys/dev/virtio/block/virtio_blk.c Tue Jan 27 19:37:02 2015 (r277808) +++ projects/clang360-import/sys/dev/virtio/block/virtio_blk.c Tue Jan 27 19:40:08 2015 (r277809) @@ -76,9 +76,8 @@ struct vtblk_softc { #define VTBLK_FLAG_READONLY 0x0002 #define VTBLK_FLAG_DETACH 0x0004 #define VTBLK_FLAG_SUSPEND 0x0008 -#define VTBLK_FLAG_DUMPING 0x0010 -#define VTBLK_FLAG_BARRIER 0x0020 -#define VTBLK_FLAG_WC_CONFIG 0x0040 +#define VTBLK_FLAG_BARRIER 0x0010 +#define VTBLK_FLAG_WC_CONFIG 0x0020 struct virtqueue *vtblk_vq; struct sglist *vtblk_sglist; @@ -95,6 +94,7 @@ struct vtblk_softc { int vtblk_request_count; enum vtblk_cache_mode vtblk_write_cache; + struct bio_queue vtblk_dump_queue; struct vtblk_request vtblk_dump_request; }; @@ -162,7 +162,7 @@ static void vtblk_queue_completed(struct struct bio_queue *); static void vtblk_done_completed(struct vtblk_softc *, struct bio_queue *); -static void vtblk_drain_vq(struct vtblk_softc *, int); +static void vtblk_drain_vq(struct vtblk_softc *); static void vtblk_drain(struct vtblk_softc *); static void vtblk_startio(struct vtblk_softc *); @@ -177,9 +177,10 @@ static int vtblk_quiesce(struct vtblk_so static void vtblk_vq_intr(void *); static void vtblk_stop(struct vtblk_softc *); -static void vtblk_dump_prepare(struct vtblk_softc *); +static void vtblk_dump_quiesce(struct vtblk_softc *); static int vtblk_dump_write(struct vtblk_softc *, void *, off_t, size_t); static int vtblk_dump_flush(struct vtblk_softc *); +static void vtblk_dump_complete(struct vtblk_softc *); static void vtblk_set_write_cache(struct vtblk_softc *, int); static int vtblk_write_cache_enabled(struct vtblk_softc *sc, @@ -302,6 +303,7 @@ vtblk_attach(device_t dev) sc->vtblk_dev = dev; VTBLK_LOCK_INIT(sc, device_get_nameunit(dev)); bioq_init(&sc->vtblk_bioq); + TAILQ_INIT(&sc->vtblk_dump_queue); TAILQ_INIT(&sc->vtblk_req_free); TAILQ_INIT(&sc->vtblk_req_ready); @@ -506,25 +508,19 @@ vtblk_dump(void *arg, void *virtual, vm_ int error; dp = arg; + error = 0; if ((sc = dp->d_drv1) == NULL) return (ENXIO); VTBLK_LOCK(sc); - if ((sc->vtblk_flags & VTBLK_FLAG_DUMPING) == 0) { - vtblk_dump_prepare(sc); - sc->vtblk_flags |= VTBLK_FLAG_DUMPING; - } + vtblk_dump_quiesce(sc); if (length > 0) error = vtblk_dump_write(sc, virtual, offset, length); - else if (virtual == NULL && offset == 0) - error = vtblk_dump_flush(sc); - else { - error = EINVAL; - sc->vtblk_flags &= ~VTBLK_FLAG_DUMPING; - } + if (error || (virtual == NULL && offset == 0)) + vtblk_dump_complete(sc); VTBLK_UNLOCK(sc); @@ -996,7 +992,7 @@ vtblk_done_completed(struct vtblk_softc } static void -vtblk_drain_vq(struct vtblk_softc *sc, int skip_done) +vtblk_drain_vq(struct vtblk_softc *sc) { struct virtqueue *vq; struct vtblk_request *req; @@ -1006,9 +1002,7 @@ vtblk_drain_vq(struct vtblk_softc *sc, i last = 0; while ((req = virtqueue_drain(vq, &last)) != NULL) { - if (!skip_done) - vtblk_bio_done(sc, req->vbr_bp, ENXIO); - + vtblk_bio_done(sc, req->vbr_bp, ENXIO); vtblk_request_enqueue(sc, req); } @@ -1031,7 +1025,7 @@ vtblk_drain(struct vtblk_softc *sc) vtblk_queue_completed(sc, &queue); vtblk_done_completed(sc, &queue); - vtblk_drain_vq(sc, 0); + vtblk_drain_vq(sc); } while ((req = vtblk_request_next_ready(sc)) != NULL) { @@ -1256,31 +1250,16 @@ vtblk_stop(struct vtblk_softc *sc) } static void -vtblk_dump_prepare(struct vtblk_softc *sc) +vtblk_dump_quiesce(struct vtblk_softc *sc) { - device_t dev; - struct virtqueue *vq; - - dev = sc->vtblk_dev; - vq = sc->vtblk_vq; - - vtblk_stop(sc); /* - * Drain all requests caught in-flight in the virtqueue, - * skipping biodone(). When dumping, only one request is - * outstanding at a time, and we just poll the virtqueue - * for the response. + * Spin here until all the requests in-flight at the time of the + * dump are completed and queued. The queued requests will be + * biodone'd once the dump is finished. */ - vtblk_drain_vq(sc, 1); - - if (virtio_reinit(dev, sc->vtblk_features) != 0) { - panic("%s: cannot reinit VirtIO block device during dump", - device_get_nameunit(dev)); - } - - virtqueue_disable_intr(vq); - virtio_reinit_complete(dev); + while (!virtqueue_empty(sc->vtblk_vq)) + vtblk_queue_completed(sc, &sc->vtblk_dump_queue); } static int @@ -1327,6 +1306,17 @@ vtblk_dump_flush(struct vtblk_softc *sc) } static void +vtblk_dump_complete(struct vtblk_softc *sc) +{ + + vtblk_dump_flush(sc); + + VTBLK_UNLOCK(sc); + vtblk_done_completed(sc, &sc->vtblk_dump_queue); + VTBLK_LOCK(sc); +} + +static void vtblk_set_write_cache(struct vtblk_softc *sc, int wc) { Modified: projects/clang360-import/sys/dev/vt/hw/fb/vt_fb.c ============================================================================== --- projects/clang360-import/sys/dev/vt/hw/fb/vt_fb.c Tue Jan 27 19:37:02 2015 (r277808) +++ projects/clang360-import/sys/dev/vt/hw/fb/vt_fb.c Tue Jan 27 19:40:08 2015 (r277809) @@ -53,6 +53,8 @@ static struct vt_driver vt_fb_driver = { .vd_priority = VD_PRIORITY_GENERIC+10, .vd_fb_ioctl = vt_fb_ioctl, .vd_fb_mmap = vt_fb_mmap, + .vd_suspend = vt_fb_suspend, + .vd_resume = vt_fb_resume, }; VT_DRIVER_DECLARE(vt_fb, vt_fb_driver); @@ -450,15 +452,15 @@ vt_fb_attach(struct fb_info *info) } void -vt_fb_resume(void) +vt_fb_suspend(struct vt_device *vd) { - vt_resume(); + vt_suspend(vd); } void -vt_fb_suspend(void) +vt_fb_resume(struct vt_device *vd) { - vt_suspend(); + vt_resume(vd); } Modified: projects/clang360-import/sys/dev/vt/hw/fb/vt_fb.h ============================================================================== --- projects/clang360-import/sys/dev/vt/hw/fb/vt_fb.h Tue Jan 27 19:37:02 2015 (r277808) +++ projects/clang360-import/sys/dev/vt/hw/fb/vt_fb.h Tue Jan 27 19:40:08 2015 (r277809) @@ -33,8 +33,8 @@ #define _DEV_VT_HW_FB_VT_FB_H_ /* Generic framebuffer interface call vt_fb_attach to init VT(9) */ int vt_fb_attach(struct fb_info *info); -void vt_fb_resume(void); -void vt_fb_suspend(void); +void vt_fb_resume(struct vt_device *vd); +void vt_fb_suspend(struct vt_device *vd); vd_init_t vt_fb_init; vd_blank_t vt_fb_blank; Modified: projects/clang360-import/sys/dev/vt/vt.h ============================================================================== --- projects/clang360-import/sys/dev/vt/vt.h Tue Jan 27 19:37:02 2015 (r277808) +++ projects/clang360-import/sys/dev/vt/vt.h Tue Jan 27 19:40:08 2015 (r277809) @@ -90,8 +90,6 @@ SYSCTL_INT(_kern_vt, OID_AUTO, _name, CT struct vt_driver; void vt_allocate(struct vt_driver *, void *); -void vt_resume(void); -void vt_suspend(void); typedef unsigned int vt_axis_t; @@ -162,6 +160,9 @@ struct vt_device { #define VD_PASTEBUFSZ(vd) ((vd)->vd_pastebuf.vpb_bufsz) #define VD_PASTEBUFLEN(vd) ((vd)->vd_pastebuf.vpb_len) +void vt_resume(struct vt_device *vd); +void vt_suspend(struct vt_device *vd); + /* * Per-window terminal screen buffer. * @@ -314,6 +315,8 @@ typedef int vd_fb_mmap_t(struct vt_devic typedef void vd_drawrect_t(struct vt_device *, int, int, int, int, int, term_color_t); typedef void vd_setpixel_t(struct vt_device *, int, int, term_color_t); +typedef void vd_suspend_t(struct vt_device *); +typedef void vd_resume_t(struct vt_device *); struct vt_driver { char vd_name[16]; @@ -337,6 +340,10 @@ struct vt_driver { /* Update display setting on vt switch. */ vd_postswitch_t *vd_postswitch; + /* Suspend/resume handlers. */ + vd_suspend_t *vd_suspend; + vd_resume_t *vd_resume; + /* Priority to know which one can override */ int vd_priority; #define VD_PRIORITY_DUMB 10 Modified: projects/clang360-import/sys/dev/vt/vt_core.c ============================================================================== --- projects/clang360-import/sys/dev/vt/vt_core.c Tue Jan 27 19:37:02 2015 (r277808) +++ projects/clang360-import/sys/dev/vt/vt_core.c Tue Jan 27 19:40:08 2015 (r277809) @@ -167,6 +167,8 @@ static void vt_update_static(void *); #ifndef SC_NO_CUTPASTE static void vt_mouse_paste(void); #endif +static void vt_suspend_handler(void *priv); +static void vt_resume_handler(void *priv); SET_DECLARE(vt_drv_set, struct vt_driver); @@ -2552,6 +2554,12 @@ vt_upgrade(struct vt_device *vd) vd->vd_flags |= VDF_ASYNC; callout_reset(&vd->vd_timer, hz / VT_TIMERFREQ, vt_timer, vd); vd->vd_timer_armed = 1; + + /* Register suspend/resume handlers. */ + EVENTHANDLER_REGISTER(power_suspend_early, vt_suspend_handler, + vd, EVENTHANDLER_PRI_ANY); + EVENTHANDLER_REGISTER(power_resume, vt_resume_handler, vd, + EVENTHANDLER_PRI_ANY); } VT_UNLOCK(vd); @@ -2655,26 +2663,54 @@ vt_allocate(struct vt_driver *drv, void termcn_cnregister(vd->vd_windows[VT_CONSWINDOW]->vw_terminal); } +static void +vt_suspend_handler(void *priv) +{ + struct vt_device *vd; + + vd = priv; + if (vd->vd_driver != NULL && vd->vd_driver->vd_suspend != NULL) + vd->vd_driver->vd_suspend(vd); +} + +static void +vt_resume_handler(void *priv) +{ + struct vt_device *vd; + + vd = priv; + if (vd->vd_driver != NULL && vd->vd_driver->vd_resume != NULL) + vd->vd_driver->vd_resume(vd); +} + void -vt_suspend() +vt_suspend(struct vt_device *vd) { + int error; if (vt_suspendswitch == 0) return; /* Save current window. */ - main_vd->vd_savedwindow = main_vd->vd_curwindow; + vd->vd_savedwindow = vd->vd_curwindow; /* Ask holding process to free window and switch to console window */ - vt_proc_window_switch(main_vd->vd_windows[VT_CONSWINDOW]); + vt_proc_window_switch(vd->vd_windows[VT_CONSWINDOW]); + + /* Wait for the window switch to complete. */ + error = 0; + VT_LOCK(vd); + while (vd->vd_curwindow != vd->vd_windows[VT_CONSWINDOW] && error == 0) + error = cv_wait_sig(&vd->vd_winswitch, &vd->vd_lock); + VT_UNLOCK(vd); } void -vt_resume() +vt_resume(struct vt_device *vd) { if (vt_suspendswitch == 0) return; /* Switch back to saved window */ - if (main_vd->vd_savedwindow != NULL) - vt_proc_window_switch(main_vd->vd_savedwindow); - main_vd->vd_savedwindow = NULL; + if (vd->vd_savedwindow != NULL) + vt_proc_window_switch(vd->vd_savedwindow); + vd->vd_savedwindow = NULL; } Modified: projects/clang360-import/sys/netipsec/key.c ============================================================================== --- projects/clang360-import/sys/netipsec/key.c Tue Jan 27 19:37:02 2015 (r277808) +++ projects/clang360-import/sys/netipsec/key.c Tue Jan 27 19:40:08 2015 (r277809) @@ -2421,8 +2421,6 @@ key_setdumpsp(struct secpolicy *sp, u_in struct mbuf *result = NULL, *m; struct seclifetime lt; - SPTREE_RLOCK_ASSERT(); - m = key_setsadbmsg(type, 0, SADB_SATYPE_UNSPEC, seq, pid, sp->refcnt); if (!m) goto fail; Modified: projects/clang360-import/sys/powerpc/pseries/plpar_iommu.c ============================================================================== --- projects/clang360-import/sys/powerpc/pseries/plpar_iommu.c Tue Jan 27 19:37:02 2015 (r277808) +++ projects/clang360-import/sys/powerpc/pseries/plpar_iommu.c Tue Jan 27 19:40:08 2015 (r277809) @@ -191,13 +191,13 @@ phyp_iommu_map(device_t dev, bus_dma_seg tce = trunc_page(segs[i].ds_addr); tce |= 0x3; /* read/write */ - if (papr_supports_stuff_tce) { - error = phyp_hcall(H_STUFF_TCE, window->map->iobn, - alloced, tce, allocsize/PAGE_SIZE); - } else { - for (j = 0; j < allocsize; j += PAGE_SIZE) - error = phyp_hcall(H_PUT_TCE, window->map->iobn, - alloced + j, tce + j); + for (j = 0; j < allocsize; j += PAGE_SIZE) { + error = phyp_hcall(H_PUT_TCE, window->map->iobn, + alloced + j, tce + j); + if (error < 0) { + panic("IOMMU mapping error: %d\n", error); + return (ENOMEM); + } } segs[i].ds_addr = alloced + (segs[i].ds_addr & PAGE_MASK); Modified: projects/clang360-import/sys/sys/eventhandler.h ============================================================================== --- projects/clang360-import/sys/sys/eventhandler.h Tue Jan 27 19:37:02 2015 (r277808) +++ projects/clang360-import/sys/sys/eventhandler.h Tue Jan 27 19:40:08 2015 (r277809) @@ -182,6 +182,7 @@ EVENTHANDLER_DECLARE(shutdown_final, shu typedef void (*power_change_fn)(void *); EVENTHANDLER_DECLARE(power_resume, power_change_fn); EVENTHANDLER_DECLARE(power_suspend, power_change_fn); +EVENTHANDLER_DECLARE(power_suspend_early, power_change_fn); /* Low memory event */ typedef void (*vm_lowmem_handler_t)(void *, int); Modified: projects/clang360-import/sys/ufs/ufs/ufs_quota.c ============================================================================== --- projects/clang360-import/sys/ufs/ufs/ufs_quota.c Tue Jan 27 19:37:02 2015 (r277808) +++ projects/clang360-import/sys/ufs/ufs/ufs_quota.c Tue Jan 27 19:40:08 2015 (r277809) @@ -495,11 +495,15 @@ quotaon(struct thread *td, struct mount struct nameidata nd; error = priv_check(td, PRIV_UFS_QUOTAON); - if (error) + if (error != 0) { + vfs_unbusy(mp); return (error); + } - if (mp->mnt_flag & MNT_RDONLY) + if ((mp->mnt_flag & MNT_RDONLY) != 0) { + vfs_unbusy(mp); return (EROFS); + } ump = VFSTOUFS(mp); dq = NODQUOT; Modified: projects/clang360-import/sys/ufs/ufs/ufs_vfsops.c ============================================================================== --- projects/clang360-import/sys/ufs/ufs/ufs_vfsops.c Tue Jan 27 19:37:02 2015 (r277808) +++ projects/clang360-import/sys/ufs/ufs/ufs_vfsops.c Tue Jan 27 19:40:08 2015 (r277809) @@ -92,6 +92,9 @@ ufs_quotactl(mp, cmds, id, arg) void *arg; { #ifndef QUOTA + if ((cmds >> SUBCMDSHIFT) == Q_QUOTAON) + vfs_unbusy(mp); + return (EOPNOTSUPP); #else struct thread *td; @@ -112,11 +115,16 @@ ufs_quotactl(mp, cmds, id, arg) break; default: + if (cmd == Q_QUOTAON) + vfs_unbusy(mp); return (EINVAL); } } - if ((u_int)type >= MAXQUOTAS) + if ((u_int)type >= MAXQUOTAS) { + if (cmd == Q_QUOTAON) + vfs_unbusy(mp); return (EINVAL); + } switch (cmd) { case Q_QUOTAON: Modified: projects/clang360-import/usr.bin/sed/main.c ============================================================================== --- projects/clang360-import/usr.bin/sed/main.c Tue Jan 27 19:37:02 2015 (r277808) +++ projects/clang360-import/usr.bin/sed/main.c Tue Jan 27 19:40:08 2015 (r277809) @@ -411,6 +411,8 @@ mf_fgets(SPACE *sp, enum e_spflag spflag unlink(tmpfname); if ((outfile = fopen(tmpfname, "w")) == NULL) err(1, "%s", fname); + if (outfile != NULL && outfile != stdout) + fclose(outfile); fchown(fileno(outfile), sb.st_uid, sb.st_gid); fchmod(fileno(outfile), sb.st_mode & ALLPERMS); outfname = tmpfname; Modified: projects/clang360-import/usr.bin/sed/process.c ============================================================================== --- projects/clang360-import/usr.bin/sed/process.c Tue Jan 27 19:37:02 2015 (r277808) +++ projects/clang360-import/usr.bin/sed/process.c Tue Jan 27 19:40:08 2015 (r277809) @@ -324,7 +324,7 @@ applies(struct s_command *cp) } else r = 1; } - } else if (MATCH(cp->a1)) { + } else if (cp->a1 && MATCH(cp->a1)) { /* * If the second address is a number less than or * equal to the line number first selected, only Modified: projects/clang360-import/usr.sbin/pmcstudy/pmcstudy.c ============================================================================== --- projects/clang360-import/usr.sbin/pmcstudy/pmcstudy.c Tue Jan 27 19:37:02 2015 (r277808) +++ projects/clang360-import/usr.sbin/pmcstudy/pmcstudy.c Tue Jan 27 19:40:08 2015 (r277809) @@ -1796,6 +1796,10 @@ process_file(char *filename) if (filename == NULL) { io = my_popen(command, "r", &pid_of_command); + if (io == NULL) { + printf("Can't popen the command %s\n", command); + return; + } } else { io = fopen(filename, "r"); if (io == NULL) { @@ -1808,8 +1812,10 @@ process_file(char *filename) if (cnts == NULL) { /* Nothing we can do */ printf("Nothing to do -- no counters built\n"); - if (io) { - fclose(io); + if (filename) { + fclose(io); + } else { + my_pclose(io, pid_of_command); } return; }