Date: Mon, 6 Feb 2017 04:30:18 +0000 (UTC) From: "Andrey V. Elsukov" <ae@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r313313 - in projects/ipsec: cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt cddl/contrib/opensolaris/lib/libdtrace/common etc sbin/decryptcore sbin/hastctl sbin/hastd sbin/ifc... Message-ID: <201702060430.v164UIRt059014@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ae Date: Mon Feb 6 04:30:18 2017 New Revision: 313313 URL: https://svnweb.freebsd.org/changeset/base/313313 Log: Merge from head/. Added: projects/ipsec/sbin/nvmecontrol/wdc.c - copied unchanged from r313312, head/sbin/nvmecontrol/wdc.c Modified: projects/ipsec/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.enabled2.ksh projects/ipsec/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.include.ksh projects/ipsec/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c projects/ipsec/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c projects/ipsec/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c projects/ipsec/etc/devd.conf projects/ipsec/sbin/decryptcore/decryptcore.c projects/ipsec/sbin/hastctl/Makefile projects/ipsec/sbin/hastd/Makefile projects/ipsec/sbin/hastd/hast_checksum.c projects/ipsec/sbin/hastd/hast_proto.c projects/ipsec/sbin/ifconfig/ifieee80211.c projects/ipsec/sbin/kldload/kldload.c projects/ipsec/sbin/nvmecontrol/Makefile projects/ipsec/sbin/nvmecontrol/firmware.c projects/ipsec/sbin/nvmecontrol/logpage.c projects/ipsec/sbin/nvmecontrol/nvmecontrol.8 projects/ipsec/sbin/nvmecontrol/nvmecontrol.c projects/ipsec/sbin/nvmecontrol/nvmecontrol.h projects/ipsec/sbin/savecore/savecore.c projects/ipsec/sys/amd64/include/pcpu.h projects/ipsec/sys/amd64/linux/linux_dummy.c projects/ipsec/sys/amd64/linux/linux_proto.h projects/ipsec/sys/amd64/linux/linux_syscall.h projects/ipsec/sys/amd64/linux/linux_syscalls.c projects/ipsec/sys/amd64/linux/linux_sysent.c projects/ipsec/sys/amd64/linux/linux_systrace_args.c projects/ipsec/sys/amd64/linux/syscalls.master projects/ipsec/sys/amd64/linux32/linux32_dummy.c projects/ipsec/sys/amd64/linux32/linux32_proto.h projects/ipsec/sys/amd64/linux32/linux32_syscall.h projects/ipsec/sys/amd64/linux32/linux32_syscalls.c projects/ipsec/sys/amd64/linux32/linux32_sysent.c projects/ipsec/sys/amd64/linux32/linux32_systrace_args.c projects/ipsec/sys/amd64/linux32/syscalls.master projects/ipsec/sys/arm/include/_types.h projects/ipsec/sys/arm64/include/_types.h projects/ipsec/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c projects/ipsec/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h projects/ipsec/sys/cddl/dev/dtrace/dtrace_ioctl.c projects/ipsec/sys/compat/freebsd32/freebsd32_misc.c projects/ipsec/sys/compat/linux/linux_file.c projects/ipsec/sys/compat/linux/linux_misc.c projects/ipsec/sys/compat/linux/linux_socket.h projects/ipsec/sys/dev/iwm/if_iwm.c projects/ipsec/sys/dev/iwm/if_iwm_mac_ctxt.c projects/ipsec/sys/dev/iwm/if_iwm_pcie_trans.c projects/ipsec/sys/dev/iwm/if_iwm_phy_db.c projects/ipsec/sys/dev/iwm/if_iwm_phy_db.h projects/ipsec/sys/dev/iwm/if_iwm_scan.c projects/ipsec/sys/dev/iwm/if_iwm_util.c projects/ipsec/sys/dev/iwm/if_iwmreg.h projects/ipsec/sys/dev/iwm/if_iwmvar.h projects/ipsec/sys/dev/mmc/mmc.c projects/ipsec/sys/dev/mmc/mmcreg.h projects/ipsec/sys/dev/sdhci/sdhci.c projects/ipsec/sys/dev/sdhci/sdhci.h projects/ipsec/sys/dev/sdhci/sdhci_fdt.c projects/ipsec/sys/dev/sdhci/sdhci_pci.c projects/ipsec/sys/dev/usb/serial/uftdi.c projects/ipsec/sys/dev/usb/serial/usb_serial.c projects/ipsec/sys/dev/usb/serial/usb_serial.h projects/ipsec/sys/i386/linux/linux_dummy.c projects/ipsec/sys/i386/linux/linux_proto.h projects/ipsec/sys/i386/linux/linux_syscall.h projects/ipsec/sys/i386/linux/linux_syscalls.c projects/ipsec/sys/i386/linux/linux_sysent.c projects/ipsec/sys/i386/linux/linux_systrace_args.c projects/ipsec/sys/i386/linux/syscalls.master projects/ipsec/sys/kern/kern_cpuset.c projects/ipsec/sys/kern/kern_descrip.c projects/ipsec/sys/kern/kern_mutex.c projects/ipsec/sys/kern/kern_rmlock.c projects/ipsec/sys/kern/kern_rwlock.c projects/ipsec/sys/kern/kern_sx.c projects/ipsec/sys/kern/subr_witness.c projects/ipsec/sys/kern/vfs_subr.c projects/ipsec/sys/mips/include/_types.h projects/ipsec/sys/mips/include/pcpu.h projects/ipsec/sys/net/iflib.c projects/ipsec/sys/net/netisr.c projects/ipsec/sys/powerpc/include/_types.h projects/ipsec/sys/powerpc/include/cpufunc.h projects/ipsec/sys/powerpc/include/pcpu.h projects/ipsec/sys/riscv/include/_types.h projects/ipsec/sys/riscv/include/atomic.h projects/ipsec/sys/sparc64/include/_types.h projects/ipsec/sys/sparc64/include/pcpu.h projects/ipsec/sys/sys/lockstat.h projects/ipsec/sys/sys/mutex.h projects/ipsec/sys/sys/rwlock.h projects/ipsec/sys/sys/sdt.h projects/ipsec/sys/sys/sx.h projects/ipsec/sys/sys/syscallsubr.h projects/ipsec/sys/sys/types.h projects/ipsec/sys/vm/vm_object.h projects/ipsec/sys/x86/include/_types.h projects/ipsec/tools/tools/nanobsd/embedded/rpi2.cfg projects/ipsec/usr.bin/sed/main.c Directory Properties: projects/ipsec/ (props changed) projects/ipsec/cddl/ (props changed) projects/ipsec/cddl/contrib/opensolaris/ (props changed) projects/ipsec/sys/cddl/contrib/opensolaris/ (props changed) Modified: projects/ipsec/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.enabled2.ksh ============================================================================== --- projects/ipsec/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.enabled2.ksh Mon Feb 6 03:29:50 2017 (r313312) +++ projects/ipsec/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.enabled2.ksh Mon Feb 6 04:30:18 2017 (r313313) @@ -77,7 +77,7 @@ main(int argc, char **argv) } EOF -cc -c -xO2 test.c +cc -c -O2 test.c if [ $? -ne 0 ]; then print -u2 "failed to compile test.c" exit 1 Modified: projects/ipsec/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.include.ksh ============================================================================== --- projects/ipsec/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.include.ksh Mon Feb 6 03:29:50 2017 (r313312) +++ projects/ipsec/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.include.ksh Mon Feb 6 04:30:18 2017 (r313313) @@ -25,7 +25,7 @@ # # ident "%Z%%M% %I% %E% SMI" -# Make sure <unistd.h> defines _DTRACE_VERSION +# Make sure <sys/sdt.h> defines _DTRACE_VERSION DIR=/var/tmp/dtest.$$ @@ -33,7 +33,7 @@ mkdir $DIR cd $DIR cat > test.c <<EOF -#include <unistd.h> +#include <sys/sdt.h> int main(int argc, char **argv) @@ -46,7 +46,7 @@ main(int argc, char **argv) } EOF -cc -xarch=generic -o test test.c +cc -o test test.c if [ $? -ne 0 ]; then print -u2 "failed to compile test.c" exit 1 Modified: projects/ipsec/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c ============================================================================== --- projects/ipsec/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c Mon Feb 6 03:29:50 2017 (r313312) +++ projects/ipsec/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c Mon Feb 6 04:30:18 2017 (r313313) @@ -462,18 +462,8 @@ dof_add_probe(dt_idhash_t *dhp, dt_ident dt_buf_write(dtp, &ddo->ddo_enoffs, pip->pi_enoffs, pip->pi_nenoffs * sizeof (uint32_t), sizeof (uint32_t)); - /* - * If pi_rname isn't set, the relocation will be against the - * function name. If it is, the relocation will be against - * pi_rname. This will be used if the function is scoped - * locally so an alternate symbol is added for the purpose - * of this relocation. - */ - if (pip->pi_rname == NULL) - dofr.dofr_name = dofpr.dofpr_func; - else - dofr.dofr_name = dof_add_string(ddo, pip->pi_rname); - dofr.dofr_type = DOF_RELO_SETX; + dofr.dofr_name = dof_add_string(ddo, pip->pi_rname); + dofr.dofr_type = DOF_RELO_DOFREL; dofr.dofr_offset = dt_buf_len(&ddo->ddo_probes); dofr.dofr_data = 0; Modified: projects/ipsec/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c ============================================================================== --- projects/ipsec/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c Mon Feb 6 03:29:50 2017 (r313312) +++ projects/ipsec/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c Mon Feb 6 04:30:18 2017 (r313313) @@ -237,7 +237,7 @@ printf("%s:%s(%d): DOODAD\n",__FUNCTION_ rel->r_offset = s->dofs_offset + dofr[j].dofr_offset; rel->r_info = ELF32_R_INFO(count + dep->de_global, - R_386_32); + R_386_PC32); #elif defined(__mips__) /* XXX */ printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); @@ -253,15 +253,6 @@ printf("%s:%s(%d): DOODAD\n",__FUNCTION_ #elif defined(__riscv__) /* XXX */ printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); -#elif defined(__sparc) - /* - * Add 4 bytes to hit the low half of this 64-bit - * big-endian address. - */ - rel->r_offset = s->dofs_offset + - dofr[j].dofr_offset + 4; - rel->r_info = ELF32_R_INFO(count + dep->de_global, - R_SPARC_32); #else #error unknown ISA #endif @@ -270,7 +261,7 @@ printf("%s:%s(%d): DOODAD\n",__FUNCTION_ sym->st_value = 0; sym->st_size = 0; sym->st_info = ELF32_ST_INFO(STB_GLOBAL, STT_FUNC); - sym->st_other = 0; + sym->st_other = ELF32_ST_VISIBILITY(STV_HIDDEN); sym->st_shndx = SHN_UNDEF; rel++; @@ -287,11 +278,7 @@ printf("%s:%s(%d): DOODAD\n",__FUNCTION_ sym->st_value = 0; sym->st_size = dof->dofh_filesz; sym->st_info = ELF32_ST_INFO(STB_GLOBAL, STT_OBJECT); -#ifdef illumos - sym->st_other = 0; -#else sym->st_other = ELF32_ST_VISIBILITY(STV_HIDDEN); -#endif sym->st_shndx = ESHDR_DOF; sym++; @@ -448,18 +435,8 @@ prepare_elf64(dtrace_hdl_t *dtp, const d #elif defined(__i386) || defined(__amd64) rel->r_offset = s->dofs_offset + dofr[j].dofr_offset; -#ifdef illumos rel->r_info = ELF64_R_INFO(count + dep->de_global, - R_AMD64_64); -#else - rel->r_info = ELF64_R_INFO(count + dep->de_global, - R_X86_64_RELATIVE); -#endif -#elif defined(__sparc) - rel->r_offset = s->dofs_offset + - dofr[j].dofr_offset; - rel->r_info = ELF64_R_INFO(count + dep->de_global, - R_SPARC_64); + R_X86_64_PC64); #else #error unknown ISA #endif @@ -468,7 +445,7 @@ prepare_elf64(dtrace_hdl_t *dtp, const d sym->st_value = 0; sym->st_size = 0; sym->st_info = GELF_ST_INFO(STB_GLOBAL, STT_FUNC); - sym->st_other = 0; + sym->st_other = ELF64_ST_VISIBILITY(STV_HIDDEN); sym->st_shndx = SHN_UNDEF; rel++; @@ -485,11 +462,7 @@ prepare_elf64(dtrace_hdl_t *dtp, const d sym->st_value = 0; sym->st_size = dof->dofh_filesz; sym->st_info = GELF_ST_INFO(STB_GLOBAL, STT_OBJECT); -#ifdef illumos - sym->st_other = 0; -#else sym->st_other = ELF64_ST_VISIBILITY(STV_HIDDEN); -#endif sym->st_shndx = ESHDR_DOF; sym++; @@ -797,16 +770,15 @@ dump_elf64(dtrace_hdl_t *dtp, const dof_ } static int -dt_symtab_lookup(Elf_Data *data_sym, int nsym, uintptr_t addr, uint_t shn, - GElf_Sym *sym, int uses_funcdesc, Elf *elf) +dt_symtab_lookup(Elf_Data *data_sym, int start, int end, uintptr_t addr, + uint_t shn, GElf_Sym *sym, int uses_funcdesc, Elf *elf) { - int i, ret = -1; Elf64_Addr symval; Elf_Scn *opd_scn; Elf_Data *opd_desc; - GElf_Sym s; + int i; - for (i = 0; i < nsym && gelf_getsym(data_sym, i, sym) != NULL; i++) { + for (i = start; i < end && gelf_getsym(data_sym, i, sym) != NULL; i++) { if (GELF_ST_TYPE(sym->st_info) == STT_FUNC) { symval = sym->st_value; if (uses_funcdesc) { @@ -816,20 +788,12 @@ dt_symtab_lookup(Elf_Data *data_sym, int *(uint64_t*)((char *)opd_desc->d_buf + symval); } if ((uses_funcdesc || shn == sym->st_shndx) && - symval <= addr && - addr < symval + sym->st_size) { - if (GELF_ST_BIND(sym->st_info) == STB_GLOBAL) - return (0); - - ret = 0; - s = *sym; - } + symval <= addr && addr < symval + sym->st_size) + return (0); } } - if (ret == 0) - *sym = s; - return (ret); + return (-1); } #if defined(__aarch64__) @@ -1237,10 +1201,11 @@ process_obj(dtrace_hdl_t *dtp, const cha dt_provider_t *pvp; dt_probe_t *prp; uint32_t off, eclass, emachine1, emachine2; - size_t symsize, nsym, isym, istr, len; + size_t symsize, osym, nsym, isym, istr, len; key_t objkey; dt_link_pair_t *pair, *bufs = NULL; dt_strtab_t *strtab; + void *tmp; if ((fd = open64(obj, O_RDWR)) == -1) { return (dt_link_error(dtp, elf, fd, bufs, @@ -1374,12 +1339,13 @@ process_obj(dtrace_hdl_t *dtp, const cha * target (text) section to replace the call instruction with * one or more nops. * - * If the function containing the probe is locally scoped - * (static), we create an alias used by the relocation in the - * generated object. The alias, a new symbol, will be global - * (so that the relocation from the generated object can be - * resolved), and hidden (so that it is converted to a local - * symbol at link time). Such aliases have this form: + * To avoid runtime overhead, the relocations added to the + * generated object should be resolved at static link time. We + * therefore create aliases for the functions that contain + * probes. An alias is global (so that the relocation from the + * generated object can be resolved), and hidden (so that its + * address is known at static link time). Such aliases have this + * form: * * $dtrace<key>.<function> * @@ -1417,16 +1383,13 @@ process_obj(dtrace_hdl_t *dtp, const cha if (strncmp(s, dt_prefix, sizeof (dt_prefix) - 1) != 0) continue; - if (dt_symtab_lookup(data_sym, isym, rela.r_offset, - shdr_rel.sh_info, &fsym, - (emachine1 == EM_PPC64), elf) != 0) { + if (dt_symtab_lookup(data_sym, 0, isym, rela.r_offset, + shdr_rel.sh_info, &fsym, (emachine1 == EM_PPC64), + elf) != 0) { dt_strtab_destroy(strtab); goto err; } - if (GELF_ST_BIND(fsym.st_info) != STB_LOCAL) - continue; - if (fsym.st_name > data_str->d_size) { dt_strtab_destroy(strtab); goto err; @@ -1462,12 +1425,12 @@ process_obj(dtrace_hdl_t *dtp, const cha } /* - * If needed, allocate the additional space for the symbol - * table and string table copying the old data into the new - * buffers, and marking the buffers as dirty. We inject those - * newly allocated buffers into the libelf data structures, but - * are still responsible for freeing them once we're done with - * the elf handle. + * If any probes were found, allocate the additional space for + * the symbol table and string table, copying the old data into + * the new buffers, and marking the buffers as dirty. We inject + * those newly allocated buffers into the libelf data + * structures, but are still responsible for freeing them once + * we're done with the elf handle. */ if (nsym > 0) { /* @@ -1501,7 +1464,9 @@ process_obj(dtrace_hdl_t *dtp, const cha bufs = pair; bcopy(data_str->d_buf, pair->dlp_str, data_str->d_size); + tmp = data_str->d_buf; data_str->d_buf = pair->dlp_str; + pair->dlp_str = tmp; data_str->d_size += len; (void) elf_flagdata(data_str, ELF_C_SET, ELF_F_DIRTY); @@ -1509,16 +1474,20 @@ process_obj(dtrace_hdl_t *dtp, const cha (void) gelf_update_shdr(scn_str, &shdr_str); bcopy(data_sym->d_buf, pair->dlp_sym, data_sym->d_size); + tmp = data_sym->d_buf; data_sym->d_buf = pair->dlp_sym; + pair->dlp_sym = tmp; data_sym->d_size += nsym * symsize; (void) elf_flagdata(data_sym, ELF_C_SET, ELF_F_DIRTY); shdr_sym.sh_size += nsym * symsize; (void) gelf_update_shdr(scn_sym, &shdr_sym); + osym = isym; nsym += isym; } else { dt_strtab_destroy(strtab); + continue; } /* @@ -1577,8 +1546,11 @@ process_obj(dtrace_hdl_t *dtp, const cha bcopy(s, pname, p - s); pname[p - s] = '\0'; - if (dt_symtab_lookup(data_sym, isym, rela.r_offset, - shdr_rel.sh_info, &fsym, + if (dt_symtab_lookup(data_sym, osym, isym, + rela.r_offset, shdr_rel.sh_info, &fsym, + (emachine1 == EM_PPC64), elf) != 0 && + dt_symtab_lookup(data_sym, 0, osym, + rela.r_offset, shdr_rel.sh_info, &fsym, (emachine1 == EM_PPC64), elf) != 0) goto err; @@ -1588,37 +1560,30 @@ process_obj(dtrace_hdl_t *dtp, const cha assert(GELF_ST_TYPE(fsym.st_info) == STT_FUNC); /* - * If a NULL relocation name is passed to - * dt_probe_define(), the function name is used for the - * relocation. The relocation needs to use a mangled - * name if the symbol is locally scoped; the function - * name may need to change if we've found the global - * alias for the locally scoped symbol (we prefer - * global symbols to locals in dt_symtab_lookup()). + * If this is our first time encountering this symbol, + * emit an alias. */ s = (char *)data_str->d_buf + fsym.st_name; - r = NULL; - if (GELF_ST_BIND(fsym.st_info) == STB_LOCAL) { + if (strncmp(s, dt_symprefix, + sizeof (dt_symprefix) - 1) != 0) { + u_int bind = GELF_ST_BIND(fsym.st_info); + dsym = fsym; dsym.st_name = istr; - dsym.st_info = GELF_ST_INFO(STB_GLOBAL, - STT_FUNC); - dsym.st_other = - ELF64_ST_VISIBILITY(STV_ELIMINATE); + dsym.st_info = GELF_ST_INFO(bind == STB_LOCAL ? + STB_GLOBAL : bind, STT_FUNC); + dsym.st_other = GELF_ST_VISIBILITY(STV_HIDDEN); (void) gelf_update_sym(data_sym, isym, &dsym); - - r = (char *)data_str->d_buf + istr; - istr += 1 + sprintf(r, dt_symfmt, - dt_symprefix, objkey, s); + r = (char *) data_str->d_buf + istr; + istr += 1 + sprintf(r, dt_symfmt, dt_symprefix, objkey, + s); isym++; assert(isym <= nsym); - - } else if (strncmp(s, dt_symprefix, - strlen(dt_symprefix)) == 0) { + } else { r = s; - if ((s = strchr(s, '.')) == NULL) - goto err; + s = strchr(s, '.'); + assert(s != NULL); s++; } @@ -1697,9 +1662,6 @@ process_obj(dtrace_hdl_t *dtp, const cha (void) elf_end(elf); (void) close(fd); -#ifndef illumos - if (nsym > 0) -#endif while ((pair = bufs) != NULL) { bufs = pair->dlp_next; dt_free(dtp, pair->dlp_str); Modified: projects/ipsec/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c ============================================================================== --- projects/ipsec/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c Mon Feb 6 03:29:50 2017 (r313312) +++ projects/ipsec/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c Mon Feb 6 04:30:18 2017 (r313313) @@ -545,9 +545,7 @@ dt_probe_define(dt_provider_t *pvp, dt_p for (pip = prp->pr_inst; pip != NULL; pip = pip->pi_next) { if (strcmp(pip->pi_fname, fname) == 0 && - ((rname == NULL && pip->pi_rname == NULL) || - (rname != NULL && pip->pi_rname != NULL && - strcmp(pip->pi_rname, rname) == 0))) + strcmp(pip->pi_rname, rname) == 0) break; } @@ -565,7 +563,7 @@ dt_probe_define(dt_provider_t *pvp, dt_p if ((pip->pi_fname = strdup(fname)) == NULL) goto nomem; - if (rname != NULL && (pip->pi_rname = strdup(rname)) == NULL) + if ((pip->pi_rname = strdup(rname)) == NULL) goto nomem; pip->pi_noffs = 0; @@ -605,7 +603,7 @@ dt_probe_define(dt_provider_t *pvp, dt_p dt_dprintf("defined probe %s %s:%s %s() +0x%x (%s)\n", isenabled ? "(is-enabled)" : "", pvp->pv_desc.dtvd_name, prp->pr_ident->di_name, fname, offset, - rname != NULL ? rname : fname); + rname); assert(*noffs < *maxoffs); (*offs)[(*noffs)++] = offset; Modified: projects/ipsec/etc/devd.conf ============================================================================== --- projects/ipsec/etc/devd.conf Mon Feb 6 03:29:50 2017 (r313312) +++ projects/ipsec/etc/devd.conf Mon Feb 6 04:30:18 2017 (r313313) @@ -272,7 +272,7 @@ nomatch 10 { match "bus" "pccard[0-9]+"; match "manufacturer" "0x1234"; match "product" "0x2323"; - action "kldload if_deqna"; + action "kldload -n if_deqna"; }; attach 10 { device-name "deqna[0-9]+"; Modified: projects/ipsec/sbin/decryptcore/decryptcore.c ============================================================================== --- projects/ipsec/sbin/decryptcore/decryptcore.c Mon Feb 6 03:29:50 2017 (r313312) +++ projects/ipsec/sbin/decryptcore/decryptcore.c Mon Feb 6 04:30:18 2017 (r313313) @@ -31,7 +31,6 @@ __FBSDID("$FreeBSD$"); #include <sys/capsicum.h> #include <sys/endian.h> #include <sys/kerneldump.h> -#include <sys/stat.h> #include <sys/sysctl.h> #include <sys/wait.h> @@ -232,8 +231,6 @@ decrypt(const char *privkeyfile, const c pjdlog_errno(LOG_ERR, "Unable to read data from %s", input); goto failed; - } else if (bytes == 0) { - break; } if (bytes > 0) { @@ -249,10 +246,7 @@ decrypt(const char *privkeyfile, const c } } - if (olen == 0) - continue; - - if (write(ofd, buf, olen) != olen) { + if (olen > 0 && write(ofd, buf, olen) != olen) { pjdlog_errno(LOG_ERR, "Unable to write data to %s", output); goto failed; @@ -274,7 +268,6 @@ int main(int argc, char **argv) { char core[PATH_MAX], encryptedcore[PATH_MAX], keyfile[PATH_MAX]; - struct stat sb; const char *crashdir, *dumpnr, *privatekey; int ch, debug; size_t ii; @@ -297,16 +290,23 @@ main(int argc, char **argv) usesyslog = true; break; case 'c': - strncpy(core, optarg, sizeof(core)); + if (strlcpy(core, optarg, sizeof(core)) >= sizeof(core)) + pjdlog_exitx(1, "Core file path is too long."); break; case 'd': crashdir = optarg; break; case 'e': - strncpy(encryptedcore, optarg, sizeof(encryptedcore)); + if (strlcpy(encryptedcore, optarg, + sizeof(encryptedcore)) >= sizeof(encryptedcore)) { + pjdlog_exitx(1, "Encrypted core file path is too long."); + } break; case 'k': - strncpy(keyfile, optarg, sizeof(keyfile)); + if (strlcpy(keyfile, optarg, sizeof(keyfile)) >= + sizeof(keyfile)) { + pjdlog_exitx(1, "Key file path is too long."); + } break; case 'n': dumpnr = optarg; @@ -362,7 +362,7 @@ main(int argc, char **argv) pjdlog_debug_set(debug); if (!decrypt(privatekey, keyfile, encryptedcore, core)) { - if (stat(core, &sb) == 0 && unlink(core) != 0) + if (unlink(core) == -1 && errno != ENOENT) pjdlog_exit(1, "Unable to remove core"); exit(1); } Modified: projects/ipsec/sbin/hastctl/Makefile ============================================================================== --- projects/ipsec/sbin/hastctl/Makefile Mon Feb 6 03:29:50 2017 (r313312) +++ projects/ipsec/sbin/hastctl/Makefile Mon Feb 6 04:30:18 2017 (r313313) @@ -33,11 +33,7 @@ CFLAGS+=-DINET6 CFLAGS+=-DYY_NO_UNPUT CFLAGS+=-DYY_NO_INPUT -LIBADD= util -.if ${MK_OPENSSL} != "no" -LIBADD+= crypto -CFLAGS+=-DHAVE_CRYPTO -.endif +LIBADD= md util YFLAGS+=-v Modified: projects/ipsec/sbin/hastd/Makefile ============================================================================== --- projects/ipsec/sbin/hastd/Makefile Mon Feb 6 03:29:50 2017 (r313312) +++ projects/ipsec/sbin/hastd/Makefile Mon Feb 6 04:30:18 2017 (r313313) @@ -31,11 +31,7 @@ CFLAGS+=-DINET CFLAGS+=-DINET6 .endif -LIBADD= geom pthread util -.if ${MK_OPENSSL} != "no" -LIBADD+= crypto -CFLAGS+=-DHAVE_CRYPTO -.endif +LIBADD= geom md pthread util YFLAGS+=-v Modified: projects/ipsec/sbin/hastd/hast_checksum.c ============================================================================== --- projects/ipsec/sbin/hastd/hast_checksum.c Mon Feb 6 03:29:50 2017 (r313312) +++ projects/ipsec/sbin/hastd/hast_checksum.c Mon Feb 6 04:30:18 2017 (r313313) @@ -31,22 +31,15 @@ __FBSDID("$FreeBSD$"); #include <string.h> #include <strings.h> -#ifdef HAVE_CRYPTO -#include <openssl/sha.h> -#endif - #include <crc32.h> #include <hast.h> #include <nv.h> +#include <sha256.h> #include <pjdlog.h> #include "hast_checksum.h" -#ifdef HAVE_CRYPTO #define MAX_HASH_SIZE SHA256_DIGEST_LENGTH -#else -#define MAX_HASH_SIZE 4 -#endif static void hast_crc32_checksum(const unsigned char *data, size_t size, @@ -60,7 +53,6 @@ hast_crc32_checksum(const unsigned char *hsizep = sizeof(crc); } -#ifdef HAVE_CRYPTO static void hast_sha256_checksum(const unsigned char *data, size_t size, unsigned char *hash, size_t *hsizep) @@ -72,7 +64,6 @@ hast_sha256_checksum(const unsigned char SHA256_Final(hash, &ctx); *hsizep = SHA256_DIGEST_LENGTH; } -#endif /* HAVE_CRYPTO */ const char * checksum_name(int num) @@ -102,11 +93,9 @@ checksum_send(const struct hast_resource case HAST_CHECKSUM_CRC32: hast_crc32_checksum(*datap, *sizep, hash, &hsize); break; -#ifdef HAVE_CRYPTO case HAST_CHECKSUM_SHA256: hast_sha256_checksum(*datap, *sizep, hash, &hsize); break; -#endif default: PJDLOG_ABORT("Invalid checksum: %d.", res->hr_checksum); } @@ -138,10 +127,8 @@ checksum_recv(const struct hast_resource } if (strcmp(algo, "crc32") == 0) hast_crc32_checksum(*datap, *sizep, chash, &chsize); -#ifdef HAVE_CRYPTO else if (strcmp(algo, "sha256") == 0) hast_sha256_checksum(*datap, *sizep, chash, &chsize); -#endif else { pjdlog_error("Unknown checksum algorithm '%s'.", algo); return (-1); /* Unknown checksum algorithm. */ Modified: projects/ipsec/sbin/hastd/hast_proto.c ============================================================================== --- projects/ipsec/sbin/hastd/hast_proto.c Mon Feb 6 03:29:50 2017 (r313312) +++ projects/ipsec/sbin/hastd/hast_proto.c Mon Feb 6 04:30:18 2017 (r313313) @@ -42,9 +42,7 @@ __FBSDID("$FreeBSD$"); #include <pjdlog.h> #include <proto.h> -#ifdef HAVE_CRYPTO #include "hast_checksum.h" -#endif #include "hast_compression.h" #include "hast_proto.h" @@ -68,9 +66,7 @@ struct hast_pipe_stage { static struct hast_pipe_stage pipeline[] = { { "compression", compression_send, compression_recv }, -#ifdef HAVE_CRYPTO { "checksum", checksum_send, checksum_recv } -#endif }; /* Modified: projects/ipsec/sbin/ifconfig/ifieee80211.c ============================================================================== --- projects/ipsec/sbin/ifconfig/ifieee80211.c Mon Feb 6 03:29:50 2017 (r313312) +++ projects/ipsec/sbin/ifconfig/ifieee80211.c Mon Feb 6 04:30:18 2017 (r313313) @@ -5594,12 +5594,12 @@ static struct cmd ieee80211_cmds[] = { DEF_CMD_ARG("bgscanidle", set80211bgscanidle), DEF_CMD_ARG("bgscanintvl", set80211bgscanintvl), DEF_CMD_ARG("scanvalid", set80211scanvalid), - DEF_CMD("quiet", 1, set80211quiet), - DEF_CMD("-quiet", 0, set80211quiet), - DEF_CMD_ARG("quiet_count", set80211quietcount), - DEF_CMD_ARG("quiet_period", set80211quietperiod), - DEF_CMD_ARG("quiet_dur", set80211quietduration), - DEF_CMD_ARG("quiet_offset", set80211quietoffset), + DEF_CMD("quiet", 1, set80211quiet), + DEF_CMD("-quiet", 0, set80211quiet), + DEF_CMD_ARG("quiet_count", set80211quietcount), + DEF_CMD_ARG("quiet_period", set80211quietperiod), + DEF_CMD_ARG("quiet_duration", set80211quietduration), + DEF_CMD_ARG("quiet_offset", set80211quietoffset), DEF_CMD_ARG("roam:rssi", set80211roamrssi), DEF_CMD_ARG("roam:rate", set80211roamrate), DEF_CMD_ARG("mcastrate", set80211mcastrate), Modified: projects/ipsec/sbin/kldload/kldload.c ============================================================================== --- projects/ipsec/sbin/kldload/kldload.c Mon Feb 6 03:29:50 2017 (r313312) +++ projects/ipsec/sbin/kldload/kldload.c Mon Feb 6 04:30:18 2017 (r313313) @@ -41,9 +41,6 @@ __FBSDID("$FreeBSD$"); #define PATHCTL "kern.module_path" -static int path_check(const char *, int); -static void usage(void); - /* * Check to see if the requested module is specified as a filename with no * path. If so and if a file by the same name exists in the module path, @@ -52,43 +49,37 @@ static void usage(void); static int path_check(const char *kldname, int quiet) { - int mib[5], found; - size_t miblen, pathlen; - char kldpath[MAXPATHLEN]; char *path, *tmppath, *element; struct stat sb; + int mib[5]; + char kldpath[MAXPATHLEN]; + size_t miblen, pathlen; dev_t dev; ino_t ino; + int found; - if (strchr(kldname, '/') != NULL) { + if (strchr(kldname, '/') != NULL) return (0); - } - if (strstr(kldname, ".ko") == NULL) { + if (strstr(kldname, ".ko") == NULL) return (0); - } - if (stat(kldname, &sb) != 0) { + if (stat(kldname, &sb) != 0) return (0); - } found = 0; dev = sb.st_dev; ino = sb.st_ino; miblen = nitems(mib); - if (sysctlnametomib(PATHCTL, mib, &miblen) != 0) { + if (sysctlnametomib(PATHCTL, mib, &miblen) != 0) err(1, "sysctlnametomib(%s)", PATHCTL); - } - if (sysctl(mib, miblen, NULL, &pathlen, NULL, 0) == -1) { + if (sysctl(mib, miblen, NULL, &pathlen, NULL, 0) == -1) err(1, "getting path: sysctl(%s) - size only", PATHCTL); - } path = malloc(pathlen + 1); - if (path == NULL) { + if (path == NULL) err(1, "allocating %lu bytes for the path", (unsigned long)pathlen + 1); - } - if (sysctl(mib, miblen, path, &pathlen, NULL, 0) == -1) { + if (sysctl(mib, miblen, path, &pathlen, NULL, 0) == -1) err(1, "getting path: sysctl(%s)", PATHCTL); - } tmppath = path; while ((element = strsep(&tmppath, ";")) != NULL) { @@ -97,39 +88,36 @@ path_check(const char *kldname, int quie strlcat(kldpath, "/", MAXPATHLEN); } strlcat(kldpath, kldname, MAXPATHLEN); - - if (stat(kldpath, &sb) == -1) { + + if (stat(kldpath, &sb) == -1) continue; - } found = 1; if (sb.st_dev != dev || sb.st_ino != ino) { - if (!quiet) { + if (!quiet) warnx("%s will be loaded from %s, not the " "current directory", kldname, element); - } break; - } else if (sb.st_dev == dev && sb.st_ino == ino) { + } else if (sb.st_dev == dev && sb.st_ino == ino) break; - } } free(path); - + if (!found) { - if (!quiet) { + if (!quiet) warnx("%s is not in the module path", kldname); - } return (-1); } - + return (0); } static void usage(void) { + fprintf(stderr, "usage: kldload [-nqv] file ...\n"); exit(1); } @@ -138,17 +126,17 @@ int main(int argc, char** argv) { int c; + int check_loaded; int errors; int fileid; - int verbose; int quiet; - int check_loaded; + int verbose; errors = 0; verbose = 0; quiet = 0; check_loaded = 0; - + while ((c = getopt(argc, argv, "nqv")) != -1) { switch (c) { case 'q': @@ -204,9 +192,8 @@ main(int argc, char** argv) printf("Loaded %s, id=%d\n", argv[0], fileid); } - } else { + } else errors++; - } argv++; } Modified: projects/ipsec/sbin/nvmecontrol/Makefile ============================================================================== --- projects/ipsec/sbin/nvmecontrol/Makefile Mon Feb 6 03:29:50 2017 (r313312) +++ projects/ipsec/sbin/nvmecontrol/Makefile Mon Feb 6 04:30:18 2017 (r313313) @@ -3,7 +3,7 @@ PACKAGE=runtime PROG= nvmecontrol SRCS= nvmecontrol.c devlist.c firmware.c identify.c logpage.c \ - perftest.c reset.c nvme_util.c power.c + perftest.c reset.c nvme_util.c power.c wdc.c MAN= nvmecontrol.8 .PATH: ${.CURDIR}/../../sys/dev/nvme Modified: projects/ipsec/sbin/nvmecontrol/firmware.c ============================================================================== --- projects/ipsec/sbin/nvmecontrol/firmware.c Mon Feb 6 03:29:50 2017 (r313312) +++ projects/ipsec/sbin/nvmecontrol/firmware.c Mon Feb 6 04:30:18 2017 (r313313) @@ -114,7 +114,7 @@ update_firmware(int fd, uint8_t *payload off = 0; resid = payload_size; - if ((chunk = aligned_alloc(NVME_MAX_XFER_SIZE, PAGE_SIZE)) == NULL) + if ((chunk = aligned_alloc(PAGE_SIZE, NVME_MAX_XFER_SIZE)) == NULL) errx(1, "unable to malloc %d bytes", NVME_MAX_XFER_SIZE); while (resid > 0) { Modified: projects/ipsec/sbin/nvmecontrol/logpage.c ============================================================================== --- projects/ipsec/sbin/nvmecontrol/logpage.c Mon Feb 6 03:29:50 2017 (r313312) +++ projects/ipsec/sbin/nvmecontrol/logpage.c Mon Feb 6 04:30:18 2017 (r313313) @@ -74,6 +74,12 @@ kv_lookup(const struct kv_name *kv, size return bad; } +static void +print_bin(void *data, uint32_t length) +{ + write(STDOUT_FILENO, data, length); +} + /* * 128-bit integer augments to standard values. On i386 this * doesn't exist, so we use 64-bit values. The 128-bit counters @@ -846,6 +852,8 @@ static struct logpage_function { sizeof(struct nvme_firmware_page)}, {HGST_INFO_LOG, "hgst", print_hgst_info_log, DEFAULT_SIZE}, + {HGST_INFO_LOG, "wdc", print_hgst_info_log, + DEFAULT_SIZE}, {INTEL_LOG_TEMP_STATS, "intel", print_intel_temp_stats, sizeof(struct intel_log_temp_stats)}, {INTEL_LOG_READ_LAT_LOG, "intel", print_intel_read_lat_log, @@ -870,7 +878,7 @@ logpage(int argc, char *argv[]) { int fd, nsid; int log_page = 0, pageflag = false; - int hexflag = false, ns_specified; + int binflag = false, hexflag = false, ns_specified; char ch, *p; char cname[64]; uint32_t size; @@ -880,8 +888,11 @@ logpage(int argc, char *argv[]) struct nvme_controller_data cdata; print_fn_t print_fn; - while ((ch = getopt(argc, argv, "p:xv:")) != -1) { + while ((ch = getopt(argc, argv, "bp:xv:")) != -1) { switch (ch) { + case 'b': + binflag = true; + break; case 'p': /* TODO: Add human-readable ASCII page IDs */ log_page = strtol(optarg, &p, 0); @@ -940,7 +951,9 @@ logpage(int argc, char *argv[]) print_fn = print_hex; size = DEFAULT_SIZE; - if (!hexflag) { + if (binflag) + print_fn = print_bin; + if (!binflag && !hexflag) { /* * See if there is a pretty print function for the specified log * page. If one isn't found, we just revert to the default Modified: projects/ipsec/sbin/nvmecontrol/nvmecontrol.8 ============================================================================== --- projects/ipsec/sbin/nvmecontrol/nvmecontrol.8 Mon Feb 6 03:29:50 2017 (r313312) +++ projects/ipsec/sbin/nvmecontrol/nvmecontrol.8 Mon Feb 6 04:30:18 2017 (r313313) @@ -33,7 +33,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 10, 2016 +.Dd February 4, 2017 .Dt NVMECONTROL 8 .Os .Sh NAME @@ -62,6 +62,8 @@ .Ic logpage .Aq Fl p Ar page_id .Op Fl x +.Op Fl v Ar vendor-string +.Op Fl b .Aq device id .Aq namespace id .Nm @@ -74,10 +76,48 @@ .Ic power .Op Fl l .Op Fl p power_state -.Op fl w workload_hint +.Op Fl w workload_hint +.Nm +.Ic wdc cap-diag +.Op Fl o path_template +.Aq device id +.Nm +.Ic wdc drive-log +.Op Fl o path_template +.Aq device id +.Nm +.Ic wdc get-crash-dump +.Op Fl o path_template +.Aq device id +.\" .Nm +.\" .Ic wdc purge +.\" .Aq device id +.\" .Nm +.\" .Ic wdc purge-monitor +.\" .Aq device id .Sh DESCRIPTION NVM Express (NVMe) is a storage protocol standard, for SSDs and other high-speed storage devices over PCI Express. +.Pp +.Ss logpage +The logpage command knows how to print log pages of various types. +It also knows about vendor specific log pages from hgst/wdc and intel. +Page 0xc1 for hgst/wdc contains the advanced smart information about +the drive. +Page 0xc1 is read latency stats for intel. +Page 0xc2 is write latency stats for intel. +Page 0xc5 is temperature stats for intel. +Page 0xca is advanced smart information for intel. +.Ss wdc +The various wdc command retrieve log data from the wdc/hgst drives. +The +.Fl o +flag specifies a path template to use to output the files. +Each file takes the path template (which defaults to nothing), appends +the drive's serial number and the type of dump it is followed +by .bin. +These logs must be sent to the vendor for analysis. +This tool only provides a way to extract them. .Sh EXAMPLES .Dl nvmecontrol devlist .Pp @@ -108,10 +148,21 @@ Display a human-readable summary of the Log pages defined by the NVMe specification include Error Information Log (ID=1), SMART/Health Information Log (ID=2), and Firmware Slot Log (ID=3). .Pp +.Dl nvmecontrol logpage -p 0xc1 -v wdc nvme0 +.Pp +Display a human-readable summary of the nvme0's wdc-specific advanced +SMART data. +.Pp .Dl nvmecontrol logpage -p 1 -x nvme0 .Pp Display a hexadecimal dump of the nvme0 controller's Error Information Log. .Pp +.Dl nvmecontrol logpage -p 0xcb -b nvme0 > /tmp/page-cb.bin +.Pp +Print the contents of vendor specific page 0xcb as binary data on +standard out. +Redirect it to a temporary file. +.Pp .Dl nvmecontrol firmware -s 2 -f /tmp/nvme_firmware nvme0 .Pp Download the firmware image contained in "/tmp/nvme_firmware" to slot 2 of the Modified: projects/ipsec/sbin/nvmecontrol/nvmecontrol.c ============================================================================== --- projects/ipsec/sbin/nvmecontrol/nvmecontrol.c Mon Feb 6 03:29:50 2017 (r313312) +++ projects/ipsec/sbin/nvmecontrol/nvmecontrol.c Mon Feb 6 04:30:18 2017 (r313313) @@ -45,13 +45,8 @@ __FBSDID("$FreeBSD$"); #include "nvmecontrol.h" -typedef void (*nvme_fn_t)(int argc, char *argv[]); -static struct nvme_function { - const char *name; - nvme_fn_t fn; - const char *usage; -} funcs[] = { +static struct nvme_function funcs[] = { {"devlist", devlist, DEVLIST_USAGE}, {"identify", identify, IDENTIFY_USAGE}, {"perftest", perftest, PERFTEST_USAGE}, @@ -59,15 +54,14 @@ static struct nvme_function { {"logpage", logpage, LOGPAGE_USAGE}, {"firmware", firmware, FIRMWARE_USAGE}, {"power", power, POWER_USAGE}, + {"wdc", wdc, WDC_USAGE}, {NULL, NULL, NULL}, }; -static void -usage(void) +void +gen_usage(struct nvme_function *f) { - struct nvme_function *f; - f = funcs; fprintf(stderr, "usage:\n"); while (f->name != NULL) { fprintf(stderr, "%s", f->usage); @@ -76,6 +70,21 @@ usage(void) exit(1); } +void +dispatch(int argc, char *argv[], struct nvme_function *tbl) +{ + struct nvme_function *f = tbl; + + while (f->name != NULL) { + if (strcmp(argv[1], f->name) == 0) + f->fn(argc-1, &argv[1]); + f++; + } *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201702060430.v164UIRt059014>