Browse Source

Merge remote-tracking branch 'origin/freebsd/current/master' into hardened/current/master

Conflicts:
	contrib/telnet/telnet/commands.c (unresolved)
	share/mk/src.opts.mk (unresolved)
hardened/current/master
Shawn Webb 11 months ago
parent
commit
e1600a2991
Signed by: Shawn Webb <shawn.webb@hardenedbsd.org> GPG Key ID: FF2E67A277F8E1FA
100 changed files with 3339 additions and 890 deletions
  1. +2
    -2
      contrib/binutils/binutils/doc/binutils.texi
  2. +3
    -0
      contrib/binutils/gas/doc/as.texinfo
  3. +13
    -0
      contrib/elftoolchain/addr2line/addr2line.c
  4. +98
    -14
      contrib/elftoolchain/readelf/readelf.c
  5. +43
    -20
      contrib/elftoolchain/size/size.c
  6. +5
    -0
      contrib/telnet/telnet/commands.c
  7. +4
    -0
      gnu/usr.bin/binutils/as/as.1
  8. +4
    -4
      gnu/usr.bin/binutils/objdump/objdump.1
  9. +1
    -0
      lib/libc/gen/Makefile.inc
  10. +1
    -1
      lib/libc/gen/daemon.3
  11. +2
    -1
      sbin/nvmecontrol/Makefile
  12. +3
    -3
      sbin/nvmecontrol/devlist.c
  13. +10
    -6
      sbin/nvmecontrol/firmware.c
  14. +6
    -16
      sbin/nvmecontrol/format.c
  15. +31
    -43
      sbin/nvmecontrol/identify.c
  16. +1
    -0
      sbin/nvmecontrol/identify_ext.c
  17. +286
    -19
      sbin/nvmecontrol/logpage.c
  18. +1
    -1
      sbin/nvmecontrol/ns.c
  19. +80
    -0
      sbin/nvmecontrol/nsid.c
  20. +24
    -3
      sbin/nvmecontrol/nvmecontrol.8
  21. +9
    -29
      sbin/nvmecontrol/nvmecontrol.c
  22. +3
    -3
      sbin/nvmecontrol/nvmecontrol.h
  23. +2
    -1
      share/man/man4/mxge.4
  24. +3
    -0
      share/mk/src.opts.mk
  25. +32
    -18
      sys/amd64/amd64/pmap.c
  26. +24
    -13
      sys/arm64/arm64/pmap.c
  27. +2
    -2
      sys/arm64/include/pte.h
  28. +3
    -1
      sys/conf/files
  29. +4
    -0
      sys/conf/newvers.sh
  30. +0
    -49
      sys/contrib/dev/acpica/changes.txt
  31. +0
    -16
      sys/contrib/dev/acpica/compiler/asldefine.h
  32. +0
    -15
      sys/contrib/dev/acpica/compiler/aslglobal.h
  33. +4
    -55
      sys/contrib/dev/acpica/compiler/aslload.c
  34. +1
    -2
      sys/contrib/dev/acpica/compiler/aslmessages.c
  35. +0
    -1
      sys/contrib/dev/acpica/compiler/aslmessages.h
  36. +6
    -0
      sys/contrib/dev/acpica/compiler/aslstubs.c
  37. +9
    -9
      sys/contrib/dev/acpica/compiler/aslsupport.l
  38. +1
    -1
      sys/contrib/dev/acpica/components/dispatcher/dsinit.c
  39. +1
    -8
      sys/contrib/dev/acpica/components/events/evgpe.c
  40. +1
    -1
      sys/contrib/dev/acpica/components/events/evgpeblk.c
  41. +1
    -1
      sys/contrib/dev/acpica/components/events/evxface.c
  42. +1
    -1
      sys/contrib/dev/acpica/components/events/evxfgpe.c
  43. +6
    -6
      sys/contrib/dev/acpica/components/executer/exconfig.c
  44. +11
    -46
      sys/contrib/dev/acpica/components/namespace/nsaccess.c
  45. +210
    -0
      sys/contrib/dev/acpica/components/namespace/nseval.c
  46. +31
    -20
      sys/contrib/dev/acpica/components/namespace/nsinit.c
  47. +12
    -0
      sys/contrib/dev/acpica/components/namespace/nsload.c
  48. +13
    -0
      sys/contrib/dev/acpica/components/namespace/nsutils.c
  49. +13
    -0
      sys/contrib/dev/acpica/components/tables/tbdata.c
  50. +0
    -7
      sys/contrib/dev/acpica/components/tables/tbxfload.c
  51. +1
    -0
      sys/contrib/dev/acpica/components/utilities/utinit.c
  52. +12
    -6
      sys/contrib/dev/acpica/components/utilities/utxfinit.c
  53. +1
    -2
      sys/contrib/dev/acpica/include/acevents.h
  54. +1
    -0
      sys/contrib/dev/acpica/include/acglobal.h
  55. +4
    -0
      sys/contrib/dev/acpica/include/acnamesp.h
  56. +1
    -1
      sys/contrib/dev/acpica/include/acpixf.h
  57. +14
    -14
      sys/contrib/ipfilter/netinet/ip_fil_freebsd.c
  58. +4
    -1
      sys/dev/acpica/acpi_resource.c
  59. +1
    -0
      sys/dev/cxgbe/adapter.h
  60. +1
    -0
      sys/dev/cxgbe/t4_main.c
  61. +31
    -0
      sys/dev/cxgbe/t4_sched.c
  62. +47
    -1
      sys/dev/mlx5/mlx5_en/mlx5_en_main.c
  63. +4
    -19
      sys/dev/mxge/if_mxge.c
  64. +225
    -35
      sys/dev/nvme/nvme.h
  65. +33
    -1
      sys/dev/nvme/nvme_ctrlr.c
  66. +15
    -0
      sys/dev/nvme/nvme_ns.c
  67. +34
    -0
      sys/dev/nvme/nvme_qpair.c
  68. +7
    -0
      sys/fs/unionfs/union_subr.c
  69. +28
    -0
      sys/fs/unionfs/union_vnops.c
  70. +19
    -5
      sys/i386/i386/pmap.c
  71. +5
    -3
      sys/i386/i386/pmap_base.c
  72. +4
    -1
      sys/i386/include/pmap_base.h
  73. +2
    -2
      sys/kern/imgact_elf.c
  74. +1
    -1
      sys/kern/kern_exec.c
  75. +5
    -7
      sys/kern/kern_umtx.c
  76. +11
    -8
      sys/kern/subr_witness.c
  77. +2
    -0
      sys/modules/mxge/mxge/Makefile
  78. +18
    -0
      sys/net/if_dead.c
  79. +17
    -0
      sys/net/if_lagg.c
  80. +1
    -1
      sys/net/if_spppsubr.c
  81. +30
    -1
      sys/net/if_var.h
  82. +7
    -2
      sys/net/iflib.c
  83. +112
    -42
      sys/netinet/in_pcb.c
  84. +6
    -6
      sys/netinet/in_pcb.h
  85. +4
    -10
      sys/netinet/sctp_asconf.c
  86. +2
    -5
      sys/netinet/sctp_os_bsd.h
  87. +83
    -82
      sys/netinet/sctp_output.c
  88. +2
    -6
      sys/netinet/sctp_pcb.c
  89. +1
    -1
      sys/netinet/sctp_pcb.h
  90. +4
    -6
      sys/netinet/sctp_usrreq.c
  91. +1238
    -0
      sys/netinet/tcp_ratelimit.c
  92. +141
    -0
      sys/netinet/tcp_ratelimit.h
  93. +23
    -23
      sys/netinet/tcp_usrreq.c
  94. +84
    -93
      sys/netinet6/frag6.c
  95. +14
    -14
      sys/netinet6/icmp6.c
  96. +3
    -3
      sys/netinet6/in6_mcast.c
  97. +8
    -8
      sys/netinet6/in6_pcb.c
  98. +1
    -1
      sys/netinet6/in6_pcb.h
  99. +0
    -35
      sys/netinet6/in6_proto.c
  100. +6
    -6
      sys/netinet6/in6_src.c

+ 2
- 2
contrib/binutils/binutils/doc/binutils.texi View File

@@ -1624,8 +1624,8 @@ program to compile and work.
specify archives, @command{objdump} shows information on each of the member
object files.

@command{objdump} will be removed from a future version of the
FreeBSD base system. Users who require @command{objdump} are advised
GNU @command{objdump} will be removed from a future version of the
FreeBSD base system. Users who require GNU @command{objdump} are advised
to install the binutils port or package.

@c man end

+ 3
- 0
contrib/binutils/gas/doc/as.texinfo View File

@@ -1295,6 +1295,9 @@ computer-readable series of instructions. Different versions of
@section The GNU Assembler

@c man begin DESCRIPTION
@sc{gnu} @command{as} will be removed from a future version of the
FreeBSD base system. Users who require
@sc{gnu} @command{as} are advised to install the binutils port or package.

@sc{gnu} @command{as} is really a family of assemblers.
@ifclear GENERIC

+ 13
- 0
contrib/elftoolchain/addr2line/addr2line.c View File

@@ -25,6 +25,8 @@
*/

#include <sys/param.h>

#include <capsicum_helpers.h>
#include <dwarf.h>
#include <err.h>
#include <fcntl.h>
@@ -649,6 +651,7 @@ find_section_base(const char *exe, Elf *e, const char *section)
int
main(int argc, char **argv)
{
cap_rights_t rights;
Elf *e;
Dwarf_Debug dbg;
Dwarf_Error de;
@@ -706,6 +709,16 @@ main(int argc, char **argv)
if ((fd = open(exe, O_RDONLY)) < 0)
err(EXIT_FAILURE, "%s", exe);

if (caph_rights_limit(fd, cap_rights_init(&rights, CAP_FSTAT,
CAP_MMAP_R)) < 0)
errx(EXIT_FAILURE, "caph_rights_limit");

caph_cache_catpages();
if (caph_limit_stdio() < 0)
errx(EXIT_FAILURE, "failed to limit stdio rights");
if (caph_enter() < 0)
errx(EXIT_FAILURE, "failed to enter capability mode");

if (dwarf_init(fd, DW_DLC_READ, NULL, NULL, &dbg, &de))
errx(EXIT_FAILURE, "dwarf_init: %s", dwarf_errmsg(de));


+ 98
- 14
contrib/elftoolchain/readelf/readelf.c View File

@@ -26,8 +26,10 @@

#include <sys/param.h>
#include <sys/queue.h>

#include <ar.h>
#include <assert.h>
#include <capsicum_helpers.h>
#include <ctype.h>
#include <dwarf.h>
#include <err.h>
@@ -45,6 +47,9 @@
#include <time.h>
#include <unistd.h>

#include <libcasper.h>
#include <casper/cap_fileargs.h>

#include "_elftc.h"

ELFTC_VCSID("$Id: readelf.c 3649 2018-11-24 03:26:23Z emaste $");
@@ -322,11 +327,13 @@ static void dump_mips_specific_info(struct readelf *re);
static void dump_notes(struct readelf *re);
static void dump_notes_content(struct readelf *re, const char *buf, size_t sz,
off_t off);
static void dump_notes_data(const char *name, uint32_t type, const char *buf,
size_t sz);
static void dump_notes_data(struct readelf *re, const char *name,
uint32_t type, const char *buf, size_t sz);
static void dump_svr4_hash(struct section *s);
static void dump_svr4_hash64(struct readelf *re, struct section *s);
static void dump_gnu_hash(struct readelf *re, struct section *s);
static void dump_gnu_property_type_0(struct readelf *re, const char *buf,
size_t sz);
static void dump_hash(struct readelf *re);
static void dump_phdr(struct readelf *re);
static void dump_ppc_attributes(uint8_t *p, uint8_t *pe);
@@ -3517,6 +3524,62 @@ dump_gnu_hash(struct readelf *re, struct section *s)
free(bl);
}

static struct flag_desc gnu_property_x86_feature_1_and_bits[] = {
{ GNU_PROPERTY_X86_FEATURE_1_IBT, "IBT" },
{ GNU_PROPERTY_X86_FEATURE_1_SHSTK, "SHSTK" },
{ 0, NULL }
};

static void
dump_gnu_property_type_0(struct readelf *re, const char *buf, size_t sz)
{
size_t i;
uint32_t type, prop_sz;

printf(" Properties: ");
while (sz > 0) {
if (sz < 8)
goto bad;

type = *(const uint32_t *)(const void *)buf;
prop_sz = *(const uint32_t *)(const void *)(buf + 4);
buf += 8;
sz -= 8;

if (prop_sz > sz)
goto bad;

if (type >= GNU_PROPERTY_LOPROC &&
type <= GNU_PROPERTY_HIPROC) {
if (re->ehdr.e_machine != EM_X86_64) {
printf("machine type %x unknown\n",
re->ehdr.e_machine);
goto unknown;
}
switch (type) {
case GNU_PROPERTY_X86_FEATURE_1_AND:
printf("x86 features:");
if (prop_sz != 4)
goto bad;
dump_flags(gnu_property_x86_feature_1_and_bits,
*(const uint32_t *)(const void *)buf);
break;
}
}

buf += roundup2(prop_sz, 8);
sz -= roundup2(prop_sz, 8);
}
return;
bad:
printf("corrupt GNU property\n");
unknown:
printf("remaining description data:");
for (i = 0; i < sz; i++)
printf(" %02x", (unsigned char)buf[i]);
printf("\n");
}

static void
dump_hash(struct readelf *re)
{
@@ -3608,7 +3671,8 @@ static struct flag_desc note_feature_ctl_flags[] = {
};

static void
dump_notes_data(const char *name, uint32_t type, const char *buf, size_t sz)
dump_notes_data(struct readelf *re, const char *name, uint32_t type,
const char *buf, size_t sz)
{
size_t i;
const uint32_t *ubuf;
@@ -3640,6 +3704,12 @@ dump_notes_data(const char *name, uint32_t type, const char *buf, size_t sz)
dump_flags(note_feature_ctl_flags, ubuf[0]);
return;
}
} else if (strcmp(name, "GNU") == 0) {
switch (type) {
case NT_GNU_PROPERTY_TYPE_0:
dump_gnu_property_type_0(re, buf, sz);
return;
}
}
unknown:
printf(" description data:");
@@ -3684,7 +3754,7 @@ dump_notes_content(struct readelf *re, const char *buf, size_t sz, off_t off)
printf(" %-13s %#010jx", name, (uintmax_t) note->n_descsz);
printf(" %s\n", note_type(name, re->ehdr.e_type,
note->n_type));
dump_notes_data(name, note->n_type, buf, note->n_descsz);
dump_notes_data(re, name, note->n_type, buf, note->n_descsz);
buf += roundup2(note->n_descsz, 4);
}
}
@@ -7149,15 +7219,8 @@ process_members:
}

static void
dump_object(struct readelf *re)
dump_object(struct readelf *re, int fd)
{
int fd;

if ((fd = open(re->filename, O_RDONLY)) == -1) {
warn("open %s failed", re->filename);
return;
}

if ((re->flags & DISPLAY_FILENAME) != 0)
printf("\nFile: %s\n", re->filename);

@@ -7524,9 +7587,11 @@ readelf_usage(int status)
int
main(int argc, char **argv)
{
cap_rights_t rights;
fileargs_t *fa;
struct readelf *re, re_storage;
unsigned long si;
int opt, i;
int fd, opt, i;
char *ep;

re = &re_storage;
@@ -7649,9 +7714,28 @@ main(int argc, char **argv)
errx(EXIT_FAILURE, "ELF library initialization failed: %s",
elf_errmsg(-1));

cap_rights_init(&rights, CAP_FCNTL, CAP_FSTAT, CAP_MMAP_R, CAP_SEEK);
fa = fileargs_init(argc, argv, O_RDONLY, 0, &rights, FA_OPEN);
if (fa == NULL)
err(1, "Unable to initialize casper fileargs");

caph_cache_catpages();
if (caph_limit_stdio() < 0) {
fileargs_free(fa);
err(1, "Unable to limit stdio rights");
}
if (caph_enter_casper() < 0) {
fileargs_free(fa);
err(1, "Unable to enter capability mode");
}

for (i = 0; i < argc; i++) {
re->filename = argv[i];
dump_object(re);
fd = fileargs_open(fa, re->filename);
if (fd < 0)
warn("open %s failed", re->filename);
else
dump_object(re, fd);
}

exit(EXIT_SUCCESS);

+ 43
- 20
contrib/elftoolchain/size/size.c View File

@@ -25,6 +25,7 @@
*/

#include <assert.h>
#include <capsicum_helpers.h>
#include <err.h>
#include <fcntl.h>
#include <gelf.h>
@@ -36,6 +37,9 @@
#include <string.h>
#include <unistd.h>

#include <libcasper.h>
#include <casper/cap_fileargs.h>

#include "_elftc.h"

ELFTC_VCSID("$Id: size.c 3458 2016-05-09 15:01:25Z emaste $");
@@ -46,7 +50,6 @@ ELFTC_VCSID("$Id: size.c 3458 2016-05-09 15:01:25Z emaste $");

enum return_code {
RETURN_OK,
RETURN_NOINPUT,
RETURN_DATAERR,
RETURN_USAGE
};
@@ -68,7 +71,6 @@ static int show_totals;
static int size_option;
static enum radix_style radix = RADIX_DECIMAL;
static enum output_style style = STYLE_BERKELEY;
static const char *default_args[2] = { "a.out", NULL };

static struct {
int row;
@@ -97,7 +99,7 @@ static void berkeley_header(void);
static void berkeley_totals(void);
static int handle_core(char const *, Elf *elf, GElf_Ehdr *);
static void handle_core_note(Elf *, GElf_Ehdr *, GElf_Phdr *, char **);
static int handle_elf(char const *);
static int handle_elf(int, char const *);
static void handle_phdr(Elf *, GElf_Ehdr *, GElf_Phdr *, uint32_t,
const char *);
static void show_version(void);
@@ -119,8 +121,11 @@ static void tbl_flush(void);
int
main(int argc, char **argv)
{
int ch, r, rc;
const char **files, *fn;
cap_rights_t rights;
fileargs_t *fa;
int ch, fd, r, rc;
const char *fn;
char *defaultfn;

rc = RETURN_OK;

@@ -193,21 +198,45 @@ main(int argc, char **argv)
argc -= optind;
argv += optind;

files = (argc == 0) ? default_args : (void *) argv;
if (argc == 0) {
defaultfn = strdup("a.out");
if (defaultfn == NULL)
err(EXIT_FAILURE, "strdup");
argc = 1;
argv = &defaultfn;
} else {
defaultfn = NULL;
}

while ((fn = *files) != NULL) {
rc = handle_elf(fn);
cap_rights_init(&rights, CAP_FSTAT, CAP_MMAP_R);
fa = fileargs_init(argc, argv, O_RDONLY, 0, &rights, FA_OPEN);
if (fa == NULL)
err(EXIT_FAILURE, "failed to initialize fileargs");

caph_cache_catpages();
if (caph_limit_stdio() < 0)
err(EXIT_FAILURE, "failed to limit stdio rights");
if (caph_enter_casper() < 0)
err(EXIT_FAILURE, "failed to enter capability mode");

for (; argc > 0; argc--, argv++) {
fn = argv[0];
fd = fileargs_open(fa, fn);
if (fd < 0) {
warn("%s: Failed to open", fn);
continue;
}
rc = handle_elf(fd, fn);
if (rc != RETURN_OK)
warnx(rc == RETURN_NOINPUT ?
"'%s': No such file" :
"%s: File format not recognized", fn);
files++;
warnx("%s: File format not recognized", fn);
}
if (style == STYLE_BERKELEY) {
if (show_totals)
berkeley_totals();
tbl_flush();
}
fileargs_free(fa);
free(defaultfn);
return (rc);
}

@@ -582,7 +611,7 @@ handle_core(char const *name, Elf *elf, GElf_Ehdr *elfhdr)
* or the size of the text, data, bss sections will be printed out.
*/
static int
handle_elf(char const *name)
handle_elf(int fd, const char *name)
{
GElf_Ehdr elfhdr;
GElf_Shdr shdr;
@@ -590,13 +619,7 @@ handle_elf(char const *name)
Elf_Arhdr *arhdr;
Elf_Scn *scn;
Elf_Cmd elf_cmd;
int exit_code, fd;

if (name == NULL)
return (RETURN_NOINPUT);

if ((fd = open(name, O_RDONLY, 0)) < 0)
return (RETURN_NOINPUT);
int exit_code;

elf_cmd = ELF_C_READ;
elf1 = elf_begin(fd, elf_cmd, NULL);

+ 5
- 0
contrib/telnet/telnet/commands.c View File

@@ -1659,10 +1659,15 @@ env_init(void)

gethostname(hbuf, sizeof(hbuf));
hbuf[sizeof(hbuf)-1] = '\0';
<<<<<<< HEAD
cp = NULL;
asprintf(&cp, "%s%s", hbuf, cp2);
if (cp == NULL)
errx(EX_OSERR, "Unable to allocate memory.");
=======
asprintf(&cp, "%s%s", hbuf, cp2);
assert(cp != NULL);
>>>>>>> origin/freebsd/current/master
free(ep->value);
ep->value = (unsigned char *)cp;
}

+ 4
- 0
gnu/usr.bin/binutils/as/as.1 View File

@@ -293,6 +293,10 @@ as [\fB\-a\fR[\fBcdhlns\fR][=\fIfile\fR]] [\fB\-\-alternate\fR] [\fB\-D\fR]
[\fB\-\-rename\-section\fR \fIoldname\fR=\fInewname\fR]
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
\&\s-1GNU\s0 \fBas\fR will be removed from a future version of the
FreeBSD base system. Users who require
\&\s-1GNU\s0 \fBas\fR are advised to install the binutils port or package.
.PP
\&\s-1GNU\s0 \fBas\fR is really a family of assemblers.
If you use (or have used) the \s-1GNU\s0 assembler on one architecture, you
should find a fairly similar environment when you use it on another

+ 4
- 4
gnu/usr.bin/binutils/objdump/objdump.1 View File

@@ -179,13 +179,13 @@ information is mostly useful to programmers who are working on the
compilation tools, as opposed to programmers who just want their
program to compile and work.
.PP
\&\fBobjdump\fR will be removed from a future version of the
FreeBSD base system. Users who require \&\fBobjdump\fR are advised
to install the binutils port or package.
.PP
\&\fIobjfile\fR... are the object files to be examined. When you
specify archives, \fBobjdump\fR shows information on each of the member
object files.
.PP
GNU \&\fBobjdump\fR will be removed from a future version of the
FreeBSD base system. Users who require GNU \&\fBobjdump\fR are advised
to install the binutils port or package.
.SH "OPTIONS"
.IX Header "OPTIONS"
The long and short forms of options, shown here as alternatives, are

+ 1
- 0
lib/libc/gen/Makefile.inc View File

@@ -325,6 +325,7 @@ MLINKS+=arc4random.3 arc4random_buf.3 \
arc4random.3 arc4random_uniform.3
MLINKS+=auxv.3 elf_aux_info.3
MLINKS+=ctermid.3 ctermid_r.3
MLINKS+=daemon.3 daemonfd.3
MLINKS+=devname.3 devname_r.3
MLINKS+=devname.3 fdevname.3
MLINKS+=devname.3 fdevname_r.3

+ 1
- 1
lib/libc/gen/daemon.3 View File

@@ -93,7 +93,7 @@ function may fail and set
.Va errno
for any of the errors specified for the library functions
.Xr fork 2
.Xr open 2,
.Xr open 2 ,
and
.Xr setsid 2 .
.Sh SEE ALSO

+ 2
- 1
sbin/nvmecontrol/Makefile View File

@@ -3,7 +3,8 @@
PACKAGE=runtime
PROG= nvmecontrol
SRCS= comnd.c nvmecontrol.c
SRCS+= devlist.c firmware.c format.c identify.c logpage.c ns.c perftest.c power.c reset.c
SRCS+= devlist.c firmware.c format.c identify.c logpage.c ns.c nsid.c
SRCS+= perftest.c power.c reset.c
#SRCS+= passthru.c
SRCS+= identify_ext.c nvme_util.c nc_util.c
MAN= nvmecontrol.8

+ 3
- 3
sbin/nvmecontrol/devlist.c View File

@@ -107,11 +107,11 @@ devlist(const struct cmd *f, int argc, char *argv[])
printf("%6s: %s\n", name, mn);

for (i = 0; i < cdata.nn; i++) {
sprintf(name, "%s%d%s%d", NVME_CTRLR_PREFIX, ctrlr,
NVME_NS_PREFIX, i+1);
read_namespace_data(fd, i+1, &nsdata);
read_namespace_data(fd, i + 1, &nsdata);
if (nsdata.nsze == 0)
continue;
sprintf(name, "%s%d%s%d", NVME_CTRLR_PREFIX, ctrlr,
NVME_NS_PREFIX, i + 1);
printf(" %10s (%lldMB)\n",
name,
nsdata.nsze *

+ 10
- 6
sbin/nvmecontrol/firmware.c View File

@@ -104,7 +104,7 @@ slot_has_valid_firmware(int fd, int slot)
int has_fw = false;

read_logpage(fd, NVME_LOG_FIRMWARE_SLOT,
NVME_GLOBAL_NAMESPACE_TAG, &fw, sizeof(fw));
NVME_GLOBAL_NAMESPACE_TAG, 0, 0, 0, &fw, sizeof(fw));

if (fw.revision[slot-1] != 0LLU)
has_fw = true;
@@ -224,7 +224,7 @@ firmware(const struct cmd *f, int argc, char *argv[])
int activate_action, reboot_required;
char prompt[64];
void *buf = NULL;
int32_t size = 0;
int32_t size = 0, nsid;
uint16_t oacs_fw;
uint8_t fw_slot1_ro, fw_num_slots;
struct nvme_controller_data cdata;
@@ -253,10 +253,6 @@ firmware(const struct cmd *f, int argc, char *argv[])
arg_help(argc, argv, f);
}

/* Check that a controller (and not a namespace) was specified. */
if (strstr(opt.dev, NVME_NS_PREFIX) != NULL)
arg_help(argc, argv, f);

if (opt.activate && opt.fw_img == NULL && opt.slot == 0) {
fprintf(stderr,
"Slot number to activate not specified.\n");
@@ -264,6 +260,14 @@ firmware(const struct cmd *f, int argc, char *argv[])
}

open_dev(opt.dev, &fd, 1, 1);

/* Check that a controller (and not a namespace) was specified. */
get_nsid(fd, NULL, &nsid);
if (nsid != 0) {
close(fd);
arg_help(argc, argv, f);
}

read_controller_data(fd, &cdata);

oacs_fw = (cdata.oacs >> NVME_CTRLR_DATA_OACS_FIRMWARE_SHIFT) &

+ 6
- 16
sbin/nvmecontrol/format.c View File

@@ -1,8 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (C) 2018 Alexander Motin <mav@FreeBSD.org>
* All rights reserved.
* Copyright (C) 2018-2019 Alexander Motin <mav@FreeBSD.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -117,7 +116,7 @@ format(const struct cmd *f, int argc, char *argv[])
struct nvme_controller_data cd;
struct nvme_namespace_data nsd;
struct nvme_pt_command pt;
char path[64];
char *path;
const char *target;
uint32_t nsid;
int lbaf, ms, pi, pil, ses, fd;
@@ -125,7 +124,7 @@ format(const struct cmd *f, int argc, char *argv[])
if (arg_parse(argc, argv, f))
return;

if (opt.Eflag || opt.Cflag || opt.ses != SES_NONE) {
if ((int)opt.Eflag + opt.Cflag + (opt.ses != SES_NONE) > 1) {
fprintf(stderr,
"Only one of -E, -C or -s may be specified\n");
arg_help(argc, argv, f);
@@ -143,18 +142,9 @@ format(const struct cmd *f, int argc, char *argv[])
else
ses = opt.ses;

/*
* Check if the specified device node exists before continuing.
* This is a cleaner check for cases where the correct controller
* is specified, but an invalid namespace on that controller.
*/
open_dev(target, &fd, 1, 1);

/*
* If device node contains "ns", we consider it a namespace,
* otherwise, consider it a controller.
*/
if (strstr(target, NVME_NS_PREFIX) == NULL) {
get_nsid(fd, &path, &nsid);
if (nsid == 0) {
nsid = NVME_GLOBAL_NAMESPACE_TAG;
} else {
/*
@@ -164,9 +154,9 @@ format(const struct cmd *f, int argc, char *argv[])
* string to get the controller substring and namespace ID.
*/
close(fd);
parse_ns_str(target, path, &nsid);
open_dev(path, &fd, 1, 1);
}
free(path);

/* Check that controller can execute this command. */
read_controller_data(fd, &cd);

+ 31
- 43
sbin/nvmecontrol/identify.c View File

@@ -3,6 +3,7 @@
*
* Copyright (C) 2012-2013 Intel Corporation
* All rights reserved.
* Copyright (C) 2018-2019 Alexander Motin <mav@FreeBSD.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -44,6 +45,8 @@ __FBSDID("$FreeBSD$");
#include "nvmecontrol.h"
#include "nvmecontrol_ext.h"

#define NONE 0xfffffffeu

static struct options {
bool hex;
bool verbose;
@@ -53,7 +56,7 @@ static struct options {
.hex = false,
.verbose = false,
.dev = NULL,
.nsid = 0,
.nsid = NONE,
};

void
@@ -170,12 +173,11 @@ print_namespace(struct nvme_namespace_data *nsdata)
}

static void
identify_ctrlr(const struct cmd *f, int argc, char *argv[])
identify_ctrlr(int fd)
{
struct nvme_controller_data cdata;
int fd, hexlength;
int hexlength;

open_dev(opt.dev, &fd, 1, 1);
read_controller_data(fd, &cdata);
close(fd);

@@ -189,41 +191,16 @@ identify_ctrlr(const struct cmd *f, int argc, char *argv[])
exit(0);
}

if (opt.verbose) {
fprintf(stderr, "-v not currently supported without -x\n");
arg_help(argc, argv, f);
}

nvme_print_controller(&cdata);
exit(0);
}

static void
identify_ns(const struct cmd *f, int argc, char *argv[])
identify_ns(int fd, uint32_t nsid)
{
struct nvme_namespace_data nsdata;
char path[64];
int fd, hexlength;
uint32_t nsid;
int hexlength;

open_dev(opt.dev, &fd, 1, 1);
if (strstr(opt.dev, NVME_NS_PREFIX) != NULL) {
/*
* Now we know that provided device name is valid, that is
* good for error reporting if specified controller name is
* valid, but namespace ID is not. But we send IDENTIFY
* commands to the controller, not the namespace, since it
* is an admin cmd. The namespace ID will be specified in
* the IDENTIFY command itself. So parse the namespace's
* device node string to get the controller device substring
* and namespace ID.
*/
close(fd);
parse_ns_str(opt.dev, path, &nsid);
open_dev(path, &fd, 1, 1);
} else {
nsid = opt.nsid;
}
read_namespace_data(fd, nsid, &nsdata);
close(fd);

@@ -237,11 +214,6 @@ identify_ns(const struct cmd *f, int argc, char *argv[])
exit(0);
}

if (opt.verbose) {
fprintf(stderr, "-v not currently supported without -x\n");
arg_help(argc, argv, f);
}

print_namespace(&nsdata);
exit(0);
}
@@ -249,16 +221,32 @@ identify_ns(const struct cmd *f, int argc, char *argv[])
static void
identify(const struct cmd *f, int argc, char *argv[])
{
char *path;
int fd;
uint32_t nsid;

arg_parse(argc, argv, f);

/*
* If device node contains "ns" or nsid is specified, we consider
* it a namespace request, otherwise, consider it a controller.
*/
if (strstr(opt.dev, NVME_NS_PREFIX) == NULL && opt.nsid == 0)
identify_ctrlr(f, argc, argv);
open_dev(opt.dev, &fd, 1, 1);
get_nsid(fd, &path, &nsid);
if (nsid != 0) {
/*
* We got namespace device, but we need to send IDENTIFY
* commands to the controller, not the namespace, since it
* is an admin cmd. The namespace ID will be specified in
* the IDENTIFY command itself.
*/
close(fd);
open_dev(path, &fd, 1, 1);
}
free(path);
if (opt.nsid != NONE)
nsid = opt.nsid;

if (nsid == 0)
identify_ctrlr(fd);
else
identify_ns(f, argc, argv);
identify_ns(fd, nsid);
}

static const struct opts identify_opts[] = {

+ 1
- 0
sbin/nvmecontrol/identify_ext.c View File

@@ -3,6 +3,7 @@
*
* Copyright (C) 2012-2013 Intel Corporation
* All rights reserved.
* Copyright (C) 2018-2019 Alexander Motin <mav@FreeBSD.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions

+ 286
- 19
sbin/nvmecontrol/logpage.c View File

@@ -6,6 +6,7 @@
*
* Copyright (C) 2012-2013 Intel Corporation
* All rights reserved.
* Copyright (C) 2018-2019 Alexander Motin <mav@FreeBSD.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -57,12 +58,18 @@ static struct options {
bool binary;
bool hex;
uint32_t page;
uint8_t lsp;
uint16_t lsi;
bool rae;
const char *vendor;
const char *dev;
} opt = {
.binary = false,
.hex = false,
.page = NONE,
.lsp = 0,
.lsi = 0,
.rae = false,
.vendor = NULL,
.dev = NULL,
};
@@ -75,6 +82,12 @@ static const struct opts logpage_opts[] = {
"Dump the log page as hex"),
OPT("page", 'p', arg_uint32, opt, page,
"Page to dump"),
OPT("lsp", 'f', arg_uint8, opt, lsp,
"Log Specific Field"),
OPT("lsi", 'i', arg_uint16, opt, lsp,
"Log Specific Identifier"),
OPT("rae", 'r', arg_none, opt, rae,
"Retain Asynchronous Event"),
OPT("vendor", 'v', arg_string, opt, vendor,
"Vendor specific formatting"),
{ NULL, 0, arg_none, NULL, NULL }
@@ -103,11 +116,38 @@ CMD_COMMAND(logpage_cmd);

static SLIST_HEAD(,logpage_function) logpages;

static int
logpage_compare(struct logpage_function *a, struct logpage_function *b)
{
int c;

if ((a->vendor == NULL) != (b->vendor == NULL))
return (a->vendor == NULL ? -1 : 1);
if (a->vendor != NULL) {
c = strcmp(a->vendor, b->vendor);
if (c != 0)
return (c);
}
return ((int)a->log_page - (int)b->log_page);
}

void
logpage_register(struct logpage_function *p)
{
struct logpage_function *l, *a;

SLIST_INSERT_HEAD(&logpages, p, link);
a = NULL;
l = SLIST_FIRST(&logpages);
while (l != NULL) {
if (logpage_compare(l, p) > 0)
break;
a = l;
l = SLIST_NEXT(l, link);
}
if (a == NULL)
SLIST_INSERT_HEAD(&logpages, p, link);
else
SLIST_INSERT_AFTER(a, p, link);
}

const char *
@@ -150,19 +190,28 @@ get_log_buffer(uint32_t size)
}

void
read_logpage(int fd, uint8_t log_page, uint32_t nsid, void *payload,
uint32_t payload_size)
read_logpage(int fd, uint8_t log_page, uint32_t nsid, uint8_t lsp,
uint16_t lsi, uint8_t rae, void *payload, uint32_t payload_size)
{
struct nvme_pt_command pt;
struct nvme_error_information_entry *err_entry;
int i, err_pages;
u_int i, err_pages, numd;

numd = payload_size / sizeof(uint32_t) - 1;
memset(&pt, 0, sizeof(pt));
pt.cmd.opc = NVME_OPC_GET_LOG_PAGE;
pt.cmd.nsid = htole32(nsid);
pt.cmd.cdw10 = ((payload_size/sizeof(uint32_t)) - 1) << 16;
pt.cmd.cdw10 |= log_page;
pt.cmd.cdw10 = htole32(pt.cmd.cdw10);
pt.cmd.cdw10 = htole32(
(numd << 16) | /* NUMDL */
(rae << 15) | /* RAE */
(lsp << 8) | /* LSP */
log_page); /* LID */
pt.cmd.cdw11 = htole32(
((uint32_t)lsi << 16) | /* LSI */
(numd >> 16)); /* NUMDU */
pt.cmd.cdw12 = 0; /* LPOL */
pt.cmd.cdw13 = 0; /* LPOU */
pt.cmd.cdw14 = 0; /* UUID Index */
pt.buf = payload;
pt.len = payload_size;
pt.is_read = 1;
@@ -186,6 +235,21 @@ read_logpage(int fd, uint8_t log_page, uint32_t nsid, void *payload,
nvme_firmware_page_swapbytes(
(struct nvme_firmware_page *)payload);
break;
case NVME_LOG_CHANGED_NAMESPACE:
nvme_ns_list_swapbytes((struct nvme_ns_list *)payload);
break;
case NVME_LOG_COMMAND_EFFECT:
nvme_command_effects_page_swapbytes(
(struct nvme_command_effects_page *)payload);
break;
case NVME_LOG_RES_NOTIFICATION:
nvme_res_notification_page_swapbytes(
(struct nvme_res_notification_page *)payload);
break;
case NVME_LOG_SANITIZE_STATUS:
nvme_sanitize_status_page_swapbytes(
(struct nvme_sanitize_status_page *)payload);
break;
case INTEL_LOG_TEMP_STATS:
intel_log_temp_stats_swapbytes(
(struct intel_log_temp_stats *)payload);
@@ -243,6 +307,9 @@ print_log_error(const struct nvme_controller_data *cdata __unused, void *buf, ui
printf(" LBA: %ju\n", entry->lba);
printf(" Namespace ID: %u\n", entry->nsid);
printf(" Vendor specific info: %u\n", entry->vendor_specific);
printf(" Transport type: %u\n", entry->trtype);
printf(" Command specific info:%ju\n", entry->csi);
printf(" Transport specific: %u\n", entry->ttsi);
}
}

@@ -315,6 +382,10 @@ print_log_health(const struct nvme_controller_data *cdata __unused, void *buf, u
printf("Temperature Sensor %d: ", i + 1);
print_temp(health->temp_sensor[i]);
}
printf("Temperature 1 Transition Count: %d\n", health->tmt1tc);
printf("Temperature 2 Transition Count: %d\n", health->tmt2tc);
printf("Total Time For Temperature 1: %d\n", health->ttftmt1);
printf("Total Time For Temperature 2: %d\n", health->ttftmt2);
}

static void
@@ -362,6 +433,160 @@ print_log_firmware(const struct nvme_controller_data *cdata, void *buf, uint32_t
}
}

static void
print_log_ns(const struct nvme_controller_data *cdata __unused, void *buf,
uint32_t size __unused)
{
struct nvme_ns_list *nsl;
u_int i;

nsl = (struct nvme_ns_list *)buf;
printf("Changed Namespace List\n");
printf("======================\n");

for (i = 0; i < nitems(nsl->ns) && nsl->ns[i] != 0; i++) {
printf("%08x\n", nsl->ns[i]);
}
}

static void
print_log_command_effects(const struct nvme_controller_data *cdata __unused,
void *buf, uint32_t size __unused)
{
struct nvme_command_effects_page *ce;
u_int i;
uint32_t s;

ce = (struct nvme_command_effects_page *)buf;
printf("Commands Supported and Effects\n");
printf("==============================\n");
printf(" Command\tLBCC\tNCC\tNIC\tCCC\tCSE\tUUID\n");

for (i = 0; i < 255; i++) {
s = ce->acs[i];
if (((s >> NVME_CE_PAGE_CSUP_SHIFT) &
NVME_CE_PAGE_CSUP_MASK) == 0)
continue;
printf("Admin\t%02x\t%s\t%s\t%s\t%s\t%u\t%s\n", i,
((s >> NVME_CE_PAGE_LBCC_SHIFT) &
NVME_CE_PAGE_LBCC_MASK) ? "Yes" : "No",
((s >> NVME_CE_PAGE_NCC_SHIFT) &
NVME_CE_PAGE_NCC_MASK) ? "Yes" : "No",
((s >> NVME_CE_PAGE_NIC_SHIFT) &
NVME_CE_PAGE_NIC_MASK) ? "Yes" : "No",
((s >> NVME_CE_PAGE_CCC_SHIFT) &
NVME_CE_PAGE_CCC_MASK) ? "Yes" : "No",
((s >> NVME_CE_PAGE_CSE_SHIFT) &
NVME_CE_PAGE_CSE_MASK),
((s >> NVME_CE_PAGE_UUID_SHIFT) &
NVME_CE_PAGE_UUID_MASK) ? "Yes" : "No");
}
for (i = 0; i < 255; i++) {
s = ce->iocs[i];
if (((s >> NVME_CE_PAGE_CSUP_SHIFT) &
NVME_CE_PAGE_CSUP_MASK) == 0)
continue;
printf("I/O\t%02x\t%s\t%s\t%s\t%s\t%u\t%s\n", i,
((s >> NVME_CE_PAGE_LBCC_SHIFT) &
NVME_CE_PAGE_LBCC_MASK) ? "Yes" : "No",
((s >> NVME_CE_PAGE_NCC_SHIFT) &
NVME_CE_PAGE_NCC_MASK) ? "Yes" : "No",
((s >> NVME_CE_PAGE_NIC_SHIFT) &
NVME_CE_PAGE_NIC_MASK) ? "Yes" : "No",
((s >> NVME_CE_PAGE_CCC_SHIFT) &
NVME_CE_PAGE_CCC_MASK) ? "Yes" : "No",
((s >> NVME_CE_PAGE_CSE_SHIFT) &
NVME_CE_PAGE_CSE_MASK),
((s >> NVME_CE_PAGE_UUID_SHIFT) &
NVME_CE_PAGE_UUID_MASK) ? "Yes" : "No");
}
}

static void
print_log_res_notification(const struct nvme_controller_data *cdata __unused,
void *buf, uint32_t size __unused)
{
struct nvme_res_notification_page *rn;

rn = (struct nvme_res_notification_page *)buf;
printf("Reservation Notification\n");
printf("========================\n");

printf("Log Page Count: %ju\n", rn->log_page_count);
printf("Log Page Type: ");
switch (rn->log_page_type) {
case 0:
printf("Empty Log Page\n");
break;
case 1:
printf("Registration Preempted\n");
break;
case 2:
printf("Reservation Released\n");
break;
case 3:
printf("Reservation Preempted\n");
break;
default:
printf("Unknown %x\n", rn->log_page_type);
break;
};
printf("Number of Available Log Pages: %d\n", rn->available_log_pages);
printf("Namespace ID: 0x%x\n", rn->nsid);
}

static void
print_log_sanitize_status(const struct nvme_controller_data *cdata __unused,
void *buf, uint32_t size __unused)
{
struct nvme_sanitize_status_page *ss;
u_int p;

ss = (struct nvme_sanitize_status_page *)buf;
printf("Sanitize Status\n");
printf("===============\n");

printf("Sanitize Progress: %u%% (%u/65535)\n",
(ss->sprog * 100 + 32768) / 65536, ss->sprog);
printf("Sanitize Status: ");
switch ((ss->sstat >> NVME_SS_PAGE_SSTAT_STATUS_SHIFT) &
NVME_SS_PAGE_SSTAT_STATUS_MASK) {
case NVME_SS_PAGE_SSTAT_STATUS_NEVER:
printf("Never sanitized");
break;
case NVME_SS_PAGE_SSTAT_STATUS_COMPLETED:
printf("Completed");
break;
case NVME_SS_PAGE_SSTAT_STATUS_INPROG:
printf("In Progress");
break;
case NVME_SS_PAGE_SSTAT_STATUS_FAILED:
printf("Failed");
break;
case NVME_SS_PAGE_SSTAT_STATUS_COMPLETEDWD:
printf("Completed with deallocation");
break;
default:
printf("Unknown");
break;
}
p = (ss->sstat & NVME_SS_PAGE_SSTAT_PASSES_SHIFT) >>
NVME_SS_PAGE_SSTAT_PASSES_MASK;
if (p > 0)
printf(", %d passes", p);
if ((ss->sstat & NVME_SS_PAGE_SSTAT_GDE_SHIFT) >>
NVME_SS_PAGE_SSTAT_GDE_MASK)
printf(", Global Data Erased");
printf("\n");
printf("Sanitize Command Dword 10: 0x%x\n", ss->scdw10);
printf("Time For Overwrite: %u sec\n", ss->etfo);
printf("Time For Block Erase: %u sec\n", ss->etfbe);
printf("Time For Crypto Erase: %u sec\n", ss->etfce);
printf("Time For Overwrite No-Deallocate: %u sec\n", ss->etfownd);
printf("Time For Block Erase No-Deallocate: %u sec\n", ss->etfbewnd);
printf("Time For Crypto Erase No-Deallocate: %u sec\n", ss->etfcewnd);
}

/*
* Table of log page printer / sizing.
*
@@ -377,6 +602,48 @@ NVME_LOGPAGE(health,
NVME_LOGPAGE(fw,
NVME_LOG_FIRMWARE_SLOT, NULL, "Firmware Information",
print_log_firmware, sizeof(struct nvme_firmware_page));
NVME_LOGPAGE(ns,
NVME_LOG_CHANGED_NAMESPACE, NULL, "Changed Namespace List",
print_log_ns, sizeof(struct nvme_ns_list));
NVME_LOGPAGE(ce,
NVME_LOG_COMMAND_EFFECT, NULL, "Commands Supported and Effects",
print_log_command_effects, sizeof(struct nvme_command_effects_page));
NVME_LOGPAGE(dst,
NVME_LOG_DEVICE_SELF_TEST, NULL, "Device Self-test",
NULL, 564);
NVME_LOGPAGE(thi,
NVME_LOG_TELEMETRY_HOST_INITIATED, NULL, "Telemetry Host-Initiated",
NULL, DEFAULT_SIZE);
NVME_LOGPAGE(tci,
NVME_LOG_TELEMETRY_CONTROLLER_INITIATED, NULL, "Telemetry Controller-Initiated",
NULL, DEFAULT_SIZE);
NVME_LOGPAGE(egi,
NVME_LOG_ENDURANCE_GROUP_INFORMATION, NULL, "Endurance Group Information",
NULL, DEFAULT_SIZE);
NVME_LOGPAGE(plpns,
NVME_LOG_PREDICTABLE_LATENCY_PER_NVM_SET, NULL, "Predictable Latency Per NVM Set",
NULL, DEFAULT_SIZE);
NVME_LOGPAGE(ple,
NVME_LOG_PREDICTABLE_LATENCY_EVENT_AGGREGATE, NULL, "Predictable Latency Event Aggregate",
NULL, DEFAULT_SIZE);
NVME_LOGPAGE(ana,
NVME_LOG_ASYMMETRIC_NAMESPAVE_ACCESS, NULL, "Asymmetric Namespace Access",
NULL, DEFAULT_SIZE);
NVME_LOGPAGE(pel,
NVME_LOG_PERSISTENT_EVENT_LOG, NULL, "Persistent Event Log",
NULL, DEFAULT_SIZE);
NVME_LOGPAGE(lbasi,
NVME_LOG_LBA_STATUS_INFORMATION, NULL, "LBA Status Information",
NULL, DEFAULT_SIZE);
NVME_LOGPAGE(egea,
NVME_LOG_ENDURANCE_GROUP_EVENT_AGGREGATE, NULL, "Endurance Group Event Aggregate",
NULL, DEFAULT_SIZE);
NVME_LOGPAGE(res_notification,
NVME_LOG_RES_NOTIFICATION, NULL, "Reservation Notification",
print_log_res_notification, sizeof(struct nvme_res_notification_page));
NVME_LOGPAGE(sanitize_status,
NVME_LOG_SANITIZE_STATUS, NULL, "Sanitize Status",
print_log_sanitize_status, sizeof(struct nvme_sanitize_status_page));

static void
logpage_help(void)
@@ -399,8 +666,7 @@ static void
logpage(const struct cmd *f, int argc, char *argv[])
{
int fd;
bool ns_specified;
char cname[64];
char *path;
uint32_t nsid, size;
void *buf;
const struct logpage_function *lpf;
@@ -421,15 +687,15 @@ logpage(const struct cmd *f, int argc, char *argv[])
fprintf(stderr, "Missing page_id (-p).\n");
arg_help(argc, argv, f);
}
if (strstr(opt.dev, NVME_NS_PREFIX) != NULL) {
ns_specified = true;
parse_ns_str(opt.dev, cname, &nsid);
open_dev(cname, &fd, 1, 1);
} else {
ns_specified = false;
open_dev(opt.dev, &fd, 1, 1);
get_nsid(fd, &path, &nsid);
if (nsid == 0) {
nsid = NVME_GLOBAL_NAMESPACE_TAG;
open_dev(opt.dev, &fd, 1, 1);
} else {
close(fd);
open_dev(path, &fd, 1, 1);
}
free(path);

read_controller_data(fd, &cdata);

@@ -441,7 +707,7 @@ logpage(const struct cmd *f, int argc, char *argv[])
* supports the SMART/Health information log page on a per
* namespace basis.
*/
if (ns_specified) {
if (nsid != NVME_GLOBAL_NAMESPACE_TAG) {
if (opt.page != NVME_LOG_HEALTH_INFORMATION)
errx(1, "log page %d valid only at controller level",
opt.page);
@@ -469,7 +735,8 @@ logpage(const struct cmd *f, int argc, char *argv[])
continue;
if (opt.page != lpf->log_page)
continue;
print_fn = lpf->print_fn;
if (lpf->print_fn != NULL)
print_fn = lpf->print_fn;
size = lpf->size;
break;
}
@@ -482,7 +749,7 @@ logpage(const struct cmd *f, int argc, char *argv[])

/* Read the log page */
buf = get_log_buffer(size);
read_logpage(fd, opt.page, nsid, buf, size);
read_logpage(fd, opt.page, nsid, opt.lsp, opt.lsi, opt.rae, buf, size);
print_fn(&cdata, buf, size);

close(fd);

+ 1
- 1
sbin/nvmecontrol/ns.c View File

@@ -2,7 +2,7 @@
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2017 Netflix, Inc.
* Copyright (C) 2018 Alexander Motin <mav@FreeBSD.org>
* Copyright (C) 2018-2019 Alexander Motin <mav@FreeBSD.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions

+ 80
- 0
sbin/nvmecontrol/nsid.c View File

@@ -0,0 +1,80 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (C) 2019 Alexander Motin <mav@FreeBSD.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/

#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");

#include <sys/param.h>

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include "nvmecontrol.h"
#include "comnd.h"

/* Tables for command line parsing */

static cmd_fn_t gnsid;

static struct nsid_options {
const char *dev;
} nsid_opt = {
.dev = NULL,
};

static const struct args nsid_args[] = {
{ arg_string, &nsid_opt.dev, "namespace-id" },
{ arg_none, NULL, NULL },
};

static struct cmd nsid_cmd = {
.name = "nsid",
.fn = gnsid,
.descr = "Get controller and NSID for namespace",
.ctx_size = sizeof(nsid_opt),
.opts = NULL,
.args = nsid_args,
};

CMD_COMMAND(nsid_cmd);

static void
gnsid(const struct cmd *f, int argc, char *argv[])
{
char *path;
int fd;
uint32_t nsid;

arg_parse(argc, argv, f);

open_dev(nsid_opt.dev, &fd, 1, 1);
get_nsid(fd, &path, &nsid);
close(fd);
printf("%s\t%u\n", path, nsid);
free(path);
}

+ 24
- 3
sbin/nvmecontrol/nvmecontrol.8 View File

@@ -1,5 +1,5 @@
.\"
.\" Copyright (c) 2018 Alexander Motin <mav@FreeBSD.org>
.\" Copyright (c) 2018-2019 Alexander Motin <mav@FreeBSD.org>
.\" Copyright (c) 2012 Intel Corporation
.\" All rights reserved.
.\"
@@ -34,7 +34,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd July 31, 2019
.Dd August 2, 2019
.Dt NVMECONTROL 8
.Os
.Sh NAME
@@ -66,6 +66,9 @@
.Op Fl x
.Op Fl v Ar vendor-string
.Op Fl b
.Op Fl f Ar LSP
.Op Fl i Ar LSI
.Op Fl r
.Aq device id
.Aq namespace id
.Nm
@@ -114,6 +117,10 @@
.Aq Fl n Ar nsid
.Aq device id
.Nm
.Ic nsid
.Aq device id
.Aq namespace id
.Nm
.Ic firmware
.Op Fl s Ar slot
.Op Fl f Ar path_to_firmware
@@ -168,6 +175,14 @@ Drive Error Log
Health/SMART Data
.It Dv Page 0x03
Firmware Information
.It Dv Page 0x04
Changed Namespace List
.It Dv Page 0x05
Commands Supported and Effects
.It Dv Page 0x80
Reservation Notification
.It Dv Page 0x81
Sanitize Status
.It Dv Page 0xc1
Advanced SMART information (WDC/HGST)
.It Dv Page 0xc1
@@ -181,13 +196,19 @@ Advanced SMART information (Intel)
.El
.Pp
Specifying
.Fl p
.Fl v
.Ic help
will list all valid vendors and pages.
.Fl x
will print the page as hex.
.Fl b
will print the binary data for the page.
.Fl s
will set Log Specific Field.
.Fl i
will set Log Specific Identifier.
.Fl r
will set Retain Asynchronous Event.
.Ss ns
Various namespace management commands.
If namespace management is supported by device, allow list, create and delete

+ 9
- 29
sbin/nvmecontrol/nvmecontrol.c View File

@@ -146,16 +146,6 @@ open_dev(const char *str, int *fd, int show_error, int exit_on_error)
{
char full_path[64];

if (!strnstr(str, NVME_CTRLR_PREFIX, strlen(NVME_CTRLR_PREFIX))) {
if (show_error)
warnx("controller/namespace ids must begin with '%s'",
NVME_CTRLR_PREFIX);
if (exit_on_error)
exit(1);
else
return (EINVAL);
}

snprintf(full_path, sizeof(full_path), _PATH_DEV"%s", str);
*fd = open(full_path, O_RDWR);
if (*fd < 0) {
@@ -171,26 +161,16 @@ open_dev(const char *str, int *fd, int show_error, int exit_on_error)
}

void
parse_ns_str(const char *ns_str, char *ctrlr_str, uint32_t *nsid)
get_nsid(int fd, char **ctrlr_str, uint32_t *nsid)
{
char *nsloc;

/*
* Pull the namespace id from the string. +2 skips past the "ns" part
* of the string. Don't search past 10 characters into the string,
* otherwise we know it is malformed.
*/
nsloc = strnstr(ns_str, NVME_NS_PREFIX, 10);
if (nsloc != NULL)
*nsid = strtol(nsloc + 2, NULL, 10);
if (nsloc == NULL || (*nsid == 0 && errno != 0))
errx(1, "invalid namespace ID '%s'", ns_str);

/*
* The controller string will include only the nvmX part of the
* nvmeXnsY string.
*/
snprintf(ctrlr_str, nsloc - ns_str + 1, "%s", ns_str);
struct nvme_get_nsid gnsid;

if (ioctl(fd, NVME_GET_NSID, &gnsid) < 0)
err(1, "NVME_GET_NSID ioctl failed");
if (ctrlr_str != NULL)
*ctrlr_str = strndup(gnsid.cdev, sizeof(gnsid.cdev));
if (nsid != NULL)
*nsid = gnsid.nsid;
}

int

+ 3
- 3
sbin/nvmecontrol/nvmecontrol.h View File

@@ -69,13 +69,13 @@ void logpage_register(struct logpage_function *p);
#define NVME_NS_PREFIX "ns"

int open_dev(const char *str, int *fd, int show_error, int exit_on_error);
void parse_ns_str(const char *ns_str, char *ctrlr_str, uint32_t *nsid);
void get_nsid(int fd, char **ctrlr_str, uint32_t *nsid);
void read_controller_data(int fd, struct nvme_controller_data *cdata);
void read_namespace_data(int fd, uint32_t nsid, struct nvme_namespace_data *nsdata);
void print_hex(void *data, uint32_t length);
void print_namespace(struct nvme_namespace_data *nsdata);
void read_logpage(int fd, uint8_t log_page, uint32_t nsid, void *payload,
uint32_t payload_size);
void read_logpage(int fd, uint8_t log_page, uint32_t nsid, uint8_t lsp,
uint16_t lsi, uint8_t rae, void *payload, uint32_t payload_size);
void print_temp(uint16_t t);
void print_intel_add_smart(const struct nvme_controller_data *cdata __unused, void *buf, uint32_t size __unused);


+ 2
- 1
share/man/man4/mxge.4 View File

@@ -31,7 +31,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd February 13, 2008
.Dd August 2, 2019
.Dt MXGE 4
.Os
.Sh NAME
@@ -43,6 +43,7 @@ place the following lines in your
kernel configuration file:
.Bd -ragged -offset indent
.Cd "device firmware"
.Cd "device zlib"
.Cd "device mxge"
.Ed
.Pp

+ 3
- 0
share/mk/src.opts.mk View File

@@ -213,8 +213,11 @@ __DEFAULT_NO_OPTIONS = \
OFED \
OFED_EXTRA \
OPENLDAP \
<<<<<<< HEAD
OPENNTPD \
PORTSNAP \
=======
>>>>>>> origin/freebsd/current/master
REPRODUCIBLE_BUILD \
RPCBIND_WARMSTART_SUPPORT \
SHARED_TOOLCHAIN \

+ 32
- 18
sys/amd64/amd64/pmap.c View File

@@ -1103,6 +1103,13 @@ static caddr_t crashdumpmap;
#define PMAP_ENTER_NORECLAIM 0x1000000 /* Don't reclaim PV entries. */
#define PMAP_ENTER_NOREPLACE 0x2000000 /* Don't replace mappings. */

/*
* Internal flags for pmap_mapdev_internal() and
* pmap_change_attr_locked().
*/
#define MAPDEV_FLUSHCACHE 0x0000001 /* Flush cache after mapping. */
#define MAPDEV_SETATTR 0x0000002 /* Modify existing attrs. */

static void free_pv_chunk(struct pv_chunk *pc);
static void free_pv_entry(pmap_t pmap, pv_entry_t pv);
static pv_entry_t get_pv_entry(pmap_t pmap, struct rwlock **lockp);
@@ -1123,7 +1130,7 @@ static pv_entry_t pmap_pvh_remove(struct md_page *pvh, pmap_t pmap,
vm_offset_t va);

static int pmap_change_attr_locked(vm_offset_t va, vm_size_t size, int mode,
bool noflush);
int flags);
static boolean_t pmap_demote_pde(pmap_t pmap, pd_entry_t *pde, vm_offset_t va);
static boolean_t pmap_demote_pde_locked(pmap_t pmap, pd_entry_t *pde,
vm_offset_t va, struct rwlock **lockp);
@@ -7717,7 +7724,7 @@ pmap_pde_attr(pd_entry_t *pde, int cache_bits, int mask)
* NOT real memory.
*/
static void *
pmap_mapdev_internal(vm_paddr_t pa, vm_size_t size, int mode, bool noflush)
pmap_mapdev_internal(vm_paddr_t pa, vm_size_t size, int mode, int flags)
{
struct pmap_preinit_mapping *ppim;
vm_offset_t va, offset;
@@ -7751,7 +7758,8 @@ pmap_mapdev_internal(vm_paddr_t pa, vm_size_t size, int mode, bool noflush)
for (i = 0; i < PMAP_PREINIT_MAPPING_COUNT; i++) {
ppim = pmap_preinit_mapping + i;
if (ppim->pa == pa && ppim->sz == size &&
ppim->mode == mode)
(ppim->mode == mode ||
(flags & MAPDEV_SETATTR) == 0))
return ((void *)(ppim->va + offset));
}
/*
@@ -7760,9 +7768,12 @@ pmap_mapdev_internal(vm_paddr_t pa, vm_size_t size, int mode, bool noflush)
*/
if (pa < dmaplimit && pa + size <= dmaplimit) {
va = PHYS_TO_DMAP(pa);
PMAP_LOCK(kernel_pmap);
i = pmap_change_attr_locked(va, size, mode, noflush);
PMAP_UNLOCK(kernel_pmap);
if ((flags & MAPDEV_SETATTR) != 0) {
PMAP_LOCK(kernel_pmap);
i = pmap_change_attr_locked(va, size, mode, flags);
PMAP_UNLOCK(kernel_pmap);
} else
i = 0;
if (!i)
return ((void *)(va + offset));
}
@@ -7773,7 +7784,7 @@ pmap_mapdev_internal(vm_paddr_t pa, vm_size_t size, int mode, bool noflush)
for (tmpsize = 0; tmpsize < size; tmpsize += PAGE_SIZE)
pmap_kenter_attr(va + tmpsize, pa + tmpsize, mode);
pmap_invalidate_range(kernel_pmap, va, va + tmpsize);
if (!noflush)
if ((flags & MAPDEV_FLUSHCACHE) != 0)
pmap_invalidate_cache_range(va, va + tmpsize);
return ((void *)(va + offset));
}
@@ -7782,28 +7793,31 @@ void *
pmap_mapdev_attr(vm_paddr_t pa, vm_size_t size, int mode)
{

return (pmap_mapdev_internal(pa, size, mode, false));
return (pmap_mapdev_internal(pa, size, mode, MAPDEV_FLUSHCACHE |
MAPDEV_SETATTR));
}

void *
pmap_mapdev(vm_paddr_t pa, vm_size_t size)
{

return (pmap_mapdev_internal(pa, size, PAT_UNCACHEABLE, false));
return (pmap_mapdev_attr(pa, size, PAT_UNCACHEABLE));
}

void *
pmap_mapdev_pciecfg(vm_paddr_t pa, vm_size_t size)
{

return (pmap_mapdev_internal(pa, size, PAT_UNCACHEABLE, true));
return (pmap_mapdev_internal(pa, size, PAT_UNCACHEABLE,
MAPDEV_SETATTR));
}

void *
pmap_mapbios(vm_paddr_t pa, vm_size_t size)
{

return (pmap_mapdev_internal(pa, size, PAT_WRITE_BACK, false));
return (pmap_mapdev_internal(pa, size, PAT_WRITE_BACK,
MAPDEV_FLUSHCACHE));
}

void
@@ -7942,13 +7956,13 @@ pmap_change_attr(vm_offset_t va, vm_size_t size, int mode)
int error;

PMAP_LOCK(kernel_pmap);
error = pmap_change_attr_locked(va, size, mode, false);
error = pmap_change_attr_locked(va, size, mode, MAPDEV_FLUSHCACHE);
PMAP_UNLOCK(kernel_pmap);
return (error);
}

static int
pmap_change_attr_locked(vm_offset_t va, vm_size_t size, int mode, bool noflush)
pmap_change_attr_locked(vm_offset_t va, vm_size_t size, int mode, int flags)
{
vm_offset_t base, offset, tmpva;
vm_paddr_t pa_start, pa_end, pa_end1;
@@ -8065,7 +8079,7 @@ pmap_change_attr_locked(vm_offset_t va, vm_size_t size, int mode, bool noflush)
/* Run ended, update direct map. */
error = pmap_change_attr_locked(
PHYS_TO_DMAP(pa_start),
pa_end - pa_start, mode, noflush);
pa_end - pa_start, mode, flags);
if (error != 0)
break;
/* Start physical address run. */
@@ -8095,7 +8109,7 @@ pmap_change_attr_locked(vm_offset_t va, vm_size_t size, int mode, bool noflush)
/* Run ended, update direct map. */
error = pmap_change_attr_locked(
PHYS_TO_DMAP(pa_start),
pa_end - pa_start, mode, noflush);
pa_end - pa_start, mode, flags);
if (error != 0)
break;
/* Start physical address run. */
@@ -8123,7 +8137,7 @@ pmap_change_attr_locked(vm_offset_t va, vm_size_t size, int mode, bool noflush)
/* Run ended, update direct map. */
error = pmap_change_attr_locked(
PHYS_TO_DMAP(pa_start),
pa_end - pa_start, mode, noflush);
pa_end - pa_start, mode, flags);
if (error != 0)
break;
/* Start physical address run. */
@@ -8138,7 +8152,7 @@ pmap_change_attr_locked(vm_offset_t va, vm_size_t size, int mode, bool noflush)
pa_end1 = MIN(pa_end, dmaplimit);
if (pa_start != pa_end1)
error = pmap_change_attr_locked(PHYS_TO_DMAP(pa_start),
pa_end1 - pa_start, mode, noflush);
pa_end1 - pa_start, mode, flags);
}

/*
@@ -8147,7 +8161,7 @@ pmap_change_attr_locked(vm_offset_t va, vm_size_t size, int mode, bool noflush)
*/
if (changed) {
pmap_invalidate_range(kernel_pmap, base, tmpva);
if (!noflush)
if ((flags & MAPDEV_FLUSHCACHE) != 0)
pmap_invalidate_cache_range(base, tmpva);
}
return (error);

+ 24
- 13
sys/arm64/arm64/pmap.c View File

@@ -221,8 +221,11 @@ __FBSDID("$FreeBSD$");
* The presence of this flag indicates that the mapping is writeable.
* If the ATTR_AP_RO bit is also set, then the mapping is clean, otherwise it is
* dirty. This flag may only be set on managed mappings.
*
* The DBM bit is reserved on ARMv8.0 but it seems we can safely treat it
* as a software managed bit.
*/
static pt_entry_t ATTR_SW_DBM;
#define ATTR_SW_DBM ATTR_DBM

struct pmap kernel_pmap_store;

@@ -784,15 +787,6 @@ pmap_bootstrap(vm_offset_t l0pt, vm_offset_t l1pt, vm_paddr_t kernstart,
uint64_t kern_delta;
int i;

#ifdef notyet
/* Determine whether the hardware implements DBM management. */
uint64_t reg = READ_SPECIALREG(ID_AA64MMFR1_EL1);
ATTR_SW_DBM = ID_AA64MMFR1_HAFDBS(reg) == ID_AA64MMFR1_HAFDBS_AF_DBS ?
ATTR_DBM : _ATTR_SW_DBM;
#else
ATTR_SW_DBM = _ATTR_SW_DBM;
#endif

kern_delta = KERNBASE - kernstart;

printf("pmap_bootstrap %lx %lx %lx\n", l1pt, kernstart, kernlen);
@@ -1530,6 +1524,16 @@ _pmap_alloc_l3(pmap_t pmap, vm_pindex_t ptepindex, struct rwlock **lockp)
if ((m->flags & PG_ZERO) == 0)
pmap_zero_page(m);

/*
* Because of AArch64's weak memory consistency model, we must have a
* barrier here to ensure that the stores for zeroing "m", whether by
* pmap_zero_page() or an earlier function, are visible before adding
* "m" to the page table. Otherwise, a page table walk by another
* processor's MMU could see the mapping to "m" and a stale, non-zero
* PTE within "m".
*/
dmb(ishst);

/*
* Map the pagetable page into the process address space, if
* it isn't already there.
@@ -1781,12 +1785,14 @@ pmap_growkernel(vm_offset_t addr)
panic("pmap_growkernel: no memory to grow kernel");
if ((nkpg->flags & PG_ZERO) == 0)
pmap_zero_page(nkpg);
/* See the dmb() in _pmap_alloc_l3(). */
dmb(ishst);
paddr = VM_PAGE_TO_PHYS(nkpg);
pmap_store(l1, paddr | L1_TABLE);
continue; /* try again */
}
l2 = pmap_l1_to_l2(l1, kernel_vm_end);
if ((pmap_load(l2) & ATTR_AF) != 0) {
if (pmap_load(l2) != 0) {
kernel_vm_end = (kernel_vm_end + L2_SIZE) & ~L2_OFFSET;
if (kernel_vm_end - 1 >= vm_map_max(kernel_map)) {
kernel_vm_end = vm_map_max(kernel_map);
@@ -1802,9 +1808,10 @@ pmap_growkernel(vm_offset_t addr)
panic("pmap_growkernel: no memory to grow kernel");
if ((nkpg->flags & PG_ZERO) == 0)
pmap_zero_page(nkpg);
/* See the dmb() in _pmap_alloc_l3(). */
dmb(ishst);
paddr = VM_PAGE_TO_PHYS(nkpg);
pmap_load_store(l2, paddr | L2_TABLE);
pmap_invalidate_page(kernel_pmap, kernel_vm_end);
pmap_store(l2, paddr | L2_TABLE);

kernel_vm_end = (kernel_vm_end + L2_SIZE) & ~L2_OFFSET;
if (kernel_vm_end - 1 >= vm_map_max(kernel_map)) {
@@ -5537,6 +5544,10 @@ pmap_demote_l2_locked(pmap_t pmap, pt_entry_t *l2, vm_offset_t va,
/*
* If the page table page is not leftover from an earlier promotion,
* or the mapping attributes have changed, (re)initialize the L3 table.
*
* When pmap_update_entry() clears the old L2 mapping, it (indirectly)
* performs a dsb(). That dsb() ensures that the stores for filling
* "l3" are visible before "l3" is added to the page table.
*/
if (ml3->valid == 0 || (l3[0] & ATTR_MASK) != (newl3 & ATTR_MASK))
pmap_fill_l3(l3, newl3);

+ 2
- 2
sys/arm64/include/pte.h View File

@@ -43,8 +43,8 @@ typedef uint64_t pt_entry_t; /* page table entry */
#define ATTR_MASK_L UINT64_C(0x0000000000000fff)
#define ATTR_MASK (ATTR_MASK_H | ATTR_MASK_L)
/* Bits 58:55 are reserved for software */
#define ATTR_SW_UNUSED (1UL << 58)
#define _ATTR_SW_DBM (1UL << 57)
#define ATTR_SW_UNUSED2 (1UL << 58)
#define ATTR_SW_UNUSED1 (1UL << 57)
#define ATTR_SW_MANAGED (1UL << 56)
#define ATTR_SW_WIRED (1UL << 55)
#define ATTR_UXN (1UL << 54)

+ 3
- 1
sys/conf/files View File

@@ -2442,7 +2442,8 @@ mwlboot.fw optional mwlfw \
compile-with "${NORMAL_FW}" \
no-obj no-implicit-rule \
clean "mwlboot.fw"
dev/mxge/if_mxge.c optional mxge pci
dev/mxge/if_mxge.c optional mxge pci \
compile-with "${ZLIB_C}"
dev/mxge/mxge_eth_z8e.c optional mxge pci
dev/mxge/mxge_ethp_z8e.c optional mxge pci
dev/mxge/mxge_rss_eth_z8e.c optional mxge pci
@@ -4285,6 +4286,7 @@ netinet/tcp_lro.c optional inet | inet6
netinet/tcp_output.c optional inet | inet6
netinet/tcp_offload.c optional tcp_offload inet | tcp_offload inet6
netinet/tcp_hpts.c optional tcphpts inet | tcphpts inet6
netinet/tcp_ratelimit.c optional ratelimit inet | ratelimit inet6
netinet/tcp_pcap.c optional inet tcppcap | inet6 tcppcap \
compile-with "${NORMAL_C} ${NO_WNONNULL}"
netinet/tcp_reass.c optional inet | inet6

+ 4
- 0
sys/conf/newvers.sh View File

@@ -291,6 +291,10 @@ if [ -n "$git_cmd" ] ; then
git=" ${git}"
fi
fi
git_cnt=$($git_cmd rev-list --count HEAD 2>/dev/null)
if [ -n "$git_cnt" ] ; then
git="${git}-c${git_cnt}"
fi
git_b=$($git_cmd rev-parse --abbrev-ref HEAD)
if [ -n "$git_b" ] ; then
git="${git}(${git_b})"

+ 0
- 49
sys/contrib/dev/acpica/changes.txt View File

@@ -1,52 +1,3 @@
----------------------------------------
03 July 2019. Summary of changes for version 20190703:


1) ACPICA kernel-resident subsystem:

Remove legacy module-level support code. There were still some remnants
of the legacy module-level code executions. Since we no longer support
this option, this is essentially dead code and has been removed from the
ACPICA source.

iASL: ensure that _WAK, _PTS, _TTS, and _Sx are declared only at the root
scope. If these named objects are declared outside the root scope, they
will not be invoked by any host Operating System.

Clear status of GPEs on first direct enable. ACPI GPEs (other than the EC
one) can be enabled in two situations. First, the GPEs with existing _Lxx
and _Exx methods are enabled implicitly by ACPICA during system
initialization. Second, the GPEs without these methods (like GPEs listed
by _PRW objects for wakeup devices) need to be enabled directly by the
code that is going to use them (e.g. ACPI power management or device
drivers).

In the former case, if the status of a given GPE is set to start with,
its handler method (either _Lxx or _Exx) needs to be invoked to take care
of the events (possibly) signaled before the GPE was enabled. In the
latter case, however, the first caller of AcpiEnableGpe() for a given GPE
should not be expected to care about any events that might be signaled
through it earlier. In that case, it is better to clear the status of
the GPE before enabling it, to prevent stale events from triggering
unwanted actions (like spurious system resume, for example).

For this reason, modify AcpiEvAddGpeReference() to take an additional
boolean argument indicating whether or not the GPE status needs to be
cleared when its reference counter changes from zero to one and make
AcpiEnableGpe() pass TRUE to it through that new argument.


2) iASL Compiler/Disassembler and ACPICA tools:

The tool generation process has been migrated to MSVC 2017, and all
project files have been upgraded. The new project files appear in the
directory \acpica\generate\msvc2017. This change effectively deprecates
the older project files in \acpica\generate\msvc9.

iASL: ensure that _WAK, _PTS, _TTS, and _Sx are declared only at the root
scope. If these named objects are declared outside the root scope, they
will not be invoked by any host Operating System

----------------------------------------
09 May 2019. Summary of changes for version 20190509:


+ 0
- 16
sys/contrib/dev/acpica/compiler/asldefine.h View File

@@ -298,20 +298,4 @@
#define COMMENT_CAPTURE_ON AslGbl_CommentState.CaptureComments = TRUE;
#define COMMENT_CAPTURE_OFF AslGbl_CommentState.CaptureComments = FALSE;

/*
* Special name segments - these must only be declared at the root scope
*/
#define NAMESEG__PTS "_PTS"
#define NAMESEG__WAK "_WAK"
#define NAMESEG__S0 "_S0_"
#define NAMESEG__S1 "_S1_"
#define NAMESEG__S2 "_S2_"
#define NAMESEG__S3 "_S3_"
#define NAMESEG__S4 "_S4_"
#define NAMESEG__S5 "_S5_"
#define NAMESEG__TTS "_TTS"

#define MAX_SPECIAL_NAMES 9


#endif /* ASLDEFINE.H */

+ 0
- 15
sys/contrib/dev/acpica/compiler/aslglobal.h View File

@@ -223,28 +223,13 @@ const char *AslGbl_OpFlagNames[ACPI_NUM_OP_FLAGS] =
"OP_NOT_FOUND_DURING_LOAD"
};

const char *AslGbl_SpecialNamedObjects [MAX_SPECIAL_NAMES] =
{
NAMESEG__PTS,
NAMESEG__WAK,
NAMESEG__S0,
NAMESEG__S1,
NAMESEG__S2,
NAMESEG__S3,
NAMESEG__S4,
NAMESEG__S5,
NAMESEG__TTS
};

#else
extern ASL_FILE_DESC AslGbl_FileDescs [ASL_NUM_FILES];
extern UINT32 AslGbl_ExceptionCount[ASL_NUM_REPORT_LEVELS];
extern const char *AslGbl_OpFlagNames[ACPI_NUM_OP_FLAGS];
extern const char *AslGbl_SpecialNamedObjects[MAX_SPECIAL_NAMES];
#endif



/*
* Parser and other externals
*/

+ 4
- 55
sys/contrib/dev/acpica/compiler/aslload.c View File

@@ -164,7 +164,6 @@

static ACPI_STATUS
LdLoadFieldElements (
UINT32 AmlType,
ACPI_PARSE_OBJECT *Op,
ACPI_WALK_STATE *WalkState);

@@ -191,10 +190,6 @@ LdCommonNamespaceEnd (
UINT32 Level,
void *Context);

static void
LdCheckSpecialNames (
ACPI_NAMESPACE_NODE *Node,
ACPI_PARSE_OBJECT *Op);

/*******************************************************************************
*
@@ -252,8 +247,7 @@ LdLoadNamespace (
*
* FUNCTION: LdLoadFieldElements
*
* PARAMETERS: AmlType - Type to search
* Op - Parent node (Field)
* PARAMETERS: Op - Parent node (Field)
* WalkState - Current walk state
*
* RETURN: Status
@@ -265,7 +259,6 @@ LdLoadNamespace (

static ACPI_STATUS
LdLoadFieldElements (
UINT32 AmlType,
ACPI_PARSE_OBJECT *Op,
ACPI_WALK_STATE *WalkState)
{
@@ -281,7 +274,7 @@ LdLoadFieldElements (
{
Status = AcpiNsLookup (WalkState->ScopeInfo,
SourceRegion->Asl.Value.String,
AmlType, ACPI_IMODE_EXECUTE,
ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE,
ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node);
if (Status == AE_NOT_FOUND)
{
@@ -514,15 +507,11 @@ LdNamespace1Begin (
*/
switch (Op->Asl.AmlOpcode)
{
case AML_INDEX_FIELD_OP:

Status = LdLoadFieldElements (ACPI_TYPE_LOCAL_REGION_FIELD, Op, WalkState);
return (Status);

case AML_BANK_FIELD_OP:
case AML_INDEX_FIELD_OP:
case AML_FIELD_OP:

Status = LdLoadFieldElements (ACPI_TYPE_REGION, Op, WalkState);
Status = LdLoadFieldElements (Op, WalkState);
return (Status);

case AML_INT_CONNECTION_OP:
@@ -977,10 +966,6 @@ LdNamespace1Begin (
}
}

/* Check special names like _WAK and _PTS */

LdCheckSpecialNames (Node, Op);

if (ForceNewScope)
{
Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState);
@@ -1019,42 +1004,6 @@ FinishNode:
}


/*******************************************************************************
*
* FUNCTION: LdCheckSpecialNames
*
* PARAMETERS: Node - Node that represents the named object
* Op - Named object declaring this named object
*
* RETURN: None
*
* DESCRIPTION: Check if certain named objects are declared in the incorrect
* scope. Special named objects are listed in
* AslGbl_SpecialNamedObjects and can only be declared at the root
* scope.
*
******************************************************************************/

static void
LdCheckSpecialNames (
ACPI_NAMESPACE_NODE *Node,
ACPI_PARSE_OBJECT *Op)
{
UINT32 i;


for (i = 0; i < MAX_SPECIAL_NAMES; i++)
{
if (ACPI_COMPARE_NAMESEG(Node->Name.Ascii, AslGbl_SpecialNamedObjects[i]) &&
Node->Parent != AcpiGbl_RootNode)
{
AslError (ASL_ERROR, ASL_MSG_INVALID_SPECIAL_NAME, Op, Op->Asl.ExternalName);
return;
}
}
}


/*******************************************************************************
*
* FUNCTION: LdNamespace2Begin

+ 1
- 2
sys/contrib/dev/acpica/compiler/aslmessages.c View File

@@ -365,8 +365,7 @@ const char *AslCompilerMsgs [] =
/* ASL_MSG_REGION_LENGTH */ "Operation Region declared with zero length",
/* ASL_MSG_TEMPORARY_OBJECT */ "Object is created temporarily in another method and cannot be accessed",
/* ASL_MSG_UNDEFINED_EXTERNAL */ "Named object was declared external but the actual definition does not exist",
/* ASL_MSG_BUFFER_FIELD_OVERFLOW */ "Buffer field extends beyond end of target buffer",
/* ASL_MSG_INVALID_SPECIAL_NAME */ "declaration of this named object outside root scope is illegal"
/* ASL_MSG_BUFFER_FIELD_OVERFLOW */ "Buffer field extends beyond end of target buffer"
};

/* Table compiler */

+ 0
- 1
sys/contrib/dev/acpica/compiler/aslmessages.h View File

@@ -368,7 +368,6 @@ typedef enum
ASL_MSG_TEMPORARY_OBJECT,
ASL_MSG_UNDEFINED_EXTERNAL,
ASL_MSG_BUFFER_FIELD_OVERFLOW,
ASL_MSG_INVALID_SPECIAL_NAME,

/* These messages are used by the Data Table compiler only */


+ 6
- 0
sys/contrib/dev/acpica/compiler/aslstubs.c View File

@@ -166,6 +166,12 @@
* Things like Events, Global Lock, etc. are not used
* by the compiler, so they are stubbed out here.
*/
void
AcpiNsExecModuleCodeList (
void)
{
}

ACPI_STATUS
AcpiNsInitializeObjects (
void)

+ 9
- 9
sys/contrib/dev/acpica/compiler/aslsupport.l View File

@@ -220,7 +220,7 @@ AslDoLineDirective (

while ((c = input()) != '\n' && c != EOF)
{
*AslGbl_LineBufPtr = (char) c;
*AslGbl_LineBufPtr = c;