diff options
-rw-r--r-- | bin/sh/jobs.c | 36 | ||||
-rw-r--r-- | bin/sh/parser.c | 2 | ||||
-rw-r--r-- | libexec/rtld-elf/map_object.c | 3 | ||||
-rw-r--r-- | libexec/rtld-elf/rtld.c | 57 | ||||
-rw-r--r-- | libexec/rtld-elf/rtld.h | 1 | ||||
-rw-r--r-- | share/man/man9/make_dev.9 | 3 | ||||
-rw-r--r-- | share/mk/bsd.lib.mk | 27 | ||||
-rw-r--r-- | share/mk/bsd.prog.mk | 6 | ||||
-rwxr-xr-x | share/mk/meta2deps.sh | 2 | ||||
-rw-r--r-- | sys/arm64/include/param.h | 2 | ||||
-rw-r--r-- | sys/conf/kmod.mk | 4 | ||||
-rw-r--r-- | sys/dev/pci/pci_host_generic.c | 11 | ||||
-rw-r--r-- | sys/kern/kern_timeout.c | 10 | ||||
-rw-r--r-- | sys/kern/subr_sleepqueue.c | 3 | ||||
-rw-r--r-- | sys/sys/callout.h | 8 | ||||
-rw-r--r-- | usr.sbin/daemon/daemon.8 | 8 | ||||
-rw-r--r-- | usr.sbin/daemon/daemon.c | 14 |
17 files changed, 126 insertions, 71 deletions
diff --git a/bin/sh/jobs.c b/bin/sh/jobs.c index b531231e4a59..b5d084cad3e2 100644 --- a/bin/sh/jobs.c +++ b/bin/sh/jobs.c @@ -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(' '); diff --git a/bin/sh/parser.c b/bin/sh/parser.c index d324d88a8f18..da6defdb2c79 100644 --- a/bin/sh/parser.c +++ b/bin/sh/parser.c @@ -1671,7 +1671,7 @@ varname: c = pgetc_linecont(); } while (is_digit(c)); } else { - STPUTC(c, out); + USTPUTC(c, out); c = pgetc_linecont(); } } else if (is_special(c)) { diff --git a/libexec/rtld-elf/map_object.c b/libexec/rtld-elf/map_object.c index f4f6f4221816..30af4cefddbe 100644 --- a/libexec/rtld-elf/map_object.c +++ b/libexec/rtld-elf/map_object.c @@ -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; diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 912358c0c1d1..6a405c30f508 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -2627,6 +2627,40 @@ relocate_object_dag(Obj_Entry *root, bool bind_now, Obj_Entry *rtldobj, } /* + * 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); diff --git a/libexec/rtld-elf/rtld.h b/libexec/rtld-elf/rtld.h index 5fbfb271a3bf..8b7024b841ad 100644 --- a/libexec/rtld-elf/rtld.h +++ b/libexec/rtld-elf/rtld.h @@ -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. diff --git a/share/man/man9/make_dev.9 b/share/man/man9/make_dev.9 index 0c53e8d3916b..fa186e649bd3 100644 --- a/share/man/man9/make_dev.9 +++ b/share/man/man9/make_dev.9 @@ -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 diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk index b4c28ae15e66..97939947a64c 100644 --- a/share/mk/bsd.lib.mk +++ b/share/mk/bsd.lib.mk @@ -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} +.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} -.endif .endfor .endif +.endif +.endif -.include <bsd.dep.mk> .include <bsd.clang-analyze.mk> .include <bsd.obj.mk> .include <bsd.sys.mk> diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk index fac11175c2ca..469245d84266 100644 --- a/share/mk/bsd.prog.mk +++ b/share/mk/bsd.prog.mk @@ -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> diff --git a/share/mk/meta2deps.sh b/share/mk/meta2deps.sh index c012fd3e211f..f9412b05f0cb 100755 --- a/share/mk/meta2deps.sh +++ b/share/mk/meta2deps.sh @@ -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 diff --git a/sys/arm64/include/param.h b/sys/arm64/include/param.h index 45220122a84e..d4d49554ebdf 100644 --- a/sys/arm64/include/param.h +++ b/sys/arm64/include/param.h @@ -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 diff --git a/sys/conf/kmod.mk b/sys/conf/kmod.mk index ed15afa1c7fb..a7bbe27761f4 100644 --- a/sys/conf/kmod.mk +++ b/sys/conf/kmod.mk @@ -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" diff --git a/sys/dev/pci/pci_host_generic.c b/sys/dev/pci/pci_host_generic.c index 8335383111e2..f0c8d45dca0f 100644 --- a/sys/dev/pci/pci_host_generic.c +++ b/sys/dev/pci/pci_host_generic.c @@ -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) { diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c index 9c9d25f56b1d..b13a63f8c2e6 100644 --- a/sys/kern/kern_timeout.c +++ b/sys/kern/kern_timeout.c @@ -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 @@ again: 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 @@ again: 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); diff --git a/sys/kern/subr_sleepqueue.c b/sys/kern/subr_sleepqueue.c index bbbec920ef0d..12908f682c31 100644 --- a/sys/kern/subr_sleepqueue.c +++ b/sys/kern/subr_sleepqueue.c @@ -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); diff --git a/sys/sys/callout.h b/sys/sys/callout.h index 3e71c87a14ca..689b54749275 100644 --- a/sys/sys/callout.h +++ b/sys/sys/callout.h @@ -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) \ diff --git a/usr.sbin/daemon/daemon.8 b/usr.sbin/daemon/daemon.8 index 87cfd980aec2..dab9e3f2ab9c 100644 --- a/usr.sbin/daemon/daemon.8 +++ b/usr.sbin/daemon/daemon.8 @@ -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 diff --git a/usr.sbin/daemon/daemon.c b/usr.sbin/daemon/daemon.c index 7bdd2a6183d9..bd2f2722a0d7 100644 --- a/usr.sbin/daemon/daemon.c +++ b/usr.sbin/daemon/daemon.c @@ -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 @@ restart: 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; |