diff options
103 files changed, 1052 insertions, 353 deletions
diff --git a/bin/sh/options.h b/bin/sh/options.h index a059e19707b1..2ce2e6ebedf2 100644 --- a/bin/sh/options.h +++ b/bin/sh/options.h @@ -74,7 +74,7 @@ extern char optval[NOPTS]; extern const char optletter[NSHORTOPTS]; #ifdef DEFINE_OPTIONS char optval[NOPTS]; -const char optletter[NSHORTOPTS] = "efIimnsxvVECabupTPh"; +const char optletter[NSHORTOPTS] __nonstring = "efIimnsxvVECabupTPh"; static const unsigned char optname[] = "\007errexit" "\006noglob" diff --git a/bin/test/test.c b/bin/test/test.c index a35c5b424d3f..5ba5df5d7e44 100644 --- a/bin/test/test.c +++ b/bin/test/test.c @@ -116,7 +116,7 @@ enum token { #define TOKEN_TYPE(token) ((token) & 0xff00) static const struct t_op { - char op_text[2]; + char op_text[2] __nonstring; short op_num; } ops1[] = { {"=", STREQ}, diff --git a/contrib/kyua/cli/cmd_debug.cpp b/contrib/kyua/cli/cmd_debug.cpp index 700c4b3ea851..978ccae0fdf1 100644 --- a/contrib/kyua/cli/cmd_debug.cpp +++ b/contrib/kyua/cli/cmd_debug.cpp @@ -149,7 +149,11 @@ cmd_debug::run(cmdline::ui* ui, const cmdline::parsed_cmdline& cmdline, const engine::test_filter filter = engine::test_filter::parse( test_case_name); - auto debugger = std::shared_ptr< engine::debugger >(new dbg(ui, cmdline)); + engine::debugger_ptr debugger = nullptr; + if (cmdline.has_option(pause_before_cleanup_upon_fail_option.long_name()) + || cmdline.has_option(pause_before_cleanup_option.long_name())) { + debugger = std::shared_ptr< engine::debugger >(new dbg(ui, cmdline)); + } const drivers::debug_test::result result = drivers::debug_test::drive( debugger, diff --git a/contrib/kyua/doc/kyua-db-exec.1.in b/contrib/kyua/doc/kyua-db-exec.1.in index 04f34c7b54e7..2e3bada4f849 100644 --- a/contrib/kyua/doc/kyua-db-exec.1.in +++ b/contrib/kyua/doc/kyua-db-exec.1.in @@ -62,7 +62,7 @@ The following subcommand options are recognized: .Bl -tag -width XX .It Fl -no-headers Avoids printing the headers of the table in the output of the command. -.It Fl -results-file Ar path , Fl s Ar path +.It Fl -results-file Ar path , Fl r Ar path __include__ results-file-flag-read.mdoc .El .Ss Results files diff --git a/contrib/kyua/doc/kyua-db-migrate.1.in b/contrib/kyua/doc/kyua-db-migrate.1.in index 67e46de46fec..4a1852aafd36 100644 --- a/contrib/kyua/doc/kyua-db-migrate.1.in +++ b/contrib/kyua/doc/kyua-db-migrate.1.in @@ -47,7 +47,7 @@ database lives. .Pp The following subcommand options are recognized: .Bl -tag -width XX -.It Fl -results-file Ar path , Fl s Ar path +.It Fl -results-file Ar path , Fl r Ar path __include__ results-file-flag-read.mdoc .El .Ss Results files diff --git a/contrib/kyua/doc/kyua-report-html.1.in b/contrib/kyua/doc/kyua-report-html.1.in index 1f9f55b69a3f..3ff044ca8d30 100644 --- a/contrib/kyua/doc/kyua-report-html.1.in +++ b/contrib/kyua/doc/kyua-report-html.1.in @@ -64,7 +64,7 @@ The directory must not exist unless the option is provided. The default is .Pa ./html . -.It Fl -results-file Ar path , Fl s Ar path +.It Fl -results-file Ar path , Fl r Ar path __include__ results-file-flag-read.mdoc .It Fl -results-filter Ar types Comma-separated list of the test result types to include in the report. diff --git a/contrib/kyua/doc/kyua-report-junit.1.in b/contrib/kyua/doc/kyua-report-junit.1.in index f1ad3a2e7f29..508ea30a3f6e 100644 --- a/contrib/kyua/doc/kyua-report-junit.1.in +++ b/contrib/kyua/doc/kyua-report-junit.1.in @@ -50,7 +50,7 @@ The following subcommand options are recognized: .Bl -tag -width XX .It Fl -output Ar directory Specifies the file into which to store the JUnit report. -.It Fl -results-file Ar path , Fl s Ar path +.It Fl -results-file Ar path , Fl r Ar path __include__ results-file-flag-read.mdoc .El .Ss Caveats diff --git a/contrib/kyua/doc/kyua-report.1.in b/contrib/kyua/doc/kyua-report.1.in index 8e2485f9c4ac..a3e4d75456cf 100644 --- a/contrib/kyua/doc/kyua-report.1.in +++ b/contrib/kyua/doc/kyua-report.1.in @@ -70,7 +70,7 @@ and .Pa /dev/stderr can be used to specify the standard output and the standard error, respectively. -.It Fl -results-file Ar path , Fl s Ar path +.It Fl -results-file Ar path , Fl r Ar path __include__ results-file-flag-read.mdoc .It Fl -results-filter Ar types Comma-separated list of the test result types to include in the report. diff --git a/contrib/kyua/doc/kyua-test.1.in b/contrib/kyua/doc/kyua-test.1.in index 8cd5f34ae6af..07db6cf461c2 100644 --- a/contrib/kyua/doc/kyua-test.1.in +++ b/contrib/kyua/doc/kyua-test.1.in @@ -69,7 +69,7 @@ Specifies the Kyuafile to process. Defaults to a .Pa Kyuafile file in the current directory. -.It Fl -results-file Ar path , Fl s Ar path +.It Fl -results-file Ar path , Fl r Ar path __include__ results-file-flag-write.mdoc .El .Pp diff --git a/contrib/kyua/engine/scheduler.cpp b/contrib/kyua/engine/scheduler.cpp index 4c40bf31046e..a0719ec461ab 100644 --- a/contrib/kyua/engine/scheduler.cpp +++ b/contrib/kyua/engine/scheduler.cpp @@ -1283,7 +1283,9 @@ scheduler::exec_handle scheduler::scheduler_handle::spawn_test( const model::test_program_ptr test_program, const std::string& test_case_name, - const config::tree& user_config) + const config::tree& user_config, + const utils::optional<utils::fs::path>& stdout_target, + const utils::optional<utils::fs::path>& stderr_target) { _pimpl->generic.check_interrupt(); @@ -1305,7 +1307,7 @@ scheduler::scheduler_handle::spawn_test( run_test_program(interface, test_program, test_case_name, user_config), test_case.get_metadata().timeout(), - unprivileged_user); + unprivileged_user, stdout_target, stderr_target); const exec_data_ptr data(new test_exec_data( test_program, test_case_name, interface, user_config, handle.pid())); @@ -1563,8 +1565,16 @@ scheduler::scheduler_handle::debug_test( const fs::path& stdout_target, const fs::path& stderr_target) { + optional<fs::path> out = none; + optional<fs::path> err = none; + const model::test_case& test_case = test_program->find(test_case_name); + if (test_case.get_debugger() != nullptr) { + out = stdout_target; + err = stderr_target; + } + const exec_handle exec_handle = spawn_test( - test_program, test_case_name, user_config); + test_program, test_case_name, user_config, out, err); result_handle_ptr result_handle = wait_any(); // TODO(jmmv): We need to do this while the subprocess is alive. This is @@ -1574,12 +1584,12 @@ scheduler::scheduler_handle::debug_test( // Unfortunately, we cannot do so. We cannot just read and block from a // file, waiting for further output to appear... as this only works on pipes // or sockets. We need a better interface for this whole thing. - { + if (test_case.get_debugger() == nullptr) { std::unique_ptr< std::ostream > output = utils::open_ostream( stdout_target); *output << utils::read_file(result_handle->stdout_file()); } - { + if (test_case.get_debugger() == nullptr) { std::unique_ptr< std::ostream > output = utils::open_ostream( stderr_target); *output << utils::read_file(result_handle->stderr_file()); diff --git a/contrib/kyua/engine/scheduler.hpp b/contrib/kyua/engine/scheduler.hpp index ee01c83b4991..508a0c0cbfd9 100644 --- a/contrib/kyua/engine/scheduler.hpp +++ b/contrib/kyua/engine/scheduler.hpp @@ -74,6 +74,8 @@ #include "utils/process/executor_fwd.hpp" #include "utils/process/status_fwd.hpp" +using utils::none; + namespace engine { namespace scheduler { @@ -248,7 +250,9 @@ public: const utils::config::tree&); exec_handle spawn_test(const model::test_program_ptr, const std::string&, - const utils::config::tree&); + const utils::config::tree&, + const utils::optional<utils::fs::path>& = none, + const utils::optional<utils::fs::path>& = none); result_handle_ptr wait_any(void); result_handle_ptr debug_test(const model::test_program_ptr, diff --git a/contrib/ncurses/progs/infocmp.c b/contrib/ncurses/progs/infocmp.c index 7932203ac2b1..f61633cfad80 100644 --- a/contrib/ncurses/progs/infocmp.c +++ b/contrib/ncurses/progs/infocmp.c @@ -687,7 +687,7 @@ compare_predicate(PredType type, PredIdx idx, const char *name) #define DATAX() DATA("", "") typedef struct { - const char from[4]; + const char from[8]; const char to[12]; } assoc; diff --git a/include/search.h b/include/search.h index 0615da2b42ba..5ac25a0d491f 100644 --- a/include/search.h +++ b/include/search.h @@ -77,6 +77,7 @@ void twalk(const posix_tnode *, void (*)(const posix_tnode *, VISIT, int)); int hcreate_r(size_t, struct hsearch_data *); void hdestroy_r(struct hsearch_data *); int hsearch_r(ENTRY, ACTION, ENTRY **, struct hsearch_data *); +void tdestroy(void *, void (*)(void *)); #endif __END_DECLS diff --git a/lib/geom/part/geom_part.c b/lib/geom/part/geom_part.c index ac1bc25118f1..852eec2d790a 100644 --- a/lib/geom/part/geom_part.c +++ b/lib/geom/part/geom_part.c @@ -46,6 +46,7 @@ #include <string.h> #include <strings.h> #include <unistd.h> + #include <libxo/xo.h> #include "core/geom.h" @@ -651,11 +652,12 @@ gpart_show_geom(struct ggeom *gp, const char *element, int show_providers) pp = LIST_FIRST(&gp->lg_consumer)->lg_provider; secsz = pp->lg_sectorsize; xo_open_instance("part"); - xo_emit("=>{t:start/%*jd} {t:sectors/%*jd} {t:name/%*s} {:scheme} ({h:size/%ld}){t:state}\n", - wblocks, (intmax_t)first, wblocks, (intmax_t)(last - first + 1), - wname, gp->lg_name, - scheme, pp->lg_mediasize, - s ? " [CORRUPT]": ""); + xo_emit("=>{t:start/%*jd} {t:sectors/%*jd} " + "{t:name/%*s} {:scheme} ({h:size/%jd})" + "{t:state}\n", + wblocks, (intmax_t)first, wblocks, (intmax_t)(last - first + 1), + wname, gp->lg_name, scheme, (intmax_t)pp->lg_mediasize, + s ? " [CORRUPT]": ""); xo_open_list("partitions"); while ((pp = find_provider(gp, first)) != NULL) { @@ -670,35 +672,43 @@ gpart_show_geom(struct ggeom *gp, const char *element, int show_providers) idx = atoi(s); if (first < sector) { xo_open_instance(s); - xo_emit(" {t:start/%*jd} {t:sectors/%*jd} {P:/%*s} {ne:free}- free - ({h:size/%ld})\n", - wblocks, (intmax_t)first, wblocks, - (intmax_t)(sector - first), wname, "", - "true", (sector - first) * secsz); + xo_emit(" {t:start/%*jd} " + "{t:sectors/%*jd} " + "{P:/%*s} " + "{ne:free}- free - ({h:size/%jd})\n", + wblocks, (intmax_t)first, + wblocks, (intmax_t)(sector - first), + wname, "", + "true", (intmax_t)(sector - first) * secsz); xo_close_instance(s); } xo_open_instance(s); xo_emit(" {t:start/%*jd} {t:sectors/%*jd}", - wblocks, (intmax_t)sector, wblocks, (intmax_t)length); + wblocks, (intmax_t)sector, wblocks, (intmax_t)length); if (show_providers) { - xo_emit(" {t:name/%*s}{e:index/%d}", wname, pp->lg_name, idx); - } else - xo_emit(" {t:index/%*d}{e:name}", wname, idx, pp->lg_name); + xo_emit(" {t:name/%*s}{e:index/%d}", + wname, pp->lg_name, idx); + } else { + xo_emit(" {t:index/%*d}{e:name}", + wname, idx, pp->lg_name); + } - if (strcmp(element, "label") == 0) + if (strcmp(element, "label") == 0) { xo_emit(" {:label}{e:type}{e:rawtype}", - find_provcfg(pp, element), - find_provcfg(pp, "type"), - find_provcfg(pp, "rawtype")); - else if (strcmp(element, "type") == 0) + find_provcfg(pp, element), + find_provcfg(pp, "type"), + find_provcfg(pp, "rawtype")); + } else if (strcmp(element, "type") == 0) { xo_emit(" {:type}{e:label}{e:rawtype}", - find_provcfg(pp, element), - find_provcfg(pp, "label"), - find_provcfg(pp, "rawtype")); - else + find_provcfg(pp, element), + find_provcfg(pp, "label"), + find_provcfg(pp, "rawtype")); + } else { xo_emit(" {:rawtype}{e:type}{e:label}", - find_provcfg(pp, element), - find_provcfg(pp, "type"), - find_provcfg(pp, "label")); + find_provcfg(pp, element), + find_provcfg(pp, "type"), + find_provcfg(pp, "label")); + } idx = 0; LIST_FOREACH(gc, &pp->lg_config, lg_config) { @@ -713,7 +723,7 @@ gpart_show_geom(struct ggeom *gp, const char *element, int show_providers) } if (idx) xo_emit("]"); - xo_emit(" ({h:size/%ld})\n", pp->lg_mediasize); + xo_emit(" ({h:size/%jd})\n", (intmax_t)pp->lg_mediasize); xo_close_instance(s); first = end + 1; } @@ -721,9 +731,10 @@ gpart_show_geom(struct ggeom *gp, const char *element, int show_providers) if (first <= last) { xo_open_instance("unallocated"); length = last - first + 1; - xo_emit(" {t:start/%*jd} {t:sectors/%*jd} {P:/%*s} {ne:free}- free - ({h:size/%ld})\n", + xo_emit(" {t:start/%*jd} {t:sectors/%*jd} " + "{P:/%*s} {ne:free}- free - ({h:size/%jd})\n", wblocks, (intmax_t)first, wblocks, (intmax_t)length, - wname, "", "true", length * secsz); + wname, "", "true", (intmax_t)length * secsz); xo_close_instance("unallocated"); } xo_close_list("partitions"); @@ -1112,7 +1123,7 @@ gpart_bootfile_read(const char *bootfile, ssize_t *size) if (sb.st_size == 0) errx(EXIT_FAILURE, "%s: empty file", bootfile); if (*size > 0 && sb.st_size > *size) - errx(EXIT_FAILURE, "%s: file too big (%zu limit)", bootfile, + errx(EXIT_FAILURE, "%s: file too big (%zd limit)", bootfile, *size); *size = sb.st_size; diff --git a/lib/googletest/Makefile.inc b/lib/googletest/Makefile.inc index 43ebace19a15..b1f7fa814166 100644 --- a/lib/googletest/Makefile.inc +++ b/lib/googletest/Makefile.inc @@ -10,3 +10,6 @@ CXXFLAGS+= ${GTESTS_FLAGS} # Silence warnings about usage of deprecated implicit copy constructors CXXWARNFLAGS+= -Wno-deprecated-copy + +# Silence warnings about implicit character conversions in gtest-printers.h +CXXWARNFLAGS+= ${NO_WCHARACTER_CONVERSION} diff --git a/lib/libc/gen/err.3 b/lib/libc/gen/err.3 index 088ead71239b..70a214152a19 100644 --- a/lib/libc/gen/err.3 +++ b/lib/libc/gen/err.3 @@ -114,6 +114,22 @@ preceded by another colon and space unless the argument is .Dv NULL . .Pp +If the kernel returned an extended error string in addition to the +.Va errno +code, the +.Fn err +function prints the string with interpolated values for parameters, +as provided to the corresponding invocation of +.Xr EXTERROR 9 . +If the extended error string was not provided, but extended error +information was, or even if string was provided and the +.Ev EXTERROR_VERBOSE +environment variable is present, an additional report is printed. +The report includes at least the category of the error, the name of +the source file (if known by the used version of libc), +the source line number, and parameters. +The format of the printed string is not contractual and might be changed. +.Pp In the case of the .Fn errc , .Fn verrc , diff --git a/lib/libc/gen/err.c b/lib/libc/gen/err.c index 16cbe27693e7..793bf7522e42 100644 --- a/lib/libc/gen/err.c +++ b/lib/libc/gen/err.c @@ -120,7 +120,7 @@ vexterr(bool doexterr, int code, const char *fmt, va_list ap) } fprintf(err_file, "%s", strerror(code)); if (doexterr && extstatus == 0 && exterr[0] != '\0') - fprintf(err_file, " (extended error %s)", exterr); + fprintf(err_file, " (%s)", exterr); fprintf(err_file, "\n"); } diff --git a/lib/libc/gen/exterr_cat_filenames.h b/lib/libc/gen/exterr_cat_filenames.h new file mode 100644 index 000000000000..883dd98289cd --- /dev/null +++ b/lib/libc/gen/exterr_cat_filenames.h @@ -0,0 +1,17 @@ +/* + * Automatically @generated, use + * tools/build/make_libc_exterr_cat_filenames.sh + */ + [EXTERR_CAT_FUSE_DEVICE] = "fs/fuse/fuse_device.c", + [EXTERR_CAT_FUSE_VFS] = "fs/fuse/fuse_vfsops.c", + [EXTERR_CAT_FUSE_VNOPS] = "fs/fuse/fuse_vnops.c", + [EXTERR_CAT_GEOM] = "geom/geom_subr.c", + [EXTERR_CAT_GEOMVFS] = "geom/geom_vfs.c", + [EXTERR_CAT_FILEDESC] = "kern/kern_descrip.c", + [EXTERR_CAT_INOTIFY] = "kern/vfs_inotify.c", + [EXTERR_CAT_GENIO] = "kern/sys_generic.c", + [EXTERR_CAT_VFSBIO] = "kern/vfs_bio.c", + [EXTERR_CAT_VFSSYSCALL] = "kern/vfs_syscalls.c", + [EXTERR_CAT_BRIDGE] = "net/if_bridge.c", + [EXTERR_CAT_SWAP] = "vm/swap_pager.c", + [EXTERR_CAT_MMAP] = "vm/vm_mmap.c", diff --git a/lib/libc/gen/uexterr_format.c b/lib/libc/gen/uexterr_format.c index e8ddfbd578e3..8d3b458ca9f2 100644 --- a/lib/libc/gen/uexterr_format.c +++ b/lib/libc/gen/uexterr_format.c @@ -8,28 +8,85 @@ * under sponsorship from the FreeBSD Foundation. */ -#include <sys/types.h> +#include <sys/param.h> #include <sys/exterrvar.h> #include <exterr.h> +#include <stdbool.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> +#include <unistd.h> + +static const char * const cat_to_filenames[] = { +#include "exterr_cat_filenames.h" +}; + +static const char * +cat_to_filename(int category) +{ + if (category < 0 || category >= nitems(cat_to_filenames) || + cat_to_filenames[category] == NULL) + return ("unknown"); + return (cat_to_filenames[category]); +} + +static const char exterror_verbose_name[] = "EXTERROR_VERBOSE"; +enum exterr_verbose_state { + EXTERR_VERBOSE_UNKNOWN = 100, + EXTERR_VERBOSE_DEFAULT, + EXTERR_VERBOSE_ALLOW, +}; +static enum exterr_verbose_state exterror_verbose = EXTERR_VERBOSE_UNKNOWN; + +static void +exterr_verbose_init(void) +{ + /* + * No need to care about thread-safety, the result is + * idempotent. + */ + if (exterror_verbose != EXTERR_VERBOSE_UNKNOWN) + return; + if (issetugid()) { + exterror_verbose = EXTERR_VERBOSE_DEFAULT; + } else if (getenv(exterror_verbose_name) != NULL) { + exterror_verbose = EXTERR_VERBOSE_ALLOW; + } else { + exterror_verbose = EXTERR_VERBOSE_DEFAULT; + } +} int __uexterr_format(const struct uexterror *ue, char *buf, size_t bufsz) { + bool has_msg; + if (bufsz > UEXTERROR_MAXLEN) bufsz = UEXTERROR_MAXLEN; if (ue->error == 0) { strlcpy(buf, "", bufsz); return (0); } - if (ue->msg[0] == '\0') { - snprintf(buf, bufsz, - "errno %d category %u (src line %u) p1 %#jx p2 %#jx", - ue->error, ue->cat, ue->src_line, - (uintmax_t)ue->p1, (uintmax_t)ue->p2); + exterr_verbose_init(); + has_msg = ue->msg[0] != '\0'; + + if (has_msg) { + snprintf(buf, bufsz, ue->msg, (uintmax_t)ue->p1, + (uintmax_t)ue->p2); } else { - strlcpy(buf, ue->msg, bufsz); + strlcpy(buf, "", bufsz); + } + + if (exterror_verbose == EXTERR_VERBOSE_ALLOW || !has_msg) { + char lbuf[128]; + + snprintf(lbuf, sizeof(lbuf), + "errno %d category %u (src sys/%s:%u) p1 %#jx p2 %#jx", + ue->error, ue->cat, cat_to_filename(ue->cat), + ue->src_line, (uintmax_t)ue->p1, (uintmax_t)ue->p2); + if (has_msg) + strlcat(buf, " ", bufsz); + strlcat(buf, lbuf, bufsz); } return (0); } diff --git a/lib/libc/stdlib/Makefile.inc b/lib/libc/stdlib/Makefile.inc index b878a7625e9f..c311ba3d2bcc 100644 --- a/lib/libc/stdlib/Makefile.inc +++ b/lib/libc/stdlib/Makefile.inc @@ -1,19 +1,76 @@ # machine-independent stdlib sources .PATH: ${LIBC_SRCTOP}/${LIBC_ARCH}/stdlib ${LIBC_SRCTOP}/stdlib -MISRCS+=C99_Exit.c a64l.c abort.c abs.c atexit.c atof.c atoi.c atol.c atoll.c \ - bsearch.c bsearch_b.c \ - cxa_thread_atexit.c cxa_thread_atexit_impl.c \ - div.c exit.c getenv.c getopt.c getopt_long.c \ - getsubopt.c hcreate.c hcreate_r.c hdestroy_r.c heapsort.c heapsort_b.c \ - hsearch_r.c imaxabs.c imaxdiv.c \ - insque.c l64a.c labs.c ldiv.c llabs.c lldiv.c lsearch.c memalignment.c \ - merge.c mergesort_b.c ptsname.c qsort.c qsort_r.c qsort_r_compat.c \ - qsort_s.c quick_exit.c radixsort.c rand.c \ - random.c reallocarray.c reallocf.c realpath.c recallocarray.c remque.c \ - set_constraint_handler_s.c strfmon.c strtoimax.c \ - strtol.c strtold.c strtoll.c strtoq.c strtoul.c strtonum.c strtoull.c \ - strtoumax.c strtouq.c system.c tdelete.c tfind.c tsearch.c twalk.c +MISRCS+= \ + C99_Exit.c \ + a64l.c \ + abort.c \ + abs.c \ + atexit.c \ + atof.c \ + atoi.c \ + atol.c \ + atoll.c \ + bsearch.c \ + bsearch_b.c \ + cxa_thread_atexit.c \ + cxa_thread_atexit_impl.c \ + div.c \ + exit.c \ + getenv.c \ + getopt.c \ + getopt_long.c \ + getsubopt.c \ + hcreate.c \ + hcreate_r.c \ + hdestroy_r.c \ + heapsort.c \ + heapsort_b.c \ + hsearch_r.c \ + imaxabs.c \ + imaxdiv.c \ + insque.c \ + l64a.c \ + labs.c \ + ldiv.c \ + llabs.c \ + lldiv.c \ + lsearch.c \ + memalignment.c \ + merge.c \ + mergesort_b.c \ + ptsname.c \ + qsort.c \ + qsort_r.c \ + qsort_r_compat.c \ + qsort_s.c \ + quick_exit.c \ + radixsort.c \ + rand.c \ + random.c \ + reallocarray.c \ + reallocf.c \ + realpath.c \ + recallocarray.c \ + remque.c \ + set_constraint_handler_s.c \ + strfmon.c \ + strtoimax.c \ + strtol.c \ + strtold.c \ + strtoll.c \ + strtoq.c \ + strtoul.c \ + strtonum.c \ + strtoull.c \ + strtoumax.c \ + strtouq.c \ + system.c \ + tdelete.c \ + tdestroy.c \ + tfind.c \ + tsearch.c \ + twalk.c CFLAGS.qsort.c+= -Wsign-compare @@ -90,4 +147,5 @@ MLINKS+=strtoul.3 strtoull.3 \ strtoul.3 strtoumax.3 MLINKS+=tsearch.3 tdelete.3 \ tsearch.3 tfind.3 \ - tsearch.3 twalk.3 + tsearch.3 twalk.3 \ + tsearch.3 tdestroy.3 diff --git a/lib/libc/stdlib/Symbol.map b/lib/libc/stdlib/Symbol.map index 8b7e97c3cbdc..03a6d0b543ac 100644 --- a/lib/libc/stdlib/Symbol.map +++ b/lib/libc/stdlib/Symbol.map @@ -134,6 +134,7 @@ FBSD_1.8 { FBSD_1.9 { memalignment; recallocarray; + tdestroy; }; FBSDprivate_1.0 { diff --git a/lib/libc/stdlib/tdestroy.c b/lib/libc/stdlib/tdestroy.c new file mode 100644 index 000000000000..c324e151da11 --- /dev/null +++ b/lib/libc/stdlib/tdestroy.c @@ -0,0 +1,68 @@ +/* + * Copyright 2025 The FreeBSD Foundation + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This software was developed by Konstantin Belousov <kib@FreeBSD.org> + * under sponsorship from the FreeBSD Foundation. + */ + +#define _SEARCH_PRIVATE +#include <search.h> +#include <stdlib.h> + +static void +nul_node_free(void *node __unused) +{ +} + +/* Find the leftmost node. */ +static posix_tnode * +tdestroy_find_leftmost(posix_tnode *tn) +{ + while (tn->llink != NULL) + tn = tn->llink; + return (tn); +} + +/* + * This algorithm for non-recursive non-allocating destruction of the tree + * is described in + * https://codegolf.stackexchange.com/questions/478/free-a-binary-tree/489#489P + * and in https://devblogs.microsoft.com/oldnewthing/20251107-00/?p=111774. + */ +void +tdestroy(void *rootp, void (*node_free)(void *)) +{ + posix_tnode *tn, *tn_leftmost, *xtn; + + tn = rootp; + if (tn == NULL) + return; + if (node_free == NULL) + node_free = nul_node_free; + tn_leftmost = tn; + + while (tn != NULL) { + /* + * Make the right subtree the left subtree of the + * leftmost node, and recalculate the leftmost. + */ + tn_leftmost = tdestroy_find_leftmost(tn_leftmost); + if (tn->rlink != NULL) { + tn_leftmost->llink = tn->rlink; + tn_leftmost = tn_leftmost->llink; + } + + /* + * At this point, all children of tn have been + * arranged to be reachable via tn->left. We can + * safely delete the current node and advance to its + * left child as the new root. + */ + xtn = tn->llink; + node_free(tn->key); + free(tn); + tn = xtn; + } +} diff --git a/lib/libc/stdlib/tsearch.3 b/lib/libc/stdlib/tsearch.3 index edee01cafc52..f412c37a4ef0 100644 --- a/lib/libc/stdlib/tsearch.3 +++ b/lib/libc/stdlib/tsearch.3 @@ -36,6 +36,7 @@ .In search.h .Ft void * .Fn tdelete "const void * restrict key" "posix_tnode ** restrict rootp" "int (*compar) (const void *, const void *)" +.Fn tdestroy "posix_tnode *root" "(void (*node_free)(void *)" .Ft posix_tnode * .Fn tfind "const void *key" "posix_tnode * const *rootp" "int (*compar) (const void *, const void *)" .Ft posix_tnode * @@ -45,6 +46,7 @@ .Sh DESCRIPTION The .Fn tdelete , +.Fn tdestroy , .Fn tfind , .Fn tsearch , and @@ -95,6 +97,13 @@ If the node to be deleted is the root of the binary search tree, will be adjusted. .Pp The +.Fn tdestroy +function destroys the whole search tree, freeing all allocated nodes. +If tree keys need special handling on free, the +.Fa node_free +function can be provided, which is called on each key. +.Pp +The .Fn twalk function walks the binary search tree rooted in @@ -128,7 +137,9 @@ is NULL or the datum cannot be found. .Pp The .Fn twalk -function returns no value. +and +.Fn tdestroy +functions return no value. .Sh EXAMPLES This example uses .Fn tsearch @@ -184,6 +195,7 @@ main(void) tdelete(four, &root, comp); twalk(root, printwalk); + tdestroy(root, NULL); return 0; } .Ed @@ -192,8 +204,17 @@ main(void) .Xr hsearch 3 , .Xr lsearch 3 .Sh STANDARDS -These functions conform to +These +.Fn tdelete , +.Fn tfind , +.Fn tsearch , +and +.Fn twalk +functions conform to .St -p1003.1-2008 . +The +.Fn tdestroy +function is the glibc extension. .Pp The .Fa posix_tnode diff --git a/lib/libc/tests/stdlib/tsearch_test.c b/lib/libc/tests/stdlib/tsearch_test.c index ee9deec588cb..f42729e5e75c 100644 --- a/lib/libc/tests/stdlib/tsearch_test.c +++ b/lib/libc/tests/stdlib/tsearch_test.c @@ -147,10 +147,75 @@ ATF_TC_BODY(tsearch_test, tc) ATF_CHECK_EQ(NULL, root); } +static int nodes; + +struct my_data { + int key; +}; + +static struct my_data * +new_my_data(int key) +{ + struct my_data *res; + + res = malloc(sizeof(struct my_data)); + res->key = key; + nodes++; + return (res); +} + +void +free_my_data(void *mdp) +{ + free(mdp); + nodes--; +} + +static int +compare_my_data(const void *mdp1, const void *mdp2) +{ + const struct my_data *md1, *md2; + + md1 = mdp1; + md2 = mdp2; + + return (md1->key - md2->key); +} + +static posix_tnode *root = NULL; + +static void +insert(int x) +{ + struct my_data *md; + + md = new_my_data(x); + tsearch(md, &root, compare_my_data); +} + +ATF_TC_WITHOUT_HEAD(tdestroy_test); +ATF_TC_BODY(tdestroy_test, tc) +{ + root = NULL; + insert(1); + insert(100); + insert(1000); + insert(5); + insert(6); + insert(12); + insert(2000); + insert(3); + + ATF_CHECK_EQ(8, nodes); + tdestroy(root, free_my_data); + ATF_CHECK_EQ(0, nodes); +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, tsearch_test); + ATF_TP_ADD_TC(tp, tdestroy_test); return (atf_no_error()); } diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index 7e5a07ccd55a..f8c92a5cd319 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -3757,7 +3757,8 @@ struct nl_astats { struct pfr_astats *a; size_t max; size_t count; - uint64_t total_count; + uint32_t total_count; + uint32_t zeroed; }; #define _OUT(_field) offsetof(struct pfr_astats, _field) @@ -3792,6 +3793,7 @@ snl_attr_get_pfr_astats(struct snl_state *ss, struct nlattr *nla, static struct snl_attr_parser ap_table_get_astats[] = { { .type = PF_TAS_ASTATS, .off = 0, .cb = snl_attr_get_pfr_astats }, { .type = PF_TAS_ASTATS_COUNT, .off = _OUT(total_count), .cb = snl_attr_get_uint32 }, + { .type = PF_TAS_ASTATS_ZEROED, .off = _OUT(zeroed), .cb = snl_attr_get_uint32 }, }; #undef _OUT SNL_DECLARE_PARSER(table_astats_parser, struct genlmsghdr, snl_f_p_empty, ap_table_get_astats); @@ -3843,3 +3845,68 @@ pfctl_get_astats(struct pfctl_handle *h, const struct pfr_table *tbl, return (0); } + +static int +_pfctl_clr_astats(struct pfctl_handle *h, const struct pfr_table *tbl, + struct pfr_addr *addrs, int size, int *nzero, int flags) +{ + struct snl_writer nw; + struct snl_errmsg_data e = {}; + struct nlmsghdr *hdr; + uint32_t seq_id; + struct nl_astats attrs; + int family_id; + + family_id = snl_get_genl_family(&h->ss, PFNL_FAMILY_NAME); + if (family_id == 0) + return (ENOTSUP); + + snl_init_writer(&h->ss, &nw); + hdr = snl_create_genl_msg_request(&nw, family_id, PFNL_CMD_TABLE_CLEAR_ASTATS); + + snl_add_msg_attr_table(&nw, PF_TA_TABLE, tbl); + snl_add_msg_attr_u32(&nw, PF_TA_FLAGS, flags); + for (int i = 0; i < size; i++) + snl_add_msg_attr_pfr_addr(&nw, PF_TA_ADDR, &addrs[i]); + + if ((hdr = snl_finalize_msg(&nw)) == NULL) + return (ENXIO); + seq_id = hdr->nlmsg_seq; + + if (! snl_send_message(&h->ss, hdr)) + return (ENXIO); + + while ((hdr = snl_read_reply_multi(&h->ss, seq_id, &e)) != NULL) { + if (! snl_parse_nlmsg(&h->ss, hdr, &table_astats_parser, &attrs)) + continue; + } + + if (nzero) + *nzero = attrs.zeroed; + + return (e.error); +} + +int +pfctl_clr_astats(struct pfctl_handle *h, const struct pfr_table *tbl, + struct pfr_addr *addrs, int size, int *nzero, int flags) +{ + int ret; + int off = 0; + int partial_zeroed; + int chunk_size; + + do { + chunk_size = MIN(size - off, 256); + ret = _pfctl_clr_astats(h, tbl, &addrs[off], chunk_size, + &partial_zeroed, flags); + if (ret != 0) + break; + if (nzero) + *nzero += partial_zeroed; + off += chunk_size; + } while (off < size); + + return (ret); +} + diff --git a/lib/libpfctl/libpfctl.h b/lib/libpfctl/libpfctl.h index 9576118fe146..b885497ab0e8 100644 --- a/lib/libpfctl/libpfctl.h +++ b/lib/libpfctl/libpfctl.h @@ -587,5 +587,7 @@ int pfctl_clear_addrs(struct pfctl_handle *h, const struct pfr_table *filter, int pfctl_get_astats(struct pfctl_handle *h, const struct pfr_table *tbl, struct pfr_astats *addr, int *size, int flags); +int pfctl_clr_astats(struct pfctl_handle *h, const struct pfr_table *tbl, + struct pfr_addr *addr, int size, int *nzero, int flags); #endif diff --git a/lib/libsys/ioctl.2 b/lib/libsys/ioctl.2 index e96c5c48d097..5784f43ef98b 100644 --- a/lib/libsys/ioctl.2 +++ b/lib/libsys/ioctl.2 @@ -25,7 +25,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd September 11, 2013 +.Dd December 29, 2025 .Dt IOCTL 2 .Os .Sh NAME @@ -110,6 +110,9 @@ The system call will fail if: .Bl -tag -width Er +.It Bq Er EACCES +The process does not have permission to call this +.Nm . .It Bq Er EBADF The .Fa fd diff --git a/sbin/ipfw/ipfw.8 b/sbin/ipfw/ipfw.8 index 7a81c84de3e4..867a43868ecc 100644 --- a/sbin/ipfw/ipfw.8 +++ b/sbin/ipfw/ipfw.8 @@ -1,5 +1,5 @@ .\" -.Dd December 10, 2025 +.Dd December 29, 2025 .Dt IPFW 8 .Os .Sh NAME @@ -104,6 +104,11 @@ in-kernel NAT.\& .Cm config .Ar config-options .Nm +.Op Fl q +.Cm nat +.Ar number +.Cm delete +.Nm .Cm nat .Ar number .Cm show @@ -839,8 +844,12 @@ When a packet matches a rule with the .Cm setmark keyword, a 32-bit numeric mark is assigned to the packet. The mark is an extension to the tags. -As tags, mark is "sticky" so the value is kept the same within the kernel and -is lost when the packet leaves the kernel. +The mark is preserved for a packet within a single ipfw ruleset traversal +and is lost when the packet is checked against the active ruleset +next time (see +.Sx PACKET FLOW +section) or leaves ipfw context (e.g. accepted, +diverted, bridged or routed). Unlike tags, mark can be matched as a lookup table key or compared with bitwise mask applied against another value. Each packet can have only one mark, so @@ -3507,6 +3516,15 @@ For more information about aliasing modes, refer to See Section .Sx EXAMPLES for some examples of nat usage. +.Pp +To delete specific nat configuration instance, use the following command: +.Bd -ragged -offset indent +.Bk -words +.Cm nat +.Ar nat_number +.Cm delete +.Ek +.Ed .Ss REDIRECT AND LSNAT SUPPORT IN IPFW Redirect and LSNAT support follow closely the syntax used in .Xr natd 8 . diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y index 127e2c257d69..c52eb3f86c60 100644 --- a/sbin/pfctl/parse.y +++ b/sbin/pfctl/parse.y @@ -7604,6 +7604,7 @@ map_tos(char *s, int *val) { "cs6", IPTOS_DSCP_CS6 }, { "cs7", IPTOS_DSCP_CS7 }, { "ef", IPTOS_DSCP_EF }, + { "va", IPTOS_DSCP_VA }, { "inetcontrol", IPTOS_PREC_INTERNETCONTROL }, { "lowdelay", IPTOS_LOWDELAY }, { "netcontrol", IPTOS_PREC_NETCONTROL }, diff --git a/sbin/pfctl/pfctl_radix.c b/sbin/pfctl/pfctl_radix.c index 3ea127dd2451..e8d3a1b8dcc3 100644 --- a/sbin/pfctl/pfctl_radix.c +++ b/sbin/pfctl/pfctl_radix.c @@ -201,23 +201,13 @@ int pfr_clr_astats(struct pfr_table *tbl, struct pfr_addr *addr, int size, int *nzero, int flags) { - struct pfioc_table io; + int ret; - if (size < 0 || !tbl || (size && !addr)) { - errno = EINVAL; - return (-1); - } - bzero(&io, sizeof io); - io.pfrio_flags = flags; - io.pfrio_table = *tbl; - io.pfrio_buffer = addr; - io.pfrio_esize = sizeof(*addr); - io.pfrio_size = size; - if (ioctl(dev, DIOCRCLRASTATS, &io) == -1) - return (-1); - if (nzero) - *nzero = io.pfrio_nzero; - return (0); + ret = pfctl_clr_astats(pfh, tbl, addr, size, nzero, flags); + if (ret != 0) + errno = ret; + + return (ret); } int diff --git a/share/man/man4/cpuctl.4 b/share/man/man4/cpuctl.4 index fc42cf14f254..5846fc4129f8 100644 --- a/share/man/man4/cpuctl.4 +++ b/share/man/man4/cpuctl.4 @@ -1,3 +1,6 @@ +.\" +.\" SPDX-License-Identifier: BSD-2-Clause +.\" .\" Copyright (c) 2006-2008 Stanislav Sedov <stas@FreeBSD.org> .\" All rights reserved. .\" @@ -63,7 +66,7 @@ All of the supported operations are invoked using the .Xr ioctl 2 system call. Currently, the following ioctls are defined: -.Bl -tag -width CPUCTL_CPUID_COUNT +.Bl -tag -width indent .It Dv CPUCTL_RDMSR Fa cpuctl_msr_args_t *args .It Dv CPUCTL_WRMSR Fa cpuctl_msr_args_t *args Read/write CPU machine specific register. @@ -92,6 +95,7 @@ typedef struct { uint32_t data[4]; } cpuctl_cpuid_args_t; .Ed +.Pp It is equivalent to the .Dv CPUCTL_CPUID_COUNT request with @@ -107,6 +111,7 @@ typedef struct { uint32_t data[4]; } cpuctl_cpuid_count_args_t; .Ed +.Pp The .Va level field indicates the CPUID level to retrieve, diff --git a/share/man/man4/genet.4 b/share/man/man4/genet.4 index 665aaff49507..1de92294ee9d 100644 --- a/share/man/man4/genet.4 +++ b/share/man/man4/genet.4 @@ -1,3 +1,6 @@ +.\" +.\" SPDX-License-Identifier: BSD-2-Clause +.\" .\" Copyright (c) 2021 Michael J. Karels .\" .\" Redistribution and use in source and binary forms, with or without @@ -22,7 +25,7 @@ .\" SUCH DAMAGE. .\" .Dd December 8, 2021 -.Dt GENET 4 +.Dt GENET 4 aarch64 .Os .Sh NAME .Nm genet diff --git a/share/man/man4/linprocfs.4 b/share/man/man4/linprocfs.4 index dcd1c642b409..043dedbd723a 100644 --- a/share/man/man4/linprocfs.4 +++ b/share/man/man4/linprocfs.4 @@ -1,7 +1,7 @@ .\" Written by Garrett Wollman .\" This file is in the public domain. .\" -.Dd May 29, 2025 +.Dd December 26, 2025 .Dt LINPROCFS 4 .Os .Sh NAME @@ -126,11 +126,11 @@ Information about the swap device if any. Time since the last boot and time spent in idle state. .It Pa /compat/linux/proc/version Version of the emulated linux system. -.It Pa /compat/linux/proc/pid +.It Pa /compat/linux/proc/ Ns Ao Ar pid Ac A directory containing process information for process -.Pa pid . +.Ar pid . .It Pa /compat/linux/proc/self -A directory containing process information for the current process. +A symlink to a directory containing process information for the current process. .El .Sh EXAMPLES To mount a diff --git a/share/man/man4/linuxkpi_wlan.4 b/share/man/man4/linuxkpi_wlan.4 index 136e04c32bb7..65c77d8d7631 100644 --- a/share/man/man4/linuxkpi_wlan.4 +++ b/share/man/man4/linuxkpi_wlan.4 @@ -6,7 +6,7 @@ .\" This documentation was written by Bj\xc3\xb6rn Zeeb under sponsorship from .\" the FreeBSD Foundation. .\" -.Dd June 13, 2025 +.Dd December 28, 2025 .Dt LINUXKPI_WLAN 4 .Os .Sh NAME @@ -112,6 +112,13 @@ Print statistics for a given, associated .Xr wlan 4 interface; typically IF would be .Em wlan0 . +.It Va compat.linuxkpi.80211.IF.dump_stas_queues +Like +.Va compat.linuxkpi.80211.IF.dump_stas +but also print queue statistics. +This sysctl is +.Sq hidden +and normally only needed for debugging purposes. .El .Sh SEE ALSO .Xr iwlwifi 4 , diff --git a/share/man/man4/vt.4 b/share/man/man4/vt.4 index 6176c8c3093e..d59030cfff9d 100644 --- a/share/man/man4/vt.4 +++ b/share/man/man4/vt.4 @@ -420,7 +420,6 @@ at boot: .Xr getty 8 , .Xr kldload 8 , .Xr moused 8 , -.Xr vidcontrol 8 , .Xr vtfontcvt 8 .Sh HISTORY The diff --git a/share/man/man5/src.conf.5 b/share/man/man5/src.conf.5 index 1d55ab074a45..f028a3d1aac4 100644 --- a/share/man/man5/src.conf.5 +++ b/share/man/man5/src.conf.5 @@ -1,5 +1,5 @@ .\" DO NOT EDIT-- this file is @generated by tools/build/options/makeman. -.Dd December 21, 2025 +.Dd December 29, 2025 .Dt SRC.CONF 5 .Os .Sh NAME @@ -1590,6 +1590,13 @@ option. Exclude build metadata (such as the build time, user, or host) from the kernel, boot loaders, and uname output, so that builds produce bit-for-bit identical output. +.It Va WITH_REPRODUCIBLE_PATHS +Modify the paths encoded in binary artifacts to be standard path + +Normally, the actual path is encoded in the binary. However, this makes the +build differ depending on the path it was built from. With this option enabled, +the paths recorded are /usr/src, regardless of the actual path. With this option +disabled, the actual paths are recorded. .It Va WITHOUT_RESCUE Do not build .Xr rescue 8 . diff --git a/share/man/man7/environ.7 b/share/man/man7/environ.7 index 51fb6544fc5a..ada2cc45a650 100644 --- a/share/man/man7/environ.7 +++ b/share/man/man7/environ.7 @@ -114,6 +114,18 @@ A startup list of commands read by .Xr ex 1 and .Xr vi 1 . +.It Ev EXTERROR_VERBOSE +Request the +.Xr err 3 +and +.Xr uexterr_gettext +functions to unconditionally report additional information, +mostly useful for the (kernel) developer to diagnose the issue. +See +.Xr err 3 +and +.Xr exterror 9 +for more details. .It Ev HOME A user's login directory, set by .Xr login 1 @@ -298,6 +310,7 @@ built-in command in .Xr cd 1 , .Xr csh 1 , .Xr env 1 , +.Xr err 3 , .Xr ex 1 , .Xr login 1 , .Xr printenv 1 , @@ -311,7 +324,8 @@ built-in command in .Xr system 3 , .Xr termcap 3 , .Xr termcap 5 , -.Xr simd 7 +.Xr simd 7 , +.Xr exterror 9 .Sh HISTORY The .Nm diff --git a/share/man/man9/exterror.9 b/share/man/man9/exterror.9 index fd4b732b8213..a7c7a11d1315 100644 --- a/share/man/man9/exterror.9 +++ b/share/man/man9/exterror.9 @@ -90,6 +90,16 @@ The .Fn EXTERROR macro can take two optional 64-bit integer arguments, whose meaning is specific to the subsystem. +The format string may include up to two printf-like format +specifiers to insert the optional argument values in the +user output, which is done in userspace. +.Pp +The format specifier must be for an integer type, and include the +.Dq j +format modifier to accept only the types +.Vt intmax_t +or +.Vt uintmax_t . .El .Pp The strings passed as the second argument are only retained diff --git a/share/man/man9/locking.9 b/share/man/man9/locking.9 index b29cd07e2c2a..ad044b6e1d46 100644 --- a/share/man/man9/locking.9 +++ b/share/man/man9/locking.9 @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd February 3, 2023 +.Dd December 28, 2025 .Dt LOCKING 9 .Os .Sh NAME @@ -371,9 +371,9 @@ functions, and any of the .Fn sleep functions. -.Bl -column ".Ic xxxxxxxxxxxxxxxx" ".Xr XXXXXXXXX" ".Xr XXXXXXXXX" ".Xr XXXXXXX" ".Xr XXXXXXXXX" ".Xr XXXXXX" -offset 3n +.Bl -column " You want:" "spin mtx " "mutex/rw " "rmlock " "sleep rm " "sx/lk " -offset 3n .It Em " You want:" Ta spin mtx Ta mutex/rw Ta rmlock Ta sleep rm Ta sx/lk Ta sleep -.It Em "You have: " Ta -------- Ta -------- Ta ------ Ta -------- Ta ------ Ta ------ +.It Em "You have:" Ta -------- Ta -------- Ta ------ Ta -------- Ta ----- Ta ------ .It spin mtx Ta \&ok Ta \&no Ta \&no Ta \&no Ta \&no Ta \&no-1 .It mutex/rw Ta \&ok Ta \&ok Ta \&ok Ta \&no Ta \&no Ta \&no-1 .It rmlock Ta \&ok Ta \&ok Ta \&ok Ta \&no Ta \&no Ta \&no-1 @@ -407,13 +407,13 @@ Note that non-blocking try operations on locks are always permitted. .Ss Context mode table The next table shows what can be used in different contexts. At this time this is a rather easy to remember table. -.Bl -column ".Ic Xxxxxxxxxxxxxxxxxxx" ".Xr XXXXXXXXX" ".Xr XXXXXXXXX" ".Xr XXXXXXX" ".Xr XXXXXXXXX" ".Xr XXXXXX" -offset 3n +.Bl -column "interrupt filter: " "spin mtx " "mutex/rw " "rmlock " "sleep rm " "sx/lk " -offset 3n .It Em "Context:" Ta spin mtx Ta mutex/rw Ta rmlock Ta sleep rm Ta sx/lk Ta sleep .It interrupt filter: Ta \&ok Ta \&no Ta \&no Ta \&no Ta \&no Ta \&no .It interrupt thread: Ta \&ok Ta \&ok Ta \&ok Ta \&no Ta \&no Ta \&no -.It callout: Ta \&ok Ta \&ok Ta \&ok Ta \&no Ta \&no Ta \&no -.It direct callout: Ta \&ok Ta \&no Ta \&no Ta \&no Ta \&no Ta \&no -.It system call: Ta \&ok Ta \&ok Ta \&ok Ta \&ok Ta \&ok Ta \&ok +.It callout: Ta \&ok Ta \&ok Ta \&ok Ta \&no Ta \&no Ta \&no +.It direct callout: Ta \&ok Ta \&no Ta \&no Ta \&no Ta \&no Ta \&no +.It system call: Ta \&ok Ta \&ok Ta \&ok Ta \&ok Ta \&ok Ta \&ok .El .Sh SEE ALSO .Xr lockstat 1 , diff --git a/share/mk/bsd.debug.mk b/share/mk/bsd.debug.mk index cf2fb4356aef..9f4dc5d90484 100644 --- a/share/mk/bsd.debug.mk +++ b/share/mk/bsd.debug.mk @@ -16,7 +16,7 @@ MK_WERROR= no # If reproducible build mode is enabled, map the root of the source # directory to /usr/src and the root of the object directory to # /usr/obj. -.if ${MK_REPRODUCIBLE_BUILD} != "no" && !defined(DEBUG_PREFIX) +.if ${MK_REPRODUCIBLE_PATHS} != "no" && !defined(DEBUG_PREFIX) .if defined(SRCTOP) DEBUG_PREFIX+= ${SRCTOP:S,/$,,}=/usr/src .endif diff --git a/share/mk/bsd.opts.mk b/share/mk/bsd.opts.mk index 66eb427c3505..4902e6a6bf4c 100644 --- a/share/mk/bsd.opts.mk +++ b/share/mk/bsd.opts.mk @@ -79,6 +79,7 @@ __DEFAULT_NO_OPTIONS = \ INSTALL_AS_USER \ MANSPLITPKG \ REPRODUCIBLE_BUILD \ + REPRODUCIBLE_PATHS \ RETPOLINE \ RUN_TESTS \ STALE_STAGED \ diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk index 2134886abcf5..c5f2c2bb783f 100644 --- a/share/mk/bsd.sys.mk +++ b/share/mk/bsd.sys.mk @@ -93,6 +93,11 @@ CWARNFLAGS.clang+= -Wno-error=unused-but-set-parameter # Similar to gcc >= 8.1 -Wno-error=cast-function-type below CWARNFLAGS.clang+= -Wno-error=cast-function-type-mismatch .endif +.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 210000 +CXXWARNFLAGS.clang+= -Wno-c++20-extensions +CXXWARNFLAGS.clang+= -Wno-c++23-lambda-attributes +CXXWARNFLAGS.clang+= -Wno-nullability-completeness +.endif .endif # WARNS <= 6 .if ${WARNS} <= 3 CWARNFLAGS.clang+= -Wno-tautological-compare -Wno-unused-value\ @@ -128,6 +133,9 @@ NO_WARRAY_PARAMETER= -Wno-array-parameter NO_WSTRICT_PROTOTYPES= -Wno-strict-prototypes NO_WDEPRECATED_NON_PROTOTYPE=-Wno-deprecated-non-prototype .endif +.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 210000 +NO_WCHARACTER_CONVERSION=-Wno-character-conversion +.endif .if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 50200 NO_WUNUSED_BUT_SET_VARIABLE=-Wno-unused-but-set-variable .endif diff --git a/share/mk/googletest.test.inc.mk b/share/mk/googletest.test.inc.mk index 9ef5a3ceac00..5f4445e76205 100644 --- a/share/mk/googletest.test.inc.mk +++ b/share/mk/googletest.test.inc.mk @@ -10,3 +10,6 @@ GTESTS_CXXFLAGS+= -frtti CXXFLAGS+= -I${DESTDIR}${INCLUDEDIR}/private NO_WTHREAD_SAFETY= + +# Silence warnings about implicit character conversions in gtest-printers.h +CXXWARNFLAGS+= ${NO_WCHARACTER_CONVERSION} diff --git a/share/vt/fonts/Makefile b/share/vt/fonts/Makefile index 01f56a235e5e..706207e70070 100644 --- a/share/vt/fonts/Makefile +++ b/share/vt/fonts/Makefile @@ -21,7 +21,7 @@ FILES= ${FONTS} INDEX.fonts CLEANFILES+= ${FONTS} -.SUFFIXES: .bdf .fnt .fnt.uu .hex +.SUFFIXES: .bdf .fnt .hex .bdf.fnt .hex.fnt: vtfontcvt -o ${.TARGET} ${.IMPSRC} diff --git a/stand/efi/loader/arch/amd64/multiboot2.c b/stand/efi/loader/arch/amd64/multiboot2.c index 086dba33895a..b1c60601a8bd 100644 --- a/stand/efi/loader/arch/amd64/multiboot2.c +++ b/stand/efi/loader/arch/amd64/multiboot2.c @@ -558,5 +558,11 @@ obj_exec(struct preloaded_file *fp) return (EFTYPE); } -struct file_format multiboot2 = { loadfile, exec }; -struct file_format multiboot2_obj = { obj_loadfile, obj_exec }; +struct file_format multiboot2 = { + .l_load = loadfile, + .l_exec = exec +}; +struct file_format multiboot2_obj = { + .l_load = obj_loadfile, + .l_exec = obj_exec +}; diff --git a/stand/efi/loader/arch/arm/exec.c b/stand/efi/loader/arch/arm/exec.c index 3963b6c0104b..50e94af05fd2 100644 --- a/stand/efi/loader/arch/arm/exec.c +++ b/stand/efi/loader/arch/arm/exec.c @@ -90,8 +90,8 @@ __elfN(arm_exec)(struct preloaded_file *fp) } static struct file_format arm_elf = { - __elfN(arm_load), - __elfN(arm_exec) + .l_load = __elfN(arm_load), + .l_exec = __elfN(arm_exec) }; struct file_format *file_formats[] = { diff --git a/stand/efi/loader/arch/arm64/exec.c b/stand/efi/loader/arch/arm64/exec.c index 89e2ad7521a8..6b5181b54507 100644 --- a/stand/efi/loader/arch/arm64/exec.c +++ b/stand/efi/loader/arch/arm64/exec.c @@ -43,8 +43,8 @@ static int elf64_exec(struct preloaded_file *amp); static int elf64_obj_exec(struct preloaded_file *amp); static struct file_format arm64_elf = { - elf64_loadfile, - elf64_exec + .l_load = elf64_loadfile, + .l_exec = elf64_exec }; struct file_format *file_formats[] = { diff --git a/stand/efi/loader/arch/riscv/exec.c b/stand/efi/loader/arch/riscv/exec.c index 8d1a0bd03de0..64e522775471 100644 --- a/stand/efi/loader/arch/riscv/exec.c +++ b/stand/efi/loader/arch/riscv/exec.c @@ -106,8 +106,8 @@ __elfN(exec)(struct preloaded_file *fp) } static struct file_format riscv_elf = { - __elfN(loadfile), - __elfN(exec) + .l_load = __elfN(loadfile), + .l_exec = __elfN(exec) }; struct file_format *file_formats[] = { diff --git a/stand/i386/libi386/elf32_freebsd.c b/stand/i386/libi386/elf32_freebsd.c index ae5702e5e65f..40111bdd4d6c 100644 --- a/stand/i386/libi386/elf32_freebsd.c +++ b/stand/i386/libi386/elf32_freebsd.c @@ -39,8 +39,14 @@ static int elf32_exec(struct preloaded_file *amp); static int elf32_obj_exec(struct preloaded_file *amp); -struct file_format i386_elf = { elf32_loadfile, elf32_exec }; -struct file_format i386_elf_obj = { elf32_obj_loadfile, elf32_obj_exec }; +struct file_format i386_elf = { + .l_load = elf32_loadfile, + .l_exec = elf32_exec +}; +struct file_format i386_elf_obj = { + .l_load = elf32_obj_loadfile, + .l_exec = elf32_obj_exec +}; /* * There is an ELF kernel and one or more ELF modules loaded. diff --git a/stand/i386/libi386/elf64_freebsd.c b/stand/i386/libi386/elf64_freebsd.c index 89cc249e9d96..73d1ad088824 100644 --- a/stand/i386/libi386/elf64_freebsd.c +++ b/stand/i386/libi386/elf64_freebsd.c @@ -43,8 +43,14 @@ static int elf64_exec(struct preloaded_file *amp); static int elf64_obj_exec(struct preloaded_file *amp); -struct file_format amd64_elf = { elf64_loadfile, elf64_exec }; -struct file_format amd64_elf_obj = { elf64_obj_loadfile, elf64_obj_exec }; +struct file_format amd64_elf = { + .l_load = elf64_loadfile, + .l_exec = elf64_exec +}; +struct file_format amd64_elf_obj = { + .l_load = elf64_obj_loadfile, + .l_exec = elf64_obj_exec +}; /* * i386's pmap_pae.h doesn't provide this, so diff --git a/stand/i386/libi386/multiboot.c b/stand/i386/libi386/multiboot.c index e2bd44fe83f5..f30787ecebe0 100644 --- a/stand/i386/libi386/multiboot.c +++ b/stand/i386/libi386/multiboot.c @@ -67,9 +67,14 @@ static int multiboot_exec(struct preloaded_file *); static int multiboot_obj_loadfile(char *, uint64_t, struct preloaded_file **); static int multiboot_obj_exec(struct preloaded_file *fp); -struct file_format multiboot = { multiboot_loadfile, multiboot_exec }; -struct file_format multiboot_obj = - { multiboot_obj_loadfile, multiboot_obj_exec }; +struct file_format multiboot = { + .l_load = multiboot_loadfile, + .l_exec = multiboot_exec +}; +struct file_format multiboot_obj = { + .l_load = multiboot_obj_loadfile, + .l_exec = multiboot_obj_exec +}; extern void multiboot_tramp(); diff --git a/stand/kboot/kboot/arch/aarch64/exec.c b/stand/kboot/kboot/arch/aarch64/exec.c index df3e922dfe11..bc7cd6917e13 100644 --- a/stand/kboot/kboot/arch/aarch64/exec.c +++ b/stand/kboot/kboot/arch/aarch64/exec.c @@ -73,8 +73,8 @@ int bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp, #endif static struct file_format arm64_elf = { - elf64_loadfile, - elf64_exec + .l_load = elf64_loadfile, + .l_exec = elf64_exec }; struct file_format *file_formats[] = { diff --git a/stand/kboot/kboot/arch/powerpc64/ppc64_elf_freebsd.c b/stand/kboot/kboot/arch/powerpc64/ppc64_elf_freebsd.c index ae398e357df2..65c43a411433 100644 --- a/stand/kboot/kboot/arch/powerpc64/ppc64_elf_freebsd.c +++ b/stand/kboot/kboot/arch/powerpc64/ppc64_elf_freebsd.c @@ -157,10 +157,9 @@ ppc64_elf_exec(struct preloaded_file *fp) while (1) {} } -struct file_format ppc_elf64 = -{ - ppc64_elf_loadfile, - ppc64_elf_exec +struct file_format ppc_elf64 = { + .l_load = ppc64_elf_loadfile, + .l_exec = ppc64_elf_exec }; /* diff --git a/stand/powerpc/ofw/elf_freebsd.c b/stand/powerpc/ofw/elf_freebsd.c index 4d34fa18c5dd..5f8d84ac8bec 100644 --- a/stand/powerpc/ofw/elf_freebsd.c +++ b/stand/powerpc/ofw/elf_freebsd.c @@ -97,8 +97,7 @@ __elfN(ofw_exec)(struct preloaded_file *fp) panic("exec returned"); } -struct file_format ofw_elf = -{ - __elfN(ofw_loadfile), - __elfN(ofw_exec) +struct file_format ofw_elf = { + .l_load = __elfN(ofw_loadfile), + .l_exec = __elfN(ofw_exec) }; diff --git a/stand/powerpc/ofw/ppc-common.ldscript b/stand/powerpc/ofw/ppc-common.ldscript index e12dee74824a..edd37eba8fca 100644 --- a/stand/powerpc/ofw/ppc-common.ldscript +++ b/stand/powerpc/ofw/ppc-common.ldscript @@ -9,7 +9,7 @@ PHDRS SECTIONS { /* Read-only sections, merged into text segment: */ - . = 0x02c00000 + SIZEOF_HEADERS; + . = 0x02c00000 + SIZEOF_HEADERS + 32; .interp : { *(.interp) } :text .hash : { *(.hash) } .dynsym : { *(.dynsym) } diff --git a/stand/powerpc/ofw/ppc64_elf_freebsd.c b/stand/powerpc/ofw/ppc64_elf_freebsd.c index bc68d129f353..92d394963678 100644 --- a/stand/powerpc/ofw/ppc64_elf_freebsd.c +++ b/stand/powerpc/ofw/ppc64_elf_freebsd.c @@ -101,8 +101,7 @@ ppc64_ofw_elf_exec(struct preloaded_file *fp) panic("exec returned"); } -struct file_format ofw_elf64 = -{ - ppc64_ofw_elf_loadfile, - ppc64_ofw_elf_exec +struct file_format ofw_elf64 = { + .l_load = ppc64_ofw_elf_loadfile, + .l_exec = ppc64_ofw_elf_exec }; diff --git a/stand/uboot/arch/powerpc/ppc64_elf_freebsd.c b/stand/uboot/arch/powerpc/ppc64_elf_freebsd.c index e500b862de2e..1df64d166840 100644 --- a/stand/uboot/arch/powerpc/ppc64_elf_freebsd.c +++ b/stand/uboot/arch/powerpc/ppc64_elf_freebsd.c @@ -88,8 +88,7 @@ ppc64_uboot_elf_exec(struct preloaded_file *fp) panic("exec returned"); } -struct file_format uboot_elf64 = -{ - ppc64_uboot_elf_loadfile, - ppc64_uboot_elf_exec +struct file_format uboot_elf64 = { + .l_load = ppc64_uboot_elf_loadfile, + .l_exec = ppc64_uboot_elf_exec }; diff --git a/stand/uboot/elf_freebsd.c b/stand/uboot/elf_freebsd.c index 3b1bdc542538..772ba32bb7b7 100644 --- a/stand/uboot/elf_freebsd.c +++ b/stand/uboot/elf_freebsd.c @@ -87,6 +87,6 @@ __elfN(uboot_exec)(struct preloaded_file *fp) } struct file_format uboot_elf = { - __elfN(uboot_load), - __elfN(uboot_exec) + .l_load = __elfN(uboot_load), + .l_exec = __elfN(uboot_exec) }; diff --git a/stand/userboot/userboot/elf32_freebsd.c b/stand/userboot/userboot/elf32_freebsd.c index c2492dce7397..984218f419d9 100644 --- a/stand/userboot/userboot/elf32_freebsd.c +++ b/stand/userboot/userboot/elf32_freebsd.c @@ -39,8 +39,14 @@ static int elf32_exec(struct preloaded_file *amp); static int elf32_obj_exec(struct preloaded_file *amp); -struct file_format i386_elf = { elf32_loadfile, elf32_exec }; -struct file_format i386_elf_obj = { elf32_obj_loadfile, elf32_obj_exec }; +struct file_format i386_elf = { + .l_load = elf32_loadfile, + .l_exec = elf32_exec +}; +struct file_format i386_elf_obj = { + .l_load = elf32_obj_loadfile, + .l_exec = elf32_obj_exec +}; #define GUEST_STACK 0x1000 /* Initial stack base */ #define GUEST_GDT 0x3000 /* Address of initial GDT */ diff --git a/stand/userboot/userboot/elf64_freebsd.c b/stand/userboot/userboot/elf64_freebsd.c index 5a63fdb4990c..b4cbefd07aad 100644 --- a/stand/userboot/userboot/elf64_freebsd.c +++ b/stand/userboot/userboot/elf64_freebsd.c @@ -43,8 +43,14 @@ static int elf64_exec(struct preloaded_file *amp); static int elf64_obj_exec(struct preloaded_file *amp); -struct file_format amd64_elf = { elf64_loadfile, elf64_exec }; -struct file_format amd64_elf_obj = { elf64_obj_loadfile, elf64_obj_exec }; +struct file_format amd64_elf = { + .l_load = elf64_loadfile, + .l_exec = elf64_exec +}; +struct file_format amd64_elf_obj = { + .l_load = elf64_obj_loadfile, + .l_exec = elf64_obj_exec +}; #define GUEST_NULL_SEL 0 #define GUEST_CODE_SEL 1 diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c index 773a786d08f7..3f18817030c1 100644 --- a/sys/cam/scsi/scsi_da.c +++ b/sys/cam/scsi/scsi_da.c @@ -2059,8 +2059,9 @@ dainit(void) status = xpt_register_async(AC_FOUND_DEVICE, daasync, NULL, NULL); if (status != CAM_REQ_CMP) { - printf("da: Failed to attach master async callback " - "due to status 0x%x!\n", status); + printf( + "da: Failed to attach master async callback due to status 0x%x!\n", + status); } else if (da_send_ordered) { /* Register our shutdown event handler */ if ((EVENTHANDLER_REGISTER(shutdown_post_sync, dashutdown, @@ -2186,10 +2187,10 @@ daasync(void *callback_arg, uint32_t code, path, daasync, AC_FOUND_DEVICE, cgd); - if (status != CAM_REQ_CMP - && status != CAM_REQ_INPROG) - printf("daasync: Unable to attach to new device " - "due to status 0x%x\n", status); + if (status != CAM_REQ_CMP && status != CAM_REQ_INPROG) + printf( + "daasync: Unable to attach to new device due to status 0x%x\n", + status); return; } case AC_ADVINFO_CHANGED: /* Doesn't touch periph */ @@ -2372,8 +2373,7 @@ dasysctlinit(void *context, int pending) SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "optimal_nonseq_zones", CTLFLAG_RD, &softc->optimal_nonseq_zones, - "Optimal Number of Non-Sequentially Written Sequential Write " - "Preferred Zones"); + "Optimal Number of Non-Sequentially Written Sequential Write Preferred Zones"); SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "max_seq_zones", CTLFLAG_RD, &softc->max_seq_zones, @@ -2859,8 +2859,8 @@ daregister(struct cam_periph *periph, void *arg) M_NOWAIT|M_ZERO); if (softc == NULL) { - printf("daregister: Unable to probe new device. " - "Unable to allocate softc\n"); + printf( + "daregister: Unable to probe new device. Unable to allocate softc\n"); return(CAM_REQ_CMP_ERR); } @@ -3035,8 +3035,8 @@ daregister(struct cam_periph *periph, void *arg) if (cam_iosched_init(&softc->cam_iosched, periph, softc->disk, daschedule) != 0) { - printf("daregister: Unable to probe new device. " - "Unable to allocate iosched memory\n"); + printf( + "daregister: Unable to probe new device. Unable to allocate iosched memory\n"); free(softc, M_DEVBUF); return(CAM_REQ_CMP_ERR); } @@ -3115,8 +3115,9 @@ da_zone_cmd(struct cam_periph *periph, union ccb *ccb, struct bio *bp, zone_sa = da_zone_bio_to_scsi(bp->bio_zone.zone_cmd); if (zone_sa == -1) { - xpt_print(periph->path, "Cannot translate zone " - "cmd %#x to SCSI\n", bp->bio_zone.zone_cmd); + xpt_print(periph->path, + "Cannot translate zone cmd %#x to SCSI\n", + bp->bio_zone.zone_cmd); error = EINVAL; goto bailout; } @@ -3180,8 +3181,7 @@ da_zone_cmd(struct cam_periph *periph, union ccb *ccb, struct bio *bp, if (error != 0) { error = EINVAL; xpt_print(periph->path, - "scsi_ata_zac_mgmt_out() returned an " - "error!"); + "scsi_ata_zac_mgmt_out() returned an error!"); goto bailout; } } @@ -3198,8 +3198,8 @@ da_zone_cmd(struct cam_periph *periph, union ccb *ccb, struct bio *bp, num_entries = rep->entries_allocated; if (num_entries == 0) { - xpt_print(periph->path, "No entries allocated for " - "Report Zones request\n"); + xpt_print(periph->path, + "No entries allocated for Report Zones request\n"); error = EINVAL; goto bailout; } @@ -3208,8 +3208,8 @@ da_zone_cmd(struct cam_periph *periph, union ccb *ccb, struct bio *bp, alloc_size = min(alloc_size, softc->disk->d_maxsize); rz_ptr = malloc(alloc_size, M_SCSIDA, M_NOWAIT | M_ZERO); if (rz_ptr == NULL) { - xpt_print(periph->path, "Unable to allocate memory " - "for Report Zones request\n"); + xpt_print(periph->path, + "Unable to allocate memory for Report Zones request\n"); error = ENOMEM; goto bailout; } @@ -3266,8 +3266,7 @@ da_zone_cmd(struct cam_periph *periph, union ccb *ccb, struct bio *bp, if (error != 0) { error = EINVAL; xpt_print(periph->path, - "scsi_ata_zac_mgmt_in() returned an " - "error!"); + "scsi_ata_zac_mgmt_in() returned an error!"); goto bailout; } } @@ -3599,8 +3598,8 @@ out: mode_buf_len = 192; mode_buf = malloc(mode_buf_len, M_SCSIDA, M_NOWAIT); if (mode_buf == NULL) { - xpt_print(periph->path, "Unable to send mode sense - " - "malloc failure\n"); + xpt_print(periph->path, + "Unable to send mode sense - malloc failure\n"); if ((softc->flags & DA_FLAG_CAN_RC16) != 0) softc->state = DA_STATE_PROBE_RC16; else @@ -3882,8 +3881,7 @@ out: log_dir = malloc(sizeof(*log_dir), M_SCSIDA, M_NOWAIT|M_ZERO); if (log_dir == NULL) { - xpt_print(periph->path, "Couldn't malloc log_dir " - "data\n"); + xpt_print(periph->path, "Couldn't malloc log_dir data\n"); daprobedone(periph, start_ccb); break; } @@ -3932,8 +3930,7 @@ out: id_dir = malloc(sizeof(*id_dir), M_SCSIDA, M_NOWAIT | M_ZERO); if (id_dir == NULL) { - xpt_print(periph->path, "Couldn't malloc id_dir " - "data\n"); + xpt_print(periph->path, "Couldn't malloc id_dir data\n"); daprobedone(periph, start_ccb); break; } @@ -3981,8 +3978,7 @@ out: sup_cap = malloc(sizeof(*sup_cap), M_SCSIDA, M_NOWAIT|M_ZERO); if (sup_cap == NULL) { - xpt_print(periph->path, "Couldn't malloc sup_cap " - "data\n"); + xpt_print(periph->path, "Couldn't malloc sup_cap data\n"); daprobedone(periph, start_ccb); break; } @@ -4032,8 +4028,7 @@ out: ata_zone = malloc(sizeof(*ata_zone), M_SCSIDA, M_NOWAIT|M_ZERO); if (ata_zone == NULL) { - xpt_print(periph->path, "Couldn't malloc ata_zone " - "data\n"); + xpt_print(periph->path, "Couldn't malloc ata_zone data\n"); daprobedone(periph, start_ccb); break; } @@ -4084,8 +4079,7 @@ out: if (bdc == NULL) { xpt_release_ccb(start_ccb); - xpt_print(periph->path, "Couldn't malloc zone VPD " - "data\n"); + xpt_print(periph->path, "Couldn't malloc zone VPD data\n"); break; } scsi_inquiry(&start_ccb->csio, @@ -4201,8 +4195,7 @@ da_delete_unmap(struct cam_periph *periph, union ccb *ccb, struct bio *bp) if (totalcount + c > softc->unmap_max_lba || ranges >= softc->unmap_max_ranges) { xpt_print(periph->path, - "%s issuing short delete %ld > %ld" - "|| %d >= %d", + "%s issuing short delete %ld > %ld || %d >= %d", da_delete_method_desc[softc->delete_method], totalcount + c, softc->unmap_max_lba, ranges, softc->unmap_max_ranges); @@ -4483,8 +4476,8 @@ cmd6workaround(union ccb *ccb) (*cdb != READ_6 && *cdb != WRITE_6)) return 0; - xpt_print(ccb->ccb_h.path, "READ(6)/WRITE(6) not supported, " - "increasing minimum_cmd_size to 10.\n"); + xpt_print(ccb->ccb_h.path, + "READ(6)/WRITE(6) not supported, increasing minimum_cmd_size to 10.\n"); softc->minimum_cmd_size = 10; bcopy(cdb, &cmd6, sizeof(struct scsi_rw_6)); @@ -5124,8 +5117,7 @@ dadone_proberc(struct cam_periph *periph, union ccb *done_ccb) &cgd.inq_data, &sense_key_desc, &asc_desc); snprintf(announce_buf, DA_ANNOUNCETMP_SZ, - "Attempt to query device " - "size failed: %s, %s", + "Attempt to query device size failed: %s, %s", sense_key_desc, asc_desc); } else { if (have_sense) @@ -5135,9 +5127,8 @@ dadone_proberc(struct cam_periph *periph, union ccb *done_ccb) "got CAM status %#x\n", done_ccb->ccb_h.status); } - - xpt_print(periph->path, "fatal error, " - "failed to attach to device\n"); + xpt_print(periph->path, + "fatal error, failed to attach to device\n"); announce_buf = NULL; @@ -5171,8 +5162,8 @@ dadone_proberc(struct cam_periph *periph, union ccb *done_ccb) &softc->sysctl_task); } else { /* XXX This message is useless! */ - xpt_print(periph->path, "fatal error, " - "could not acquire reference count\n"); + xpt_print(periph->path, + "fatal error, could not acquire reference count\n"); } } @@ -5410,8 +5401,7 @@ dadone_probebdc(struct cam_periph *periph, union ccb *done_ccb) DA_ZONE_IF_ATA_SAT : DA_ZONE_IF_SCSI; } else if ((bdc->flags & SVPD_ZBC_MASK) != SVPD_ZBC_NR) { - xpt_print(periph->path, "Unknown zoned " - "type %#x", + xpt_print(periph->path, "Unknown zoned type %#x", bdc->flags & SVPD_ZBC_MASK); } } @@ -6516,8 +6506,9 @@ dasetgeom(struct cam_periph *periph, uint32_t block_len, uint64_t maxsector, if ((cdai.ccb_h.status & CAM_DEV_QFRZN) != 0) cam_release_devq(cdai.ccb_h.path, 0, 0, 0, FALSE); if (cdai.ccb_h.status != CAM_REQ_CMP) { - xpt_print(periph->path, "%s: failed to set read " - "capacity advinfo\n", __func__); + xpt_print(periph->path, + "%s: failed to set read capacity advinfo\n", + __func__); /* Use cam_error_print() to decode the status */ cam_error_print((union ccb *)&cdai, CAM_ESF_CAM_STATUS, CAM_EPF_ALL); diff --git a/sys/compat/linux/linux_timer.c b/sys/compat/linux/linux_timer.c index ed9133359302..230be9572b85 100644 --- a/sys/compat/linux/linux_timer.c +++ b/sys/compat/linux/linux_timer.c @@ -131,7 +131,7 @@ linux_timer_settime(struct thread *td, struct linux_timer_settime_args *uap) return (error); error = kern_ktimer_settime(td, uap->timerid, flags, &val, ovalp); if (error == 0 && uap->old != NULL) { - error = native_to_linux_itimerspec(&l_val, &val); + error = native_to_linux_itimerspec(&l_oval, &oval); if (error == 0) error = copyout(&l_oval, uap->old, sizeof(l_oval)); } @@ -158,7 +158,7 @@ linux_timer_settime64(struct thread *td, struct linux_timer_settime64_args *uap) return (error); error = kern_ktimer_settime(td, uap->timerid, flags, &val, ovalp); if (error == 0 && uap->old != NULL) { - error = native_to_linux_itimerspec64(&l_val, &val); + error = native_to_linux_itimerspec64(&l_oval, &oval); if (error == 0) error = copyout(&l_oval, uap->old, sizeof(l_oval)); } diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c index 02724433d89d..1ac28dfef448 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.c +++ b/sys/compat/linuxkpi/common/src/linux_80211.c @@ -282,7 +282,7 @@ lkpi_nl80211_sta_info_to_str(struct sbuf *s, const char *prefix, } static void -lkpi_80211_dump_lvif_stas(struct lkpi_vif *lvif, struct sbuf *s) +lkpi_80211_dump_lvif_stas(struct lkpi_vif *lvif, struct sbuf *s, bool dump_queues) { struct lkpi_hw *lhw; struct ieee80211_hw *hw; @@ -292,6 +292,7 @@ lkpi_80211_dump_lvif_stas(struct lkpi_vif *lvif, struct sbuf *s) struct ieee80211_sta *sta; struct station_info sinfo; int error; + uint8_t tid; vif = LVIF_TO_VIF(lvif); vap = LVIF_TO_VAP(lvif); @@ -376,6 +377,39 @@ lkpi_80211_dump_lvif_stas(struct lkpi_vif *lvif, struct sbuf *s) sbuf_printf(s, " he_dcm %u he_gi %u he_ru_alloc %u eht_gi %u\n", sinfo.txrate.he_dcm, sinfo.txrate.he_gi, sinfo.txrate.he_ru_alloc, sinfo.txrate.eht_gi); + + if (!dump_queues) + continue; + + /* Dump queue information. */ + sbuf_printf(s, " Queue information:\n"); + sbuf_printf(s, " frms direct tx %ju\n", lsta->frms_tx); + for (tid = 0; tid <= IEEE80211_NUM_TIDS; tid++) { + struct lkpi_txq *ltxq; + + if (sta->txq[tid] == NULL) { + sbuf_printf(s, " tid %-2u NOQ\n", tid); + continue; + } + + ltxq = TXQ_TO_LTXQ(sta->txq[tid]); +#ifdef __notyet__ + sbuf_printf(s, " tid %-2u flags: %b " + "txq_generation %u skbq len %d\n", + tid, ltxq->flags, LKPI_TXQ_FLAGS_BITS, + ltxq->txq_generation, + skb_queue_len_lockless(<xq->skbq)); +#else + sbuf_printf(s, " tid %-2u " + "txq_generation %u skbq len %d\n", + tid, + ltxq->txq_generation, + skb_queue_len_lockless(<xq->skbq)); +#endif + sbuf_printf(s, " frms_enqueued %ju frms_dequeued %ju " + "frms_tx %ju\n", + ltxq->frms_enqueued, ltxq->frms_dequeued, ltxq->frms_tx); + } } wiphy_unlock(hw->wiphy); } @@ -393,7 +427,28 @@ lkpi_80211_dump_stas(SYSCTL_HANDLER_ARGS) sbuf_new_for_sysctl(&s, NULL, 1024, req); - lkpi_80211_dump_lvif_stas(lvif, &s); + lkpi_80211_dump_lvif_stas(lvif, &s, false); + + sbuf_finish(&s); + sbuf_delete(&s); + + return (0); +} + +static int +lkpi_80211_dump_sta_queues(SYSCTL_HANDLER_ARGS) +{ + struct lkpi_vif *lvif; + struct sbuf s; + + if (req->newptr) + return (EPERM); + + lvif = (struct lkpi_vif *)arg1; + + sbuf_new_for_sysctl(&s, NULL, 1024, req); + + lkpi_80211_dump_lvif_stas(lvif, &s, true); sbuf_finish(&s); sbuf_delete(&s); @@ -638,7 +693,8 @@ skip_bw: sta = IEEE80211_VHT_MCS_NOT_SUPPORTED; else { sta = MIN(sta, card); - rx_nss = i + 1; + if (rx_nss == 0) + rx_nss = i + 1; } } rx_map |= (sta << (2 * i)); @@ -4173,6 +4229,11 @@ lkpi_ic_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], SYSCTL_CHILDREN(node), OID_AUTO, "dump_stas", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, lvif, 0, lkpi_80211_dump_stas, "A", "Dump sta statistics of this vif"); + SYSCTL_ADD_PROC(&lvif->sysctl_ctx, + SYSCTL_CHILDREN(node), OID_AUTO, "dump_stas_queues", + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE | CTLFLAG_SKIP, lvif, 0, + lkpi_80211_dump_sta_queues, "A", + "Dump queue statistics for any sta of this vif"); IMPROVE(); @@ -5513,6 +5574,8 @@ lkpi_80211_txq_tx_one(struct lkpi_sta *lsta, struct mbuf *m) #endif ni = lsta->ni; + ieee80211_output_seqno_assign(ni, -1, m); + k = NULL; keyix = IEEE80211_KEYIX_NONE; wh = mtod(m, struct ieee80211_frame *); @@ -5667,6 +5730,8 @@ lkpi_80211_txq_tx_one(struct lkpi_sta *lsta, struct mbuf *m) dev_kfree_skb(skb); return; } + /* Reset header as data might have moved. */ + hdr = (void *)skb->data; } #endif @@ -5690,6 +5755,7 @@ lkpi_80211_txq_tx_one(struct lkpi_sta *lsta, struct mbuf *m) LKPI_80211_LTXQ_LOCK(ltxq); skb_queue_tail(<xq->skbq, skb); + ltxq->frms_enqueued++; #ifdef LINUXKPI_DEBUG_80211 if (linuxkpi_debug_80211 & D80211_TRACE_TX) printf("%s:%d mo_wake_tx_queue :: %d %lu lsta %p sta %p " @@ -5719,6 +5785,7 @@ ops_tx: control.sta = sta; wiphy_lock(hw->wiphy); lkpi_80211_mo_tx(hw, &control, skb); + lsta->frms_tx++; wiphy_unlock(hw->wiphy); } @@ -8121,6 +8188,8 @@ linuxkpi_ieee80211_tx_dequeue(struct ieee80211_hw *hw, LKPI_80211_LTXQ_LOCK(ltxq); skb = skb_dequeue(<xq->skbq); + if (skb != NULL) + ltxq->frms_dequeued++; LKPI_80211_LTXQ_UNLOCK(ltxq); stopped: @@ -8769,18 +8838,21 @@ linuxkpi_ieee80211_handle_wake_tx_queue(struct ieee80211_hw *hw, struct ieee80211_txq *txq) { struct lkpi_hw *lhw; - struct ieee80211_txq *ntxq; - struct ieee80211_tx_control control; - struct sk_buff *skb; lhw = HW_TO_LHW(hw); LKPI_80211_LHW_TXQ_LOCK(lhw); ieee80211_txq_schedule_start(hw, txq->ac); do { + struct lkpi_txq *ltxq; + struct ieee80211_txq *ntxq; + struct ieee80211_tx_control control; + struct sk_buff *skb; + ntxq = ieee80211_next_txq(hw, txq->ac); if (ntxq == NULL) break; + ltxq = TXQ_TO_LTXQ(ntxq); memset(&control, 0, sizeof(control)); control.sta = ntxq->sta; @@ -8788,6 +8860,7 @@ linuxkpi_ieee80211_handle_wake_tx_queue(struct ieee80211_hw *hw, skb = linuxkpi_ieee80211_tx_dequeue(hw, ntxq); if (skb == NULL) break; + ltxq->frms_tx++; lkpi_80211_mo_tx(hw, &control, skb); } while(1); diff --git a/sys/compat/linuxkpi/common/src/linux_80211.h b/sys/compat/linuxkpi/common/src/linux_80211.h index fcbef46fc6de..d4f18fcafbba 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.h +++ b/sys/compat/linuxkpi/common/src/linux_80211.h @@ -154,6 +154,9 @@ struct lkpi_txq { bool stopped; uint32_t txq_generation; struct sk_buff_head skbq; + uint64_t frms_enqueued; + uint64_t frms_dequeued; + uint64_t frms_tx; /* Must be last! */ struct ieee80211_txq txq __aligned(CACHE_LINE_SIZE); @@ -180,6 +183,7 @@ struct lkpi_sta { bool in_mgd; /* XXX-BZ should this be per-vif? */ struct station_info sinfo; /* statistics */ + uint64_t frms_tx; /* (*tx) */ /* Must be last! */ struct ieee80211_sta sta __aligned(CACHE_LINE_SIZE); diff --git a/sys/conf/kern.opts.mk b/sys/conf/kern.opts.mk index cef4dd11ba58..81b117492916 100644 --- a/sys/conf/kern.opts.mk +++ b/sys/conf/kern.opts.mk @@ -56,6 +56,7 @@ __DEFAULT_NO_OPTIONS = \ KERNEL_RETPOLINE \ RATELIMIT \ REPRODUCIBLE_BUILD \ + REPRODUCIBLE_PATHS \ VERIEXEC # Some options are totally broken on some architectures. We disable them. If you diff --git a/sys/conf/kern.post.mk b/sys/conf/kern.post.mk index 7cdfd17778db..343abc5853f7 100644 --- a/sys/conf/kern.post.mk +++ b/sys/conf/kern.post.mk @@ -372,7 +372,7 @@ _ILINKS+= x86 _ILINKS+= i386 .endif -.if ${MK_REPRODUCIBLE_BUILD} != "no" +.if ${MK_REPRODUCIBLE_PATHS} != "no" PREFIX_SYSDIR=/usr/src/sys PREFIX_OBJDIR=/usr/obj/usr/src/${MACHINE}.${MACHINE_CPUARCH}/sys/${KERN_IDENT} CFLAGS+= -ffile-prefix-map=${SYSDIR}=${PREFIX_SYSDIR} diff --git a/sys/conf/kmod.mk b/sys/conf/kmod.mk index 6e20dce0653f..edc311348971 100644 --- a/sys/conf/kmod.mk +++ b/sys/conf/kmod.mk @@ -303,7 +303,7 @@ all: ${PROG} beforedepend: ${_ILINKS} beforebuild: ${_ILINKS} -.if ${MK_REPRODUCIBLE_BUILD} != "no" +.if ${MK_REPRODUCIBLE_PATHS} != "no" PREFIX_SYSDIR=/usr/src/sys CFLAGS+= -ffile-prefix-map=${SYSDIR}=${PREFIX_SYSDIR} .if defined(KERNBUILDDIR) diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/cmn_err.h b/sys/contrib/openzfs/include/os/freebsd/spl/sys/cmn_err.h index 93dd1196d977..fa55b3917669 100644 --- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/cmn_err.h +++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/cmn_err.h @@ -52,28 +52,28 @@ extern "C" { #ifndef _ASM extern void cmn_err(int, const char *, ...) - __attribute__((format(printf, 2, 3))); + __attribute__((format(__printf__, 2, 3))); extern void vzcmn_err(zoneid_t, int, const char *, __va_list) - __attribute__((format(printf, 3, 0))); + __attribute__((format(__printf__, 3, 0))); extern void vcmn_err(int, const char *, __va_list) - __attribute__((format(printf, 2, 0))); + __attribute__((format(__printf__, 2, 0))); extern void zcmn_err(zoneid_t, int, const char *, ...) - __attribute__((format(printf, 3, 4))); + __attribute__((format(__printf__, 3, 4))); extern void vzprintf(zoneid_t, const char *, __va_list) - __attribute__((format(printf, 2, 0))); + __attribute__((format(__printf__, 2, 0))); extern void zprintf(zoneid_t, const char *, ...) - __attribute__((format(printf, 2, 3))); + __attribute__((format(__printf__, 2, 3))); extern void vuprintf(const char *, __va_list) - __attribute__((format(printf, 1, 0))); + __attribute__((format(__printf__, 1, 0))); extern void panic(const char *, ...) - __attribute__((format(printf, 1, 2), __noreturn__)); + __attribute__((format(__printf__, 1, 2), __noreturn__)); #define cmn_err_once(ce, ...) \ do { \ diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/kmem.h b/sys/contrib/openzfs/include/os/freebsd/spl/sys/kmem.h index a9619d7d0219..4ae96c91a5f3 100644 --- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/kmem.h +++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/kmem.h @@ -55,9 +55,9 @@ MALLOC_DECLARE(M_SOLARIS); typedef struct vmem vmem_t; extern char *kmem_asprintf(const char *, ...) - __attribute__((format(printf, 1, 2))); + __attribute__((format(__printf__, 1, 2))); extern char *kmem_vasprintf(const char *fmt, va_list ap) - __attribute__((format(printf, 1, 0))); + __attribute__((format(__printf__, 1, 0))); extern int kmem_scnprintf(char *restrict str, size_t size, const char *restrict fmt, ...); diff --git a/sys/contrib/openzfs/include/sys/spa.h b/sys/contrib/openzfs/include/sys/spa.h index 2a4cc60c4aa8..db30b5a066de 100644 --- a/sys/contrib/openzfs/include/sys/spa.h +++ b/sys/contrib/openzfs/include/sys/spa.h @@ -1127,9 +1127,9 @@ extern void spa_set_allocator(spa_t *spa, const char *allocator); /* Miscellaneous support routines */ extern void spa_load_failed(spa_t *spa, const char *fmt, ...) - __attribute__((format(printf, 2, 3))); + __attribute__((format(__printf__, 2, 3))); extern void spa_load_note(spa_t *spa, const char *fmt, ...) - __attribute__((format(printf, 2, 3))); + __attribute__((format(__printf__, 2, 3))); extern void spa_activate_mos_feature(spa_t *spa, const char *feature, dmu_tx_t *tx); extern void spa_deactivate_mos_feature(spa_t *spa, const char *feature); diff --git a/sys/contrib/openzfs/include/sys/vdev.h b/sys/contrib/openzfs/include/sys/vdev.h index 510474d6c085..86f2235f03ac 100644 --- a/sys/contrib/openzfs/include/sys/vdev.h +++ b/sys/contrib/openzfs/include/sys/vdev.h @@ -54,7 +54,7 @@ extern int zfs_nocacheflush; typedef boolean_t vdev_open_children_func_t(vdev_t *vd); extern void vdev_dbgmsg(vdev_t *vd, const char *fmt, ...) - __attribute__((format(printf, 2, 3))); + __attribute__((format(__printf__, 2, 3))); extern void vdev_dbgmsg_print_tree(vdev_t *, int); extern int vdev_open(vdev_t *); extern void vdev_open_children(vdev_t *); diff --git a/sys/contrib/openzfs/include/sys/zfs_debug.h b/sys/contrib/openzfs/include/sys/zfs_debug.h index 0f021d15157b..6fe5cf062c17 100644 --- a/sys/contrib/openzfs/include/sys/zfs_debug.h +++ b/sys/contrib/openzfs/include/sys/zfs_debug.h @@ -68,7 +68,7 @@ extern int zfs_dbgmsg_enable; extern void __set_error(const char *file, const char *func, int line, int err); extern void __zfs_dbgmsg(char *buf); extern void __dprintf(boolean_t dprint, const char *file, const char *func, - int line, const char *fmt, ...) __attribute__((format(printf, 5, 6))); + int line, const char *fmt, ...) __attribute__((format(__printf__, 5, 6))); /* * Some general principles for using zfs_dbgmsg(): diff --git a/sys/crypto/chacha20/chacha.c b/sys/crypto/chacha20/chacha.c index cb06003b0ecf..0509b05cab22 100644 --- a/sys/crypto/chacha20/chacha.c +++ b/sys/crypto/chacha20/chacha.c @@ -50,8 +50,8 @@ typedef struct chacha_ctx chacha_ctx; a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \ c = PLUS(c,d); b = ROTATE(XOR(b,c), 7); -static const char sigma[16] = "expand 32-byte k"; -static const char tau[16] = "expand 16-byte k"; +static const char sigma[16] __nonstring = "expand 32-byte k"; +static const char tau[16] __nonstring = "expand 16-byte k"; LOCAL void chacha_keysetup(chacha_ctx *x,const u8 *k,u32 kbits) diff --git a/sys/dev/ocs_fc/ocs_ddump.h b/sys/dev/ocs_fc/ocs_ddump.h index b7d7eefad813..3cffff6d9670 100644 --- a/sys/dev/ocs_fc/ocs_ddump.h +++ b/sys/dev/ocs_fc/ocs_ddump.h @@ -46,8 +46,7 @@ extern void ocs_ddump_startfile(ocs_textbuf_t *textbuf); extern void ocs_ddump_endfile(ocs_textbuf_t *textbuf); extern void ocs_ddump_section(ocs_textbuf_t *textbuf, const char *name, uint32_t instance); extern void ocs_ddump_endsection(ocs_textbuf_t *textbuf, const char *name, uint32_t instance); -__attribute__((format(printf,3,4))) -extern void ocs_ddump_value(ocs_textbuf_t *textbuf, const char *name, const char *fmt, ...); +extern void ocs_ddump_value(ocs_textbuf_t *textbuf, const char *name, const char *fmt, ...) __printflike(3, 4); extern void ocs_ddump_buffer(ocs_textbuf_t *textbuf, const char *name, uint32_t instance, void *buffer, uint32_t size); extern int32_t ocs_save_ddump(ocs_t *ocs, uint32_t flags, uint32_t qentries); extern int32_t ocs_get_saved_ddump(ocs_t *ocs, ocs_textbuf_t *textbuf); diff --git a/sys/dev/ocs_fc/ocs_mgmt.h b/sys/dev/ocs_fc/ocs_mgmt.h index 7b59a3916ca8..9781aec18462 100644 --- a/sys/dev/ocs_fc/ocs_mgmt.h +++ b/sys/dev/ocs_fc/ocs_mgmt.h @@ -95,8 +95,7 @@ extern void ocs_mgmt_end_section(ocs_textbuf_t *textbuf, const char *name, int i extern void ocs_mgmt_end_unnumbered_section(ocs_textbuf_t *textbuf, const char *name); extern void ocs_mgmt_emit_property_name(ocs_textbuf_t *textbuf, int access, const char *name); extern void ocs_mgmt_emit_string(ocs_textbuf_t *textbuf, int access, const char *name, const char *value); -__attribute__((format(printf,4,5))) -extern void ocs_mgmt_emit_int(ocs_textbuf_t *textbuf, int access, const char *name, const char *fmt, ...); +extern void ocs_mgmt_emit_int(ocs_textbuf_t *textbuf, int access, const char *name, const char *fmt, ...) __printflike(4, 5); extern void ocs_mgmt_emit_boolean(ocs_textbuf_t *textbuf, int access, const char *name, const int value); extern int parse_wwn(char *wwn_in, uint64_t *wwn_out); diff --git a/sys/dev/ocs_fc/ocs_os.h b/sys/dev/ocs_fc/ocs_os.h index 331d5b07aecd..55ee98b3cc58 100644 --- a/sys/dev/ocs_fc/ocs_os.h +++ b/sys/dev/ocs_fc/ocs_os.h @@ -711,7 +711,7 @@ typedef struct { * @return returns 0 for success, a negative error code value for failure. */ -extern int ocs_sem_init(ocs_sem_t *sem, int val, const char *name, ...) __attribute__((format(printf, 3, 4))); +extern int ocs_sem_init(ocs_sem_t *sem, int val, const char *name, ...) __printflike(3, 4); /** * @brief execute a P (decrement) operation diff --git a/sys/dev/ocs_fc/ocs_utils.h b/sys/dev/ocs_fc/ocs_utils.h index e3a952e0cf26..7c9c9ae85b74 100644 --- a/sys/dev/ocs_fc/ocs_utils.h +++ b/sys/dev/ocs_fc/ocs_utils.h @@ -103,10 +103,8 @@ extern int32_t ocs_textbuf_init(ocs_t *ocs, ocs_textbuf_t *textbuf, void *buffer extern void ocs_textbuf_free(ocs_t *ocs, ocs_textbuf_t *textbuf); extern void ocs_textbuf_putc(ocs_textbuf_t *textbuf, uint8_t c); extern void ocs_textbuf_puts(ocs_textbuf_t *textbuf, char *s); -__attribute__((format(printf,2,3))) -extern void ocs_textbuf_printf(ocs_textbuf_t *textbuf, const char *fmt, ...); -__attribute__((format(printf,2,0))) -extern void ocs_textbuf_vprintf(ocs_textbuf_t *textbuf, const char *fmt, va_list ap); +extern void ocs_textbuf_printf(ocs_textbuf_t *textbuf, const char *fmt, ...) __printflike(2, 3); +extern void ocs_textbuf_vprintf(ocs_textbuf_t *textbuf, const char *fmt, va_list ap) __printflike(2, 0); extern void ocs_textbuf_buffer(ocs_textbuf_t *textbuf, uint8_t *buffer, uint32_t buffer_length); extern void ocs_textbuf_copy(ocs_textbuf_t *textbuf, uint8_t *buffer, uint32_t buffer_length); extern int32_t ocs_textbuf_remaining(ocs_textbuf_t *textbuf); @@ -325,10 +323,8 @@ typedef struct ocs_ramlog_s ocs_ramlog_t; extern ocs_ramlog_t *ocs_ramlog_init(ocs_t *ocs, uint32_t buffer_len, uint32_t buffer_count); extern void ocs_ramlog_free(ocs_t *ocs, ocs_ramlog_t *ramlog); extern void ocs_ramlog_clear(ocs_t *ocs, ocs_ramlog_t *ramlog, int clear_start_of_day, int clear_recent); -__attribute__((format(printf,2,3))) -extern int32_t ocs_ramlog_printf(void *os, const char *fmt, ...); -__attribute__((format(printf,2,0))) -extern int32_t ocs_ramlog_vprintf(ocs_ramlog_t *ramlog, const char *fmt, va_list ap); +extern int32_t ocs_ramlog_printf(void *os, const char *fmt, ...) __printflike(2, 3); +extern int32_t ocs_ramlog_vprintf(ocs_ramlog_t *ramlog, const char *fmt, va_list ap) __printflike(2, 0); extern int32_t ocs_ddump_ramlog(ocs_textbuf_t *textbuf, ocs_ramlog_t *ramlog); #endif diff --git a/sys/dev/qlnx/qlnxe/qlnx_os.c b/sys/dev/qlnx/qlnxe/qlnx_os.c index 9963f472c615..99110e5e2d8f 100644 --- a/sys/dev/qlnx/qlnxe/qlnx_os.c +++ b/sys/dev/qlnx/qlnxe/qlnx_os.c @@ -2539,7 +2539,7 @@ qlnx_hw_set_multi(qlnx_host_t *ha, uint8_t *mta, uint32_t mcnt, break; } - mta += ETHER_HDR_LEN; + mta += ETHER_ADDR_LEN; } return; } @@ -2552,7 +2552,7 @@ qlnx_copy_maddr(void *arg, struct sockaddr_dl *sdl, u_int mcnt) if (mcnt == QLNX_MAX_NUM_MULTICAST_ADDRS) return (0); - bcopy(LLADDR(sdl), &mta[mcnt * ETHER_HDR_LEN], ETHER_HDR_LEN); + bcopy(LLADDR(sdl), &mta[mcnt * ETHER_ADDR_LEN], ETHER_ADDR_LEN); return (1); } @@ -2560,7 +2560,7 @@ qlnx_copy_maddr(void *arg, struct sockaddr_dl *sdl, u_int mcnt) static int qlnx_set_multi(qlnx_host_t *ha, uint32_t add_multi) { - uint8_t mta[QLNX_MAX_NUM_MULTICAST_ADDRS * ETHER_HDR_LEN]; + uint8_t mta[QLNX_MAX_NUM_MULTICAST_ADDRS * ETHER_ADDR_LEN]; if_t ifp = ha->ifp; u_int mcnt; diff --git a/sys/dev/xen/blkback/blkback.c b/sys/dev/xen/blkback/blkback.c index c6cba729b991..dcfdcafa9351 100644 --- a/sys/dev/xen/blkback/blkback.c +++ b/sys/dev/xen/blkback/blkback.c @@ -152,7 +152,7 @@ struct xbb_softc; struct xbb_xen_req; static void xbb_attach_failed(struct xbb_softc *xbb, int err, const char *fmt, - ...) __attribute__((format(printf, 3, 4))); + ...) __printflike(3, 4); static int xbb_shutdown(struct xbb_softc *xbb); /*------------------------------ Data Structures -----------------------------*/ diff --git a/sys/fs/fuse/fuse_device.c b/sys/fs/fuse/fuse_device.c index cee477865c42..41387de3ce71 100644 --- a/sys/fs/fuse/fuse_device.c +++ b/sys/fs/fuse/fuse_device.c @@ -82,7 +82,7 @@ #include <sys/sysctl.h> #include <sys/poll.h> #include <sys/selinfo.h> -#define EXTERR_CATEGORY EXTERR_CAT_FUSE +#define EXTERR_CATEGORY EXTERR_CAT_FUSE_DEVICE #include <sys/exterrvar.h> #include "fuse.h" diff --git a/sys/fs/fuse/fuse_vfsops.c b/sys/fs/fuse/fuse_vfsops.c index b617925c4e5f..0ff79913128a 100644 --- a/sys/fs/fuse/fuse_vfsops.c +++ b/sys/fs/fuse/fuse_vfsops.c @@ -81,7 +81,7 @@ #include <sys/mount.h> #include <sys/sysctl.h> #include <sys/fcntl.h> -#define EXTERR_CATEGORY EXTERR_CAT_FUSE +#define EXTERR_CATEGORY EXTERR_CAT_FUSE_VFS #include <sys/exterrvar.h> #include "fuse.h" diff --git a/sys/fs/fuse/fuse_vnops.c b/sys/fs/fuse/fuse_vnops.c index ef5aee5de34c..0e049b1f07a9 100644 --- a/sys/fs/fuse/fuse_vnops.c +++ b/sys/fs/fuse/fuse_vnops.c @@ -89,7 +89,7 @@ #include <sys/buf.h> #include <sys/sysctl.h> #include <sys/vmmeter.h> -#define EXTERR_CATEGORY EXTERR_CAT_FUSE +#define EXTERR_CATEGORY EXTERR_CAT_FUSE_VNOPS #include <sys/exterrvar.h> #include <vm/vm.h> diff --git a/sys/modules/linux/Makefile b/sys/modules/linux/Makefile index eb4e17ec706b..8904e8005416 100644 --- a/sys/modules/linux/Makefile +++ b/sys/modules/linux/Makefile @@ -76,6 +76,7 @@ SRCS+= imgact_linux.c \ .if ${MACHINE_CPUARCH} == "i386" EXPORT_SYMS= +EXPORT_SYMS+= linux_device_register_handler EXPORT_SYMS+= linux_get_osname EXPORT_SYMS+= linux_get_osrelease EXPORT_SYMS+= linux_ioctl_register_handler diff --git a/sys/modules/linux_common/Makefile b/sys/modules/linux_common/Makefile index 291fc6d25f8c..1fa740b8b823 100644 --- a/sys/modules/linux_common/Makefile +++ b/sys/modules/linux_common/Makefile @@ -13,6 +13,7 @@ SRCS+= linux_x86.c linux_vdso_selector_x86.c .endif EXPORT_SYMS= +EXPORT_SYMS+= linux_device_register_handler EXPORT_SYMS+= linux_get_osname EXPORT_SYMS+= linux_get_osrelease diff --git a/sys/modules/qat/qat_api/Makefile b/sys/modules/qat/qat_api/Makefile index 24fbcb46a987..22802c87758d 100644 --- a/sys/modules/qat/qat_api/Makefile +++ b/sys/modules/qat/qat_api/Makefile @@ -84,7 +84,7 @@ opt_qat.h: @echo "#define QAT_DISABLE_SAFE_DC_MODE 1" >> ${.TARGET} .endif .endif - +EXPORT_SYMS=YES .include <bsd.kmod.mk> CWARNFLAGS+= -Wno-cast-qual diff --git a/sys/modules/qat/qat_common/Makefile b/sys/modules/qat/qat_common/Makefile index af8ce86d6be2..541a5da91d40 100644 --- a/sys/modules/qat/qat_common/Makefile +++ b/sys/modules/qat/qat_common/Makefile @@ -40,5 +40,5 @@ opt_qat.h: @echo "#define QAT_DISABLE_SAFE_DC_MODE 1" >> ${.TARGET} .endif .endif - +EXPORT_SYMS=YES .include <bsd.kmod.mk> diff --git a/sys/netpfil/pf/pf_nl.c b/sys/netpfil/pf/pf_nl.c index 6bd858373bd2..0a8538607ed7 100644 --- a/sys/netpfil/pf/pf_nl.c +++ b/sys/netpfil/pf/pf_nl.c @@ -2434,6 +2434,39 @@ out: free(pfrastats, M_PF); return (error); } +static int +pf_handle_table_clear_astats(struct nlmsghdr *hdr, struct nl_pstate *npt) +{ + struct nl_parsed_table_addrs attrs = { 0 }; + struct nl_writer *nw = npt->nw; + struct genlmsghdr *ghdr_new; + int error; + + error = nl_parse_nlmsg(hdr, &table_addr_parser, npt, &attrs); + if (error != 0) + return (error); + + PF_RULES_WLOCK(); + error = pfr_clr_astats(&attrs.table, &attrs.addrs[0], + attrs.addr_count, &attrs.nchange, + attrs.flags | PFR_FLAG_USERIOCTL); + PF_RULES_WUNLOCK(); + + if (!nlmsg_reply(nw, hdr, sizeof(struct genlmsghdr))) + return (ENOMEM); + + ghdr_new = nlmsg_reserve_object(nw, struct genlmsghdr); + ghdr_new->cmd = PFNL_CMD_TABLE_CLEAR_ASTATS; + ghdr_new->version = 0; + ghdr_new->reserved = 0; + + nlattr_add_u32(nw, PF_TAS_ASTATS_ZEROED, attrs.nchange); + + if (!nlmsg_end(nw)) + return (ENOMEM); + + return (error); +} static const struct nlhdr_parser *all_parsers[] = { &state_parser, @@ -2708,6 +2741,13 @@ static const struct genl_cmd pf_cmds[] = { .cmd_flags = GENL_CMD_CAP_DUMP | GENL_CMD_CAP_HASPOL, .cmd_priv = PRIV_NETINET_PF, }, + { + .cmd_num = PFNL_CMD_TABLE_CLEAR_ASTATS, + .cmd_name = "TABLE_CLEAR_ASTATS", + .cmd_cb = pf_handle_table_clear_astats, + .cmd_flags = GENL_CMD_CAP_DUMP | GENL_CMD_CAP_HASPOL, + .cmd_priv = PRIV_NETINET_PF, + }, }; void diff --git a/sys/netpfil/pf/pf_nl.h b/sys/netpfil/pf/pf_nl.h index 5ca14758932a..216f3d13db32 100644 --- a/sys/netpfil/pf/pf_nl.h +++ b/sys/netpfil/pf/pf_nl.h @@ -72,6 +72,7 @@ enum { PFNL_CMD_TABLE_SET_ADDR = 34, PFNL_CMD_TABLE_GET_ADDR = 35, PFNL_CMD_TABLE_GET_ASTATS = 36, + PFNL_CMD_TABLE_CLEAR_ASTATS = 37, __PFNL_CMD_MAX, }; #define PFNL_CMD_MAX (__PFNL_CMD_MAX -1) @@ -504,6 +505,7 @@ enum pf_table_astats_t { PF_TAS_ASTATS = 2, /* nested, pfr_astats_t */ PF_TAS_FLAGS = 3, /* u32 */ PF_TAS_ASTATS_COUNT = 4, /* u32 */ + PF_TAS_ASTATS_ZEROED = 5, /* u32 */ }; #ifdef _KERNEL diff --git a/sys/sys/exterr_cat.h b/sys/sys/exterr_cat.h index 318e774542ca..24f07539fe35 100644 --- a/sys/sys/exterr_cat.h +++ b/sys/sys/exterr_cat.h @@ -8,6 +8,17 @@ * under sponsorship from the FreeBSD Foundation. */ +/* + * The category identifiers for the extended errors. + * The ids participate in ABI between kernel and libc, so they must + * never be reused or changed. Only new ids can be added. + * + * After adding a new category id, run + * tools/build/make_libc_exterr_cat_filenames.sh + * from the top of the source tree, and commit updated file + * lib/libc/gen/exterr_cat_filenames.h + */ + #ifndef _SYS_EXTERR_CAT_H_ #define _SYS_EXTERR_CAT_H_ @@ -15,7 +26,7 @@ #define EXTERR_CAT_FILEDESC 2 #define EXTERR_KTRACE 3 /* To allow inclusion of this file into kern_ktrace.c */ -#define EXTERR_CAT_FUSE 4 +#define EXTERR_CAT_FUSE_VNOPS 4 #define EXTERR_CAT_INOTIFY 5 #define EXTERR_CAT_GENIO 6 #define EXTERR_CAT_BRIDGE 7 @@ -24,6 +35,8 @@ #define EXTERR_CAT_VFSBIO 10 #define EXTERR_CAT_GEOMVFS 11 #define EXTERR_CAT_GEOM 12 +#define EXTERR_CAT_FUSE_VFS 13 +#define EXTERR_CAT_FUSE_DEVICE 14 #endif diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 6b09552c5fee..68dcadd2b2f1 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -1620,6 +1620,7 @@ vm_map_insert1(vm_map_t map, vm_object_t object, vm_ooffset_t offset, vm_inherit_t inheritance; u_long bdry; u_int bidx; + int cflags; VM_MAP_ASSERT_LOCKED(map); KASSERT(object != kernel_object || @@ -1696,20 +1697,36 @@ vm_map_insert1(vm_map_t map, vm_object_t object, vm_ooffset_t offset, } cred = NULL; - if ((cow & (MAP_ACC_NO_CHARGE | MAP_NOFAULT | MAP_CREATE_GUARD)) != 0) - goto charged; - if ((cow & MAP_ACC_CHARGED) || ((prot & VM_PROT_WRITE) && - ((protoeflags & MAP_ENTRY_NEEDS_COPY) || object == NULL))) { - if (!(cow & MAP_ACC_CHARGED) && !swap_reserve(end - start)) - return (KERN_RESOURCE_SHORTAGE); - KASSERT(object == NULL || - (protoeflags & MAP_ENTRY_NEEDS_COPY) != 0 || - object->cred == NULL, - ("overcommit: vm_map_insert o %p", object)); - cred = curthread->td_ucred; + if ((cow & (MAP_ACC_NO_CHARGE | MAP_NOFAULT | MAP_CREATE_GUARD)) != 0) { + cflags = OBJCO_NO_CHARGE; + } else { + cflags = 0; + if ((cow & MAP_ACC_CHARGED) != 0 || + ((prot & VM_PROT_WRITE) != 0 && + ((protoeflags & MAP_ENTRY_NEEDS_COPY) != 0 || + object == NULL))) { + if ((cow & MAP_ACC_CHARGED) == 0) { + if (!swap_reserve(end - start)) + return (KERN_RESOURCE_SHORTAGE); + + /* + * Only inform vm_object_coalesce() + * that the object was charged if + * there is no need for CoW, so the + * swap amount reserved is applicable + * to the prev_entry->object. + */ + if ((protoeflags & MAP_ENTRY_NEEDS_COPY) == 0) + cflags |= OBJCO_CHARGED; + } + KASSERT(object == NULL || + (protoeflags & MAP_ENTRY_NEEDS_COPY) != 0 || + object->cred == NULL, + ("overcommit: vm_map_insert o %p", object)); + cred = curthread->td_ucred; + } } -charged: /* Expand the kernel pmap, if necessary. */ if (map == kernel_map && end > kernel_vm_end) { int rv; @@ -1741,8 +1758,7 @@ charged: vm_object_coalesce(prev_entry->object.vm_object, prev_entry->offset, (vm_size_t)(prev_entry->end - prev_entry->start), - (vm_size_t)(end - prev_entry->end), cred != NULL && - (protoeflags & MAP_ENTRY_NEEDS_COPY) == 0)) { + (vm_size_t)(end - prev_entry->end), cflags)) { /* * We were able to extend the object. Determine if we * can extend the previous map entry to include the diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index 501ace32bd11..234586893b59 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -197,12 +197,14 @@ kern_mmap(struct thread *td, const struct mmap_req *mrp) check_fp_fn = mrp->mr_check_fp_fn; if ((prot & ~(_PROT_ALL | PROT_MAX(_PROT_ALL))) != 0) { - return (EXTERROR(EINVAL, "unknown PROT bits")); + return (EXTERROR(EINVAL, "unknown PROT bits %#jx", prot)); } max_prot = PROT_MAX_EXTRACT(prot); prot = PROT_EXTRACT(prot); if (max_prot != 0 && (max_prot & prot) != prot) { - return (EXTERROR(ENOTSUP, "prot is not subset of max_prot")); + return (EXTERROR(ENOTSUP, + "prot %#jx is not subset of max_prot %#jx", + prot, max_prot)); } p = td->td_proc; @@ -236,7 +238,7 @@ kern_mmap(struct thread *td, const struct mmap_req *mrp) if ((len == 0 && p->p_osrel >= P_OSREL_MAP_ANON) || ((flags & MAP_ANON) != 0 && (fd != -1 || pos != 0))) { return (EXTERROR(EINVAL, - "offset not zero/fd not -1 for MAP_ANON", + "offset %#jd not zero/fd %#jd not -1 for MAP_ANON", fd, pos)); } } else { @@ -247,8 +249,8 @@ kern_mmap(struct thread *td, const struct mmap_req *mrp) if (flags & MAP_STACK) { if ((fd != -1) || ((prot & (PROT_READ | PROT_WRITE)) != (PROT_READ | PROT_WRITE))) { - return (EXTERROR(EINVAL, "MAP_STACK with prot < rw", - prot)); + return (EXTERROR(EINVAL, + "MAP_STACK with prot %#jx < rw", prot)); } flags |= MAP_ANON; pos = 0; @@ -257,18 +259,21 @@ kern_mmap(struct thread *td, const struct mmap_req *mrp) MAP_STACK | MAP_NOSYNC | MAP_ANON | MAP_EXCL | MAP_NOCORE | MAP_PREFAULT_READ | MAP_GUARD | MAP_32BIT | MAP_ALIGNMENT_MASK)) != 0) { - return (EXTERROR(EINVAL, "reserved flag set")); + return (EXTERROR(EINVAL, "reserved flag set (flags %#jx)", + flags)); } if ((flags & (MAP_EXCL | MAP_FIXED)) == MAP_EXCL) { - return (EXTERROR(EINVAL, "EXCL without FIXED")); + return (EXTERROR(EINVAL, "EXCL without FIXED (flags %#jx)", + flags)); } if ((flags & (MAP_SHARED | MAP_PRIVATE)) == (MAP_SHARED | MAP_PRIVATE)) { - return (EXTERROR(EINVAL, "both SHARED and PRIVATE set")); + return (EXTERROR(EINVAL, + "both SHARED and PRIVATE set (flags %#jx)", flags)); } if (prot != PROT_NONE && (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC)) != 0) { - return (EXTERROR(EINVAL, "invalid prot", prot)); + return (EXTERROR(EINVAL, "invalid prot %#jx", prot)); } if ((flags & MAP_GUARD) != 0 && (prot != PROT_NONE || fd != -1 || pos != 0 || (flags & ~(MAP_FIXED | MAP_GUARD | MAP_EXCL | @@ -295,7 +300,7 @@ kern_mmap(struct thread *td, const struct mmap_req *mrp) if (align != 0 && align != MAP_ALIGNED_SUPER && (align >> MAP_ALIGNMENT_SHIFT >= sizeof(void *) * NBBY || align >> MAP_ALIGNMENT_SHIFT < PAGE_SHIFT)) { - return (EXTERROR(EINVAL, "bad alignment", align)); + return (EXTERROR(EINVAL, "bad alignment %#jx", align)); } /* @@ -310,8 +315,8 @@ kern_mmap(struct thread *td, const struct mmap_req *mrp) */ addr -= pageoff; if ((addr & PAGE_MASK) != 0) { - return (EXTERROR(EINVAL, "fixed mapping not aligned", - addr)); + return (EXTERROR(EINVAL, + "fixed mapping at %#jx not aligned", addr)); } /* Address range must be all in user VM space. */ @@ -321,7 +326,8 @@ kern_mmap(struct thread *td, const struct mmap_req *mrp) } if (flags & MAP_32BIT && addr + size > MAP_32BIT_MAX_ADDR) { return (EXTERROR(EINVAL, - "fixed 32bit mapping does not fit into 4G")); + "fixed 32bit mapping of [%#jx %#jx] does not fit into 4G", + addr, addr + size)); } } else if (flags & MAP_32BIT) { /* @@ -1495,7 +1501,7 @@ vm_mmap(vm_map_t map, vm_offset_t *addr, vm_size_t size, vm_prot_t prot, handle, &foff, &object, &writecounted); break; default: - error = EXTERROR(EINVAL, "unsupported backing obj type", + error = EXTERROR(EINVAL, "unsupported backing obj type %jd", handle_type); break; } @@ -1578,7 +1584,7 @@ vm_mmap_object(vm_map_t map, vm_offset_t *addr, vm_size_t size, vm_prot_t prot, * exec). */ if ((foff & PAGE_MASK) != 0) { - return (EXTERROR(EINVAL, "offset not page-aligned", foff)); + return (EXTERROR(EINVAL, "offset %#jx not page-aligned", foff)); } if ((flags & MAP_FIXED) == 0) { @@ -1587,7 +1593,8 @@ vm_mmap_object(vm_map_t map, vm_offset_t *addr, vm_size_t size, vm_prot_t prot, } else { if (*addr != trunc_page(*addr)) { return (EXTERROR(EINVAL, - "non-fixed mapping address not aligned", *addr)); + "non-fixed mapping address %#jx not aligned", + *addr)); } fitit = false; } @@ -1599,7 +1606,7 @@ vm_mmap_object(vm_map_t map, vm_offset_t *addr, vm_size_t size, vm_prot_t prot, } if (foff != 0) { return (EXTERROR(EINVAL, - "anon mapping with non-zero offset")); + "anon mapping with non-zero offset %#jx", foff)); } docow = 0; } else if (flags & MAP_PREFAULT_READ) @@ -1702,6 +1709,6 @@ vm_mmap_to_errno(int rv) } if ((curthread->td_pflags2 & (TDP2_UEXTERR | TDP2_EXTERR)) == TDP2_UEXTERR) - EXTERROR(error, "mach error", rv); + EXTERROR(error, "mach error %jd", rv); return (error); } diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index 117900135ac3..f4c54ba91742 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -2161,9 +2161,9 @@ vm_object_populate(vm_object_t object, vm_pindex_t start, vm_pindex_t end) */ boolean_t vm_object_coalesce(vm_object_t prev_object, vm_ooffset_t prev_offset, - vm_size_t prev_size, vm_size_t next_size, boolean_t reserved) + vm_size_t prev_size, vm_size_t next_size, int cflags) { - vm_pindex_t next_pindex; + vm_pindex_t next_end, next_pindex; if (prev_object == NULL) return (TRUE); @@ -2197,10 +2197,12 @@ vm_object_coalesce(vm_object_t prev_object, vm_ooffset_t prev_offset, return (FALSE); } + next_end = next_pindex + next_size; + /* * Account for the charge. */ - if (prev_object->cred != NULL) { + if (prev_object->cred != NULL && (cflags & OBJCO_NO_CHARGE) == 0) { /* * If prev_object was charged, then this mapping, * although not charged now, may become writable @@ -2211,38 +2213,50 @@ vm_object_coalesce(vm_object_t prev_object, vm_ooffset_t prev_offset, * entry, and swap reservation for this entry is * managed in appropriate time. */ - if (!reserved && !swap_reserve_by_cred(ptoa(next_size), - prev_object->cred)) { - VM_OBJECT_WUNLOCK(prev_object); - return (FALSE); + if (next_end > prev_object->size) { + vm_size_t charge = ptoa(next_end - prev_object->size); + + if ((cflags & OBJCO_CHARGED) == 0) { + if (!swap_reserve_by_cred(charge, + prev_object->cred)) { + VM_OBJECT_WUNLOCK(prev_object); + return (FALSE); + } + } else if (prev_object->size > next_pindex) { + /* + * The caller charged, but: + * - the object has already accounted for the + * space, + * - and the object end is between previous + * mapping end and next_end. + */ + swap_release_by_cred(ptoa(prev_object->size - + next_pindex), prev_object->cred); + } + prev_object->charge += charge; + } else if ((cflags & OBJCO_CHARGED) != 0) { + /* + * The caller charged, but the object has + * already accounted for the space. Whole new + * mapping charge should be released, + */ + swap_release_by_cred(ptoa(next_size), + prev_object->cred); } - prev_object->charge += ptoa(next_size); } /* * Remove any pages that may still be in the object from a previous * deallocation. */ - if (next_pindex < prev_object->size) { - vm_object_page_remove(prev_object, next_pindex, next_pindex + - next_size, 0); -#if 0 - if (prev_object->cred != NULL) { - KASSERT(prev_object->charge >= - ptoa(prev_object->size - next_pindex), - ("object %p overcharged 1 %jx %jx", prev_object, - (uintmax_t)next_pindex, (uintmax_t)next_size)); - prev_object->charge -= ptoa(prev_object->size - - next_pindex); - } -#endif - } + if (next_pindex < prev_object->size) + vm_object_page_remove(prev_object, next_pindex, next_end, 0); /* * Extend the object if necessary. */ - if (next_pindex + next_size > prev_object->size) - prev_object->size = next_pindex + next_size; + if (next_end > prev_object->size) + prev_object->size = next_end; #ifdef INVARIANTS /* @@ -2254,7 +2268,7 @@ vm_object_coalesce(vm_object_t prev_object, vm_ooffset_t prev_offset, vm_pindex_t pidx; pidx = swap_pager_seek_data(prev_object, next_pindex); - KASSERT(pidx >= next_pindex + next_size, + KASSERT(pidx >= next_end, ("found obj %p pindex %#jx e %#jx %#jx %#jx", prev_object, pidx, (uintmax_t)prev_offset, (uintmax_t)prev_size, (uintmax_t)next_size)); diff --git a/sys/vm/vm_object.h b/sys/vm/vm_object.h index e58fae5f0090..98afb93f8389 100644 --- a/sys/vm/vm_object.h +++ b/sys/vm/vm_object.h @@ -228,6 +228,12 @@ struct vm_object { #define OBJPR_NOTMAPPED 0x2 /* Don't unmap pages. */ #define OBJPR_VALIDONLY 0x4 /* Ignore invalid pages. */ +/* + * Options for vm_object_coalesce(). + */ +#define OBJCO_CHARGED 0x1 /* The next_size was charged already */ +#define OBJCO_NO_CHARGE 0x2 /* Do not do swap accounting at all */ + TAILQ_HEAD(object_q, vm_object); extern struct object_q vm_object_list; /* list of allocated objects */ @@ -354,7 +360,7 @@ vm_object_t vm_object_allocate_anon(vm_pindex_t, vm_object_t, struct ucred *, vm_size_t); vm_object_t vm_object_allocate_dyn(objtype_t, vm_pindex_t, u_short); boolean_t vm_object_coalesce(vm_object_t, vm_ooffset_t, vm_size_t, vm_size_t, - boolean_t); + int); void vm_object_collapse (vm_object_t); void vm_object_deallocate (vm_object_t); void vm_object_destroy (vm_object_t); diff --git a/sys/vm/vnode_pager.c b/sys/vm/vnode_pager.c index 040b4037df15..3504c90821e5 100644 --- a/sys/vm/vnode_pager.c +++ b/sys/vm/vnode_pager.c @@ -1523,49 +1523,47 @@ void vnode_pager_undirty_pages(vm_page_t *ma, int *rtvals, int written, off_t eof, int lpos) { - int i, pos, pos_devb; + int i, npages, pos; - if (written == 0 && eof >= lpos) - return; - for (i = 0, pos = 0; pos < written; i++, pos += PAGE_SIZE) { - if (pos < trunc_page(written)) { - rtvals[i] = VM_PAGER_OK; - vm_page_undirty(ma[i]); - } else { - /* Partially written page. */ - rtvals[i] = VM_PAGER_AGAIN; - vm_page_clear_dirty(ma[i], 0, written & PAGE_MASK); - } + /* Process pages up to round_page(written) */ + pos = written & PAGE_MASK; + npages = atop(written); + for (i = 0; i < npages; i++) { + rtvals[i] = VM_PAGER_OK; + vm_page_undirty(ma[i]); + } + if (pos != 0) { + /* Partially written page. */ + rtvals[i] = VM_PAGER_AGAIN; + vm_page_clear_dirty(ma[i], 0, pos); } - if (eof >= lpos) /* avoid truncation */ - return; - for (pos = eof, i = OFF_TO_IDX(trunc_page(pos)); pos < lpos; i++) { - if (pos != trunc_page(pos)) { - /* - * The page contains the last valid byte in - * the vnode, mark the rest of the page as - * clean, potentially making the whole page - * clean. - */ - pos_devb = roundup2(pos & PAGE_MASK, DEV_BSIZE); - vm_page_clear_dirty(ma[i], pos_devb, PAGE_SIZE - - pos_devb); - /* - * If the page was cleaned, report the pageout - * on it as successful. msync() no longer - * needs to write out the page, endlessly - * creating write requests and dirty buffers. - */ - if (ma[i]->dirty == 0) - rtvals[i] = VM_PAGER_OK; + /* Process pages from trunc_page(eof) to round_page(lpos) */ + pos = eof & PAGE_MASK; + i = atop(eof); + npages = atop(lpos); + if (i < npages && pos != 0) { + /* + * The page contains the last valid byte in the + * vnode, mark the rest of the page as clean, + * potentially making the whole page clean. + */ + pos = roundup2(pos, DEV_BSIZE); + vm_page_clear_dirty(ma[i], pos, PAGE_SIZE - pos); - pos = round_page(pos); - } else { - /* vm_pageout_flush() clears dirty */ - rtvals[i] = VM_PAGER_BAD; - pos += PAGE_SIZE; - } + /* + * If the page was cleaned, report the pageout on it + * as successful. msync() no longer needs to write + * out the page, endlessly creating write requests + * and dirty buffers. + */ + if (ma[i]->dirty == 0) + rtvals[i] = VM_PAGER_OK; + i++; + } + for (; i < npages; i++) { + /* vm_pageout_flush() clears dirty */ + rtvals[i] = VM_PAGER_BAD; } } diff --git a/sys/xen/xen_intr.h b/sys/xen/xen_intr.h index 75c3dc7c6060..4965928cc8b4 100644 --- a/sys/xen/xen_intr.h +++ b/sys/xen/xen_intr.h @@ -182,7 +182,7 @@ void xen_intr_unbind(xen_intr_handle_t *handle); */ int xen_intr_describe(xen_intr_handle_t port_handle, const char *fmt, ...) - __attribute__((format(printf, 2, 3))); + __printflike(2, 3); /** * Signal the remote peer of an interrupt source associated with an diff --git a/sys/xen/xenbus/xenbusvar.h b/sys/xen/xenbus/xenbusvar.h index ee444c132c0c..0f4168f17e6a 100644 --- a/sys/xen/xenbus/xenbusvar.h +++ b/sys/xen/xenbus/xenbusvar.h @@ -151,7 +151,7 @@ int xenbus_grant_ring(device_t dev, unsigned long ring_mfn, grant_ref_t *refp); * printf arguments. */ void xenbus_dev_error(device_t dev, int err, const char *fmt, ...) - __attribute__((format(printf, 3, 4))); + __printflike(3, 4); /** * va_list version of xenbus_dev_error(). @@ -162,7 +162,7 @@ void xenbus_dev_error(device_t dev, int err, const char *fmt, ...) * \param ap Va_list of printf arguments. */ void xenbus_dev_verror(device_t dev, int err, const char *fmt, va_list ap) - __attribute__((format(printf, 3, 0))); + __printflike(3, 0); /** * Equivalent to xenbus_dev_error(), followed by @@ -174,7 +174,7 @@ void xenbus_dev_verror(device_t dev, int err, const char *fmt, va_list ap) * printf arguments. */ void xenbus_dev_fatal(device_t dev, int err, const char *fmt, ...) - __attribute__((format(printf, 3, 4))); + __printflike(3, 4); /** * va_list version of xenbus_dev_fatal(). @@ -185,7 +185,7 @@ void xenbus_dev_fatal(device_t dev, int err, const char *fmt, ...) * \param ap Va_list of printf arguments. */ void xenbus_dev_vfatal(device_t dev, int err, const char *fmt, va_list) - __attribute__((format(printf, 3, 0))); + __printflike(3, 0); /** * Convert a member of the xenbus_state enum into an ASCII string. diff --git a/sys/xen/xenstore/xenstorevar.h b/sys/xen/xenstore/xenstorevar.h index 8b02262396e8..f34ad375bc3a 100644 --- a/sys/xen/xenstore/xenstorevar.h +++ b/sys/xen/xenstore/xenstorevar.h @@ -270,7 +270,7 @@ int xs_scanf(struct xs_transaction t, */ int xs_printf(struct xs_transaction t, const char *dir, const char *node, const char *fmt, ...) - __attribute__((format(printf, 4, 5))); + __printflike(4, 5); /** * va_list version of xenbus_printf(). diff --git a/tests/sys/kern/exterr_test.c b/tests/sys/kern/exterr_test.c index 17c84c1f8ed4..b4746a485f58 100644 --- a/tests/sys/kern/exterr_test.c +++ b/tests/sys/kern/exterr_test.c @@ -51,7 +51,7 @@ ATF_TC_BODY(gettext_extended, tc) ATF_CHECK_EQ(0, r); printf("Extended error: %s\n", exterr); /* Note: error string may need to be updated due to kernel changes */ - ATF_CHECK(strstr(exterr, "prot is not subset of max_prot") != 0); + ATF_CHECK(strstr(exterr, " is not subset of ") != 0); } ATF_TC(gettext_noextended); diff --git a/tests/sys/netpfil/pf/nat.sh b/tests/sys/netpfil/pf/nat.sh index 3d953b495953..025471f75f97 100644 --- a/tests/sys/netpfil/pf/nat.sh +++ b/tests/sys/netpfil/pf/nat.sh @@ -804,8 +804,8 @@ binat_compat_body() binat_compat_cleanup() { + [ -f ${PWD}/inetd_tester.pid ] && kill $(cat ${PWD}/inetd_tester.pid) pft_cleanup - kill $(cat ${PWD}/inetd_tester.pid) } atf_test_case "binat_match" "cleanup" @@ -872,8 +872,8 @@ binat_match_body() binat_match_cleanup() { + [ -f ${PWD}/inetd_tester.pid ] && kill $(cat ${PWD}/inetd_tester.pid) pft_cleanup - kill $(cat ${PWD}/inetd_tester.pid) } atf_test_case "empty_pool" "cleanup" diff --git a/tools/build/Makefile b/tools/build/Makefile index 2c6237c4dd7d..1eb539f06607 100644 --- a/tools/build/Makefile +++ b/tools/build/Makefile @@ -351,9 +351,12 @@ MSDOSFSINCS+= ${SRCTOP}/sys/fs/msdosfs/fat.h MSDOSFSINCS+= ${SRCTOP}/sys/fs/msdosfs/msdosfsmount.h DISKINCS+= ${SRCTOP}/sys/sys/disk/bsd.h +.if ${.MAKE.OS} == "FreeBSD" # Needed to build most of the things below, which include sys/cdefs.h either # directly or transitively +SYSINCS+= ${SRCTOP}/sys/sys/_visible.h SYSINCS+= ${SRCTOP}/sys/sys/cdefs.h +.endif # Needed to build config (since it uses libnv) SYSINCS+= ${SRCTOP}/sys/sys/_nv.h diff --git a/tools/build/make_libc_exterr_cat_filenames.sh b/tools/build/make_libc_exterr_cat_filenames.sh new file mode 100755 index 000000000000..fbde85891200 --- /dev/null +++ b/tools/build/make_libc_exterr_cat_filenames.sh @@ -0,0 +1,22 @@ +#!/bin/sh +set -e + +check="lib/libc/gen/uexterr_format.c" +target="lib/libc/gen/exterr_cat_filenames.h" + +if [ \! -f "${check}" ] ; then + echo "Script must be run from the top of the full source tree" + exit 1 +fi + +echo "/*" >"${target}" +printf " * Automatically %sgenerated, use\\n" \@ >>"${target}" +echo " * tools/build/make_libc_exterr_cat_filenames.sh" >>"${target}" +echo " */" >>"${target}" + +(find sys -type f -name '*.c' | \ + xargs grep -E '^#define[[:space:]]+EXTERR_CATEGORY[[:space:]]+EXTERR_CAT_' | \ + sed -E 's/[[:space:]]+/:/g' | \ + awk -F ':' '{filename = $1; sub(/^sys\//, "", filename); + printf("\t[%s] = \"%s\",\n", $4, filename)}') \ + >>"${target}" diff --git a/tools/build/options/WITH_REPRODUCIBLE_PATHS b/tools/build/options/WITH_REPRODUCIBLE_PATHS new file mode 100644 index 000000000000..88d4a0870976 --- /dev/null +++ b/tools/build/options/WITH_REPRODUCIBLE_PATHS @@ -0,0 +1,6 @@ +Modify the paths encoded in binary artifacts to be standard path + +Normally, the actual path is encoded in the binary. However, this makes the +build differ depending on the path it was built from. With this option enabled, +the paths recorded are /usr/src, regardless of the actual path. With this option +disabled, the actual paths are recorded. diff --git a/usr.sbin/bhyve/slirp/slirp-helper.c b/usr.sbin/bhyve/slirp/slirp-helper.c index 06f393aab724..9fb9784662fe 100644 --- a/usr.sbin/bhyve/slirp/slirp-helper.c +++ b/usr.sbin/bhyve/slirp/slirp-helper.c @@ -503,6 +503,8 @@ main(int argc, char **argv) memset(&priv, 0, sizeof(priv)); priv.sock = sd; + if (ioctl(priv.sock, FIONBIO, &(int){0}) == -1) + err(1, "ioctl(FIONBIO)"); if (pipe2(priv.wakeup, O_CLOEXEC | O_NONBLOCK) != 0) err(1, "pipe2"); |
