Merging ^/head r277777 through r277803.

This commit is contained in:
Dimitry Andric 2015-01-27 19:40:08 +00:00
commit 76f411ce48
24 changed files with 279 additions and 127 deletions

View File

@ -444,14 +444,26 @@ op_minus(struct val *a, struct val *b)
return (r); 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 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, * If the first operand is 0, no overflow is possible,
* else result of division test must match second operand * 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"); errx(ERR_EXIT, "overflow");
} }

View File

@ -20,7 +20,7 @@
ifdef(`__win32__', `dnl', `dnl ifdef(`__win32__', `dnl', `dnl
ifdef(`TEMPFILE', `dnl', `define(`TEMPFILE', maketemp(/tmp/cfXXXXXX))dnl ifdef(`TEMPFILE', `dnl', `define(`TEMPFILE', maketemp(/tmp/cfXXXXXX))dnl
syscmd(sh _CF_DIR_`'sh/makeinfo.sh _CF_DIR_ > TEMPFILE)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')') syscmd(rm -f TEMPFILE)dnl')')
##### #####
###################################################################### ######################################################################

View File

@ -537,6 +537,7 @@ ip_print(netdissect_options *ndo,
struct protoent *proto; struct protoent *proto;
ipds->ip = (const struct ip *)bp; ipds->ip = (const struct ip *)bp;
ND_TCHECK(ipds->ip->ip_vhl);
if (IP_V(ipds->ip) != 4) { /* print version if != 4 */ if (IP_V(ipds->ip) != 4) { /* print version if != 4 */
ND_PRINT((ndo, "IP%u ", IP_V(ipds->ip))); ND_PRINT((ndo, "IP%u ", IP_V(ipds->ip)));
if (IP_V(ipds->ip) == 6) if (IP_V(ipds->ip) == 6)
@ -545,10 +546,7 @@ ip_print(netdissect_options *ndo,
else if (!ndo->ndo_eflag) else if (!ndo->ndo_eflag)
ND_PRINT((ndo, "IP ")); ND_PRINT((ndo, "IP "));
if ((u_char *)(ipds->ip + 1) > ndo->ndo_snapend) { ND_TCHECK(*ipds->ip);
ND_PRINT((ndo, "%s", tstr));
return;
}
if (length < sizeof (struct ip)) { if (length < sizeof (struct ip)) {
ND_PRINT((ndo, "truncated-ip %u", length)); ND_PRINT((ndo, "truncated-ip %u", length));
return; return;
@ -677,6 +675,11 @@ ip_print(netdissect_options *ndo,
ND_PRINT((ndo, " ip-proto-%d", ipds->ip->ip_p)); ND_PRINT((ndo, " ip-proto-%d", ipds->ip->ip_p));
} }
} }
return;
trunc:
ND_PRINT((ndo, "%s", tstr));
return;
} }
void void

View File

@ -64,7 +64,7 @@ sl_if_print(netdissect_options *ndo,
register u_int length = h->len; register u_int length = h->len;
register const struct ip *ip; register const struct ip *ip;
if (caplen < SLIP_HDRLEN) { if (caplen < SLIP_HDRLEN || length < SLIP_HDRLEN) {
ND_PRINT((ndo, "%s", tstr)); ND_PRINT((ndo, "%s", tstr));
return (caplen); return (caplen);
} }

View File

@ -17,7 +17,8 @@ M4FILES!= find ${SENDMAIL_CF_DIR} -type f -name '*.m4' -print
.mc.cf: ${M4FILES} .mc.cf: ${M4FILES}
${RM} ${.TARGET} ${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} ${SENDMAIL_CF_DIR}/m4/cf.m4 ${.IMPSRC} > ${.TARGET}
${CHMOD} ${ROMODE} ${.TARGET} ${CHMOD} ${ROMODE} ${.TARGET}

View File

@ -72,7 +72,7 @@ pt_ucontext_to_fpreg(const ucontext_t *uc, struct fpreg *r)
memcpy(r, &uc->uc_mcontext.mc_fpstate, sizeof(struct save87)); memcpy(r, &uc->uc_mcontext.mc_fpstate, sizeof(struct save87));
else { else {
int i; 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)); memcpy(&r->fpr_env, &sx->sv_env, sizeof(r->fpr_env));
for (i = 0; i < 8; ++i) for (i = 0; i < 8; ++i)
memcpy(&r->fpr_acc[i], &sx->sv_fp[i].fp_acc, 10); memcpy(&r->fpr_acc[i], &sx->sv_fp[i].fp_acc, 10);

View File

@ -25,7 +25,7 @@
.\" .\"
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd January 14, 2010 .Dd January 27, 2015
.Dt GMOUNTVER 8 .Dt GMOUNTVER 8
.Os .Os
.Sh NAME .Sh NAME
@ -110,7 +110,7 @@ GEOM class.
This can be set to a number between 0 and 3 inclusive. 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 If set to 0 minimal debug information is printed, and if set to 3 the
maximum amount of debug information is printed. 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. This can be set to 0 or 1.
If set to 0, If set to 0,
.Nm .Nm

View File

@ -1,5 +1,6 @@
.\" .\"
.\" Copyright (c) 2003 Bruce M Simpson <bms@spc.org> .\" Copyright (c) 2003 Bruce M Simpson <bms@spc.org>
.\" Copyright (c) 2014 The FreeBSD Foundation
.\" All rights reserved. .\" All rights reserved.
.\" .\"
.\" Redistribution and use in source and binary forms, with or without .\" Redistribution and use in source and binary forms, with or without
@ -25,7 +26,7 @@
.\" .\"
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd July 21, 2003 .Dd January 27, 2015
.Dt PMAP_ENTER 9 .Dt PMAP_ENTER 9
.Os .Os
.Sh NAME .Sh NAME
@ -35,34 +36,129 @@
.In sys/param.h .In sys/param.h
.In vm/vm.h .In vm/vm.h
.In vm/pmap.h .In vm/pmap.h
.Ft void .Ft int
.Fo pmap_enter .Fo pmap_enter
.Fa "pmap_t pmap" "vm_offset_t va" "vm_page_t p" "vm_prot_t prot" .Fa "pmap_t pmap" "vm_offset_t va" "vm_page_t m" "vm_prot_t prot"
.Fa "boolean_t wired" .Fa "u_int flags" "int8_t psind"
.Fc .Fc
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn pmap_enter .Fn pmap_enter
function inserts the given physical page function creates a mapping in the physical map
.Fa p , .Fa pmap
into the physical map from the virtual address
.Fa pmap , .Fa va
at the virtual address to the physical page
.Fa va , .Fa m
with the protection with the protection
.Fa prot . .Fa prot .
If Any previous mapping at the virtual address
.Fa wired .Fa va
is is destroyed.
.Dv TRUE , .Pp
then increment the wired count for the page as soon as the mapping The
is inserted into .Fa flags
.Fa pmap . argument may have the following values:
.Sh IMPLEMENTATION NOTES .Bl -tag -width ".Dv PMAP_ENTER_NOSLEEP"
This routine MAY NOT lazy-evaluate the entry; it is required by .It Dv VM_PROT_READ
specification to make the requested entry at the time it is called. 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 .Sh SEE ALSO
.Xr pmap 9 .Xr pmap 9
.Sh AUTHORS .Sh AUTHORS
This manual page was written by This manual page was first written by
.An Bruce M Simpson Aq Mt bms@spc.org . .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 .

View File

@ -2749,6 +2749,8 @@ acpi_EnterSleepState(struct acpi_softc *sc, int state)
return_ACPI_STATUS (AE_OK); return_ACPI_STATUS (AE_OK);
} }
EVENTHANDLER_INVOKE(power_suspend_early);
stop_all_proc();
EVENTHANDLER_INVOKE(power_suspend); EVENTHANDLER_INVOKE(power_suspend);
if (smp_started) { if (smp_started) {
@ -2892,6 +2894,8 @@ acpi_EnterSleepState(struct acpi_softc *sc, int state)
thread_unlock(curthread); thread_unlock(curthread);
} }
resume_all_proc();
EVENTHANDLER_INVOKE(power_resume); EVENTHANDLER_INVOKE(power_resume);
/* Allow another sleep request after a while. */ /* Allow another sleep request after a while. */

View File

@ -332,22 +332,6 @@ fbd_detach(device_t dev)
return (err); 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[] = { static device_method_t fbd_methods[] = {
/* Device interface */ /* Device interface */
DEVMETHOD(device_probe, fbd_probe), DEVMETHOD(device_probe, fbd_probe),
@ -355,8 +339,6 @@ static device_method_t fbd_methods[] = {
DEVMETHOD(device_detach, fbd_detach), DEVMETHOD(device_detach, fbd_detach),
DEVMETHOD(device_shutdown, bus_generic_shutdown), DEVMETHOD(device_shutdown, bus_generic_shutdown),
DEVMETHOD(device_suspend, fbd_suspend),
DEVMETHOD(device_resume, fbd_resume),
{ 0, 0 } { 0, 0 }
}; };

View File

@ -549,7 +549,7 @@ sc_attach_unit(int unit, int flags)
/* Register suspend/resume/shutdown callbacks for the kernel console. */ /* Register suspend/resume/shutdown callbacks for the kernel console. */
if (sc_console_unit == unit) { if (sc_console_unit == unit) {
EVENTHANDLER_REGISTER(power_suspend, scsuspend, NULL, EVENTHANDLER_REGISTER(power_suspend_early, scsuspend, NULL,
EVENTHANDLER_PRI_ANY); EVENTHANDLER_PRI_ANY);
EVENTHANDLER_REGISTER(power_resume, scresume, NULL, EVENTHANDLER_REGISTER(power_resume, scresume, NULL,
EVENTHANDLER_PRI_ANY); EVENTHANDLER_PRI_ANY);

View File

@ -76,9 +76,8 @@ struct vtblk_softc {
#define VTBLK_FLAG_READONLY 0x0002 #define VTBLK_FLAG_READONLY 0x0002
#define VTBLK_FLAG_DETACH 0x0004 #define VTBLK_FLAG_DETACH 0x0004
#define VTBLK_FLAG_SUSPEND 0x0008 #define VTBLK_FLAG_SUSPEND 0x0008
#define VTBLK_FLAG_DUMPING 0x0010 #define VTBLK_FLAG_BARRIER 0x0010
#define VTBLK_FLAG_BARRIER 0x0020 #define VTBLK_FLAG_WC_CONFIG 0x0020
#define VTBLK_FLAG_WC_CONFIG 0x0040
struct virtqueue *vtblk_vq; struct virtqueue *vtblk_vq;
struct sglist *vtblk_sglist; struct sglist *vtblk_sglist;
@ -95,6 +94,7 @@ struct vtblk_softc {
int vtblk_request_count; int vtblk_request_count;
enum vtblk_cache_mode vtblk_write_cache; enum vtblk_cache_mode vtblk_write_cache;
struct bio_queue vtblk_dump_queue;
struct vtblk_request vtblk_dump_request; struct vtblk_request vtblk_dump_request;
}; };
@ -162,7 +162,7 @@ static void vtblk_queue_completed(struct vtblk_softc *,
struct bio_queue *); struct bio_queue *);
static void vtblk_done_completed(struct vtblk_softc *, static void vtblk_done_completed(struct vtblk_softc *,
struct bio_queue *); 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_drain(struct vtblk_softc *);
static void vtblk_startio(struct vtblk_softc *); static void vtblk_startio(struct vtblk_softc *);
@ -177,9 +177,10 @@ static int vtblk_quiesce(struct vtblk_softc *);
static void vtblk_vq_intr(void *); static void vtblk_vq_intr(void *);
static void vtblk_stop(struct vtblk_softc *); 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_write(struct vtblk_softc *, void *, off_t, size_t);
static int vtblk_dump_flush(struct vtblk_softc *); 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 void vtblk_set_write_cache(struct vtblk_softc *, int);
static int vtblk_write_cache_enabled(struct vtblk_softc *sc, static int vtblk_write_cache_enabled(struct vtblk_softc *sc,
@ -302,6 +303,7 @@ vtblk_attach(device_t dev)
sc->vtblk_dev = dev; sc->vtblk_dev = dev;
VTBLK_LOCK_INIT(sc, device_get_nameunit(dev)); VTBLK_LOCK_INIT(sc, device_get_nameunit(dev));
bioq_init(&sc->vtblk_bioq); bioq_init(&sc->vtblk_bioq);
TAILQ_INIT(&sc->vtblk_dump_queue);
TAILQ_INIT(&sc->vtblk_req_free); TAILQ_INIT(&sc->vtblk_req_free);
TAILQ_INIT(&sc->vtblk_req_ready); TAILQ_INIT(&sc->vtblk_req_ready);
@ -506,25 +508,19 @@ vtblk_dump(void *arg, void *virtual, vm_offset_t physical, off_t offset,
int error; int error;
dp = arg; dp = arg;
error = 0;
if ((sc = dp->d_drv1) == NULL) if ((sc = dp->d_drv1) == NULL)
return (ENXIO); return (ENXIO);
VTBLK_LOCK(sc); VTBLK_LOCK(sc);
if ((sc->vtblk_flags & VTBLK_FLAG_DUMPING) == 0) { vtblk_dump_quiesce(sc);
vtblk_dump_prepare(sc);
sc->vtblk_flags |= VTBLK_FLAG_DUMPING;
}
if (length > 0) if (length > 0)
error = vtblk_dump_write(sc, virtual, offset, length); error = vtblk_dump_write(sc, virtual, offset, length);
else if (virtual == NULL && offset == 0) if (error || (virtual == NULL && offset == 0))
error = vtblk_dump_flush(sc); vtblk_dump_complete(sc);
else {
error = EINVAL;
sc->vtblk_flags &= ~VTBLK_FLAG_DUMPING;
}
VTBLK_UNLOCK(sc); VTBLK_UNLOCK(sc);
@ -996,7 +992,7 @@ vtblk_done_completed(struct vtblk_softc *sc, struct bio_queue *queue)
} }
static void static void
vtblk_drain_vq(struct vtblk_softc *sc, int skip_done) vtblk_drain_vq(struct vtblk_softc *sc)
{ {
struct virtqueue *vq; struct virtqueue *vq;
struct vtblk_request *req; struct vtblk_request *req;
@ -1006,9 +1002,7 @@ vtblk_drain_vq(struct vtblk_softc *sc, int skip_done)
last = 0; last = 0;
while ((req = virtqueue_drain(vq, &last)) != NULL) { 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); vtblk_request_enqueue(sc, req);
} }
@ -1031,7 +1025,7 @@ vtblk_drain(struct vtblk_softc *sc)
vtblk_queue_completed(sc, &queue); vtblk_queue_completed(sc, &queue);
vtblk_done_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) { while ((req = vtblk_request_next_ready(sc)) != NULL) {
@ -1256,31 +1250,16 @@ vtblk_stop(struct vtblk_softc *sc)
} }
static void 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, * Spin here until all the requests in-flight at the time of the
* skipping biodone(). When dumping, only one request is * dump are completed and queued. The queued requests will be
* outstanding at a time, and we just poll the virtqueue * biodone'd once the dump is finished.
* for the response.
*/ */
vtblk_drain_vq(sc, 1); while (!virtqueue_empty(sc->vtblk_vq))
vtblk_queue_completed(sc, &sc->vtblk_dump_queue);
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);
} }
static int static int
@ -1326,6 +1305,17 @@ vtblk_dump_flush(struct vtblk_softc *sc)
return (vtblk_poll_request(sc, req)); return (vtblk_poll_request(sc, req));
} }
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 static void
vtblk_set_write_cache(struct vtblk_softc *sc, int wc) vtblk_set_write_cache(struct vtblk_softc *sc, int wc)
{ {

View File

@ -53,6 +53,8 @@ static struct vt_driver vt_fb_driver = {
.vd_priority = VD_PRIORITY_GENERIC+10, .vd_priority = VD_PRIORITY_GENERIC+10,
.vd_fb_ioctl = vt_fb_ioctl, .vd_fb_ioctl = vt_fb_ioctl,
.vd_fb_mmap = vt_fb_mmap, .vd_fb_mmap = vt_fb_mmap,
.vd_suspend = vt_fb_suspend,
.vd_resume = vt_fb_resume,
}; };
VT_DRIVER_DECLARE(vt_fb, vt_fb_driver); VT_DRIVER_DECLARE(vt_fb, vt_fb_driver);
@ -450,15 +452,15 @@ vt_fb_attach(struct fb_info *info)
} }
void void
vt_fb_resume(void) vt_fb_suspend(struct vt_device *vd)
{ {
vt_resume(); vt_suspend(vd);
} }
void void
vt_fb_suspend(void) vt_fb_resume(struct vt_device *vd)
{ {
vt_suspend(); vt_resume(vd);
} }

View File

@ -33,8 +33,8 @@
#define _DEV_VT_HW_FB_VT_FB_H_ #define _DEV_VT_HW_FB_VT_FB_H_
/* Generic framebuffer interface call vt_fb_attach to init VT(9) */ /* Generic framebuffer interface call vt_fb_attach to init VT(9) */
int vt_fb_attach(struct fb_info *info); int vt_fb_attach(struct fb_info *info);
void vt_fb_resume(void); void vt_fb_resume(struct vt_device *vd);
void vt_fb_suspend(void); void vt_fb_suspend(struct vt_device *vd);
vd_init_t vt_fb_init; vd_init_t vt_fb_init;
vd_blank_t vt_fb_blank; vd_blank_t vt_fb_blank;

View File

@ -90,8 +90,6 @@ SYSCTL_INT(_kern_vt, OID_AUTO, _name, CTLFLAG_RWTUN, &vt_##_name, _default,\
struct vt_driver; struct vt_driver;
void vt_allocate(struct vt_driver *, void *); void vt_allocate(struct vt_driver *, void *);
void vt_resume(void);
void vt_suspend(void);
typedef unsigned int vt_axis_t; typedef unsigned int vt_axis_t;
@ -162,6 +160,9 @@ struct vt_device {
#define VD_PASTEBUFSZ(vd) ((vd)->vd_pastebuf.vpb_bufsz) #define VD_PASTEBUFSZ(vd) ((vd)->vd_pastebuf.vpb_bufsz)
#define VD_PASTEBUFLEN(vd) ((vd)->vd_pastebuf.vpb_len) #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. * Per-window terminal screen buffer.
* *
@ -314,6 +315,8 @@ typedef int vd_fb_mmap_t(struct vt_device *, vm_ooffset_t, vm_paddr_t *, int,
typedef void vd_drawrect_t(struct vt_device *, int, int, int, int, int, typedef void vd_drawrect_t(struct vt_device *, int, int, int, int, int,
term_color_t); term_color_t);
typedef void vd_setpixel_t(struct vt_device *, 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 { struct vt_driver {
char vd_name[16]; char vd_name[16];
@ -337,6 +340,10 @@ struct vt_driver {
/* Update display setting on vt switch. */ /* Update display setting on vt switch. */
vd_postswitch_t *vd_postswitch; 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 */ /* Priority to know which one can override */
int vd_priority; int vd_priority;
#define VD_PRIORITY_DUMB 10 #define VD_PRIORITY_DUMB 10

View File

@ -167,6 +167,8 @@ static void vt_update_static(void *);
#ifndef SC_NO_CUTPASTE #ifndef SC_NO_CUTPASTE
static void vt_mouse_paste(void); static void vt_mouse_paste(void);
#endif #endif
static void vt_suspend_handler(void *priv);
static void vt_resume_handler(void *priv);
SET_DECLARE(vt_drv_set, struct vt_driver); SET_DECLARE(vt_drv_set, struct vt_driver);
@ -2552,6 +2554,12 @@ vt_upgrade(struct vt_device *vd)
vd->vd_flags |= VDF_ASYNC; vd->vd_flags |= VDF_ASYNC;
callout_reset(&vd->vd_timer, hz / VT_TIMERFREQ, vt_timer, vd); callout_reset(&vd->vd_timer, hz / VT_TIMERFREQ, vt_timer, vd);
vd->vd_timer_armed = 1; 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); VT_UNLOCK(vd);
@ -2655,26 +2663,54 @@ vt_allocate(struct vt_driver *drv, void *softc)
termcn_cnregister(vd->vd_windows[VT_CONSWINDOW]->vw_terminal); termcn_cnregister(vd->vd_windows[VT_CONSWINDOW]->vw_terminal);
} }
void static void
vt_suspend() 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(struct vt_device *vd)
{
int error;
if (vt_suspendswitch == 0) if (vt_suspendswitch == 0)
return; return;
/* Save current window. */ /* 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 */ /* 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 void
vt_resume() vt_resume(struct vt_device *vd)
{ {
if (vt_suspendswitch == 0) if (vt_suspendswitch == 0)
return; return;
/* Switch back to saved window */ /* Switch back to saved window */
if (main_vd->vd_savedwindow != NULL) if (vd->vd_savedwindow != NULL)
vt_proc_window_switch(main_vd->vd_savedwindow); vt_proc_window_switch(vd->vd_savedwindow);
main_vd->vd_savedwindow = NULL; vd->vd_savedwindow = NULL;
} }

View File

@ -2421,8 +2421,6 @@ key_setdumpsp(struct secpolicy *sp, u_int8_t type, u_int32_t seq,
struct mbuf *result = NULL, *m; struct mbuf *result = NULL, *m;
struct seclifetime lt; struct seclifetime lt;
SPTREE_RLOCK_ASSERT();
m = key_setsadbmsg(type, 0, SADB_SATYPE_UNSPEC, seq, pid, sp->refcnt); m = key_setsadbmsg(type, 0, SADB_SATYPE_UNSPEC, seq, pid, sp->refcnt);
if (!m) if (!m)
goto fail; goto fail;

View File

@ -191,13 +191,13 @@ phyp_iommu_map(device_t dev, bus_dma_segment_t *segs, int *nsegs,
tce = trunc_page(segs[i].ds_addr); tce = trunc_page(segs[i].ds_addr);
tce |= 0x3; /* read/write */ tce |= 0x3; /* read/write */
if (papr_supports_stuff_tce) { for (j = 0; j < allocsize; j += PAGE_SIZE) {
error = phyp_hcall(H_STUFF_TCE, window->map->iobn, error = phyp_hcall(H_PUT_TCE, window->map->iobn,
alloced, tce, allocsize/PAGE_SIZE); alloced + j, tce + j);
} else { if (error < 0) {
for (j = 0; j < allocsize; j += PAGE_SIZE) panic("IOMMU mapping error: %d\n", error);
error = phyp_hcall(H_PUT_TCE, window->map->iobn, return (ENOMEM);
alloced + j, tce + j); }
} }
segs[i].ds_addr = alloced + (segs[i].ds_addr & PAGE_MASK); segs[i].ds_addr = alloced + (segs[i].ds_addr & PAGE_MASK);

View File

@ -182,6 +182,7 @@ EVENTHANDLER_DECLARE(shutdown_final, shutdown_fn);
typedef void (*power_change_fn)(void *); typedef void (*power_change_fn)(void *);
EVENTHANDLER_DECLARE(power_resume, power_change_fn); EVENTHANDLER_DECLARE(power_resume, power_change_fn);
EVENTHANDLER_DECLARE(power_suspend, power_change_fn); EVENTHANDLER_DECLARE(power_suspend, power_change_fn);
EVENTHANDLER_DECLARE(power_suspend_early, power_change_fn);
/* Low memory event */ /* Low memory event */
typedef void (*vm_lowmem_handler_t)(void *, int); typedef void (*vm_lowmem_handler_t)(void *, int);

View File

@ -495,11 +495,15 @@ quotaon(struct thread *td, struct mount *mp, int type, void *fname)
struct nameidata nd; struct nameidata nd;
error = priv_check(td, PRIV_UFS_QUOTAON); error = priv_check(td, PRIV_UFS_QUOTAON);
if (error) if (error != 0) {
vfs_unbusy(mp);
return (error); return (error);
}
if (mp->mnt_flag & MNT_RDONLY) if ((mp->mnt_flag & MNT_RDONLY) != 0) {
vfs_unbusy(mp);
return (EROFS); return (EROFS);
}
ump = VFSTOUFS(mp); ump = VFSTOUFS(mp);
dq = NODQUOT; dq = NODQUOT;

View File

@ -92,6 +92,9 @@ ufs_quotactl(mp, cmds, id, arg)
void *arg; void *arg;
{ {
#ifndef QUOTA #ifndef QUOTA
if ((cmds >> SUBCMDSHIFT) == Q_QUOTAON)
vfs_unbusy(mp);
return (EOPNOTSUPP); return (EOPNOTSUPP);
#else #else
struct thread *td; struct thread *td;
@ -112,11 +115,16 @@ ufs_quotactl(mp, cmds, id, arg)
break; break;
default: default:
if (cmd == Q_QUOTAON)
vfs_unbusy(mp);
return (EINVAL); return (EINVAL);
} }
} }
if ((u_int)type >= MAXQUOTAS) if ((u_int)type >= MAXQUOTAS) {
if (cmd == Q_QUOTAON)
vfs_unbusy(mp);
return (EINVAL); return (EINVAL);
}
switch (cmd) { switch (cmd) {
case Q_QUOTAON: case Q_QUOTAON:

View File

@ -411,6 +411,8 @@ mf_fgets(SPACE *sp, enum e_spflag spflag)
unlink(tmpfname); unlink(tmpfname);
if ((outfile = fopen(tmpfname, "w")) == NULL) if ((outfile = fopen(tmpfname, "w")) == NULL)
err(1, "%s", fname); err(1, "%s", fname);
if (outfile != NULL && outfile != stdout)
fclose(outfile);
fchown(fileno(outfile), sb.st_uid, sb.st_gid); fchown(fileno(outfile), sb.st_uid, sb.st_gid);
fchmod(fileno(outfile), sb.st_mode & ALLPERMS); fchmod(fileno(outfile), sb.st_mode & ALLPERMS);
outfname = tmpfname; outfname = tmpfname;

View File

@ -324,7 +324,7 @@ applies(struct s_command *cp)
} else } else
r = 1; r = 1;
} }
} else if (MATCH(cp->a1)) { } else if (cp->a1 && MATCH(cp->a1)) {
/* /*
* If the second address is a number less than or * If the second address is a number less than or
* equal to the line number first selected, only * equal to the line number first selected, only

View File

@ -1796,6 +1796,10 @@ process_file(char *filename)
if (filename == NULL) { if (filename == NULL) {
io = my_popen(command, "r", &pid_of_command); io = my_popen(command, "r", &pid_of_command);
if (io == NULL) {
printf("Can't popen the command %s\n", command);
return;
}
} else { } else {
io = fopen(filename, "r"); io = fopen(filename, "r");
if (io == NULL) { if (io == NULL) {
@ -1808,8 +1812,10 @@ process_file(char *filename)
if (cnts == NULL) { if (cnts == NULL) {
/* Nothing we can do */ /* Nothing we can do */
printf("Nothing to do -- no counters built\n"); printf("Nothing to do -- no counters built\n");
if (io) { if (filename) {
fclose(io); fclose(io);
} else {
my_pclose(io, pid_of_command);
} }
return; return;
} }