Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Glen Barber 2016-03-02 23:53:08 +00:00
commit 42d27ee343
17 changed files with 127 additions and 72 deletions

View File

@ -322,8 +322,8 @@ static void
showjob(struct job *jp, int mode)
{
char s[64];
char statestr[64];
const char *sigstr;
char statebuf[16];
const char *statestr, *coredump;
struct procstat *ps;
struct job *j;
int col, curr, i, jobno, prev, procno;
@ -339,9 +339,10 @@ showjob(struct job *jp, int mode)
prev = j - jobtab + 1;
}
#endif
coredump = "";
ps = jp->ps + jp->nprocs - 1;
if (jp->state == 0) {
strcpy(statestr, "Running");
statestr = "Running";
#if JOBS
} else if (jp->state == JOBSTOPPED) {
while (!WIFSTOPPED(ps->status) && ps > jp->ps)
@ -350,27 +351,25 @@ showjob(struct job *jp, int mode)
i = WSTOPSIG(ps->status);
else
i = -1;
sigstr = strsignal(i);
if (sigstr != NULL)
strcpy(statestr, sigstr);
else
strcpy(statestr, "Suspended");
statestr = strsignal(i);
if (statestr == NULL)
statestr = "Suspended";
#endif
} else if (WIFEXITED(ps->status)) {
if (WEXITSTATUS(ps->status) == 0)
strcpy(statestr, "Done");
else
fmtstr(statestr, 64, "Done(%d)",
statestr = "Done";
else {
fmtstr(statebuf, sizeof(statebuf), "Done(%d)",
WEXITSTATUS(ps->status));
statestr = statebuf;
}
} else {
i = WTERMSIG(ps->status);
sigstr = strsignal(i);
if (sigstr != NULL)
strcpy(statestr, sigstr);
else
strcpy(statestr, "Unknown signal");
statestr = strsignal(i);
if (statestr == NULL)
statestr = "Unknown signal";
if (WCOREDUMP(ps->status))
strcat(statestr, " (core dumped)");
coredump = " (core dumped)";
}
for (ps = jp->ps ; procno > 0 ; ps++, procno--) { /* for each process */
@ -399,7 +398,8 @@ showjob(struct job *jp, int mode)
}
if (ps == jp->ps) {
out1str(statestr);
col += strlen(statestr);
out1str(coredump);
col += strlen(statestr) + strlen(coredump);
}
do {
out1c(' ');

View File

@ -1671,7 +1671,7 @@ parsesub: {
c = pgetc_linecont();
} while (is_digit(c));
} else {
STPUTC(c, out);
USTPUTC(c, out);
c = pgetc_linecont();
}
} else if (is_special(c)) {

View File

@ -39,7 +39,6 @@
#include "rtld.h"
static Elf_Ehdr *get_elf_header(int, const char *, const struct stat *);
static int convert_prot(int); /* Elf flags -> mmap protection */
static int convert_flags(int); /* Elf flags -> mmap flags */
/*
@ -445,7 +444,7 @@ obj_new(void)
* Given a set of ELF protection flags, return the corresponding protection
* flags for MMAP.
*/
static int
int
convert_prot(int elfflags)
{
int prot = 0;

View File

@ -2626,6 +2626,40 @@ relocate_object_dag(Obj_Entry *root, bool bind_now, Obj_Entry *rtldobj,
return (error);
}
/*
* Prepare for, or clean after, relocating an object marked with
* DT_TEXTREL or DF_TEXTREL. Before relocating, all read-only
* segments are remapped read-write. After relocations are done, the
* segment's permissions are returned back to the modes specified in
* the phdrs. If any relocation happened, or always for wired
* program, COW is triggered.
*/
static int
reloc_textrel_prot(Obj_Entry *obj, bool before)
{
const Elf_Phdr *ph;
void *base;
size_t l, sz;
int prot;
for (l = obj->phsize / sizeof(*ph), ph = obj->phdr; l > 0;
l--, ph++) {
if (ph->p_type != PT_LOAD || (ph->p_flags & PF_W) != 0)
continue;
base = obj->relocbase + trunc_page(ph->p_vaddr);
sz = round_page(ph->p_vaddr + ph->p_filesz) -
trunc_page(ph->p_vaddr);
prot = convert_prot(ph->p_flags) | (before ? PROT_WRITE : 0);
if (mprotect(base, sz, prot) == -1) {
_rtld_error("%s: Cannot write-%sable text segment: %s",
obj->path, before ? "en" : "dis",
rtld_strerror(errno));
return (-1);
}
}
return (0);
}
/*
* Relocate single object.
* Returns 0 on success, or -1 on failure.
@ -2648,28 +2682,17 @@ relocate_object(Obj_Entry *obj, bool bind_now, Obj_Entry *rtldobj,
return (-1);
}
if (obj->textrel) {
/* There are relocations to the write-protected text segment. */
if (mprotect(obj->mapbase, obj->textsize,
PROT_READ|PROT_WRITE|PROT_EXEC) == -1) {
_rtld_error("%s: Cannot write-enable text segment: %s",
obj->path, rtld_strerror(errno));
return (-1);
}
}
/* There are relocations to the write-protected text segment. */
if (obj->textrel && reloc_textrel_prot(obj, true) != 0)
return (-1);
/* Process the non-PLT non-IFUNC relocations. */
if (reloc_non_plt(obj, rtldobj, flags, lockstate))
return (-1);
if (obj->textrel) { /* Re-protected the text segment. */
if (mprotect(obj->mapbase, obj->textsize,
PROT_READ|PROT_EXEC) == -1) {
_rtld_error("%s: Cannot write-protect text segment: %s",
obj->path, rtld_strerror(errno));
return (-1);
}
}
/* Re-protected the text segment. */
if (obj->textrel && reloc_textrel_prot(obj, false) != 0)
return (-1);
/* Set the special PLT or GOT entries. */
init_pltgot(obj);

View File

@ -385,6 +385,7 @@ void *allocate_module_tls(int index);
bool allocate_tls_offset(Obj_Entry *obj);
void free_tls_offset(Obj_Entry *obj);
const Ver_Entry *fetch_ventry(const Obj_Entry *obj, unsigned long);
int convert_prot(int elfflags);
/*
* MD function declarations.

View File

@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd Jan 3, 2016
.Dd March 2, 2016
.Dt MAKE_DEV 9
.Os
.Sh NAME
@ -460,7 +460,6 @@ flag was specified and the provided device name already exists.
.Sh SEE ALSO
.Xr devctl 4 ,
.Xr devfs 5 ,
.Xr destroy_dev_drain 9 ,
.Xr dev_clone 9
.Sh HISTORY
The

View File

@ -438,30 +438,35 @@ lint: ${SRCS:M*.c}
.if defined(LIB) && !empty(LIB)
OBJS_DEPEND_GUESS+= ${SRCS:M*.h}
.if ${MK_FAST_DEPEND} == "no" && !exists(${.OBJDIR}/${DEPENDFILE})
${OBJS} ${STATICOBJS} ${POBJS}: ${OBJS_DEPEND_GUESS}
.endif
.for _S in ${SRCS:N*.[hly]}
OBJS_DEPEND_GUESS.${_S:R}.po= ${_S}
.if ${MK_FAST_DEPEND} == "no" && !exists(${.OBJDIR}/${DEPENDFILE})
${_S:R}.po: ${OBJS_DEPEND_GUESS.${_S:R}.po}
.endif
.endfor
.endif
.if defined(SHLIB_NAME) || \
defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB)
.if ${MK_FAST_DEPEND} == "no" && !exists(${.OBJDIR}/${DEPENDFILE})
${SOBJS}: ${OBJS_DEPEND_GUESS}
.endif
.for _S in ${SRCS:N*.[hly]}
OBJS_DEPEND_GUESS.${_S:R}.So= ${_S}
.if ${MK_FAST_DEPEND} == "no" && !exists(${.OBJDIR}/${DEPENDFILE})
${_S:R}.So: ${OBJS_DEPEND_GUESS.${_S:R}.So}
.endif
.endfor
.endif
.include <bsd.dep.mk>
.if defined(LIB) && !empty(LIB)
.if ${MK_FAST_DEPEND} == "no" && !exists(${.OBJDIR}/${DEPENDFILE})
${OBJS} ${STATICOBJS} ${POBJS}: ${OBJS_DEPEND_GUESS}
.for _S in ${SRCS:N*.[hly]}
${_S:R}.po: ${OBJS_DEPEND_GUESS.${_S:R}.po}
.endfor
.if defined(SHLIB_NAME) || \
defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB)
${SOBJS}: ${OBJS_DEPEND_GUESS}
.for _S in ${SRCS:N*.[hly]}
${_S:R}.So: ${OBJS_DEPEND_GUESS.${_S:R}.So}
.endfor
.endif
.endif
.endif
.include <bsd.clang-analyze.mk>
.include <bsd.obj.mk>
.include <bsd.sys.mk>

View File

@ -284,12 +284,16 @@ lint: ${SRCS:M*.c}
.if defined(PROG)
OBJS_DEPEND_GUESS+= ${SRCS:M*.h}
.endif
.include <bsd.dep.mk>
.if defined(PROG)
.if ${MK_FAST_DEPEND} == "no" && !exists(${.OBJDIR}/${DEPENDFILE})
${OBJS}: ${OBJS_DEPEND_GUESS}
.endif
.endif
.include <bsd.dep.mk>
.include <bsd.clang-analyze.mk>
.include <bsd.obj.mk>
.include <bsd.sys.mk>

View File

@ -310,7 +310,7 @@ meta2deps() {
*) seen=$dir;;
esac
case "$dir" in
${CURDIR:-.}|${CURDIR:-.}/*|"") continue;;
${CURDIR:-.}|"") continue;;
$src_re)
# avoid repeating ourselves...
case "$DPDEPS,$seensrc," in

View File

@ -42,6 +42,8 @@
#define STACKALIGNBYTES (16 - 1)
#define STACKALIGN(p) ((uint64_t)(p) & ~STACKALIGNBYTES)
#define __PCI_REROUTE_INTERRUPT
#ifndef MACHINE
#define MACHINE "arm64"
#endif

View File

@ -456,11 +456,13 @@ cleanilinks:
rm -f ${_ILINKS}
OBJS_DEPEND_GUESS+= ${SRCS:M*.h}
.include <bsd.dep.mk>
.if ${MK_FAST_DEPEND} == "no" && !exists(${.OBJDIR}/${DEPENDFILE})
${OBJS}: ${OBJS_DEPEND_GUESS}
.endif
.include <bsd.dep.mk>
.include <bsd.clang-analyze.mk>
.include <bsd.obj.mk>
.include "kern.mk"

View File

@ -143,6 +143,10 @@ generic_pcie_probe(device_t dev)
device_set_desc(dev, "Generic PCI host controller");
return (BUS_PROBE_GENERIC);
}
if (ofw_bus_is_compatible(dev, "arm,gem5_pcie")) {
device_set_desc(dev, "GEM5 PCIe host controller");
return (BUS_PROBE_DEFAULT);
}
return (ENXIO);
}
@ -208,12 +212,11 @@ pci_host_generic_attach(device_t dev)
continue; /* empty range element */
if (sc->ranges[tuple].flags & FLAG_MEM) {
error = rman_manage_region(&sc->mem_rman,
phys_base,
phys_base + size);
phys_base, phys_base + size - 1);
} else if (sc->ranges[tuple].flags & FLAG_IO) {
error = rman_manage_region(&sc->io_rman,
pci_base + PCI_IO_WINDOW_OFFSET,
pci_base + PCI_IO_WINDOW_OFFSET + size);
pci_base + PCI_IO_WINDOW_OFFSET,
pci_base + PCI_IO_WINDOW_OFFSET + size - 1);
} else
continue;
if (error) {

View File

@ -1155,14 +1155,14 @@ callout_schedule(struct callout *c, int to_ticks)
}
int
_callout_stop_safe(struct callout *c, int safe, void (*drain)(void *))
_callout_stop_safe(struct callout *c, int flags, void (*drain)(void *))
{
struct callout_cpu *cc, *old_cc;
struct lock_class *class;
int direct, sq_locked, use_lock;
int not_on_a_list;
if (safe)
if ((flags & CS_DRAIN) != 0)
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, c->c_lock,
"calling %s", __func__);
@ -1170,7 +1170,7 @@ _callout_stop_safe(struct callout *c, int safe, void (*drain)(void *))
* Some old subsystems don't hold Giant while running a callout_stop(),
* so just discard this check for the moment.
*/
if (!safe && c->c_lock != NULL) {
if ((flags & CS_DRAIN) == 0 && c->c_lock != NULL) {
if (c->c_lock == &Giant.lock_object)
use_lock = mtx_owned(&Giant);
else {
@ -1253,7 +1253,7 @@ _callout_stop_safe(struct callout *c, int safe, void (*drain)(void *))
return (-1);
}
if (safe) {
if ((flags & CS_DRAIN) != 0) {
/*
* The current callout is running (or just
* about to run) and blocking is allowed, so
@ -1370,7 +1370,7 @@ _callout_stop_safe(struct callout *c, int safe, void (*drain)(void *))
cc_exec_drain(cc, direct) = drain;
}
CC_UNLOCK(cc);
return (0);
return ((flags & CS_MIGRBLOCK) != 0);
}
CTR3(KTR_CALLOUT, "failed to stop %p func %p arg %p",
c, c->c_func, c->c_arg);

View File

@ -586,7 +586,8 @@ sleepq_check_timeout(void)
* another CPU, so synchronize with it to avoid having it
* accidentally wake up a subsequent sleep.
*/
else if (callout_stop(&td->td_slpcallout) == 0) {
else if (_callout_stop_safe(&td->td_slpcallout, CS_MIGRBLOCK, NULL)
== 0) {
td->td_flags |= TDF_TIMEOUT;
TD_SET_SLEEPING(td);
mi_switch(SW_INVOL | SWT_SLEEPQTIMO, NULL);

View File

@ -62,6 +62,12 @@ struct callout_handle {
struct callout *callout;
};
/* Flags for callout_stop_safe() */
#define CS_DRAIN 0x0001 /* callout_drain(), wait allowed */
#define CS_MIGRBLOCK 0x0002 /* Block migration, return value
indicates that the callout was
executing */
#ifdef _KERNEL
/*
* Note the flags field is actually *two* fields. The c_flags
@ -81,7 +87,7 @@ struct callout_handle {
*/
#define callout_active(c) ((c)->c_flags & CALLOUT_ACTIVE)
#define callout_deactivate(c) ((c)->c_flags &= ~CALLOUT_ACTIVE)
#define callout_drain(c) _callout_stop_safe(c, 1, NULL)
#define callout_drain(c) _callout_stop_safe(c, CS_DRAIN, NULL)
void callout_init(struct callout *, int);
void _callout_init_lock(struct callout *, struct lock_object *, int);
#define callout_init_mtx(c, mtx, flags) \

View File

@ -26,7 +26,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd September 13, 2013
.Dd March 2, 2016
.Dt DAEMON 8
.Os
.Sh NAME
@ -37,6 +37,7 @@
.Op Fl cfr
.Op Fl p Ar child_pidfile
.Op Fl P Ar supervisor_pidfile
.Op Fl t Ar title
.Op Fl u Ar user
.Ar command arguments ...
.Sh DESCRIPTION
@ -94,6 +95,8 @@ regardless of whether the
option is used or not.
.It Fl r
Supervise and restart the program if it has been terminated.
.It Fl t Ar title
Process title for the daemon to make it easily identifiable.
.It Fl u Ar user
Login name of the user to execute the program under.
Requires adequate superuser privileges.
@ -123,7 +126,8 @@ option is useful combined with the
option as
.Ar supervisor_pidfile
contains the ID of the supervisor
not the child. This is especially important if you use
not the child.
This is especially important if you use
.Fl r
in an rc script as the
.Fl p

View File

@ -56,13 +56,13 @@ main(int argc, char *argv[])
struct pidfh *ppfh, *pfh;
sigset_t mask, oldmask;
int ch, nochdir, noclose, restart, serrno;
const char *pidfile, *ppidfile, *user;
const char *pidfile, *ppidfile, *title, *user;
pid_t otherpid, pid;
nochdir = noclose = 1;
restart = 0;
ppidfile = pidfile = user = NULL;
while ((ch = getopt(argc, argv, "cfp:P:ru:")) != -1) {
ppidfile = pidfile = title = user = NULL;
while ((ch = getopt(argc, argv, "cfp:P:rt:u:")) != -1) {
switch (ch) {
case 'c':
nochdir = 0;
@ -79,6 +79,9 @@ main(int argc, char *argv[])
case 'r':
restart = 1;
break;
case 't':
title = optarg;
break;
case 'u':
user = optarg;
break;
@ -204,7 +207,10 @@ main(int argc, char *argv[])
err(1, "%s", argv[0]);
}
setproctitle("%s[%d]", argv[0], pid);
if (title != NULL)
setproctitle("%s[%d]", title, pid);
else
setproctitle("%s[%d]", argv[0], pid);
if (wait_child(pid, &mask) == 0 && restart) {
sleep(1);
goto restart;