diff options
161 files changed, 2490 insertions, 1217 deletions
diff --git a/Makefile.inc1 b/Makefile.inc1 index 9dc4f2db4a6c..74c4598dd092 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -2240,7 +2240,7 @@ _default_flavor= -default _debug=-dbg . endif -create-dtb-package: +create-dtb-package: .PHONY @if [ -f ${KSTAGEDIR}/${DISTDIR}/dtb.plist ]; then \ ${SRCDIR}/release/packages/generate-ucl.lua \ PKGNAME "dtb" \ @@ -2265,9 +2265,12 @@ create-dtb-package: -o ${REPODIR}/${PKG_ABI}/${PKG_OUTPUT_DIR} ; \ fi -create-kernel-packages: .PHONY +create-kernel-packages: .PHONY create-kernel-flavored-packages create-dtb-package +create-kernel-flavored-packages: .PHONY +.ORDER: create-kernel-flavored-packages create-dtb-package + . for flavor in "" ${_debug} -create-kernel-packages: create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},} create-dtb-package +create-kernel-flavored-packages: create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},} create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},}: _pkgbootstrap .PHONY @cd ${KSTAGEDIR}/${DISTDIR} ; \ ${METALOG_SORT_CMD} ${KSTAGEDIR}/kernel.meta | \ diff --git a/contrib/bsddialog/.gitignore b/contrib/bsddialog/.gitignore index c8fc68ed8a0e..c9613d477f7f 100644 --- a/contrib/bsddialog/.gitignore +++ b/contrib/bsddialog/.gitignore @@ -21,6 +21,7 @@ examples_library/msgbox examples_library/pause examples_library/radiolist examples_library/rangebox +examples_library/textbox examples_library/theme examples_library/timebox examples_library/yesno diff --git a/contrib/bsddialog/CHANGELOG b/contrib/bsddialog/CHANGELOG index a4cf4d01c077..7800098644d7 100644 --- a/contrib/bsddialog/CHANGELOG +++ b/contrib/bsddialog/CHANGELOG @@ -1,11 +1,57 @@ -2024-07-01 1.0.4 +2025-06-22 Version 1.0.5 + + Manual: + * fix: "User-friendly documentation for alternate screen" + https://bugs.freebsd.org/285459. + Improve bsddialog.1: --alternate-screen and --normal-screen. + + NetBSD (tested on amd64) refactoring, no function changes: + * https://gitlab.com/alfix/bsddialog/-/merge_requests/4 + lib: include <stdarg.h> in lib_util.c. + * https://gitlab.com/alfix/bsddialog/-/merge_requests/5 + a call to curses' refresh() is performed, while a local + variable is also called refresh. + * Makefiles: add install and uninstall targets (both GND and BSD) + https://gitlab.com/alfix/bsddialog/-/merge_requests/3 + + MacOS (tested on amd64) refactoring, no function changes: + * https://gitlab.com/alfix/bsddialog/-/merge_requests/6 + utility: replace u_int with unsigned int. + + Library: + * fix: useless refreshes, https://gitlab.com/alfix/bsddialog/-/issues/8: + "It takes lot of time when running over a 115200 UART". + Not fixed for bsddialog_gauge() because it has to be rewritten. + * change: bsddialog_backtitle() does not update the screen so the + backtitle is not printed. To use if a dialog is built later. + Rationale: see "115200 UART" problem above. + * add: bsddialog_backtitle_rf() to print a top title refreshing the + screen like bsddialog_backtitle() was previously. + * change: forms, ENTER is also a navigation keys in forms fields. + Request: https://bugs.freebsd.org/287592 + If conf.button.always_active is true the form is closes immediatly. + + Library and implicitly utility: + * fix: textbox buttons returned values (was always OK). + Thanks to https://reviews.freebsd.org/D48668. + * change: TAB is a navigation keys in forms. Previously it directly + switched form-fields <-> buttons. + Request: https://bugs.freebsd.org/287592 + + Utility: + * change: forms, ENTER is a also navigation keys in forms fields. + Previously it directly closed the form except with --switch-buttons + Request: https://bugs.freebsd.org/287592 + + +2024-07-01 Version 1.0.4 Utility internal refactoring (no functional change): * change: rename an internal constant to avoid a future conflict because FreeBSD is changing headers files for _FORTIFY_SOURCE. Reported and fixed by Kyle Evans. -2024-05-27 1.0.3 +2024-05-27 Version 1.0.3 Utility: change: --form and --mixedform do not print field value to output fd if diff --git a/contrib/bsddialog/LICENSE b/contrib/bsddialog/LICENSE index 7b36a8dce42e..9ea4a4a62f4b 100644 --- a/contrib/bsddialog/LICENSE +++ b/contrib/bsddialog/LICENSE @@ -1,6 +1,6 @@ BSD 2-Clause License -Copyright (c) 2021-2024, Alfonso Sabato Siciliano +Copyright (c) 2021-2025, Alfonso Sabato Siciliano Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/contrib/bsddialog/Makefile b/contrib/bsddialog/Makefile index a6af8813a48e..335b693470e6 100644 --- a/contrib/bsddialog/Makefile +++ b/contrib/bsddialog/Makefile @@ -4,7 +4,7 @@ # Written in 2023 by Alfonso Sabato Siciliano OUTPUT = bsddialog -export VERSION=1.0.4 +export VERSION=1.0.5 .CURDIR ?= ${CURDIR} LIBPATH = ${.CURDIR}/lib LIBBSDDIALOG = ${LIBPATH}/libbsddialog.so @@ -22,7 +22,15 @@ DEBUG ?= export ENABLEDEBUG=${DEBUG} ################### -all : ${OUTPUT} +all: ${OUTPUT} + +install: all + ${MAKE} -C ${LIBPATH} install + ${MAKE} -C ${UTILITYPATH} install + +uninstall: + ${MAKE} -C ${UTILITYPATH} uninstall + ${MAKE} -C ${LIBPATH} uninstall ${OUTPUT}: ${LIBBSDDIALOG} ${MAKE} -C ${UTILITYPATH} LIBPATH=${LIBPATH} @@ -36,3 +44,4 @@ clean: ${MAKE} -C ${UTILITYPATH} clean ${RM} ${OUTPUT} *.core +.PHONY: all install uninstall clean diff --git a/contrib/bsddialog/README.md b/contrib/bsddialog/README.md index 7b9b6cf8e84d..5a25109775fe 100644 --- a/contrib/bsddialog/README.md +++ b/contrib/bsddialog/README.md @@ -1,4 +1,4 @@ -# BSDDialog 1.0.4 +# BSDDialog 1.0.5 This project provides **bsddialog** and **libbsddialog**, an utility and a library to build scripts and tools with TUI dialogs and widgets. @@ -129,7 +129,6 @@ in the _Public Domain_ to build new projects: - implement global buttons handler. - doc: external tutorial, theming guide. - implement menutype.min\_on. - - improve refresh at startup, avoid dialog refresh before drawing text. - add debug API: bsddialog\_debug(y,x,refresh,"fmt",...). - add mouse support. - use alarm(2) for bsddialog\_pause. @@ -139,4 +138,4 @@ in the _Public Domain_ to build new projects: - fix --mixedform "" 0 0 0 Label 1 0 Init 1 12 0 0 2 (with 0 editable field). - add *text* customization to --hmsg *help-message* - check --passwordform *fieldlen* like --form and --mixedform. - + - add manuals to Makefiles installe and uninstall targets. diff --git a/contrib/bsddialog/examples_library/compile b/contrib/bsddialog/examples_library/compile index 9025f35426d9..1a68313090f6 100755 --- a/contrib/bsddialog/examples_library/compile +++ b/contrib/bsddialog/examples_library/compile @@ -8,14 +8,16 @@ # worldwide. This software is distributed without any warranty, see: # <http://creativecommons.org/publicdomain/zero/1.0/>. +set -x + libpath=../lib examples="menu checklist radiolist mixedlist theme infobox yesno msgbox \ - datebox form timebox rangebox pause calendar gauge mixedgauge" +datebox form timebox rangebox pause calendar gauge mixedgauge textbox" rm -f $examples for e in $examples do - cc -g -Wall -Wextra -I$libpath ${e}.c -o $e -L$libpath -lbsddialog \ - -Wl,-rpath=$libpath + cc -g -Wall -Wextra -I$libpath ${e}.c -o $e \ + -Wl,-rpath=$libpath -L$libpath -lbsddialog done diff --git a/contrib/bsddialog/examples_library/textbox.c b/contrib/bsddialog/examples_library/textbox.c new file mode 100644 index 000000000000..2e76cbb97891 --- /dev/null +++ b/contrib/bsddialog/examples_library/textbox.c @@ -0,0 +1,38 @@ +/*- + * SPDX-License-Identifier: CC0-1.0 + * + * Written in 2025 by Alfonso Sabato Siciliano. + * To the extent possible under law, the author has dedicated all copyright + * and related and neighboring rights to this software to the public domain + * worldwide. This software is distributed without any warranty, see: + * <http://creativecommons.org/publicdomain/zero/1.0/>. + */ + +#include <bsddialog.h> +#include <stdio.h> + +int main() +{ + int output; + struct bsddialog_conf conf; + + if (bsddialog_init() == BSDDIALOG_ERROR) { + printf("Error: %s\n", bsddialog_geterror()); + return (1); + } + bsddialog_initconf(&conf); + conf.title = "textbox"; + output = bsddialog_textbox(&conf, "./textbox.c", 20, 80); + bsddialog_end(); + + switch (output) { + case BSDDIALOG_ERROR: + printf("Error %s\n", bsddialog_geterror()); + return (1); + case BSDDIALOG_OK: + printf("[Exit]\n"); + break; + } + + return (0); +} diff --git a/contrib/bsddialog/lib/GNUmakefile b/contrib/bsddialog/lib/GNUmakefile index 7c7a9bc25ee4..2cb060381a46 100644 --- a/contrib/bsddialog/lib/GNUmakefile +++ b/contrib/bsddialog/lib/GNUmakefile @@ -9,6 +9,7 @@ HEADERS = bsddialog.h bsddialog_theme.h bsddialog_progressview.h SOURCES = barbox.c datebox.c formbox.c libbsddialog.c lib_util.c \ menubox.c messagebox.c textbox.c theme.c timebox.c OBJECTS = $(SOURCES:.c=.o) +PREFIX = /usr/local ifneq ($(ENABLEDEBUG),) CFLAGS += -g @@ -21,7 +22,21 @@ LIBFLAG = -shared RM = rm -f LN = ln -s -f -all : $(LIBRARY) +all: $(LIBRARY) + +install: all + ${INSTALL} -m 0644 bsddialog.h ${DESTDIR}${PREFIX}/include/bsddialog.h + ${INSTALL} -m 0644 bsddialog_progressview.h ${DESTDIR}${PREFIX}/include/bsddialog_progressview.h + ${INSTALL} -m 0644 bsddialog_theme.h ${DESTDIR}${PREFIX}/include/bsddialog_theme.h + ${INSTALL} -m 0755 ${LIBRARY_SO}.${VERSION} ${DESTDIR}${PREFIX}/lib/${LIBRARY_SO}.${VERSION} + ${LN} ${LIBRARY_SO}.${VERSION} ${DESTDIR}${PREFIX}/lib/${LIBRARY_SO} + +uninstall: + ${RM} ${DESTDIR}${PREFIX}/include/bsddialog.h + ${RM} ${DESTDIR}${PREFIX}/include/bsddialog_progressview.h + ${RM} ${DESTDIR}${PREFIX}/include/bsddialog_theme.h + ${RM} ${DESTDIR}${PREFIX}/lib/${LIBRARY_SO}.${VERSION} + ${RM} ${DESTDIR}${PREFIX}/lib/${LIBRARY_SO} $(LIBRARY): $(OBJECTS) $(CC) $(LIBFLAG) $^ -o $(LIBRARY_SO).$(VERSION) $(LDFLAGS) @@ -32,3 +47,5 @@ $(LIBRARY): $(OBJECTS) clean: $(RM) $(LIBRARY_SO)* *.o *~ + +.PHONY: all install uninstall ${LIBRARY} clean diff --git a/contrib/bsddialog/lib/Makefile b/contrib/bsddialog/lib/Makefile index 252b33f79848..c728541a9f7a 100644 --- a/contrib/bsddialog/lib/Makefile +++ b/contrib/bsddialog/lib/Makefile @@ -10,6 +10,7 @@ HEADERS = bsddialog.h bsddialog_theme.h bsddialog_progressview.h SOURCES = barbox.c datebox.c formbox.c libbsddialog.c lib_util.c \ menubox.c messagebox.c textbox.c theme.c timebox.c OBJECTS = ${SOURCES:.c=.o} +PREFIX = /usr/local .if defined(DEBUG) CFLAGS += -g @@ -23,7 +24,23 @@ LDFLAGS += -fstack-protector-strong -shared -Wl,-x -Wl,--fatal-warnings \ LN = ln -s -f RM = rm -f -all : ${LIBRARY} +all: ${LIBRARY} + +install: all + ${INSTALL} -m 0644 bsddialog.h ${DESTDIR}${PREFIX}/include/bsddialog.h + ${INSTALL} -m 0644 bsddialog_progressview.h ${DESTDIR}${PREFIX}/include/bsddialog_progressview.h + ${INSTALL} -m 0644 bsddialog_theme.h ${DESTDIR}${PREFIX}/include/bsddialog_theme.h + ${INSTALL} -m 0644 ${LIBRARY_A} ${DESTDIR}${PREFIX}/lib/${LIBRARY_A} + ${INSTALL} -m 0755 ${LIBRARY_SO}.${VERSION} ${DESTDIR}${PREFIX}/lib/${LIBRARY_SO}.${VERSION} + ${LN} ${LIBRARY_SO}.${VERSION} ${DESTDIR}${PREFIX}/lib/${LIBRARY_SO} + +uninstall: + ${RM} ${DESTDIR}${PREFIX}/include/bsddialog.h + ${RM} ${DESTDIR}${PREFIX}/include/bsddialog_progressview.h + ${RM} ${DESTDIR}${PREFIX}/include/bsddialog_theme.h + ${RM} ${DESTDIR}${PREFIX}/lib/${LIBRARY_A} + ${RM} ${DESTDIR}${PREFIX}/lib/${LIBRARY_SO}.${VERSION} + ${RM} ${DESTDIR}${PREFIX}/lib/${LIBRARY_SO} ${LIBRARY}: ${LIBRARY_SO} ${LIBRARY_A} @@ -42,3 +59,5 @@ ${LIBRARY_A}: ${OBJECTS} clean: ${RM} ${LIBRARY_SO}* *.o *~ *.gz ${LIBRARY_A} + +.PHONY: all install uninstall ${LIBRARY} clean diff --git a/contrib/bsddialog/lib/barbox.c b/contrib/bsddialog/lib/barbox.c index 4feea20c6441..51f81ecbca68 100644 --- a/contrib/bsddialog/lib/barbox.c +++ b/contrib/bsddialog/lib/barbox.c @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2021-2024 Alfonso Sabato Siciliano + * Copyright (c) 2021-2025 Alfonso Sabato Siciliano * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -371,7 +371,7 @@ bsddialog_progressview (struct bsddialog_conf *conf, const char *text, int rows, unsigned int i, mainperc, totaltodo; float readforsec; const char **minilabels; - time_t tstart, told, tnew, refresh; + time_t tstart, told, tnew, trefresh; if ((minilabels = calloc(nminibar, sizeof(char*))) == NULL) RETURN_ERROR("Cannot allocate memory for minilabels"); @@ -385,7 +385,7 @@ bsddialog_progressview (struct bsddialog_conf *conf, const char *text, int rows, minipercs[i] = minibar[i].status; } - refresh = pvconf->refresh == 0 ? 0 : pvconf->refresh - 1; + trefresh = pvconf->refresh == 0 ? 0 : pvconf->refresh - 1; retval = BSDDIALOG_OK; i = 0; update = true; @@ -398,7 +398,7 @@ bsddialog_progressview (struct bsddialog_conf *conf, const char *text, int rows, mainperc = (bsddialog_total_progview * 100) / totaltodo; time(&tnew); - if (update || tnew > told + refresh) { + if (update || tnew > told + trefresh) { retval = do_mixedgauge(conf, text, rows, cols, mainperc, nminibar, minilabels, minipercs, true); if (retval == BSDDIALOG_ERROR) @@ -440,17 +440,18 @@ bsddialog_progressview (struct bsddialog_conf *conf, const char *text, int rows, return (retval); } -static int rangebox_redraw(struct dialog *d, struct bar *b, int *bigchange) +static int +rangebox_redraw(struct dialog *d, bool redraw, struct bar *b, int *bigchange) { - if (d->built) { + if (redraw) { hide_dialog(d); refresh(); /* Important for decreasing screen */ } if (dialog_size_position(d, HBOX, MIN_WBOX, NULL) != 0) return (BSDDIALOG_ERROR); - if (draw_dialog(d) != 0) + if (draw_dialog(d) != 0) /* doupdate() in main loop */ return (BSDDIALOG_ERROR); - if (d->built) + if (redraw) refresh(); /* Important to fix grey lines expanding screen */ TEXTPAD(d, HBOX + HBUTTONS); @@ -490,7 +491,7 @@ bsddialog_rangebox(struct bsddialog_conf *conf, const char *text, int rows, RETURN_ERROR("Cannot build WINDOW bar"); b.y = b.x = 1; b.fmt = "%d"; - if (rangebox_redraw(&d, &b, &bigchange) != 0) + if (rangebox_redraw(&d, false, &b, &bigchange) != 0) return (BSDDIALOG_ERROR); loop = true; @@ -568,12 +569,12 @@ bsddialog_rangebox(struct bsddialog_conf *conf, const char *text, int rows, break; if (f1help_dialog(conf) != 0) return (BSDDIALOG_ERROR); - if (rangebox_redraw(&d, &b, &bigchange) != 0) + if (rangebox_redraw(&d, true, &b, &bigchange) != 0) return (BSDDIALOG_ERROR); break; case KEY_CTRL('l'): case KEY_RESIZE: - if (rangebox_redraw(&d, &b, &bigchange) != 0) + if (rangebox_redraw(&d, true, &b, &bigchange) != 0) return (BSDDIALOG_ERROR); break; default: @@ -594,17 +595,17 @@ bsddialog_rangebox(struct bsddialog_conf *conf, const char *text, int rows, return (retval); } -static int pause_redraw(struct dialog *d, struct bar *b) +static int pause_redraw(struct dialog *d, bool redraw, struct bar *b) { - if (d->built) { + if (redraw) { hide_dialog(d); refresh(); /* Important for decreasing screen */ } if (dialog_size_position(d, HBOX, MIN_WBOX, NULL) != 0) return (BSDDIALOG_ERROR); - if (draw_dialog(d) != 0) + if (draw_dialog(d) != 0) /* doupdate() in main loop */ return (BSDDIALOG_ERROR); - if (d->built) + if (redraw) refresh(); /* Important to fix grey lines expanding screen */ TEXTPAD(d, HBOX + HBUTTONS); @@ -633,7 +634,7 @@ bsddialog_pause(struct bsddialog_conf *conf, const char *text, int rows, RETURN_ERROR("Cannot build WINDOW bar"); b.y = b.x = 1; b.fmt = "%d"; - if (pause_redraw(&d, &b) != 0) + if (pause_redraw(&d, false, &b) != 0) return (BSDDIALOG_ERROR); tout = *seconds; @@ -687,12 +688,12 @@ bsddialog_pause(struct bsddialog_conf *conf, const char *text, int rows, break; if (f1help_dialog(conf) != 0) return (BSDDIALOG_ERROR); - if (pause_redraw(&d, &b) != 0) + if (pause_redraw(&d, true, &b) != 0) return (BSDDIALOG_ERROR); break; case KEY_CTRL('l'): case KEY_RESIZE: - if (pause_redraw(&d, &b) != 0) + if (pause_redraw(&d, true, &b) != 0) return (BSDDIALOG_ERROR); break; default: diff --git a/contrib/bsddialog/lib/bsddialog.3 b/contrib/bsddialog/lib/bsddialog.3 index cbf1653a2aca..bbd756661a78 100644 --- a/contrib/bsddialog/lib/bsddialog.3 +++ b/contrib/bsddialog/lib/bsddialog.3 @@ -1,5 +1,5 @@ .\" -.\" Copyright (c) 2021-2024 Alfonso Sabato Siciliano +.\" Copyright (c) 2021-2025 Alfonso Sabato Siciliano .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -22,11 +22,12 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd March 16, 2024 +.Dd June 22, 2025 .Dt BSDDIALOG 3 .Os .Sh NAME .Nm bsddialog_backtitle , +.Nm bsddialog_backtitle_rf , .Nm bsddialog_calendar , .Nm bsddialog_clear , .Nm bsddialog_color , @@ -65,6 +66,8 @@ .Ft int .Fn bsddialog_backtitle "struct bsddialog_conf *conf" "const char *backtitle" .Ft int +.Fn bsddialog_backtitle_rf "struct bsddialog_conf *conf" "const char *backtitle" +.Ft int .Fo bsddialog_calendar .Fa "struct bsddialog_conf *conf" .Fa "const char *text" @@ -292,7 +295,7 @@ and before .Dv false otherwise. .Pp -.Fn bsddialog_backtitle +.Fn bsddialog_backtitle_rf prints .Fa backtitle on the top of the screen. @@ -302,6 +305,11 @@ and .Fa conf.no_lines described later. .Pp +.Fn bsddialog_backtitle +is like +.Fn bsddialog_backtitle_rf +but it does not update the screen, using if a dialog is built later. +.Pp .Fn bsddialog_error returns a string to describe the last error. The function should be called after a @@ -902,7 +910,7 @@ provides a dialog for a the labels on buttons are .Dq Yes and -.Dq No . +.Dq &No . .Ss Keys .Bl -tag -width Ds .It Ctrl-l diff --git a/contrib/bsddialog/lib/bsddialog.h b/contrib/bsddialog/lib/bsddialog.h index fd0e2bc02580..fc59071c6fa0 100644 --- a/contrib/bsddialog/lib/bsddialog.h +++ b/contrib/bsddialog/lib/bsddialog.h @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2021-2024 Alfonso Sabato Siciliano + * Copyright (c) 2021-2025 Alfonso Sabato Siciliano * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -30,7 +30,7 @@ #include <stdbool.h> -#define LIBBSDDIALOG_VERSION "1.0.4" +#define LIBBSDDIALOG_VERSION "1.0.5" /* Return values */ #define BSDDIALOG_ERROR -1 @@ -179,6 +179,7 @@ int bsddialog_init_notheme(void); bool bsddialog_inmode(void); int bsddialog_end(void); int bsddialog_backtitle(struct bsddialog_conf *conf, const char *backtitle); +int bsddialog_backtitle_rf(struct bsddialog_conf *conf, const char *backtitle); int bsddialog_initconf(struct bsddialog_conf *conf); void bsddialog_clear(unsigned int y); void bsddialog_refresh(void); diff --git a/contrib/bsddialog/lib/bsddialog_theme.h b/contrib/bsddialog/lib/bsddialog_theme.h index 2071896b61f0..77938c65b6ce 100644 --- a/contrib/bsddialog/lib/bsddialog_theme.h +++ b/contrib/bsddialog/lib/bsddialog_theme.h @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2021-2023 Alfonso Sabato Siciliano + * Copyright (c) 2021-2025 Alfonso Sabato Siciliano * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/contrib/bsddialog/lib/datebox.c b/contrib/bsddialog/lib/datebox.c index ee955471799e..66f36f5f4a99 100644 --- a/contrib/bsddialog/lib/datebox.c +++ b/contrib/bsddialog/lib/datebox.c @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2022-2024 Alfonso Sabato Siciliano + * Copyright (c) 2022-2025 Alfonso Sabato Siciliano * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -296,20 +296,20 @@ print_calendar(struct bsddialog_conf *conf, WINDOW *win, int yy, int mm, int dd, } static int -calendar_redraw(struct dialog *d, WINDOW *yy_win, WINDOW *mm_win, +calendar_draw(struct dialog *d, bool redraw, WINDOW *yy_win, WINDOW *mm_win, WINDOW *dd_win) { int ycal, xcal; - if (d->built) { + if (redraw) { hide_dialog(d); refresh(); /* Important for decreasing screen */ } if (dialog_size_position(d, MINHCAL, MINWCAL, NULL) != 0) return (BSDDIALOG_ERROR); - if (draw_dialog(d) != 0) + if (draw_dialog(d) != 0) /* doupdate in main loop */ return (BSDDIALOG_ERROR); - if (d->built) + if (redraw) refresh(); /* Important to fix grey lines expanding screen */ TEXTPAD(d, MINHCAL + HBUTTONS); @@ -354,7 +354,7 @@ bsddialog_calendar(struct bsddialog_conf *conf, const char *text, int rows, if ((dd_win = newwin(1, 1, 1, 1)) == NULL) RETURN_ERROR("Cannot build WINDOW for dd"); wbkgd(dd_win, t.dialog.color); - if (calendar_redraw(&d, yy_win, mm_win, dd_win) != 0) + if (calendar_draw(&d, false, yy_win, mm_win, dd_win) != 0) return (BSDDIALOG_ERROR); sel = -1; @@ -503,12 +503,12 @@ bsddialog_calendar(struct bsddialog_conf *conf, const char *text, int rows, break; if (f1help_dialog(conf) != 0) return (BSDDIALOG_ERROR); - if (calendar_redraw(&d, yy_win, mm_win, dd_win) != 0) + if (calendar_draw(&d, true, yy_win, mm_win, dd_win) != 0) return (BSDDIALOG_ERROR); break; case KEY_CTRL('l'): case KEY_RESIZE: - if (calendar_redraw(&d, yy_win, mm_win, dd_win) != 0) + if (calendar_draw(&d, true, yy_win, mm_win, dd_win) != 0) return (BSDDIALOG_ERROR); break; default: @@ -533,11 +533,11 @@ bsddialog_calendar(struct bsddialog_conf *conf, const char *text, int rows, return (retval); } -static int datebox_redraw(struct dialog *d, struct dateitem *di) +static int datebox_draw(struct dialog *d, bool redraw, struct dateitem *di) { int y, x; - if (d->built) { + if (redraw) { hide_dialog(d); refresh(); /* Important for decreasing screen */ } @@ -545,7 +545,7 @@ static int datebox_redraw(struct dialog *d, struct dateitem *di) return (BSDDIALOG_ERROR); if (draw_dialog(d) != 0) return (BSDDIALOG_ERROR); - if (d->built) + if (redraw) refresh(); /* Important to fix grey lines expanding screen */ TEXTPAD(d, 3 /*windows*/ + HBUTTONS); @@ -624,7 +624,7 @@ bsddialog_datebox(struct bsddialog_conf *conf, const char *text, int rows, set_buttons(&d, true, OK_LABEL, CANCEL_LABEL); if (build_dateitem(conf->date.format, &yy, &mm, &dd, di) != 0) return (BSDDIALOG_ERROR); - if (datebox_redraw(&d, di) != 0) + if (datebox_draw(&d, false, di) != 0) return (BSDDIALOG_ERROR); sel = -1; @@ -716,12 +716,12 @@ bsddialog_datebox(struct bsddialog_conf *conf, const char *text, int rows, break; if (f1help_dialog(conf) != 0) return (BSDDIALOG_ERROR); - if (datebox_redraw(&d, di) != 0) + if (datebox_draw(&d, true, di) != 0) return (BSDDIALOG_ERROR); break; case KEY_CTRL('l'): case KEY_RESIZE: - if (datebox_redraw(&d, di) != 0) + if (datebox_draw(&d, true, di) != 0) return (BSDDIALOG_ERROR); break; default: diff --git a/contrib/bsddialog/lib/formbox.c b/contrib/bsddialog/lib/formbox.c index ca473356e350..a072461c43e1 100644 --- a/contrib/bsddialog/lib/formbox.c +++ b/contrib/bsddialog/lib/formbox.c @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2021-2024 Alfonso Sabato Siciliano + * Copyright (c) 2021-2025 Alfonso Sabato Siciliano * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -601,11 +601,11 @@ static int form_size_position(struct dialog *d, struct privateform *f) } static int -form_redraw(struct dialog *d, struct privateform *f, bool focusinform) +form_draw(struct dialog *d, bool redraw, struct privateform *f, bool focusinform) { unsigned int i; - if (d->built) { + if (redraw) { hide_dialog(d); refresh(); /* Important for decreasing screen */ } @@ -613,9 +613,9 @@ form_redraw(struct dialog *d, struct privateform *f, bool focusinform) f->w = f->wmin; if (form_size_position(d, f) != 0) return (BSDDIALOG_ERROR); - if (draw_dialog(d) != 0) + if (draw_dialog(d) != 0) /* doupdate() in main loop */ return (BSDDIALOG_ERROR); - if (d->built) + if (redraw) refresh(); /* Important to fix grey lines expanding screen */ TEXTPAD(d, 2 /* box borders */ + f->viewrows + HBUTTONS); @@ -707,7 +707,7 @@ bsddialog_form(struct bsddialog_conf *conf, const char *text, int rows, } form.formheight = formheight; - if (form_redraw(&d, &form, focusinform) != 0) + if (form_draw(&d, false, &form, focusinform) != 0) return (BSDDIALOG_ERROR); changeitem = switchfocus = false; @@ -719,10 +719,16 @@ bsddialog_form(struct bsddialog_conf *conf, const char *text, int rows, switch(input) { case KEY_ENTER: case 10: /* Enter */ - if (focusinform && conf->button.always_active == false) - break; - retval = BUTTONVALUE(d.bs); - loop = false; + if (focusinform && conf->button.always_active == false) { + next = nextitem(form.nitems, form.pritems, form.sel); + if (next > form.sel) + changeitem = true; /* needs next */ + else + switchfocus = true; + } else { + retval = BUTTONVALUE(d.bs); + loop = false; + } break; case 27: /* Esc */ if (conf->key.enable_esc) { @@ -732,7 +738,12 @@ bsddialog_form(struct bsddialog_conf *conf, const char *text, int rows, break; case '\t': /* TAB */ if (focusinform) { - switchfocus = true; + next = nextitem(form.nitems, form.pritems, + form.sel); + if (next > form.sel) + changeitem = true; /* needs next */ + else + switchfocus = true; } else { if (d.bs.curr + 1 < (int)d.bs.nbuttons) { d.bs.curr++; @@ -839,12 +850,12 @@ bsddialog_form(struct bsddialog_conf *conf, const char *text, int rows, retval = BSDDIALOG_ERROR; loop = false; } - if (form_redraw(&d, &form, focusinform) != 0) + if (form_draw(&d, true, &form, focusinform) != 0) return (BSDDIALOG_ERROR); break; case KEY_CTRL('l'): case KEY_RESIZE: - if (form_redraw(&d, &form, focusinform) != 0) + if (form_draw(&d, true, &form, focusinform) != 0) return (BSDDIALOG_ERROR); break; default: @@ -884,11 +895,20 @@ bsddialog_form(struct bsddialog_conf *conf, const char *text, int rows, conf->button.always_active || !focusinform, !focusinform); wnoutrefresh(d.widget); - DRAWITEM_TRICK(&form, form.sel, focusinform); + if (focusinform == false) + DRAWITEM_TRICK(&form, form.sel, false); + else { + next = firstitem(form.nitems, form.pritems); + if (next == form.sel) + DRAWITEM_TRICK(&form, form.sel, true); + else + changeitem = true; + } switchfocus = false; } if (changeitem) { + /* useless after if(switchfocus) */ DRAWITEM_TRICK(&form, form.sel, false); form.sel = next; item = &form.pritems[form.sel]; diff --git a/contrib/bsddialog/lib/lib_util.c b/contrib/bsddialog/lib/lib_util.c index d673a1a74d72..f042a2832eb9 100644 --- a/contrib/bsddialog/lib/lib_util.c +++ b/contrib/bsddialog/lib/lib_util.c @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2021-2023 Alfonso Sabato Siciliano + * Copyright (c) 2021-2025 Alfonso Sabato Siciliano * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -25,6 +25,7 @@ * SUCH DAMAGE. */ +#include <stdarg.h> #include <curses.h> #include <stdlib.h> #include <string.h> diff --git a/contrib/bsddialog/lib/lib_util.h b/contrib/bsddialog/lib/lib_util.h index 526f65b4bfaa..1adc34f3b80a 100644 --- a/contrib/bsddialog/lib/lib_util.h +++ b/contrib/bsddialog/lib/lib_util.h @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2021-2024 Alfonso Sabato Siciliano + * Copyright (c) 2021-2025 Alfonso Sabato Siciliano * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -62,7 +62,7 @@ extern bool hastermcolors; RETURN_ERROR("*" #p " is NULL"); \ } while (0) #define CHECK_ARRAY(nitem, a) do { \ - if (nitem > 0 && a == NULL) \ + if (nitem > 0 && a == NULL) \ RETURN_FMTERROR(#nitem " is %d but *" #a " is NULL", nitem); \ } while (0) /* widget utils */ diff --git a/contrib/bsddialog/lib/libbsddialog.c b/contrib/bsddialog/lib/libbsddialog.c index 555d060ebcbd..cdb5e1e251dc 100644 --- a/contrib/bsddialog/lib/libbsddialog.c +++ b/contrib/bsddialog/lib/libbsddialog.c @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2021-2023 Alfonso Sabato Siciliano + * Copyright (c) 2021-2025 Alfonso Sabato Siciliano * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -114,11 +114,21 @@ int bsddialog_backtitle(struct bsddialog_conf *conf, const char *backtitle) mvhline_set(1, 1, WACS_HLINE, SCREENCOLS - 2); } - refresh(); + wnoutrefresh(stdscr); return (BSDDIALOG_OK); } +int bsddialog_backtitle_rf(struct bsddialog_conf *conf, const char *backtitle) +{ + int rv; + + rv = bsddialog_backtitle(conf, backtitle); + doupdate(); + + return (rv); +} + bool bsddialog_inmode(void) { return (in_bsddialog_mode); diff --git a/contrib/bsddialog/lib/menubox.c b/contrib/bsddialog/lib/menubox.c index 896306b2881d..e6e2e7e3e63e 100644 --- a/contrib/bsddialog/lib/menubox.c +++ b/contrib/bsddialog/lib/menubox.c @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2021-2024 Alfonso Sabato Siciliano + * Copyright (c) 2021-2025 Alfonso Sabato Siciliano * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -391,7 +391,7 @@ drawitem(struct bsddialog_conf *conf, struct privatemenu *m, int y, bool focus) attron(t.menu.bottomdesccolor); addstr(pritem->bottomdesc); attroff(t.menu.bottomdesccolor); - refresh(); + wnoutrefresh(stdscr); } } } @@ -454,18 +454,18 @@ static int menu_size_position(struct dialog *d, struct privatemenu *m) return (0); } -static int mixedlist_redraw(struct dialog *d, struct privatemenu *m) +static int mixedlist_draw(struct dialog *d, bool redraw, struct privatemenu *m) { - if (d->built) { + if (redraw) { hide_dialog(d); refresh(); /* Important for decreasing screen */ } m->menurows = m->apimenurows; if (menu_size_position(d, m) != 0) return (BSDDIALOG_ERROR); - if (draw_dialog(d) != 0) + if (draw_dialog(d) != 0) /* doupdate() in main loop */ return (BSDDIALOG_ERROR); - if (d->built) + if (redraw) refresh(); /* Important to fix grey lines expanding screen */ TEXTPAD(d, 2/*bmenu*/ + m->menurows + HBUTTONS); @@ -532,7 +532,7 @@ do_mixedlist(struct bsddialog_conf *conf, const char *text, int rows, int cols, drawitem(d.conf, &m, m.sel, true); m.ypad = 0; m.apimenurows = menurows; - if (mixedlist_redraw(&d, &m) != 0) + if (mixedlist_draw(&d, false, &m) != 0) return (BSDDIALOG_ERROR); changeitem = false; @@ -575,12 +575,12 @@ do_mixedlist(struct bsddialog_conf *conf, const char *text, int rows, int cols, break; if (f1help_dialog(conf) != 0) return (BSDDIALOG_ERROR); - if (mixedlist_redraw(&d, &m) != 0) + if (mixedlist_draw(&d, true, &m) != 0) return (BSDDIALOG_ERROR); break; case KEY_CTRL('l'): case KEY_RESIZE: - if (mixedlist_redraw(&d, &m) != 0) + if (mixedlist_draw(&d, true, &m) != 0) return (BSDDIALOG_ERROR); break; } diff --git a/contrib/bsddialog/lib/messagebox.c b/contrib/bsddialog/lib/messagebox.c index 5132b1b089b8..c3d4a20f5404 100644 --- a/contrib/bsddialog/lib/messagebox.c +++ b/contrib/bsddialog/lib/messagebox.c @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2021-2024 Alfonso Sabato Siciliano + * Copyright (c) 2021-2025 Alfonso Sabato Siciliano * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -69,19 +69,19 @@ static int message_size_position(struct dialog *d, int *htext) return (0); } -static int message_draw(struct dialog *d, struct scroll *s) +static int message_draw(struct dialog *d, bool redraw, struct scroll *s) { int unused; - if (d->built) { + if (redraw) { /* redraw: RESIZE or F1 */ hide_dialog(d); refresh(); /* Important for decreasing screen */ } if (message_size_position(d, &s->htext) != 0) return (BSDDIALOG_ERROR); - if (draw_dialog(d) != 0) + if (draw_dialog(d) != 0) /* doupdate() in main loop */ return (BSDDIALOG_ERROR); - if (d->built) + if (redraw) refresh(); /* Important to fix grey lines expanding screen */ s->printrows = d->h - BORDER - HBUTTONS - BORDER; @@ -106,7 +106,7 @@ do_message(struct bsddialog_conf *conf, const char *text, int rows, int cols, return (BSDDIALOG_ERROR); set_buttons(&d, true, oklabel, cancellabel); s.htext = -1; - if (message_draw(&d, &s) != 0) + if (message_draw(&d, false, &s) != 0) return (BSDDIALOG_ERROR); loop = true; @@ -170,12 +170,12 @@ do_message(struct bsddialog_conf *conf, const char *text, int rows, int cols, break; if (f1help_dialog(d.conf) != 0) return (BSDDIALOG_ERROR); - if (message_draw(&d, &s) != 0) + if (message_draw(&d, true, &s) != 0) return (BSDDIALOG_ERROR); break; case KEY_CTRL('l'): case KEY_RESIZE: - if (message_draw(&d, &s) != 0) + if (message_draw(&d, true, &s) != 0) return (BSDDIALOG_ERROR); break; default: diff --git a/contrib/bsddialog/lib/textbox.c b/contrib/bsddialog/lib/textbox.c index ca3eb69fff52..1f730e0d925b 100644 --- a/contrib/bsddialog/lib/textbox.c +++ b/contrib/bsddialog/lib/textbox.c @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2021-2024 Alfonso Sabato Siciliano + * Copyright (c) 2021-2025 Alfonso Sabato Siciliano * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -101,17 +101,17 @@ static int textbox_size_position(struct dialog *d, struct scrolltext *st) return (0); } -static int textbox_draw(struct dialog *d, struct scrolltext *st) +static int textbox_draw(struct dialog *d, bool redraw, struct scrolltext *st) { - if (d->built) { + if (redraw) { hide_dialog(d); refresh(); /* Important for decreasing screen */ } if (textbox_size_position(d, st) != 0) return (BSDDIALOG_ERROR); - if (draw_dialog(d) != 0) + if (draw_dialog(d) != 0) /* wrefresh() and prefresh() in main loop */ return (BSDDIALOG_ERROR); - if (d->built) + if (redraw) refresh(); /* Important to fix grey lines expanding screen */ st->ys = d->y + 1; @@ -175,7 +175,7 @@ bsddialog_textbox(struct bsddialog_conf *conf, const char *file, int rows, fclose(fp); set_tabsize(defaulttablen); /* reset because it is curses global */ - if (textbox_draw(&d, &st) != 0) + if (textbox_draw(&d, false, &st) != 0) return (BSDDIALOG_ERROR); loop = true; @@ -254,12 +254,12 @@ bsddialog_textbox(struct bsddialog_conf *conf, const char *file, int rows, break; if (f1help_dialog(conf) != 0) return (BSDDIALOG_ERROR); - if (textbox_draw(&d, &st) != 0) + if (textbox_draw(&d, true, &st) != 0) return (BSDDIALOG_ERROR); break; case KEY_CTRL('l'): case KEY_RESIZE: - if (textbox_draw(&d, &st) != 0) + if (textbox_draw(&d, true, &st) != 0) return (BSDDIALOG_ERROR); break; } diff --git a/contrib/bsddialog/lib/theme.c b/contrib/bsddialog/lib/theme.c index 04f85b2455fa..6c17d908324b 100644 --- a/contrib/bsddialog/lib/theme.c +++ b/contrib/bsddialog/lib/theme.c @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2021-2023 Alfonso Sabato Siciliano + * Copyright (c) 2021-2025 Alfonso Sabato Siciliano * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -217,7 +217,7 @@ int bsddialog_set_theme(struct bsddialog_theme *theme) { CHECK_PTR(theme); set_theme(&t, theme); - refresh(); + wnoutrefresh(stdscr); return (BSDDIALOG_OK); } @@ -239,7 +239,7 @@ int bsddialog_set_default_theme(enum bsddialog_default_theme newtheme) "to use enum bsddialog_default_theme", newtheme); } - refresh(); + wnoutrefresh(stdscr); return (BSDDIALOG_OK); } diff --git a/contrib/bsddialog/lib/timebox.c b/contrib/bsddialog/lib/timebox.c index 1421cd7d2b81..603d5fa5d7a3 100644 --- a/contrib/bsddialog/lib/timebox.c +++ b/contrib/bsddialog/lib/timebox.c @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2021-2024 Alfonso Sabato Siciliano + * Copyright (c) 2021-2025 Alfonso Sabato Siciliano * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -62,19 +62,19 @@ drawsquare(struct bsddialog_conf *conf, WINDOW *win, unsigned int value, wnoutrefresh(win); } -static int timebox_redraw(struct dialog *d, struct clock *c) +static int timebox_draw(struct dialog *d, bool redraw, struct clock *c) { int y, x; - if (d->built) { + if (redraw) { hide_dialog(d); refresh(); /* Important for decreasing screen */ } if (dialog_size_position(d, HBOX, MINWTIME, NULL) != 0) return (BSDDIALOG_ERROR); - if (draw_dialog(d) != 0) + if (draw_dialog(d) != 0) /* doupdate() in mail loop */ return (BSDDIALOG_ERROR); - if (d->built) + if (redraw) refresh(); /* Important to fix grey lines expanding screen */ TEXTPAD(d, HBOX + HBUTTONS); @@ -117,7 +117,7 @@ bsddialog_timebox(struct bsddialog_conf *conf, const char* text, int rows, wbkgd(c[i].win, t.dialog.color); c[i].value = MIN(c[i].value, c[i].max); } - if (timebox_redraw(&d, c) != 0) + if (timebox_draw(&d, false, c) != 0) return (BSDDIALOG_ERROR); sel = -1; @@ -210,12 +210,12 @@ bsddialog_timebox(struct bsddialog_conf *conf, const char* text, int rows, break; if (f1help_dialog(conf) != 0) return (BSDDIALOG_ERROR); - if (timebox_redraw(&d, c) != 0) + if (timebox_draw(&d, true, c) != 0) return (BSDDIALOG_ERROR); break; case KEY_CTRL('l'): case KEY_RESIZE: - if (timebox_redraw(&d, c) != 0) + if (timebox_draw(&d, true, c) != 0) return (BSDDIALOG_ERROR); break; default: diff --git a/contrib/bsddialog/utility/GNUmakefile b/contrib/bsddialog/utility/GNUmakefile index 518ec0d912d6..600efc7aacf6 100644 --- a/contrib/bsddialog/utility/GNUmakefile +++ b/contrib/bsddialog/utility/GNUmakefile @@ -6,6 +6,7 @@ OUTPUT = bsddialog SOURCES = bsddialog.c util_builders.c util_cli.c util_theme.c OBJECTS = $(SOURCES:.c=.o) +PREFIX = /usr/local ifneq ($(ENABLEDEBUG),) CFLAGS += -g @@ -20,7 +21,13 @@ endif RM = rm -f -all : $(OUTPUT) +all: $(OUTPUT) + +install: all + ${INSTALL} -m 0755 ${OUTPUT} ${DESTDIR}${PREFIX}/bin/${OUTPUT} + +uninstall: + ${RM} ${DESTDIR}${PREFIX}/bin/${OUTPUT} $(OUTPUT): $(OBJECTS) $(CC) $^ -o $@ $(LDFLAGS) @@ -31,3 +38,5 @@ $(OUTPUT): $(OBJECTS) clean: $(RM) $(OUTPUT) *.o *~ + +.PHONY: all install uninstall clean diff --git a/contrib/bsddialog/utility/Makefile b/contrib/bsddialog/utility/Makefile index ab51b46a25be..e6cd541fded4 100644 --- a/contrib/bsddialog/utility/Makefile +++ b/contrib/bsddialog/utility/Makefile @@ -6,6 +6,7 @@ OUTPUT = bsddialog SOURCES = bsddialog.c util_builders.c util_cli.c util_theme.c OBJECTS = ${SOURCES:.c=.o} +PREFIX = /usr/local .if defined(DEBUG) CFLAGS += -g @@ -21,7 +22,13 @@ LDFLAGS += -ltinfow -Wl,-rpath=${LIBPATH} -L${LIBPATH} -lbsddialog INSTALL = install RM = rm -f -all : ${OUTPUT} +all: ${OUTPUT} + +install: all + ${INSTALL} -m 0755 ${OUTPUT} ${DESTDIR}${PREFIX}/bin/${OUTPUT} + +uninstall: + ${RM} ${DESTDIR}${PREFIX}/bin/${OUTPUT} ${OUTPUT}: ${OBJECTS} ${CC} ${LDFLAGS} ${OBJECTS} -o ${.PREFIX} @@ -31,3 +38,5 @@ ${OUTPUT}: ${OBJECTS} clean: ${RM} ${OUTPUT} *.o *~ *.core *.gz + +.PHONY: all install uninstall clean diff --git a/contrib/bsddialog/utility/bsddialog.1 b/contrib/bsddialog/utility/bsddialog.1 index 4586ba16020c..0ec2a96952bd 100644 --- a/contrib/bsddialog/utility/bsddialog.1 +++ b/contrib/bsddialog/utility/bsddialog.1 @@ -1,5 +1,5 @@ .\" -.\" Copyright (c) 2021-2024 Alfonso Sabato Siciliano +.\" Copyright (c) 2021-2025 Alfonso Sabato Siciliano .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd May 25, 2024 +.Dd June 22, 2025 .Dt BSDDIALOG 1 .Os .Sh NAME @@ -80,7 +80,14 @@ The following options can change the default behavior of the utility and are common to some dialog. .Bl -tag -width Ds .It Fl Fl alternate-screen -If available set alternate screen mode, see +Set alternate screen mode if the terminal and +.Xr curses 3 +provide it. +If enabled bsddialog draws to the alternate screen and restores the main screen +after exit. +See +.Dq smcup +in .Xr terminfo 5 . .It Fl Fl ascii-lines Ascii characters to draw lines. @@ -291,7 +298,11 @@ Set an exit code value for the .Dq Ok button. .It Fl Fl normal-screen -If available set normal screen mode, see +Set normal screen mode. +bsddialog does not restore the previous screen after exit. +See +.Dq rmcup +in .Xr terminfo 5 . .It Fl Fl output-fd Ar fd Print input from user interface to the specified file descriptor. @@ -737,7 +748,7 @@ Right1 generic button. .It 10 Right2 generic button. .It 11 -Right2 generic button. +Right3 generic button. .El .Sh EXAMPLES Backtitle, title and message: diff --git a/contrib/bsddialog/utility/bsddialog.c b/contrib/bsddialog/utility/bsddialog.c index 3ba21eadf7a3..bce1d0ab8452 100644 --- a/contrib/bsddialog/utility/bsddialog.c +++ b/contrib/bsddialog/utility/bsddialog.c @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2021-2024 Alfonso Sabato Siciliano + * Copyright (c) 2021-2025 Alfonso Sabato Siciliano * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/contrib/bsddialog/utility/util.h b/contrib/bsddialog/utility/util.h index 2750c2ee6951..d1f7793c9755 100644 --- a/contrib/bsddialog/utility/util.h +++ b/contrib/bsddialog/utility/util.h @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2021-2023 Alfonso Sabato Siciliano + * Copyright (c) 2021-2025 Alfonso Sabato Siciliano * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/contrib/bsddialog/utility/util_builders.c b/contrib/bsddialog/utility/util_builders.c index 2e69994a0ec0..0a968d4319f9 100644 --- a/contrib/bsddialog/utility/util_builders.c +++ b/contrib/bsddialog/utility/util_builders.c @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2021-2024 Alfonso Sabato Siciliano + * Copyright (c) 2021-2025 Alfonso Sabato Siciliano * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -82,7 +82,7 @@ int gauge_builder(BUILDER_ARGS) perc = 0; if (argc == 1) { - perc = (u_int)strtoul(argv[0], NULL, 10); + perc = (unsigned int)strtoul(argv[0], NULL, 10); perc = perc > 100 ? 100 : perc; } else if (argc > 1) { error_args(opt->name, argc - 1, argv + 1); @@ -106,7 +106,7 @@ int mixedgauge_builder(BUILDER_ARGS) exit_error(true, "bad %s pair number [<minilabel> <miniperc>]", opt->name); - mainperc = (u_int)strtoul(argv[0], NULL, 10); + mainperc = (unsigned int)strtoul(argv[0], NULL, 10); mainperc = mainperc > 100 ? 100 : mainperc; argc--; argv++; @@ -138,7 +138,7 @@ int pause_builder(BUILDER_ARGS) if (argc > 1) error_args(opt->name, argc - 1, argv + 1); - secs = (u_int)strtoul(argv[0], NULL, 10); + secs = (unsigned int)strtoul(argv[0], NULL, 10); output = bsddialog_pause(conf, text, rows, cols, &secs); return (output); @@ -189,9 +189,9 @@ static int date(BUILDER_ARGS) error_args(opt->name, argc - 3, argv + 3); } else if (argc == 3) { /* lib checks/sets max and min */ - dd = (u_int)strtoul(argv[0], NULL, 10); - mm = (u_int)strtoul(argv[1], NULL, 10); - yy = (u_int)strtoul(argv[2], NULL, 10); + dd = (unsigned int)strtoul(argv[0], NULL, 10); + mm = (unsigned int)strtoul(argv[1], NULL, 10); + yy = (unsigned int)strtoul(argv[2], NULL, 10); } if (strcmp(opt->name, "--datebox") == 0) @@ -259,9 +259,9 @@ int timebox_builder(BUILDER_ARGS) if (argc > 3) { error_args("--timebox", argc - 3, argv + 3); } else if (argc == 3) { - hh = (u_int)strtoul(argv[0], NULL, 10); - mm = (u_int)strtoul(argv[1], NULL, 10); - ss = (u_int)strtoul(argv[2], NULL, 10); + hh = (unsigned int)strtoul(argv[0], NULL, 10); + mm = (unsigned int)strtoul(argv[1], NULL, 10); + ss = (unsigned int)strtoul(argv[2], NULL, 10); } output = bsddialog_timebox(conf, text, rows, cols, &hh, &mm, &ss); @@ -315,7 +315,7 @@ get_menu_items(int argc, char **argv, bool setprefix, bool setdepth, for (i = 0; i < *nitems; i++) { (*items)[i].prefix = setprefix ? argv[j++] : ""; (*items)[i].depth = setdepth ? - (u_int)strtoul(argv[j++], NULL, 0) : 0; + (unsigned int)strtoul(argv[j++], NULL, 0) : 0; (*items)[i].name = setname ? argv[j++] : ""; (*items)[i].desc = setdesc ? argv[j++] : ""; if (setstatus) { @@ -436,7 +436,7 @@ int checklist_builder(BUILDER_ARGS) if (argc < 1) exit_error(true, "--checklist missing <menurows>"); - menurows = (u_int)strtoul(argv[0], NULL, 10); + menurows = (unsigned int)strtoul(argv[0], NULL, 10); get_menu_items(argc-1, argv+1, opt->item_prefix, opt->item_depth, true, true, true, opt->item_bottomdesc, &nitems, &items, &focusitem, opt); @@ -461,7 +461,7 @@ int menu_builder(BUILDER_ARGS) if (argc < 1) exit_error(true, "--menu missing <menurows>"); - menurows = (u_int)strtoul(argv[0], NULL, 10); + menurows = (unsigned int)strtoul(argv[0], NULL, 10); get_menu_items(argc-1, argv+1, opt->item_prefix, opt->item_depth, true, true, false, opt->item_bottomdesc, &nitems, &items, &focusitem, @@ -487,7 +487,7 @@ int radiolist_builder(BUILDER_ARGS) if (argc < 1) exit_error(true, "--radiolist missing <menurows>"); - menurows = (u_int)strtoul(argv[0], NULL, 10); + menurows = (unsigned int)strtoul(argv[0], NULL, 10); get_menu_items(argc-1, argv+1, opt->item_prefix, opt->item_depth, true, true, true, opt->item_bottomdesc, &nitems, &items, &focusitem, opt); @@ -512,7 +512,7 @@ int treeview_builder(BUILDER_ARGS) if (argc < 1) exit_error(true, "--treeview missing <menurows>"); - menurows = (u_int)strtoul(argv[0], NULL, 10); + menurows = (unsigned int)strtoul(argv[0], NULL, 10); get_menu_items(argc-1, argv+1, opt->item_prefix, true, true, true, true, opt->item_bottomdesc, &nitems, &items, &focusitem, opt); @@ -595,7 +595,7 @@ int form_builder(BUILDER_ARGS) if (argc < 1) exit_error(true, "--form missing <formheight>"); - formheight = (u_int)strtoul(argv[0], NULL, 10); + formheight = (unsigned int)strtoul(argv[0], NULL, 10); argc--; argv++; @@ -609,11 +609,11 @@ int form_builder(BUILDER_ARGS) j = 0; for (i = 0; i < nitems; i++) { items[i].label = argv[j++]; - items[i].ylabel = (u_int)strtoul(argv[j++], NULL, 10); - items[i].xlabel = (u_int)strtoul(argv[j++], NULL, 10); + items[i].ylabel = (unsigned int)strtoul(argv[j++], NULL, 10); + items[i].xlabel = (unsigned int)strtoul(argv[j++], NULL, 10); items[i].init = argv[j++]; - items[i].yfield = (u_int)strtoul(argv[j++], NULL, 10); - items[i].xfield = (u_int)strtoul(argv[j++], NULL, 10); + items[i].yfield = (unsigned int)strtoul(argv[j++], NULL, 10); + items[i].xfield = (unsigned int)strtoul(argv[j++], NULL, 10); fieldlen = (int)strtol(argv[j++], NULL, 10); if (fieldlen == 0) @@ -621,7 +621,7 @@ int form_builder(BUILDER_ARGS) else items[i].fieldlen = abs(fieldlen); - items[i].maxvaluelen = (u_int)strtoul(argv[j++], NULL, 10); + items[i].maxvaluelen = (unsigned int)strtoul(argv[j++], NULL, 10); if (items[i].maxvaluelen == 0) items[i].maxvaluelen = items[i].fieldlen; @@ -678,7 +678,7 @@ int mixedform_builder(BUILDER_ARGS) if (argc < 1) exit_error(true, "--mixedform missing <formheight>"); - formheight = (u_int)strtoul(argv[0], NULL, 10); + formheight = (unsigned int)strtoul(argv[0], NULL, 10); argc--; argv++; @@ -692,21 +692,21 @@ int mixedform_builder(BUILDER_ARGS) j = 0; for (i = 0; i < nitems; i++) { items[i].label = argv[j++]; - items[i].ylabel = (u_int)strtoul(argv[j++], NULL, 10); - items[i].xlabel = (u_int)strtoul(argv[j++], NULL, 10); + items[i].ylabel = (unsigned int)strtoul(argv[j++], NULL, 10); + items[i].xlabel = (unsigned int)strtoul(argv[j++], NULL, 10); items[i].init = argv[j++]; - items[i].yfield = (u_int)strtoul(argv[j++], NULL, 10); - items[i].xfield = (u_int)strtoul(argv[j++], NULL, 10); + items[i].yfield = (unsigned int)strtoul(argv[j++], NULL, 10); + items[i].xfield = (unsigned int)strtoul(argv[j++], NULL, 10); fieldlen = (int)strtol(argv[j++], NULL, 10); if (fieldlen == 0) items[i].fieldlen = strcols(items[i].init); else items[i].fieldlen = abs(fieldlen); - items[i].maxvaluelen = (u_int)strtoul(argv[j++], NULL, 10); + items[i].maxvaluelen = (unsigned int)strtoul(argv[j++], NULL, 10); if (items[i].maxvaluelen == 0) items[i].maxvaluelen = items[i].fieldlen; - items[i].flags = (u_int)strtoul(argv[j++], NULL, 10); + items[i].flags = (unsigned int)strtoul(argv[j++], NULL, 10); if (fieldlen <= 0) items[i].flags |= BSDDIALOG_FIELDREADONLY; @@ -765,7 +765,7 @@ int passwordform_builder(BUILDER_ARGS) if (argc < 1) exit_error(true, "--passwordform missing <formheight>"); - formheight = (u_int)strtoul(argv[0], NULL, 10); + formheight = (unsigned int)strtoul(argv[0], NULL, 10); argc--; argv++; @@ -780,11 +780,11 @@ int passwordform_builder(BUILDER_ARGS) j = 0; for (i = 0; i < nitems; i++) { items[i].label = argv[j++]; - items[i].ylabel = (u_int)strtoul(argv[j++], NULL, 10); - items[i].xlabel = (u_int)strtoul(argv[j++], NULL, 10); + items[i].ylabel = (unsigned int)strtoul(argv[j++], NULL, 10); + items[i].xlabel = (unsigned int)strtoul(argv[j++], NULL, 10); items[i].init = argv[j++]; - items[i].yfield = (u_int)strtoul(argv[j++], NULL, 10); - items[i].xfield = (u_int)strtoul(argv[j++], NULL, 10); + items[i].yfield = (unsigned int)strtoul(argv[j++], NULL, 10); + items[i].xfield = (unsigned int)strtoul(argv[j++], NULL, 10); fieldlen = (int)strtol(argv[j++], NULL, 10); items[i].fieldlen = abs(fieldlen); diff --git a/contrib/bsddialog/utility/util_cli.c b/contrib/bsddialog/utility/util_cli.c index a70de36a699e..01b6fc31f065 100644 --- a/contrib/bsddialog/utility/util_cli.c +++ b/contrib/bsddialog/utility/util_cli.c @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2021-2023 Alfonso Sabato Siciliano + * Copyright (c) 2021-2025 Alfonso Sabato Siciliano * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/contrib/bsddialog/utility/util_theme.c b/contrib/bsddialog/utility/util_theme.c index a95cadacc1b0..cca79e83b97d 100644 --- a/contrib/bsddialog/utility/util_theme.c +++ b/contrib/bsddialog/utility/util_theme.c @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2022-2024 Alfonso Sabato Siciliano + * Copyright (c) 2022-2025 Alfonso Sabato Siciliano * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -279,7 +279,7 @@ void loadtheme(const char *file, bool compatibility) break; case BOOL: boolvalue = (strstr(value, "true") != NULL) ? - true :false; + true : false; *((bool*)p[i].value) = boolvalue; break; case COLOR: diff --git a/contrib/sendmail/src/newaliases.1 b/contrib/sendmail/src/newaliases.1 index 59dc0de20cf7..cdb6eef67416 100644 --- a/contrib/sendmail/src/newaliases.1 +++ b/contrib/sendmail/src/newaliases.1 @@ -14,7 +14,7 @@ .TH NEWALIASES 1 "$Date: 2013-11-22 20:51:56 $" .SH NAME newaliases -\- rebuild the data base for the mail aliases file +\- rebuild the data base for the sendmail aliases file .SH SYNOPSIS .B newaliases .SH DESCRIPTION diff --git a/etc/mtree/BSD.include.dist b/etc/mtree/BSD.include.dist index 28c4d91ac1c0..454657183c58 100644 --- a/etc/mtree/BSD.include.dist +++ b/etc/mtree/BSD.include.dist @@ -276,9 +276,7 @@ .. kadm5 .. - kdb5 - .. - krb5 + krb5 tags=package=kerberos-dev .. lib80211 .. diff --git a/etc/mtree/BSD.root.dist b/etc/mtree/BSD.root.dist index 6ba632894ca7..95a3361b3c61 100644 --- a/etc/mtree/BSD.root.dist +++ b/etc/mtree/BSD.root.dist @@ -4,8 +4,9 @@ /set type=dir uname=root gname=wheel mode=0755 . - bin + bin tags=package=runtime .. +/set tags=package=bootloader boot defaults .. @@ -27,7 +28,7 @@ .. kernel .. - loader.conf.d tags=package=bootloader + loader.conf.d .. lua .. @@ -38,88 +39,89 @@ zfs .. .. +/unset tags dev mode=0555 tags=package=runtime .. - etc - X11 + etc tags=package=runtime + X11 tags=package=runtime .. - authpf + authpf tags=package=pf .. - autofs + autofs tags=package=autofs .. - bluetooth + bluetooth tags=package=bluetooth .. - cron.d + cron.d tags=package=cron .. - defaults + defaults tags=package=runtime .. - devd + devd tags=package=devd .. - dma + dma tags=package=dma .. - gss + gss tags=package=runtime .. - jail.conf.d + jail.conf.d tags=package=jail .. kyua tags=package=tests .. - mail + mail tags=package=runtime .. - mtree + mtree tags=package=mtree .. - newsyslog.conf.d + newsyslog.conf.d tags=package=newsyslog .. - ntp mode=0700 + ntp mode=0700 tags=package=ntp .. - pam.d + pam.d tags=package=runtime .. - periodic - daily + periodic tags=package=periodic + daily tags=package=periodic .. - monthly + monthly tags=package=periodic .. - security + security tags=package=periodic .. - weekly + weekly tags=package=periodic .. .. - pkg + pkg tags=package=pkg-bootstrap .. - ppp + ppp tags=package=ppp .. - profile.d + profile.d tags=package=runtime .. - rc.conf.d + rc.conf.d tags=package=rc .. - rc.d + rc.d tags=package=rc .. - security + security tags=package=audit .. - ssh + ssh tags=package=ssh .. - ssl + ssl tags=package=caroot certs tags=package=caroot .. untrusted tags=package=caroot .. .. - sysctl.kld.d + sysctl.kld.d tags=package=runtime .. - syslog.d + syslog.d tags=package=syslogd .. - zfs tags=package=zfs - compatibility.d + zfs tags=package=zfs + compatibility.d tags=package=zfs .. .. .. - lib - geom + lib tags=package=clibs + geom tags=package=geom .. - nvmecontrol + nvmecontrol tags=package=nvme-tools .. .. - libexec - resolvconf + libexec tags=package=clibs + resolvconf tags=package=resolvconf .. .. media tags=package=runtime @@ -132,14 +134,14 @@ .. rescue tags=package=rescue .. - root mode=0750 + root mode=0750 tags=package=runtime .. - sbin + sbin tags=package=runtime .. tmp mode=01777 tags=package=runtime .. - usr + usr tags=package=runtime .. - var + var tags=package=runtime .. .. diff --git a/etc/mtree/BSD.usr.dist b/etc/mtree/BSD.usr.dist index d7d839b94b96..6a8c155e5e73 100644 --- a/etc/mtree/BSD.usr.dist +++ b/etc/mtree/BSD.usr.dist @@ -85,15 +85,15 @@ .. i18n .. - krb5 - kdb + krb5 tags=package=kerberos-kdc + kdb tags=package=kerberos-kdc .. - plugins - kdb + plugins tags=package=kerberos-kdc + kdb tags=package=kerberos-kdc .. - preauth + preauth tags=package=kerberos-kdc .. - tls + tls tags=package=kerberos-kdc .. .. .. @@ -269,7 +269,7 @@ .. dtrace .. - et + et tags=package=kerberos-dev .. examples BSD_daemon diff --git a/etc/mtree/BSD.var.dist b/etc/mtree/BSD.var.dist index d8593e61c49e..b3372196f5f9 100644 --- a/etc/mtree/BSD.var.dist +++ b/etc/mtree/BSD.var.dist @@ -45,7 +45,7 @@ .. ipf mode=0700 tags=package=ipf .. - krb5kdc mode=0700 + krb5kdc mode=0700 tags=package=kerberos-kdc .. mtree .. diff --git a/lib/libbz2/Makefile b/lib/libbz2/Makefile index d773f202dd67..2aedbaed4328 100644 --- a/lib/libbz2/Makefile +++ b/lib/libbz2/Makefile @@ -13,4 +13,17 @@ CFLAGS+= -I${BZ2DIR} WARNS?= 3 +BZIP2_VERSION!= sed -n '/bzip2\/libbzip2 version /{s/.*version //;s/ of.*//p;q;}' ${BZ2DIR}/bzlib.h + +bzip2.pc: bzip2.pc.in + sed -e 's,@prefix@,/usr,g ; \ + s,@exec_prefix@,$${prefix},g ; \ + s,@libdir@,${LIBDIR},g ; \ + s,@sharedlibdir@,${SHLIBDIR},g ; \ + s,@includedir@,${INCLUDEDIR},g ; \ + s,@VERSION@,${BZIP2_VERSION},g ;' \ + ${.ALLSRC} > ${.TARGET} + +PCFILES= bzip2.pc + .include <bsd.lib.mk> diff --git a/lib/libbz2/bzip2.pc.in b/lib/libbz2/bzip2.pc.in new file mode 100644 index 000000000000..d91c9931a58a --- /dev/null +++ b/lib/libbz2/bzip2.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +sharedlibdir=@sharedlibdir@ +includedir=@includedir@ + +Name: bzip2 +Description: bzip2 compression library +Version: @VERSION@ +Libs: -L${libdir} -lbz2 +Cflags: -I${includedir} diff --git a/lib/libc/gen/getgrouplist.3 b/lib/libc/gen/getgrouplist.3 index e3939fc2481a..9e05ff7e7a29 100644 --- a/lib/libc/gen/getgrouplist.3 +++ b/lib/libc/gen/getgrouplist.3 @@ -33,7 +33,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd August 29, 2025 +.Dd October 9, 2025 .Dt GETGROUPLIST 3 .Os .Sh NAME @@ -48,30 +48,37 @@ .Sh DESCRIPTION The .Fn getgrouplist -function reads through the group database to retrieve the supplementary groups -for the user specified in -.Fa name , +function retrieves from the group database the supplementary groups for the user +specified in +.Fa name and returns the effective group list, whose first group is the value of .Fa basegid -and the others are the retrieved supplementary groups. +and the others are the supplementary groups. .Fa basegid -typically is the user's group number from the password database. +typically is the user's initial numerical group ID from the password database. .Pp The effective group list is returned in the array pointed to by .Fa groups . -The caller specifies the size of the +The caller specifies the length of the .Fa groups array in the integer pointed to by -.Fa ngroups ; -the actual number of groups found is returned in +.Fa ngroups . +The number of groups of the effective group list, which may be greater than the +.Fa groups +array's length, is returned through .Fa ngroups . .Sh RETURN VALUES The .Fn getgrouplist -function -returns 0 on success and \-1 if the size of the group list is too small to -hold all the user's groups. -Here, the group array will be filled with as many groups as will fit. +function returns 0 on success and \-1 if the length of the group list is too +small to hold all the user's groups. +In the latter case, the +.Fa groups +array is filled with as many groups as possible from the start of the effective +group list, and the length pointed to by +.Fa ngroups +is set to the full length of the latter, thus to a value strictly greater than +before the call. .Sh FILES .Bl -tag -width /etc/group -compact .It Pa /etc/group diff --git a/lib/libc/gen/initgroups.3 b/lib/libc/gen/initgroups.3 index 4f538fb180ec..74133e7d7048 100644 --- a/lib/libc/gen/initgroups.3 +++ b/lib/libc/gen/initgroups.3 @@ -33,7 +33,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd September 17, 2025 +.Dd October 9, 2025 .Dt INITGROUPS 3 .Os .Sh NAME @@ -67,9 +67,9 @@ The .Fn initgroups function may fail and set .Va errno -to any of the errors specified for the library function -.Xr setgroups 2 . -It may also return: +to any of the errors specified for the +.Xr setgroups 2 +system call, or to: .Bl -tag -width Er .It Bq Er ENOMEM The diff --git a/lib/libcasper/services/cap_fileargs/cap_fileargs.h b/lib/libcasper/services/cap_fileargs/cap_fileargs.h index 8207671d9753..d3a0150044d7 100644 --- a/lib/libcasper/services/cap_fileargs/cap_fileargs.h +++ b/lib/libcasper/services/cap_fileargs/cap_fileargs.h @@ -75,7 +75,7 @@ fileargs_init(int argc __unused, char *argv[] __unused, int flags, mode_t mode, cap_rights_t *rightsp __unused, int operations __unused) { fileargs_t *fa; - fa = malloc(sizeof(*fa)); + fa = (fileargs_t *)malloc(sizeof(*fa)); if (fa != NULL) { fa->fa_flags = flags; fa->fa_mode = mode; diff --git a/lib/libsys/getgroups.2 b/lib/libsys/getgroups.2 index 4881a65d532e..4e94b32d4e7b 100644 --- a/lib/libsys/getgroups.2 +++ b/lib/libsys/getgroups.2 @@ -33,7 +33,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd September 17, 2025 +.Dd October 10, 2025 .Dt GETGROUPS 2 .Os .Sh NAME @@ -107,10 +107,8 @@ array. The .Fn getgroups system call conforms to -.St -p1003.1-2008 -with the additional properties that supplementary groups are reported in -strictly ascending order and the returned size coincides with the cardinal of -the set. +.St -p1003.1-2008 , +not reporting the effective group ID. .Sh HISTORY The .Fn getgroups @@ -121,8 +119,8 @@ Since .Fx 14.3 , the .Fn getgroups -system call has treated the supplementary groups as a set, reporting them in -strictly ascending order and returning the cardinal of the set. +system call has been reporting the supplementary groups in strictly ascending +order. .Pp Before .Fx 15.0 , @@ -138,15 +136,14 @@ system call gets the supplementary groups set in the array. In particular, as evoked in .Sx HISTORY , -it does not anymore retrieve the effective GID in the first slot of +it does not anymore retrieve the effective group ID in the first slot of .Fa gidset . -Programs should not make any assumption about which group is placed in the first -slot of -.Fa gidset -other than it being the supplementary group with smallest GID. +Programs that process this slot in a specific way must be modified to obtain the +effective group ID through other means, such as a call to +.Xr getegid 2 . .Pp -The effective GID is present in the supplementary groups set if and only if it -was explicitly set as a supplementary group. +The effective group ID is present in the supplementary groups set if and only if +it was explicitly set as a supplementary group. The function .Fn initgroups enforces that, while the diff --git a/libexec/rc/rc.d/Makefile b/libexec/rc/rc.d/Makefile index 03f0933533ca..f6d1a34ceb9e 100644 --- a/libexec/rc/rc.d/Makefile +++ b/libexec/rc/rc.d/Makefile @@ -4,6 +4,7 @@ CONFDIR= /etc/rc.d CONFGROUPS= CONFS CONFSPACKAGE= rc +# Files which are always installed and go in the -rc package. CONFS= DAEMON \ FILESYSTEMS \ LOGIN \ @@ -47,8 +48,6 @@ CONFS= DAEMON \ netoptions \ netwait \ noshutdown \ - ${_nscd} \ - ${_opensm} \ os-release \ pwcheck \ quota \ @@ -77,218 +76,258 @@ CONFS= DAEMON \ var_run \ watchdogd -CONFGROUPS+= DEVD -DEVD= devd -DEVDPACKAGE= devd - -CONFGROUPS+= DEVMATCH -DEVMATCH= devmatch -DEVMATCHPACKAGE= devmatch - -CONFGROUPS+= DHCLIENT -DHCLIENT= dhclient -DHCLIENTPACKAGE= dhclient - -CONFGROUPS+= GEOM -GEOM= geli \ - geli2 \ - gptboot -GEOMPACKAGE= geom - -CONFGROUPS+= GGATED -GGATED= ggated -GGATEDPACKAGE= ggate - -CONFGROUPS+= RESOLVCONF -RESOLVCONF= resolv -RESOLVCONFPACKAGE= resolvconf - -CONFGROUPS+= CRON -CRON+= cron -CRONPACKAGE= cron - -CONFGROUPS+= CTL -CTL= ctld -CTLPACKAGE= ctl - -CONFGROUPS+= NFS -NFS= lockd \ - mountd \ - nfscbd \ - nfsclient \ - nfsd \ - nfsuserd \ - statd -NFSPACKAGE= nfs - -CONFGROUPS+= NEWSYSLOG -NEWSYSLOG= newsyslog -NEWSYSLOGPACKAGE= newsyslog - -CONFGROUPS+= POWERD -POWERD= powerd -POWERDPACKAGE= powerd - -CONFGROUPS+= PPPOED -PPPOED= pppoed -PPPOEDPACKAGE= ppp - -CONFGROUPS+= SYSLOGD -SYSLOGD= syslogd -SYSLOGDPACKAGE= syslogd - -CONFGROUPS+= RCMDS -RCMDS= rwho -RCMDSPACKAGE= rcmds +# Groups for files which don't go in -rc, or which depend on src.conf knobs. .if ${MK_ACCT} != "no" || ${MK_UTMPX} != "no" -CONFGROUPS+= ACCT -ACCTPACKAGE= acct +CONFGROUPS+= ACCT +ACCTPACKAGE= acct .if ${MK_ACCT} != "no" -ACCT+= accounting +ACCT= accounting .endif .if ${MK_UTMPX} != "no" ACCT+= utx .endif .endif -.if ${MK_ACPI} != "no" -CONFGROUPS+= ACPI +CONFGROUPS.${MK_ACPI}+= ACPI +ACPIPACKAGE= acpi ACPI= power_profile -ACPIPACKAGE= acpi -.endif -.if ${MK_APM} != "no" -CONFGROUPS+= APM -APM+= apm +CONFGROUPS.${MK_APM}+= APM +APMPACKAGE= apm +APM= apm .if ${MACHINE} == "i386" APM+= apmd .endif -APMPACKAGE= apm -.endif -.if ${MK_AUDIT} != "no" -CONFGROUPS+= AUDIT -AUDIT+= auditd -AUDIT+= auditdistd -AUDITPACKAGE= audit -.endif +CONFGROUPS.${MK_AUDIT}+= AUDIT +AUDITPACKAGE= audit +AUDIT= auditd \ + auditdistd -.if ${MK_AUTOFS} != "no" -CONFGROUPS+= AUTOFS +CONFGROUPS.${MK_AUTOFS}+= AUTOFS +AUTOFSPACKAGE= autofs AUTOFS= automount \ automountd \ autounmountd -AUTOFSPACKAGE= autofs -.endif -.if ${MK_BLACKLIST} != "no" -CONFGROUPS+= BLOCKLIST +CONFGROUPS.${MK_BLACKLIST}+= BLOCKLIST +BLOCKLISTPACKAGE= blocklist BLOCKLIST= blacklistd -BLOCKLISTPACKAGE=blocklist -.endif -.if ${MK_BLUETOOTH} != "no" -CONFGROUPS+= BLUETOOTH -BLUETOOTH+= bluetooth \ +CONFGROUPS.${MK_BLUETOOTH}+= BLUETOOTH +BLUETOOTHPACKAGE= bluetooth +BLUETOOTH= bluetooth \ bthidd \ hcsecd \ rfcomm_pppd_server \ sdpd \ ubthidhci -BLUETOOTHPACKAGE= bluetooth -.endif -.if ${MK_BOOTPARAMD} != "no" -CONFS+= bootparams -.endif +CONFGROUPS.${MK_BOOTPARAMD}+= BOOTPARAMD +BOOTPARAMD= bootparams -.if ${MK_BSNMP} != "no" -CONFGROUPS+= BSNMP -BSNMP+= bsnmpd -BSNMPPACKAGE= bsnmp -.endif +CONFGROUPS.${MK_BSNMP}+= BSNMP +BSNMPPACKAGE= bsnmp +BSNMP= bsnmpd -.if ${MK_CCD} != "no" -CONFGROUPS+= CCD +CONFGROUPS.${MK_CCD}+= CCD +CCDPACKAGE= ccdconfig CCD= ccd -CCDPACKAGE= ccdconfig -.endif -.if ${MK_CUSE} != "no" -CONFGROUPS+= VOSS -VOSS= virtual_oss -VOSSPACKAGE= sound -.endif +CONFGROUPS+= DEVD +DEVDPACKAGE= devd +DEVD= devd + +CONFGROUPS+= DEVMATCH +DEVMATCHPACKAGE= devmatch +DEVMATCH= devmatch + +CONFGROUPS+= DHCLIENT +DHCLIENTPACKAGE= dhclient +DHCLIENT= dhclient + +CONFGROUPS+= CRON +CRONPACKAGE= cron +CRON= cron -.if ${MK_KERBEROS_SUPPORT} != "no" -CONFGROUPS+= GSSD +CONFGROUPS+= CTL +CTLPACKAGE= ctl +CTL= ctld + +CONFGROUPS+= GEOM +GEOMPACKAGE= geom +GEOM= geli \ + geli2 \ + gptboot + +CONFGROUPS+= GGATED +GGATEDPACKAGE= ggate +GGATED= ggated + +CONFGROUPS.${MK_KERBEROS_SUPPORT}+=GSSD +GSSDPACKAGE= gssd GSSD= gssd -GSSDPACKAGE= gssd -.endif -.if ${MK_HAST} != "no" -CONFGROUPS+= HAST +CONFGROUPS.${MK_HAST}+= HAST +HASTPACKAGE= hast HAST= hastd -HASTPACKAGE= hast -.endif -.if ${MK_INETD} != "no" -CONFGROUPS+= INETD +CONFGROUPS.${MK_INETD}+= INETD +INETDPACKAGE= inetd INETD= inetd -INETDPACKAGE= inetd -.endif -.if ${MK_IPFILTER} != "no" -CONFGROUPS+= IPF +CONFGROUPS.${MK_IPFILTER}+= IPF +IPFPACKAGE= ipf IPF= ipfilter \ ipfs \ ipmon \ ipnat \ ippool -IPFPACKAGE= ipf -.endif -.if ${MK_IPFW} != "no" -CONFGROUPS+= IPFW -IPFW= ipfw dnctl +CONFGROUPS.${MK_IPFW}+= IPFW +IPFWPACKAGE= ipfw +IPFW= ipfw \ + dnctl .if ${MK_NETGRAPH} != "no" IPFW+= ipfw_netflow .endif -IPFWPACKAGE= ipfw -# natd is only built when ipfw is built -CONFGROUPS+= NATD -NATD+= natd -NATDPACKAGE= natd -.endif - -.if ${MK_ISCSI} != "no" -CONFGROUPS+= ISCSI +CONFGROUPS.${MK_ISCSI}+= ISCSI +ISCSIPACKAGE= iscsi ISCSI= iscsictl \ iscsid -ISCSIPACKAGE= iscsi -.endif -.if ${MK_JAIL} != "no" -CONFGROUPS+= JAIL -JAIL+= jail -JAILPACKAGE= jail -.endif +# natd is only built when ipfw is built +CONFGROUPS.${MK_IPFW}+= NATD +NATDPACKAGE= natd +NATD= natd + +CONFGROUPS.${MK_JAIL}+= JAIL +JAILPACKAGE= jail +JAIL= jail + +CONFGROUPS.${MK_LPR}+= LP +LPPACKAGE= lp +LP= lpd + +CONFGROUPS+= NEWSYSLOG +NEWSYSLOGPACKAGE= newsyslog +NEWSYSLOG= newsyslog + +CONFGROUPS+= NFS +NFSPACKAGE= nfs +NFS= lockd \ + mountd \ + nfscbd \ + nfsclient \ + nfsd \ + nfsuserd \ + statd + +CONFGROUPS.${MK_NIS}+= NIS +NISPACKAGE= yp +NIS= ypbind \ + ypldap \ + yppasswdd \ + ypserv \ + ypset \ + ypupdated \ + ypxfrd \ + nisdomain -.if ${MK_LEGACY_CONSOLE} != "no" -CONFGROUPS+= CONSOLE -CONSOLE+= moused -CONSOLE+= msconvd -CONSOLE+= syscons -CONSOLEPACKAGE= console-tools -.endif +CONFGROUPS.${MK_NS_CACHING}+= NSCD +NSCD= nscd -.if ${MK_LPR} != "no" -CONFGROUPS+= LP -LP+= lpd -LPPACKAGE= lp -.endif +CONFGROUPS.${MK_NTP}+= NTP +NTPPACKAGE= ntp +NTP= ntpd \ + ntpdate + +CONFGROUPS.${MK_NUAGEINIT}+= NUAGEINIT +NUAGEINITPACKAGE= nuageinit +NUAGEINIT= nuageinit \ + nuageinit_post_net \ + nuageinit_user_data_script + +CONFGROUPS.${MK_OFED_EXTRA}+= OPENSM +OPENSM= opensm + +CONFGROUPS.${MK_PF}+= PF +PFPACKAGE= pf +PF= pf \ + pflog \ + pfsync \ + ftp-proxy + +CONFGROUPS+= POWERD +POWERDPACKAGE= powerd +POWERD= powerd + +CONFGROUPS.${MK_PPP}+= PPP +PPPPACKAGE= ppp +PPP= ppp + +CONFGROUPS+= PPPOED +PPPOEDPACKAGE= ppp +PPPOED= pppoed + +CONFGROUPS+= SYSLOGD +SYSLOGDPACKAGE= syslogd +SYSLOGD= syslogd + +CONFGROUPS+= RCMDS +RCMDSPACKAGE= rcmds +RCMDS= rwho + +CONFGROUPS+= RESOLVCONF +RESOLVCONFPACKAGE= resolvconf +RESOLVCONF= resolv + +CONFGROUPS.${MK_SENDMAIL}+= SENDMAIL +SENDMAILPACKAGE= sendmail +SENDMAIL= sendmail + +CONFGROUPS.${MK_OPENSSH}+= SSH +SSHPACKAGE= ssh +SSH= sshd + +CONFGROUPS.${MK_UNBOUND}+= UNBOUND +UNBOUNDPACKAGE= unbound +UNBOUND= local_unbound + +CONFGROUPS.${MK_VI}+= VI +VIPACKAGE= vi +VI= virecover + +CONFGROUPS.${MK_CUSE}+= VOSS +VOSSPACKAGE= sound +VOSS= virtual_oss + +CONFGROUPS.${MK_WIRELESS}+= HOSTAPD +HOSTAPDPACKAGE= hostapd +HOSTAPD= hostapd + +CONFGROUPS.${MK_WIRELESS}+= WPA +WPAPACKAGE= wpa +WPA= wpa_supplicant + +CONFGROUPS.${MK_ZFS}+= ZFS +ZFSPACKAGE= zfs +ZFS= zfs \ + zfsbe \ + zfsd \ + zfskeys \ + zpool \ + zpoolreguid \ + zpoolupgrade \ + zvol + +CONFGROUPS.${MK_LEGACY_CONSOLE}+=SYSCONS +SYSCONSPACKAGE= console-tools +SYSCONS= moused \ + msconvd \ + syscons .if ${MK_KERBEROS} != "no" .if ${MK_MITKRB5} == "no" @@ -318,58 +357,10 @@ KRB5PACKAGE= kerberos-kdc .endif # ${MK_MITKRB5} .endif # ${MK_KERBEROS} -.if ${MK_NIS} != "no" -CONFGROUPS+= YP -YP= ypbind \ - ypldap \ - yppasswdd \ - ypserv \ - ypset \ - ypupdated \ - ypxfrd \ - nisdomain -YPPACKAGE= yp -.endif - -.if ${MK_NS_CACHING} != "no" -_nscd= nscd -.endif - -.if ${MK_NTP} != "no" -CONFGROUPS+= NTP -NTP+= ntpd \ - ntpdate -NTPPACKAGE= ntp -.endif - -.if ${MK_OFED_EXTRA} != "no" -_opensm= opensm -.endif - .if ${MK_OPENSSL} != "no" && ${MK_OPENSSL_KTLS} != "no" -CONFS+= tlsclntd \ - tlsservd -.endif - -.if ${MK_OPENSSH} != "no" -CONFGROUPS+= SSH -SSH= sshd -SSHPACKAGE= ssh -.endif - -.if ${MK_PF} != "no" -CONFGROUPS+= PF -PF= pf \ - pflog \ - pfsync \ - ftp-proxy -PFPACKAGE= pf -.endif - -.if ${MK_PPP} != "no" -CONFGROUPS+= PPP -PPP= ppp -PPPPACKAGE= ppp +CONFGROUPS+= KTLS +KTLS= tlsclntd \ + tlsservd .endif .if ${MK_INET6} != "no" || ${MK_ROUTED} != "no" @@ -384,57 +375,9 @@ RIP+= routed .endif .endif -.if ${MK_SENDMAIL} != "no" -CONFGROUPS+= SMRCD -SMRCD= sendmail -SMRCDPACKAGE= sendmail -.endif - -.if ${MK_NUAGEINIT} != "no" -CONFGROUPS+= NIUAGEINIT -NIUAGEINIT= nuageinit \ - nuageinit_post_net \ - nuageinit_user_data_script -NIUAGEINITPACKAGE= nuageinit -.endif - -.if ${MK_UNBOUND} != "no" -CONFGROUPS+= UNBOUND -UNBOUND+= local_unbound -UNBOUNDPACKAGE= unbound -.endif - -.if ${MK_VI} != "no" -CONFGROUPS+= VI -VI+= virecover -VIPACKAGE= vi -.endif - -.if ${MK_WIRELESS} != "no" -CONFGROUPS+= HOSTAPD -HOSTAPD= hostapd -HOSTAPDPACKAGE= hostapd - -CONFGROUPS+= WPA -WPA= wpa_supplicant -WPAPACKAGE= wpa -.endif - -.if ${MK_ZFS} != "no" -CONFGROUPS+= ZFS -ZFS+= zfs -ZFS+= zfsbe -ZFS+= zfsd -ZFS+= zfskeys -ZFS+= zpool -ZFS+= zpoolreguid -ZFS+= zpoolupgrade -ZFS+= zvol -ZFSPACKAGE= zfs -.endif - -.for fg in ${CONFGROUPS} +.for fg in ${CONFGROUPS} ${CONFGROUPS.yes} ${fg}MODE?= ${BINMODE} +${fg}PACKAGE?= rc .endfor .include <bsd.prog.mk> diff --git a/libexec/rc/rc.d/virtual_oss b/libexec/rc/rc.d/virtual_oss index 4f5c34ce03f3..b9c830617385 100644 --- a/libexec/rc/rc.d/virtual_oss +++ b/libexec/rc/rc.d/virtual_oss @@ -1,8 +1,8 @@ #!/bin/sh # PROVIDE: virtual_oss -# REQUIRE: kld ldconfig -# BEFORE: LOGIN sndiod +# REQUIRE: NETWORKING kld ldconfig +# BEFORE: LOGIN # KEYWORD: shutdown . /etc/rc.subr diff --git a/libexec/rc/rc.d/zpoolreguid b/libexec/rc/rc.d/zpoolreguid index f94630d9283f..c19f52d3d702 100755 --- a/libexec/rc/rc.d/zpoolreguid +++ b/libexec/rc/rc.d/zpoolreguid @@ -2,7 +2,7 @@ # PROVIDE: zpoolreguid # REQUIRE: zpool -# BEFORE: mountcritlocal +# BEFORE: FILESYSTEMS # KEYWORD: firstboot nojail . /etc/rc.subr diff --git a/libexec/rc/rc.d/zpoolupgrade b/libexec/rc/rc.d/zpoolupgrade index 1435cba7199c..5e623a9c2bf0 100755 --- a/libexec/rc/rc.d/zpoolupgrade +++ b/libexec/rc/rc.d/zpoolupgrade @@ -2,7 +2,7 @@ # PROVIDE: zpoolupgrade # REQUIRE: zpool -# BEFORE: mountcritlocal +# BEFORE: FILESYSTEMS # KEYWORD: firstboot nojail . /etc/rc.subr diff --git a/libexec/rc/tests/rc_subr_test.sh b/libexec/rc/tests/rc_subr_test.sh index fe6d3b8264c9..9ddd13b61a7c 100644 --- a/libexec/rc/tests/rc_subr_test.sh +++ b/libexec/rc/tests/rc_subr_test.sh @@ -26,6 +26,17 @@ # SUCH DAMAGE. # +atf_test_case no_cycles +no_cycles_head() +{ + atf_set "descr" "Verify that /etc/rc.d/* contains no cycles" +} + +no_cycles_body() +{ + atf_check -e empty -o ignore rcorder /etc/rc.d/* +} + atf_test_case oomprotect_all oomprotect_all_head() { @@ -130,6 +141,7 @@ EOF atf_init_test_cases() { + atf_add_test_case no_cycles atf_add_test_case oomprotect_all atf_add_test_case oomprotect_yes atf_add_test_case wait_for_pids_progress diff --git a/release/Makefile b/release/Makefile index 12f5114f8b22..13532097d56c 100644 --- a/release/Makefile +++ b/release/Makefile @@ -448,9 +448,7 @@ release: real-release vm-release cloudware-release oci-release release-done: touch release -real-release: - ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} obj - ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${RELEASE_TARGETS} +real-release: obj .WAIT ${RELEASE_TARGETS} install: release-install vm-install oci-install .WAIT cloud-install diff --git a/release/arm64/RPI.conf b/release/arm64/RPI.conf index b973687c535d..d418dae28d3a 100644 --- a/release/arm64/RPI.conf +++ b/release/arm64/RPI.conf @@ -3,8 +3,9 @@ # DTB_DIR="/usr/local/share/rpi-firmware" -DTB="bcm2710-rpi-2-b.dtb bcm2710-rpi-3-b.dtb bcm2710-rpi-3-b-plus.dtb bcm2710-rpi-cm3.dtb \ - bcm2711-rpi-4-b.dtb bcm2711-rpi-cm4-io.dtb bcm2711-rpi-cm4.dtb" +DTB="bcm2710-rpi-2-b.dtb bcm2710-rpi-3-b.dtb bcm2710-rpi-3-b-plus.dtb \ + bcm2710-rpi-cm3.dtb bcm2710-rpi-zero-2-w.dtb bcm2711-rpi-4-b.dtb \ + bcm2711-rpi-cm4-io.dtb bcm2711-rpi-cm4.dtb" EMBEDDED_TARGET_ARCH="aarch64" EMBEDDED_TARGET="arm64" EMBEDDEDBUILD=1 diff --git a/release/packages/generate-set-ucl.lua b/release/packages/generate-set-ucl.lua index ab8765c8cf2d..9ba7026b75df 100755 --- a/release/packages/generate-set-ucl.lua +++ b/release/packages/generate-set-ucl.lua @@ -1,4 +1,10 @@ #!/usr/libexec/flua +-- +-- Copyright (c) 2024-2025 Baptiste Daroussin <bapt@FreeBSD.org> +-- Copyright (c) 2025 Lexi Winter <ivy@FreeBSD.org> +-- +-- SPDX-License-Identifier: BSD-2-Clause +-- --[[ usage: generate-set-ucl.lua <template> [<variablename> <variablevalue>] diff --git a/release/packages/generate-ucl.lua b/release/packages/generate-ucl.lua index d9125182a1a4..19a9a95d5d38 100755 --- a/release/packages/generate-ucl.lua +++ b/release/packages/generate-ucl.lua @@ -1,4 +1,10 @@ #!/usr/libexec/flua +-- +-- Copyright (c) 2024-2025 Baptiste Daroussin <bapt@FreeBSD.org> +-- Copyright (c) 2025 Lexi Winter <ivy@FreeBSD.org> +-- +-- SPDX-License-Identifier: BSD-2-Clause +-- --[[ usage: generate-ucl.lua [<variablename> <variablevalue>]... <sourceucl> <destucl> diff --git a/release/scripts/make-oci-image.sh b/release/scripts/make-oci-image.sh index 6e5ad69741f7..f8ea679bfd18 100644 --- a/release/scripts/make-oci-image.sh +++ b/release/scripts/make-oci-image.sh @@ -39,10 +39,18 @@ install_packages() { local abi=$1; shift local workdir=$1; shift local rootdir=${workdir}/rootfs + + # Make sure we have the keys needed for verifying package integrity if + # not already added by a parent image. if [ ! -d ${rootdir}/usr/share/keys/pkg/trusted ]; then mkdir -p ${rootdir}/usr/share/keys/pkg/trusted fi - cp /usr/share/keys/pkg/trusted/* ${rootdir}/usr/share/keys/pkg/trusted + for i in ${curdir}/../share/keys/pkg/trusted/pkg.*; do + if [ ! -f ${rootdir}/usr/share/keys/pkg/trusted/$(basename $i) ]; then + cp $i ${rootdir}/usr/share/keys/pkg/trusted + fi + done + # We install the packages and then remove repository metadata (keeping the # metadata for what was installed). This trims more than 40Mb from the # resulting image. diff --git a/release/tools/ec2-base.conf b/release/tools/ec2-base.conf index b6354db3d9d1..ffe2646240a5 100644 --- a/release/tools/ec2-base.conf +++ b/release/tools/ec2-base.conf @@ -36,5 +36,9 @@ vm_extra_pre_umount() { # Standard FreeBSD network configuration ec2_base_networking + # Add files from packages which weren't recorded in metalog + metalog_add_data ./usr/local/etc/dhclient.conf + metalog_add_data ./usr/local/etc/ssl/cert.pem + return 0 } diff --git a/release/tools/ec2-builder.conf b/release/tools/ec2-builder.conf index a55485fec0cd..bcea69331be5 100644 --- a/release/tools/ec2-builder.conf +++ b/release/tools/ec2-builder.conf @@ -66,5 +66,9 @@ vm_extra_pre_umount() { EOF metalog_add_data ./boot/loader.conf + # Add files from packages which weren't recorded in metalog + metalog_add_data ./usr/local/etc/dhclient.conf + metalog_add_data ./usr/local/etc/ssl/cert.pem + return 0 } diff --git a/release/tools/ec2-small.conf b/release/tools/ec2-small.conf index acaffbbc0c42..f12afec75a4f 100644 --- a/release/tools/ec2-small.conf +++ b/release/tools/ec2-small.conf @@ -49,5 +49,9 @@ vm_extra_pre_umount() { # Standard FreeBSD network configuration ec2_base_networking + # Add files from packages which weren't recorded in metalog + metalog_add_data ./usr/local/etc/dhclient.conf + metalog_add_data ./usr/local/etc/ssl/cert.pem + return 0 } diff --git a/release/tools/oci-image-notoolchain.conf b/release/tools/oci-image-notoolchain.conf index a769b53f9ff6..72a62657fa76 100644 --- a/release/tools/oci-image-notoolchain.conf +++ b/release/tools/oci-image-notoolchain.conf @@ -1,67 +1,25 @@ #! /bin/sh -# Build OCI container image with almost all packages suitable for jails, excluding compiler +# Build OCI container image with almost all packages suitable for jails, +# excluding toolchain. OCI_BASE_IMAGE=runtime oci_image_build() { set_cmd ${workdir} /bin/sh install_packages ${abi} ${workdir} \ - FreeBSD-acct \ - FreeBSD-at \ - FreeBSD-audit \ - FreeBSD-autofs \ - FreeBSD-blocklist \ - FreeBSD-bsnmp \ - FreeBSD-caroot \ - FreeBSD-certctl \ - FreeBSD-clibs \ - FreeBSD-console-tools \ - FreeBSD-cron \ - FreeBSD-csh \ + FreeBSD-bmake \ FreeBSD-dma \ - FreeBSD-ee \ - FreeBSD-fd \ - FreeBSD-fetch \ - FreeBSD-ftp \ FreeBSD-inetd \ FreeBSD-ipf \ FreeBSD-ipfw \ - FreeBSD-iscsi \ - FreeBSD-jail \ - FreeBSD-kerberos \ - FreeBSD-kerberos-lib \ - FreeBSD-libarchive \ - FreeBSD-libcompiler_rt-dev \ - FreeBSD-libexecinfo \ - FreeBSD-libucl \ - FreeBSD-locales \ - FreeBSD-lp \ - FreeBSD-mtree \ FreeBSD-natd \ FreeBSD-netmap \ - FreeBSD-newsyslog \ - FreeBSD-nfs \ - FreeBSD-nuageinit \ - FreeBSD-openssl \ - FreeBSD-periodic \ FreeBSD-pf \ - FreeBSD-pkg-bootstrap \ - FreeBSD-quotacheck \ - FreeBSD-rc \ - FreeBSD-rcmds \ - FreeBSD-rescue \ - FreeBSD-resolvconf \ - FreeBSD-runtime \ FreeBSD-ssh \ - FreeBSD-syslogd \ - FreeBSD-tcpd \ FreeBSD-telnet \ - FreeBSD-ufs \ - FreeBSD-unbound \ - FreeBSD-utilities \ - FreeBSD-vi \ - FreeBSD-yp \ + FreeBSD-xz \ FreeBSD-zfs \ - FreeBSD-zoneinfo + FreeBSD-set-minimal-jail } + diff --git a/release/tools/oci-image-runtime.conf b/release/tools/oci-image-runtime.conf index 93aad1e39250..db99e5640040 100644 --- a/release/tools/oci-image-runtime.conf +++ b/release/tools/oci-image-runtime.conf @@ -9,6 +9,10 @@ OCI_BASE_IMAGE=dynamic oci_image_build() { set_cmd ${workdir} /bin/sh + # The static image installed termcap.small into /usr/share/misc/termcap + # and we are replacing it with the full termcap file. We remove the + # small one first to avoid creating a .pkgsave file. + rm ${workdir}/rootfs/usr/share/misc/termcap install_packages ${abi} ${workdir} \ FreeBSD-runtime \ FreeBSD-certctl \ diff --git a/release/tools/vmimage.subr b/release/tools/vmimage.subr index 131ebe37db6c..15c4dd53e70b 100644 --- a/release/tools/vmimage.subr +++ b/release/tools/vmimage.subr @@ -74,10 +74,15 @@ vm_base_packages_list() { # Output a list of package sets equivalent to what we get from # "installworld installkernel distribution", aka. the full base # system. - for S in base lib32 kernels; do + for S in base kernels; do echo FreeBSD-set-$S echo FreeBSD-set-$S-dbg done + case ${TARGET_ARCH} in + amd64 | aarch64 | powerpc64) + echo FreeBSD-set-lib32 + echo FreeBSD-set-lib32-dbg + esac echo FreeBSD-set-tests } @@ -208,6 +213,16 @@ vm_extra_install_packages() { install -y -r ${PKG_REPO_NAME} $pkg done metalog_add_data ./var/db/pkg/local.sqlite + + # Add some database files which are created by pkg triggers; + # at some point in the future the tools which create these + # files should probably learn how to record them in METALOG + # (which would simplify no-root installworld as well). + metalog_add_data ./etc/login.conf.db + metalog_add_data ./etc/passwd + metalog_add_data ./etc/pwd.db + metalog_add_data ./etc/spwd.db 600 + metalog_add_data ./var/db/services.db else if [ -n "${WITHOUT_QEMU}" ]; then return 0 diff --git a/sbin/mount_nullfs/mount_nullfs.8 b/sbin/mount_nullfs/mount_nullfs.8 index 17b1f45f5e42..b3cf57fd9dea 100644 --- a/sbin/mount_nullfs/mount_nullfs.8 +++ b/sbin/mount_nullfs/mount_nullfs.8 @@ -90,7 +90,7 @@ See the .Xr mount 8 man page for possible options and their meanings. Additionally the following option is supported: -.Bl -tag -width nocache +.Bl -tag -width nounixbypass .It Cm nocache Disable metadata caching in the null layer. Some lower-layer file systems may force this option. @@ -98,6 +98,32 @@ Depending on the access pattern, this may result in increased lock contention. .It Cm cache Force enable metadata caching. +.It Cm nounixbypass +Disable bypassing +.Xr unix 4 +socket files used for +.Xr bind 2 +and +.Xr connect 2 , +to the lower (mounted-from) filesystem layer. +.Pp +The effect is that lower and upper (bypassed) unix sockets +are separate. +.It Cm unixbypass +Enable the bypass of unix socket file to lower filesystem layer. +This is default. +.Pp +The effect is that +.Xr bind 2 +and +.Xr connect 2 +operations on a unix socket done from either the upper (nullfs) or lower +layer path are performed on same unix socket. +For instance, if a server +.Xr bind 2 +is done on a socket in the lower layer, then +.Xr connect 2 +on the socket file accessed via the nullfs mount, connects to the server. .El .El .Pp diff --git a/sbin/rcorder/rcorder.c b/sbin/rcorder/rcorder.c index 87b0e873c7ae..3d2a67c82a5a 100644 --- a/sbin/rcorder/rcorder.c +++ b/sbin/rcorder/rcorder.c @@ -980,9 +980,11 @@ do_file(filenode *fnode, strnodelist *stack_ptr) fnode->last->next = fnode->next; } - if (fnode->issues_count) - warnx("`%s' was seen in circular dependencies for %d times.", - fnode->filename, fnode->issues_count); + if (fnode->issues_count) { + warnx("`%s' was seen in circular dependencies %d time%s.", + fnode->filename, fnode->issues_count, + fnode->issues_count > 1 ? "s" : ""); + } DPRINTF((stderr, "nuking %s\n", fnode->filename)); } diff --git a/share/man/man4/aacraid.4 b/share/man/man4/aacraid.4 index 3bf683ac40c8..0f64f36c493a 100644 --- a/share/man/man4/aacraid.4 +++ b/share/man/man4/aacraid.4 @@ -1,3 +1,6 @@ +.\" +.\" SPDX-License-Identifier: BSD-2-Clause +.\" .\" Copyright (c) 2013 Achim Leubner .\" All rights reserved. .\" @@ -21,12 +24,12 @@ .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. -.Dd June 19, 2015 +.Dd September 29, 2025 .Dt AACRAID 4 .Os .Sh NAME .Nm aacraid -.Nd Adaptec AACRAID Controller driver +.Nd Adaptec Series 6/7/8 6G and 12G SAS+SATA RAID controller driver .Sh SYNOPSIS To compile this driver into the kernel, place the following lines in your @@ -78,9 +81,10 @@ Linux-compatible interface for the management device will be enabled and will allow Linux-based management applications to control the card. .Sh HARDWARE -Controllers supported by the +The .Nm -driver include: +driver supports the following +Adaptec 6G and 12G SAS/SATA RAID controllers: .Pp .Bl -bullet -compact .It diff --git a/share/man/man4/umass.4 b/share/man/man4/umass.4 index db4e6f0890f2..8c6b03a3afea 100644 --- a/share/man/man4/umass.4 +++ b/share/man/man4/umass.4 @@ -25,44 +25,44 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd October 2, 2025 +.Dd October 9, 2025 .Dt UMASS 4 .Os .Sh NAME .Nm umass .Nd USB Mass Storage Devices driver .Sh SYNOPSIS -To compile this driver into the kernel, -place the following line in your -kernel configuration file: -.Bd -ragged -offset indent +.Cd "device da" .Cd "device scbus" +.Cd "device pass" .Cd "device usb" .Cd "device umass" -.Ed .Pp -Alternatively, to load the driver as a -module at boot time, place the following line in +In .Xr loader.conf 5 : -.Bd -literal -offset indent -umass_load="YES" -.Ed +.Cd umass_load .Sh DESCRIPTION The .Nm driver provides support for Mass Storage devices that attach to the USB -port. +interface. .Pp -To use the -.Nm -driver, +If the appropriate hardware is detected, +the driver will be loaded automatically by +.Xr devmatch 8 . +To load the driver manually at boot time, use the +.Cm umass_load +command at the +.Xr loader 8 +prompt, or add it to +.Xr loader.conf 5 . +.Pp +To use the driver in a custom kernel, .Xr usb 4 -and one of -.Xr uhci 4 -or -.Xr ohci 4 -or -.Xr ehci 4 +and at least one of +.Xr uhci 4 , +.Xr ohci 4 , +.Xr ehci 4 , or .Xr xhci 4 must be configured in the kernel. @@ -88,16 +88,8 @@ USB hard disk drives USB floppy drives .El .Sh EXAMPLES -.Bd -literal -offset indent -device umass -device scbus -device da -device pass -.Ed -.Pp -Add the -.Nm -driver to the kernel. +Rescan all slots on a multi-slot flash reader, +where the slots map to separate LUNs on a single SCSI ID: .Bd -literal -offset indent camcontrol rescan 0:0:0 camcontrol rescan 0:0:1 @@ -105,8 +97,6 @@ camcontrol rescan 0:0:2 camcontrol rescan 0:0:3 .Ed .Pp -Rescan all slots on a multi-slot flash reader, where the slots map to separate -LUNs on a single SCSI ID. Typically only the first slot will be enabled at boot time. This assumes that the flash reader is the first SCSI bus in the system and has 4 slots. diff --git a/share/man/man7/arch.7 b/share/man/man7/arch.7 index 5de441aed699..668f5aa23155 100644 --- a/share/man/man7/arch.7 +++ b/share/man/man7/arch.7 @@ -48,23 +48,35 @@ and later, unless otherwise noted. .Fx uses a flat address space. Variables of types -.Vt unsigned long , -.Vt uintptr_t , +.Vt unsigned long and .Vt size_t -and pointers all have the same representation. +have the same representation. .Pp In order to maximize compatibility with future pointer integrity mechanisms, manipulations of pointers as integers should be performed via .Vt uintptr_t or .Vt intptr_t -and no other types. -In particular, -.Vt long +and no other types as these types are the only integer types where the +C standard guarantees that a pointer may be cast to it and then cast back +to the original type. +On CHERI systems, +.Vt uintptr_t and -.Vt ptrdiff_t -should be avoided. +.Vt intptr_t +are defined as +.Vt __uintcap_t +and +.Vt __intcap_t +which represent capabilities that can be manipulated by integer operations. +Pointers should not be cast to +.Vt long , +.Vt ptrdiff_t , +or +.Vt size_t +if they will later be cast back to a pointer that is expected to be +dereferencable as they remain bare integer types on all architectures. .Pp On some architectures, e.g., AIM variants of @@ -85,11 +97,13 @@ release to support each architecture. .Bl -column -offset indent "Architecture" "Initial Release" .It Sy Architecture Ta Sy Initial Release .It aarch64 Ta 11.0 +.It aarch64c Ta 16.0 (planned) .It amd64 Ta 5.1 .It armv7 Ta 12.0 .It powerpc64 Ta 9.0 .It powerpc64le Ta 13.0 .It riscv64 Ta 12.0 +.It riscv64c Ta 16.0 (planned) .El .Pp Discontinued architectures are shown in the following table. @@ -123,21 +137,33 @@ architectures use some variant of the ELF (see .Xr elf 5 ) .Sy Application Binary Interface (ABI) for the machine processor. -All supported ABIs can be divided into two groups: -.Bl -tag -width "Dv ILP32" +Supported ABIs can be divided into three main groups: +.Bl -tag -width "Dv L64PC128" .It Dv ILP32 .Vt int , +.Vt intptr_t , .Vt long , +and .Vt void * types machine representations all have 4-byte size. .It Dv LP64 .Vt int type machine representation uses 4 bytes, while -.Vt long +.Vt intptr_t , +.Vt long , and .Vt void * are 8 bytes. +.It Dv L64PC128 +.Vt int +type machine representation uses 4 bytes. +.Vt long +type machine representation uses 8 bytes. +.Vt intptr_t +and +.Vt void * +are 16 byte capabilities. .El .Pp Some machines support more than one @@ -169,12 +195,23 @@ Binaries targeting and earlier are no longer supported by .Fx . .Pp +Architectures with 128-bit capabilities support both a +.Dq native +.Dv L64PC128 +execution environment and a +.Dv LP64 +environment: +.Bl -column -offset indent "aarch64c" "LP64 counterpart" +.It Sy L64PC128 Ta Sy LP64 counterpart +.It Dv aarch64c Ta Dv aarch64 +.It Dv riscv64c Ta Dv riscv64 +.El +.Pp On all supported architectures: .Bl -column -offset indent "long long" "Size" .It Sy Type Ta Sy Size .It short Ta 2 .It int Ta 4 -.It long Ta sizeof(void*) .It long long Ta 8 .It float Ta 4 .It double Ta 8 @@ -188,17 +225,19 @@ The sole exception is that requires only 4-byte alignment for 64-bit integers. .Pp Machine-dependent type sizes: -.Bl -column -offset indent "Architecture" "void *" "long double" "time_t" -.It Sy Architecture Ta Sy void * Ta Sy long double Ta Sy time_t -.It aarch64 Ta 8 Ta 16 Ta 8 -.It amd64 Ta 8 Ta 16 Ta 8 -.It armv7 Ta 4 Ta 8 Ta 8 -.It i386 Ta 4 Ta 12 Ta 4 -.It powerpc Ta 4 Ta 8 Ta 8 -.It powerpcspe Ta 4 Ta 8 Ta 8 -.It powerpc64 Ta 8 Ta 8 Ta 8 -.It powerpc64le Ta 8 Ta 8 Ta 8 -.It riscv64 Ta 8 Ta 16 Ta 8 +.Bl -column -offset indent "Architecture" "long" "void *" "long double" "time_t" +.It Sy Architecture Ta Sy long Ta Sy void * Ta Sy long double Ta Sy time_t +.It aarch64 Ta 8 Ta 8 Ta 16 Ta 8 +.It aarch64c Ta 8 Ta 16 Ta 16 Ta 8 +.It amd64 Ta 8 Ta 8 Ta 16 Ta 8 +.It armv7 Ta 4 Ta 4 Ta 8 Ta 8 +.It i386 Ta 4 Ta 4 Ta 12 Ta 4 +.It powerpc Ta 4 Ta 4 Ta 8 Ta 8 +.It powerpcspe Ta 4 Ta 4 Ta 8 Ta 8 +.It powerpc64 Ta 8 Ta 8 Ta 8 Ta 8 +.It powerpc64le Ta 8 Ta 8 Ta 8 Ta 8 +.It riscv64 Ta 8 Ta 8 Ta 16 Ta 8 +.It riscv64c Ta 8 Ta 16 Ta 16 Ta 8 .El .Pp .Sy time_t @@ -207,6 +246,7 @@ is 8 bytes on all supported architectures except i386. .Bl -column -offset indent "Architecture" "Endianness" "char Signedness" .It Sy Architecture Ta Sy Endianness Ta Sy char Signedness .It aarch64 Ta little Ta unsigned +.It aarch64c Ta little Ta unsigned .It amd64 Ta little Ta signed .It armv7 Ta little Ta unsigned .It i386 Ta little Ta signed @@ -215,11 +255,13 @@ is 8 bytes on all supported architectures except i386. .It powerpc64 Ta big Ta unsigned .It powerpc64le Ta little Ta unsigned .It riscv64 Ta little Ta signed +.It riscv64c Ta little Ta signed .El .Ss Page Size .Bl -column -offset indent "Architecture" "Page Sizes" .It Sy Architecture Ta Sy Page Sizes .It aarch64 Ta 4K, 64K, 2M, 1G +.It aarch64c Ta 4K, 64K, 2M, 1G .It amd64 Ta 4K, 2M, 1G .It armv7 Ta 4K, 1M .It i386 Ta 4K, 2M (PAE), 4M @@ -228,11 +270,13 @@ is 8 bytes on all supported architectures except i386. .It powerpc64 Ta 4K .It powerpc64le Ta 4K .It riscv64 Ta 4K, 2M, 1G +.It riscv64c Ta 4K, 2M, 1G .El .Ss User Address Space Layout .Bl -column -offset indent "riscv64 (Sv48)" "0x0001000000000000" "NNNU" .It Sy Architecture Ta Sy Maximum Address Ta Sy Address Space Size .It aarch64 Ta 0x0001000000000000 Ta 256TiB +.It aarch64c Ta 0x0001000000000000 Ta 256TiB .It amd64 (LA48) Ta 0x0000800000000000 Ta 128TiB .It amd64 (LA57) Ta 0x0100000000000000 Ta 64PiB .It armv7 Ta 0xbfc00000 Ta 3GiB @@ -242,7 +286,9 @@ is 8 bytes on all supported architectures except i386. .It powerpc64 Ta 0x000fffffc0000000 Ta 4PiB .It powerpc64le Ta 0x000fffffc0000000 Ta 4PiB .It riscv64 (Sv39) Ta 0x0000004000000000 Ta 256GiB +.It riscv64c (Sv39) Ta 0x0000004000000000 Ta 256GiB .It riscv64 (Sv48) Ta 0x0000800000000000 Ta 128TiB +.It riscv64c (Sv48) Ta 0x0000800000000000 Ta 128TiB .El .Pp The layout of a process' address space can be queried via the @@ -287,6 +333,7 @@ currently supports Sv39 and Sv48 and defaults to using Sv39. .Bl -column -offset indent "Architecture" "float, double" "long double" .It Sy Architecture Ta Sy float, double Ta Sy long double .It aarch64 Ta hard Ta soft, quad precision +.It aarch64c Ta hard Ta soft, quad precision .It amd64 Ta hard Ta hard, 80 bit .It armv7 Ta hard Ta hard, double precision .It i386 Ta hard Ta hard, 80 bit @@ -295,6 +342,7 @@ currently supports Sv39 and Sv48 and defaults to using Sv39. .It powerpc64 Ta hard Ta hard, double precision .It powerpc64le Ta hard Ta hard, double precision .It riscv64 Ta hard Ta hard, quad precision +.It riscv64c Ta hard Ta hard, quad precision .El .Ss Default Tool Chain .Fx @@ -321,12 +369,12 @@ when referring to the kernel, interfaces dependent on a specific type of kernel or similar things like boot sequences. .Bl -column -offset indent "Dv MACHINE" "Dv MACHINE_CPUARCH" "Dv MACHINE_ARCH" .It Dv MACHINE Ta Dv MACHINE_CPUARCH Ta Dv MACHINE_ARCH -.It arm64 Ta aarch64 Ta aarch64 +.It arm64 Ta aarch64 Ta aarch64, aarch64c .It amd64 Ta amd64 Ta amd64 .It arm Ta arm Ta armv7 .It i386 Ta i386 Ta i386 .It powerpc Ta powerpc Ta powerpc, powerpcspe, powerpc64, powerpc64le -.It riscv Ta riscv Ta riscv64 +.It riscv Ta riscv Ta riscv64, riscv64c .El .Ss Predefined Macros The compiler provides a number of predefined macros. @@ -340,17 +388,40 @@ cc -x c -dM -E /dev/null .Ed .Pp Common type size and endianness macros: -.Bl -column -offset indent "BYTE_ORDER" "Meaning" +.Bl -column -offset indent "__SIZEOF_POINTER__" "Meaning" .It Sy Macro Ta Sy Meaning +.It Dv __SIZEOF_LONG__ Ta size in bytes of long +.It Dv __SIZEOF_POINTER__ Ta size in bytes of intptr_t and pointers +.It Dv __SIZEOF_SIZE_T__ Ta size in bytes of size_t .It Dv __LP64__ Ta 64-bit (8-byte) long and pointer, 32-bit (4-byte) int .It Dv __ILP32__ Ta 32-bit (4-byte) int, long and pointer +.It Dv __CHERI__ Ta 128-bit (16-byte) capability pointer, 64-bit (8-byte) long .It Dv BYTE_ORDER Ta Either Dv BIG_ENDIAN or Dv LITTLE_ENDIAN . .El .Pp +Because systems were historically either +.Dv __ILP32__ +or +.Dv __LP64__ +it has been common for programmers to test only one and assume the other +one in an else branch. +With the arrival of CHERI architectures, this is no longer the case. +.Dv __SIZEOF_*__ +macros should be used instead. +New uses of +.Dv __ILP32__ +and +.Dv __LP64__ +should be avoided. +Compilers for CHERI targets do not define +.Dv __LP64__ +as their pointers are 128-bit capabilities. +.Pp Architecture-specific macros: .Bl -column -offset indent "Architecture" "Predefined macros" .It Sy Architecture Ta Sy Predefined macros .It aarch64 Ta Dv __aarch64__ +.It aarch64c Ta Dv __aarch64__ , Dv __CHERI__ .It amd64 Ta Dv __amd64__ , Dv __x86_64__ .It armv7 Ta Dv __arm__ , Dv __ARM_ARCH >= 7 .It i386 Ta Dv __i386__ @@ -359,6 +430,7 @@ Architecture-specific macros: .It powerpc64 Ta Dv __powerpc__ , Dv __powerpc64__ .It powerpc64le Ta Dv __powerpc__ , Dv __powerpc64__ .It riscv64 Ta Dv __riscv , Dv __riscv_xlen == 64 +.It riscv64c Ta Dv __riscv , Dv __riscv_xlen == 64 , Dv __CHERI__ .El .Pp Compilers may define additional variants of architecture-specific macros. diff --git a/share/mk/bsd.confs.mk b/share/mk/bsd.confs.mk index 77b573c7e42c..e953e6d978dc 100644 --- a/share/mk/bsd.confs.mk +++ b/share/mk/bsd.confs.mk @@ -22,6 +22,14 @@ buildconfig: ${${group}} all: buildconfig . endif +# Take groups from both CONFGROUPS and CONFGROUPS.yes, to allow syntax like +# CONFGROUPS.${MK_FOO}=FOO. Sort and uniq the list of groups in case of +# duplicates. +.if defined(CONFGROUPS) || defined(CONFGROUPS.yes) +CONFGROUPS:=${CONFGROUPS} ${CONFGROUPS.yes} +CONFGROUPS:=${CONFGROUPS:O:u} +.endif + . for group in ${CONFGROUPS} . if defined(${group}) && !empty(${group}) diff --git a/stand/lua/cli.lua.8 b/stand/lua/cli.lua.8 index aee1d3d53579..e47ecd3d23db 100644 --- a/stand/lua/cli.lua.8 +++ b/stand/lua/cli.lua.8 @@ -52,10 +52,11 @@ For instance: local cli = require("cli") cli.foo = function(...) - -- Expand args to command name and the rest of argv. These arguments - -- are pushed directly to the stack by loader, then handed off to - -- cli_execute. cli_execute then passes them on to the invoked - -- function, where they appear as varargs that must be peeled apart into + -- Expand args to command name and the rest of argv. + -- These arguments are pushed directly to the stack by + -- loader, then handed off to cli_execute. cli_execute + -- then passes them on to the invoked function, where + -- they appear as varargs that must be peeled apart into -- their respective components. local _, argv = cli.arguments(...) @@ -63,10 +64,11 @@ cli.foo = function(...) for k, v in ipairs(argv) do print("arg #" .. tostring(k) .. ": '" .. v .. "'") end - -- Perform a loader command directly. This will not get dispatched back - -- to Lua, so it is acceptable to have a function of the exact same name - -- in loader. Lua will have the first chance to handle any commands - -- executed at the loader prompt. + -- Perform a loader command directly. This will not get + -- dispatched back to Lua, so it is acceptable to have a + -- function of the exact same name in loader. Lua will + -- have the first chance to handle any commands executed + -- at the loader prompt. loader.perform("foo") end .Ed diff --git a/sys/amd64/include/vmm.h b/sys/amd64/include/vmm.h index e35119af8572..66d8991d36e8 100644 --- a/sys/amd64/include/vmm.h +++ b/sys/amd64/include/vmm.h @@ -170,55 +170,63 @@ struct vm_eventinfo { int *iptr; /* reqidle cookie */ }; -typedef int (*vmm_init_func_t)(int ipinum); -typedef int (*vmm_cleanup_func_t)(void); -typedef void (*vmm_suspend_func_t)(void); -typedef void (*vmm_resume_func_t)(void); -typedef void * (*vmi_init_func_t)(struct vm *vm, struct pmap *pmap); -typedef int (*vmi_run_func_t)(void *vcpui, register_t rip, - struct pmap *pmap, struct vm_eventinfo *info); -typedef void (*vmi_cleanup_func_t)(void *vmi); -typedef void * (*vmi_vcpu_init_func_t)(void *vmi, struct vcpu *vcpu, - int vcpu_id); -typedef void (*vmi_vcpu_cleanup_func_t)(void *vcpui); -typedef int (*vmi_get_register_t)(void *vcpui, int num, uint64_t *retval); -typedef int (*vmi_set_register_t)(void *vcpui, int num, uint64_t val); -typedef int (*vmi_get_desc_t)(void *vcpui, int num, struct seg_desc *desc); -typedef int (*vmi_set_desc_t)(void *vcpui, int num, struct seg_desc *desc); -typedef int (*vmi_get_cap_t)(void *vcpui, int num, int *retval); -typedef int (*vmi_set_cap_t)(void *vcpui, int num, int val); -typedef struct vmspace * (*vmi_vmspace_alloc)(vm_offset_t min, vm_offset_t max); -typedef void (*vmi_vmspace_free)(struct vmspace *vmspace); -typedef struct vlapic * (*vmi_vlapic_init)(void *vcpui); -typedef void (*vmi_vlapic_cleanup)(struct vlapic *vlapic); -typedef int (*vmi_snapshot_vcpu_t)(void *vcpui, struct vm_snapshot_meta *meta); -typedef int (*vmi_restore_tsc_t)(void *vcpui, uint64_t now); +#define DECLARE_VMMOPS_FUNC(ret_type, opname, args) \ + typedef ret_type (*vmmops_##opname##_t) args; \ + ret_type vmmops_##opname args + +DECLARE_VMMOPS_FUNC(int, modinit, (int ipinum)); +DECLARE_VMMOPS_FUNC(int, modcleanup, (void)); +DECLARE_VMMOPS_FUNC(void, modresume, (void)); +DECLARE_VMMOPS_FUNC(void, modsuspend, (void)); +DECLARE_VMMOPS_FUNC(void *, init, (struct vm *vm, struct pmap *pmap)); +DECLARE_VMMOPS_FUNC(int, run, (void *vcpui, register_t pc, + struct pmap *pmap, struct vm_eventinfo *info)); +DECLARE_VMMOPS_FUNC(void, cleanup, (void *vmi)); +DECLARE_VMMOPS_FUNC(void *, vcpu_init, (void *vmi, struct vcpu *vcpu, + int vcpu_id)); +DECLARE_VMMOPS_FUNC(void, vcpu_cleanup, (void *vcpui)); +DECLARE_VMMOPS_FUNC(int, getreg, (void *vcpui, int num, uint64_t *retval)); +DECLARE_VMMOPS_FUNC(int, setreg, (void *vcpui, int num, uint64_t val)); +DECLARE_VMMOPS_FUNC(int, getdesc, (void *vcpui, int num, + struct seg_desc *desc)); +DECLARE_VMMOPS_FUNC(int, setdesc, (void *vcpui, int num, + struct seg_desc *desc)); +DECLARE_VMMOPS_FUNC(int, getcap, (void *vcpui, int num, int *retval)); +DECLARE_VMMOPS_FUNC(int, setcap, (void *vcpui, int num, int val)); +DECLARE_VMMOPS_FUNC(struct vmspace *, vmspace_alloc, + (vm_offset_t min, vm_offset_t max)); +DECLARE_VMMOPS_FUNC(void, vmspace_free, (struct vmspace *vmspace)); +DECLARE_VMMOPS_FUNC(struct vlapic *, vlapic_init, (void *vcpui)); +DECLARE_VMMOPS_FUNC(void, vlapic_cleanup, (struct vlapic *vlapic)); +DECLARE_VMMOPS_FUNC(int, vcpu_snapshot, (void *vcpui, + struct vm_snapshot_meta *meta)); +DECLARE_VMMOPS_FUNC(int, restore_tsc, (void *vcpui, uint64_t now)); struct vmm_ops { - vmm_init_func_t modinit; /* module wide initialization */ - vmm_cleanup_func_t modcleanup; - vmm_resume_func_t modsuspend; - vmm_resume_func_t modresume; - - vmi_init_func_t init; /* vm-specific initialization */ - vmi_run_func_t run; - vmi_cleanup_func_t cleanup; - vmi_vcpu_init_func_t vcpu_init; - vmi_vcpu_cleanup_func_t vcpu_cleanup; - vmi_get_register_t getreg; - vmi_set_register_t setreg; - vmi_get_desc_t getdesc; - vmi_set_desc_t setdesc; - vmi_get_cap_t getcap; - vmi_set_cap_t setcap; - vmi_vmspace_alloc vmspace_alloc; - vmi_vmspace_free vmspace_free; - vmi_vlapic_init vlapic_init; - vmi_vlapic_cleanup vlapic_cleanup; + vmmops_modinit_t modinit; /* module wide initialization */ + vmmops_modcleanup_t modcleanup; + vmmops_modresume_t modsuspend; + vmmops_modresume_t modresume; + + vmmops_init_t init; /* vm-specific initialization */ + vmmops_run_t run; + vmmops_cleanup_t cleanup; + vmmops_vcpu_init_t vcpu_init; + vmmops_vcpu_cleanup_t vcpu_cleanup; + vmmops_getreg_t getreg; + vmmops_setreg_t setreg; + vmmops_getdesc_t getdesc; + vmmops_setdesc_t setdesc; + vmmops_getcap_t getcap; + vmmops_setcap_t setcap; + vmmops_vmspace_alloc_t vmspace_alloc; + vmmops_vmspace_free_t vmspace_free; + vmmops_vlapic_init_t vlapic_init; + vmmops_vlapic_cleanup_t vlapic_cleanup; /* checkpoint operations */ - vmi_snapshot_vcpu_t vcpu_snapshot; - vmi_restore_tsc_t restore_tsc; + vmmops_vcpu_snapshot_t vcpu_snapshot; + vmmops_restore_tsc_t restore_tsc; }; extern const struct vmm_ops vmm_ops_intel; @@ -375,7 +383,6 @@ vcpu_should_yield(struct vcpu *vcpu) void *vcpu_stats(struct vcpu *vcpu); void vcpu_notify_event(struct vcpu *vcpu, bool lapic_intr); -struct vmspace *vm_vmspace(struct vm *vm); struct vm_mem *vm_mem(struct vm *vm); struct vatpic *vm_atpic(struct vm *vm); struct vatpit *vm_atpit(struct vm *vm); diff --git a/sys/amd64/vmm/vmm.c b/sys/amd64/vmm/vmm.c index c42da02d0bf6..2ac076551165 100644 --- a/sys/amd64/vmm/vmm.c +++ b/sys/amd64/vmm/vmm.c @@ -163,7 +163,6 @@ struct vm { void *rendezvous_arg; /* (x) [r] rendezvous func/arg */ vm_rendezvous_func_t rendezvous_func; struct mtx rendezvous_mtx; /* (o) rendezvous lock */ - struct vmspace *vmspace; /* (o) guest's address space */ struct vm_mem mem; /* (i) [m+v] guest memory */ char name[VM_MAX_NAMELEN+1]; /* (o) virtual machine name */ struct vcpu **vcpu; /* (o) guest vcpus */ @@ -201,7 +200,7 @@ vmmops_panic(void) } #define DEFINE_VMMOPS_IFUNC(ret_type, opname, args) \ - DEFINE_IFUNC(static, ret_type, vmmops_##opname, args) \ + DEFINE_IFUNC(, ret_type, vmmops_##opname, args) \ { \ if (vmm_is_intel()) \ return (vmm_ops_intel.opname); \ @@ -499,7 +498,7 @@ MODULE_VERSION(vmm, 1); static void vm_init(struct vm *vm, bool create) { - vm->cookie = vmmops_init(vm, vmspace_pmap(vm->vmspace)); + vm->cookie = vmmops_init(vm, vmspace_pmap(vm_vmspace(vm))); vm->iommu = NULL; vm->vioapic = vioapic_init(vm); vm->vhpet = vhpet_init(vm); @@ -584,7 +583,7 @@ int vm_create(const char *name, struct vm **retvm) { struct vm *vm; - struct vmspace *vmspace; + int error; /* * If vmm.ko could not be successfully initialized then don't attempt @@ -597,14 +596,13 @@ vm_create(const char *name, struct vm **retvm) VM_MAX_NAMELEN + 1) return (EINVAL); - vmspace = vmmops_vmspace_alloc(0, VM_MAXUSER_ADDRESS_LA48); - if (vmspace == NULL) - return (ENOMEM); - vm = malloc(sizeof(struct vm), M_VM, M_WAITOK | M_ZERO); + error = vm_mem_init(&vm->mem, 0, VM_MAXUSER_ADDRESS_LA48); + if (error != 0) { + free(vm, M_VM); + return (error); + } strcpy(vm->name, name); - vm->vmspace = vmspace; - vm_mem_init(&vm->mem); mtx_init(&vm->rendezvous_mtx, "vm rendezvous lock", 0, MTX_DEF); sx_init(&vm->vcpus_init_lock, "vm vcpus"); vm->vcpu = malloc(sizeof(*vm->vcpu) * vm_maxcpu, M_VM, M_WAITOK | @@ -685,9 +683,6 @@ vm_cleanup(struct vm *vm, bool destroy) if (destroy) { vm_mem_destroy(vm); - vmmops_vmspace_free(vm->vmspace); - vm->vmspace = NULL; - free(vm->vcpu, M_VM); sx_destroy(&vm->vcpus_init_lock); mtx_destroy(&vm->rendezvous_mtx); @@ -731,7 +726,7 @@ vm_map_mmio(struct vm *vm, vm_paddr_t gpa, size_t len, vm_paddr_t hpa) { vm_object_t obj; - if ((obj = vmm_mmio_alloc(vm->vmspace, gpa, len, hpa)) == NULL) + if ((obj = vmm_mmio_alloc(vm_vmspace(vm), gpa, len, hpa)) == NULL) return (ENOMEM); else return (0); @@ -741,19 +736,21 @@ int vm_unmap_mmio(struct vm *vm, vm_paddr_t gpa, size_t len) { - vmm_mmio_free(vm->vmspace, gpa, len); + vmm_mmio_free(vm_vmspace(vm), gpa, len); return (0); } static int vm_iommu_map(struct vm *vm) { + pmap_t pmap; vm_paddr_t gpa, hpa; struct vm_mem_map *mm; int error, i; sx_assert(&vm->mem.mem_segs_lock, SX_LOCKED); + pmap = vmspace_pmap(vm_vmspace(vm)); for (i = 0; i < VM_MAX_MEMMAPS; i++) { if (!vm_memseg_sysmem(vm, i)) continue; @@ -767,7 +764,7 @@ vm_iommu_map(struct vm *vm) mm->flags |= VM_MEMMAP_F_IOMMU; for (gpa = mm->gpa; gpa < mm->gpa + mm->len; gpa += PAGE_SIZE) { - hpa = pmap_extract(vmspace_pmap(vm->vmspace), gpa); + hpa = pmap_extract(pmap, gpa); /* * All mappings in the vmm vmspace must be @@ -816,7 +813,7 @@ vm_iommu_unmap(struct vm *vm) for (gpa = mm->gpa; gpa < mm->gpa + mm->len; gpa += PAGE_SIZE) { KASSERT(vm_page_wired(PHYS_TO_VM_PAGE(pmap_extract( - vmspace_pmap(vm->vmspace), gpa))), + vmspace_pmap(vm_vmspace(vm)), gpa))), ("vm_iommu_unmap: vm %p gpa %jx not wired", vm, (uintmax_t)gpa)); iommu_remove_mapping(vm->iommu, gpa, PAGE_SIZE); @@ -1249,7 +1246,7 @@ vm_handle_paging(struct vcpu *vcpu, bool *retu) ("vm_handle_paging: invalid fault_type %d", ftype)); if (ftype == VM_PROT_READ || ftype == VM_PROT_WRITE) { - rv = pmap_emulate_accessed_dirty(vmspace_pmap(vm->vmspace), + rv = pmap_emulate_accessed_dirty(vmspace_pmap(vm_vmspace(vm)), vme->u.paging.gpa, ftype); if (rv == 0) { VMM_CTR2(vcpu, "%s bit emulation for gpa %#lx", @@ -1259,7 +1256,7 @@ vm_handle_paging(struct vcpu *vcpu, bool *retu) } } - map = &vm->vmspace->vm_map; + map = &vm_vmspace(vm)->vm_map; rv = vm_fault(map, vme->u.paging.gpa, ftype, VM_FAULT_NORMAL, NULL); VMM_CTR3(vcpu, "vm_handle_paging rv = %d, gpa = %#lx, " @@ -1560,7 +1557,7 @@ vm_run(struct vcpu *vcpu) if (CPU_ISSET(vcpuid, &vm->suspended_cpus)) return (EINVAL); - pmap = vmspace_pmap(vm->vmspace); + pmap = vmspace_pmap(vm_vmspace(vm)); vme = &vcpu->exitinfo; evinfo.rptr = &vm->rendezvous_req_cpus; evinfo.sptr = &vm->suspend; @@ -2302,12 +2299,6 @@ vcpu_notify_event(struct vcpu *vcpu, bool lapic_intr) vcpu_unlock(vcpu); } -struct vmspace * -vm_vmspace(struct vm *vm) -{ - return (vm->vmspace); -} - struct vm_mem * vm_mem(struct vm *vm) { @@ -2519,7 +2510,7 @@ vm_get_rescnt(struct vcpu *vcpu, struct vmm_stat_type *stat) if (vcpu->vcpuid == 0) { vmm_stat_set(vcpu, VMM_MEM_RESIDENT, PAGE_SIZE * - vmspace_resident_count(vcpu->vm->vmspace)); + vmspace_resident_count(vm_vmspace(vcpu->vm))); } } @@ -2529,7 +2520,7 @@ vm_get_wiredcnt(struct vcpu *vcpu, struct vmm_stat_type *stat) if (vcpu->vcpuid == 0) { vmm_stat_set(vcpu, VMM_MEM_WIRED, PAGE_SIZE * - pmap_wired_count(vmspace_pmap(vcpu->vm->vmspace))); + pmap_wired_count(vmspace_pmap(vm_vmspace(vcpu->vm)))); } } diff --git a/sys/amd64/vmm/vmm_dev_machdep.c b/sys/amd64/vmm/vmm_dev_machdep.c index d8d2b460404c..dfebc9dcadbf 100644 --- a/sys/amd64/vmm/vmm_dev_machdep.c +++ b/sys/amd64/vmm/vmm_dev_machdep.c @@ -48,6 +48,7 @@ #include <x86/apicreg.h> #include <dev/vmm/vmm_dev.h> +#include <dev/vmm/vmm_mem.h> #include <dev/vmm/vmm_stat.h> #include "vmm_lapic.h" diff --git a/sys/arm64/include/vmm.h b/sys/arm64/include/vmm.h index e839b5dd92c9..84b286a60b38 100644 --- a/sys/arm64/include/vmm.h +++ b/sys/arm64/include/vmm.h @@ -143,6 +143,37 @@ struct vm_eventinfo { int *iptr; /* reqidle cookie */ }; +#define DECLARE_VMMOPS_FUNC(ret_type, opname, args) \ + ret_type vmmops_##opname args + +DECLARE_VMMOPS_FUNC(int, modinit, (int ipinum)); +DECLARE_VMMOPS_FUNC(int, modcleanup, (void)); +DECLARE_VMMOPS_FUNC(void *, init, (struct vm *vm, struct pmap *pmap)); +DECLARE_VMMOPS_FUNC(int, gla2gpa, (void *vcpui, struct vm_guest_paging *paging, + uint64_t gla, int prot, uint64_t *gpa, int *is_fault)); +DECLARE_VMMOPS_FUNC(int, run, (void *vcpui, register_t pc, struct pmap *pmap, + struct vm_eventinfo *info)); +DECLARE_VMMOPS_FUNC(void, cleanup, (void *vmi)); +DECLARE_VMMOPS_FUNC(void *, vcpu_init, (void *vmi, struct vcpu *vcpu, + int vcpu_id)); +DECLARE_VMMOPS_FUNC(void, vcpu_cleanup, (void *vcpui)); +DECLARE_VMMOPS_FUNC(int, exception, (void *vcpui, uint64_t esr, uint64_t far)); +DECLARE_VMMOPS_FUNC(int, getreg, (void *vcpui, int num, uint64_t *retval)); +DECLARE_VMMOPS_FUNC(int, setreg, (void *vcpui, int num, uint64_t val)); +DECLARE_VMMOPS_FUNC(int, getcap, (void *vcpui, int num, int *retval)); +DECLARE_VMMOPS_FUNC(int, setcap, (void *vcpui, int num, int val)); +DECLARE_VMMOPS_FUNC(struct vmspace *, vmspace_alloc, (vm_offset_t min, + vm_offset_t max)); +DECLARE_VMMOPS_FUNC(void, vmspace_free, (struct vmspace *vmspace)); +#ifdef notyet +#ifdef BHYVE_SNAPSHOT +DECLARE_VMMOPS_FUNC(int, snapshot, (void *vmi, struct vm_snapshot_meta *meta)); +DECLARE_VMMOPS_FUNC(int, vcpu_snapshot, (void *vcpui, + struct vm_snapshot_meta *meta)); +DECLARE_VMMOPS_FUNC(int, restore_tsc, (void *vcpui, uint64_t now)); +#endif +#endif + int vm_create(const char *name, struct vm **retvm); struct vcpu *vm_alloc_vcpu(struct vm *vm, int vcpuid); void vm_disable_vcpu_creation(struct vm *vm); @@ -232,7 +263,6 @@ vcpu_should_yield(struct vcpu *vcpu) void *vcpu_stats(struct vcpu *vcpu); void vcpu_notify_event(struct vcpu *vcpu); -struct vmspace *vm_vmspace(struct vm *vm); struct vm_mem *vm_mem(struct vm *vm); enum vm_reg_name vm_segment_name(int seg_encoding); diff --git a/sys/arm64/vmm/arm64.h b/sys/arm64/vmm/arm64.h index f9b74aef7188..f530dab05331 100644 --- a/sys/arm64/vmm/arm64.h +++ b/sys/arm64/vmm/arm64.h @@ -136,37 +136,6 @@ struct hyp { struct hypctx *ctx[]; }; -#define DEFINE_VMMOPS_IFUNC(ret_type, opname, args) \ - ret_type vmmops_##opname args; - -DEFINE_VMMOPS_IFUNC(int, modinit, (int ipinum)) -DEFINE_VMMOPS_IFUNC(int, modcleanup, (void)) -DEFINE_VMMOPS_IFUNC(void *, init, (struct vm *vm, struct pmap *pmap)) -DEFINE_VMMOPS_IFUNC(int, gla2gpa, (void *vcpui, struct vm_guest_paging *paging, - uint64_t gla, int prot, uint64_t *gpa, int *is_fault)) -DEFINE_VMMOPS_IFUNC(int, run, (void *vcpui, register_t pc, struct pmap *pmap, - struct vm_eventinfo *info)) -DEFINE_VMMOPS_IFUNC(void, cleanup, (void *vmi)) -DEFINE_VMMOPS_IFUNC(void *, vcpu_init, (void *vmi, struct vcpu *vcpu, - int vcpu_id)) -DEFINE_VMMOPS_IFUNC(void, vcpu_cleanup, (void *vcpui)) -DEFINE_VMMOPS_IFUNC(int, exception, (void *vcpui, uint64_t esr, uint64_t far)) -DEFINE_VMMOPS_IFUNC(int, getreg, (void *vcpui, int num, uint64_t *retval)) -DEFINE_VMMOPS_IFUNC(int, setreg, (void *vcpui, int num, uint64_t val)) -DEFINE_VMMOPS_IFUNC(int, getcap, (void *vcpui, int num, int *retval)) -DEFINE_VMMOPS_IFUNC(int, setcap, (void *vcpui, int num, int val)) -DEFINE_VMMOPS_IFUNC(struct vmspace *, vmspace_alloc, (vm_offset_t min, - vm_offset_t max)) -DEFINE_VMMOPS_IFUNC(void, vmspace_free, (struct vmspace *vmspace)) -#ifdef notyet -#ifdef BHYVE_SNAPSHOT -DEFINE_VMMOPS_IFUNC(int, snapshot, (void *vmi, struct vm_snapshot_meta *meta)) -DEFINE_VMMOPS_IFUNC(int, vcpu_snapshot, (void *vcpui, - struct vm_snapshot_meta *meta)) -DEFINE_VMMOPS_IFUNC(int, restore_tsc, (void *vcpui, uint64_t now)) -#endif -#endif - uint64_t vmm_call_hyp(uint64_t, ...); #if 0 diff --git a/sys/arm64/vmm/vmm.c b/sys/arm64/vmm/vmm.c index a551a2807183..aeda689f3b1a 100644 --- a/sys/arm64/vmm/vmm.c +++ b/sys/arm64/vmm/vmm.c @@ -88,7 +88,6 @@ struct vcpu { struct vfpstate *guestfpu; /* (a,i) guest fpu state */ }; -#define vcpu_lock_initialized(v) mtx_initialized(&((v)->mtx)) #define vcpu_lock_init(v) mtx_init(&((v)->mtx), "vcpu lock", 0, MTX_SPIN) #define vcpu_lock_destroy(v) mtx_destroy(&((v)->mtx)) #define vcpu_lock(v) mtx_lock_spin(&((v)->mtx)) @@ -126,7 +125,6 @@ struct vm { bool dying; /* (o) is dying */ volatile cpuset_t suspended_cpus; /* (i) suspended vcpus */ volatile cpuset_t halted_cpus; /* (x) cpus in a hard halt */ - struct vmspace *vmspace; /* (o) guest's address space */ struct vm_mem mem; /* (i) guest memory */ char name[VM_MAX_NAMELEN]; /* (o) virtual machine name */ struct vcpu **vcpu; /* (i) guest vcpus */ @@ -274,6 +272,7 @@ vcpu_cleanup(struct vcpu *vcpu, bool destroy) vmm_stat_free(vcpu->stats); fpu_save_area_free(vcpu->guestfpu); vcpu_lock_destroy(vcpu); + free(vcpu, M_VMM); } } @@ -407,7 +406,7 @@ vm_init(struct vm *vm, bool create) { int i; - vm->cookie = vmmops_init(vm, vmspace_pmap(vm->vmspace)); + vm->cookie = vmmops_init(vm, vmspace_pmap(vm_vmspace(vm))); MPASS(vm->cookie != NULL); CPU_ZERO(&vm->active_cpus); @@ -485,7 +484,7 @@ int vm_create(const char *name, struct vm **retvm) { struct vm *vm; - struct vmspace *vmspace; + int error; /* * If vmm.ko could not be successfully initialized then don't attempt @@ -497,14 +496,13 @@ vm_create(const char *name, struct vm **retvm) if (name == NULL || strlen(name) >= VM_MAX_NAMELEN) return (EINVAL); - vmspace = vmmops_vmspace_alloc(0, 1ul << 39); - if (vmspace == NULL) - return (ENOMEM); - vm = malloc(sizeof(struct vm), M_VMM, M_WAITOK | M_ZERO); + error = vm_mem_init(&vm->mem, 0, 1ul << 39); + if (error != 0) { + free(vm, M_VMM); + return (error); + } strcpy(vm->name, name); - vm->vmspace = vmspace; - vm_mem_init(&vm->mem); sx_init(&vm->vcpus_init_lock, "vm vcpus"); vm->sockets = 1; @@ -558,7 +556,7 @@ vm_cleanup(struct vm *vm, bool destroy) if (destroy) { vm_xlock_memsegs(vm); - pmap = vmspace_pmap(vm->vmspace); + pmap = vmspace_pmap(vm_vmspace(vm)); sched_pin(); PCPU_SET(curvmpmap, NULL); sched_unpin(); @@ -582,11 +580,6 @@ vm_cleanup(struct vm *vm, bool destroy) if (destroy) { vm_mem_destroy(vm); - vmmops_vmspace_free(vm->vmspace); - vm->vmspace = NULL; - - for (i = 0; i < vm->maxcpus; i++) - free(vm->vcpu[i], M_VMM); free(vm->vcpu, M_VMM); sx_destroy(&vm->vcpus_init_lock); } @@ -1090,12 +1083,6 @@ vcpu_notify_event(struct vcpu *vcpu) vcpu_unlock(vcpu); } -struct vmspace * -vm_vmspace(struct vm *vm) -{ - return (vm->vmspace); -} - struct vm_mem * vm_mem(struct vm *vm) { @@ -1416,7 +1403,7 @@ vm_handle_paging(struct vcpu *vcpu, bool *retu) vme = &vcpu->exitinfo; - pmap = vmspace_pmap(vcpu->vm->vmspace); + pmap = vmspace_pmap(vm_vmspace(vcpu->vm)); addr = vme->u.paging.gpa; esr = vme->u.paging.esr; @@ -1433,7 +1420,7 @@ vm_handle_paging(struct vcpu *vcpu, bool *retu) panic("%s: Invalid exception (esr = %lx)", __func__, esr); } - map = &vm->vmspace->vm_map; + map = &vm_vmspace(vm)->vm_map; rv = vm_fault(map, vme->u.paging.gpa, ftype, VM_FAULT_NORMAL, NULL); if (rv != KERN_SUCCESS) return (EFAULT); @@ -1507,7 +1494,7 @@ vm_run(struct vcpu *vcpu) if (CPU_ISSET(vcpuid, &vm->suspended_cpus)) return (EINVAL); - pmap = vmspace_pmap(vm->vmspace); + pmap = vmspace_pmap(vm_vmspace(vm)); vme = &vcpu->exitinfo; evinfo.rptr = NULL; evinfo.sptr = &vm->suspend; diff --git a/sys/conf/dtb.build.mk b/sys/conf/dtb.build.mk index 327d69106244..7eb0db5e8b80 100644 --- a/sys/conf/dtb.build.mk +++ b/sys/conf/dtb.build.mk @@ -1,7 +1,3 @@ - -.include <bsd.init.mk> -# Grab all the options for a kernel build. For backwards compat, we need to -# do this after bsd.own.mk. .include "kern.opts.mk" DTC?= dtc diff --git a/sys/conf/kern.opts.mk b/sys/conf/kern.opts.mk index 045e55d1b19a..cef4dd11ba58 100644 --- a/sys/conf/kern.opts.mk +++ b/sys/conf/kern.opts.mk @@ -4,6 +4,7 @@ # parts to omit (eg CDDL or SOURCELESS_HOST). Some of these will cause # config.mk to define symbols in various opt_*.h files. + # # Define MK_* variables (which are either "yes" or "no") for users # to set via WITH_*/WITHOUT_* in /etc/src.conf and override in the @@ -13,17 +14,12 @@ # that haven't been converted over. # -# Note: bsd.own.mk must be included before the rest of kern.opts.mk to make -# building on 10.x and earlier work. This should be removed when that's no -# longer supported since it confounds the defaults (since it uses the host's -# notion of defaults rather than what's default in current when building -# within sys/modules). -.include <bsd.own.mk> - # These options are used by the kernel build process (kern.mk and kmod.mk) # They have to be listed here so we can build modules outside of the # src tree. +.include <bsd.init.mk> + KLDXREF_CMD?= kldxref __DEFAULT_YES_OPTIONS = \ diff --git a/sys/contrib/openzfs/module/os/freebsd/zfs/sysctl_os.c b/sys/contrib/openzfs/module/os/freebsd/zfs/sysctl_os.c index 393bfaa65ff5..ace2360c032d 100644 --- a/sys/contrib/openzfs/module/os/freebsd/zfs/sysctl_os.c +++ b/sys/contrib/openzfs/module/os/freebsd/zfs/sysctl_os.c @@ -188,6 +188,11 @@ param_set_arc_max(SYSCTL_HANDLER_ARGS) return (0); } +SYSCTL_PROC(_vfs_zfs, OID_AUTO, arc_max, + CTLTYPE_ULONG | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, + NULL, 0, param_set_arc_max, "LU", + "Maximum ARC size in bytes (LEGACY)"); + int param_set_arc_min(SYSCTL_HANDLER_ARGS) { @@ -212,6 +217,11 @@ param_set_arc_min(SYSCTL_HANDLER_ARGS) return (0); } +SYSCTL_PROC(_vfs_zfs, OID_AUTO, arc_min, + CTLTYPE_ULONG | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, + NULL, 0, param_set_arc_min, "LU", + "Minimum ARC size in bytes (LEGACY)"); + extern uint_t zfs_arc_free_target; int @@ -235,6 +245,16 @@ param_set_arc_free_target(SYSCTL_HANDLER_ARGS) return (0); } +/* + * NOTE: This sysctl is CTLFLAG_RW not CTLFLAG_RWTUN due to its dependency on + * pagedaemon initialization. + */ +SYSCTL_PROC(_vfs_zfs, OID_AUTO, arc_free_target, + CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, + NULL, 0, param_set_arc_free_target, "IU", + "Desired number of free pages below which ARC triggers reclaim" + " (LEGACY)"); + int param_set_arc_no_grow_shift(SYSCTL_HANDLER_ARGS) { @@ -253,6 +273,187 @@ param_set_arc_no_grow_shift(SYSCTL_HANDLER_ARGS) return (0); } +SYSCTL_PROC(_vfs_zfs, OID_AUTO, arc_no_grow_shift, + CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, + NULL, 0, param_set_arc_no_grow_shift, "I", + "log2(fraction of ARC which must be free to allow growing) (LEGACY)"); + +extern uint64_t l2arc_write_max; + +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_write_max, + CTLFLAG_RWTUN, &l2arc_write_max, 0, + "Max write bytes per interval (LEGACY)"); + +extern uint64_t l2arc_write_boost; + +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_write_boost, + CTLFLAG_RWTUN, &l2arc_write_boost, 0, + "Extra write bytes during device warmup (LEGACY)"); + +extern uint64_t l2arc_headroom; + +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_headroom, + CTLFLAG_RWTUN, &l2arc_headroom, 0, + "Number of max device writes to precache (LEGACY)"); + +extern uint64_t l2arc_headroom_boost; + +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_headroom_boost, + CTLFLAG_RWTUN, &l2arc_headroom_boost, 0, + "Compressed l2arc_headroom multiplier (LEGACY)"); + +extern uint64_t l2arc_feed_secs; + +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_feed_secs, + CTLFLAG_RWTUN, &l2arc_feed_secs, 0, + "Seconds between L2ARC writing (LEGACY)"); + +extern uint64_t l2arc_feed_min_ms; + +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_feed_min_ms, + CTLFLAG_RWTUN, &l2arc_feed_min_ms, 0, + "Min feed interval in milliseconds (LEGACY)"); + +extern int l2arc_noprefetch; + +SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_noprefetch, + CTLFLAG_RWTUN, &l2arc_noprefetch, 0, + "Skip caching prefetched buffers (LEGACY)"); + +extern int l2arc_feed_again; + +SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_feed_again, + CTLFLAG_RWTUN, &l2arc_feed_again, 0, + "Turbo L2ARC warmup (LEGACY)"); + +extern int l2arc_norw; + +SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_norw, + CTLFLAG_RWTUN, &l2arc_norw, 0, + "No reads during writes (LEGACY)"); + +static int +param_get_arc_state_size(SYSCTL_HANDLER_ARGS) +{ + arc_state_t *state = (arc_state_t *)arg1; + int64_t val; + + val = zfs_refcount_count(&state->arcs_size[ARC_BUFC_DATA]) + + zfs_refcount_count(&state->arcs_size[ARC_BUFC_METADATA]); + return (sysctl_handle_64(oidp, &val, 0, req)); +} + +extern arc_state_t ARC_anon; + +SYSCTL_PROC(_vfs_zfs, OID_AUTO, anon_size, + CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_MPSAFE, + &ARC_anon, 0, param_get_arc_state_size, "Q", + "size of anonymous state"); +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, anon_metadata_esize, CTLFLAG_RD, + &ARC_anon.arcs_esize[ARC_BUFC_METADATA].rc_count, 0, + "size of evictable metadata in anonymous state"); +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, anon_data_esize, CTLFLAG_RD, + &ARC_anon.arcs_esize[ARC_BUFC_DATA].rc_count, 0, + "size of evictable data in anonymous state"); + +extern arc_state_t ARC_mru; + +SYSCTL_PROC(_vfs_zfs, OID_AUTO, mru_size, + CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_MPSAFE, + &ARC_mru, 0, param_get_arc_state_size, "Q", + "size of mru state"); +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_metadata_esize, CTLFLAG_RD, + &ARC_mru.arcs_esize[ARC_BUFC_METADATA].rc_count, 0, + "size of evictable metadata in mru state"); +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_data_esize, CTLFLAG_RD, + &ARC_mru.arcs_esize[ARC_BUFC_DATA].rc_count, 0, + "size of evictable data in mru state"); + +extern arc_state_t ARC_mru_ghost; + +SYSCTL_PROC(_vfs_zfs, OID_AUTO, mru_ghost_size, + CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_MPSAFE, + &ARC_mru_ghost, 0, param_get_arc_state_size, "Q", + "size of mru ghost state"); +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_ghost_metadata_esize, CTLFLAG_RD, + &ARC_mru_ghost.arcs_esize[ARC_BUFC_METADATA].rc_count, 0, + "size of evictable metadata in mru ghost state"); +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_ghost_data_esize, CTLFLAG_RD, + &ARC_mru_ghost.arcs_esize[ARC_BUFC_DATA].rc_count, 0, + "size of evictable data in mru ghost state"); + +extern arc_state_t ARC_mfu; + +SYSCTL_PROC(_vfs_zfs, OID_AUTO, mfu_size, + CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_MPSAFE, + &ARC_mfu, 0, param_get_arc_state_size, "Q", + "size of mfu state"); +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_metadata_esize, CTLFLAG_RD, + &ARC_mfu.arcs_esize[ARC_BUFC_METADATA].rc_count, 0, + "size of evictable metadata in mfu state"); +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_data_esize, CTLFLAG_RD, + &ARC_mfu.arcs_esize[ARC_BUFC_DATA].rc_count, 0, + "size of evictable data in mfu state"); + +extern arc_state_t ARC_mfu_ghost; + +SYSCTL_PROC(_vfs_zfs, OID_AUTO, mfu_ghost_size, + CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_MPSAFE, + &ARC_mfu_ghost, 0, param_get_arc_state_size, "Q", + "size of mfu ghost state"); +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_ghost_metadata_esize, CTLFLAG_RD, + &ARC_mfu_ghost.arcs_esize[ARC_BUFC_METADATA].rc_count, 0, + "size of evictable metadata in mfu ghost state"); +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_ghost_data_esize, CTLFLAG_RD, + &ARC_mfu_ghost.arcs_esize[ARC_BUFC_DATA].rc_count, 0, + "size of evictable data in mfu ghost state"); + +extern arc_state_t ARC_uncached; + +SYSCTL_PROC(_vfs_zfs, OID_AUTO, uncached_size, + CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_MPSAFE, + &ARC_uncached, 0, param_get_arc_state_size, "Q", + "size of uncached state"); +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, uncached_metadata_esize, CTLFLAG_RD, + &ARC_uncached.arcs_esize[ARC_BUFC_METADATA].rc_count, 0, + "size of evictable metadata in uncached state"); +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, uncached_data_esize, CTLFLAG_RD, + &ARC_uncached.arcs_esize[ARC_BUFC_DATA].rc_count, 0, + "size of evictable data in uncached state"); + +extern arc_state_t ARC_l2c_only; + +SYSCTL_PROC(_vfs_zfs, OID_AUTO, l2c_only_size, + CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_MPSAFE, + &ARC_l2c_only, 0, param_get_arc_state_size, "Q", + "size of l2c_only state"); + +/* dbuf.c */ + +/* dmu.c */ + +/* dmu_zfetch.c */ + +SYSCTL_NODE(_vfs_zfs, OID_AUTO, zfetch, CTLFLAG_RW, 0, "ZFS ZFETCH (LEGACY)"); + +extern uint32_t zfetch_max_distance; + +SYSCTL_UINT(_vfs_zfs_zfetch, OID_AUTO, max_distance, + CTLFLAG_RWTUN, &zfetch_max_distance, 0, + "Max bytes to prefetch per stream (LEGACY)"); + +extern uint32_t zfetch_max_idistance; + +SYSCTL_UINT(_vfs_zfs_zfetch, OID_AUTO, max_idistance, + CTLFLAG_RWTUN, &zfetch_max_idistance, 0, + "Max bytes to prefetch indirects for per stream (LEGACY)"); + +/* dsl_pool.c */ + +/* dnode.c */ + +/* dsl_scan.c */ + /* metaslab.c */ int @@ -313,6 +514,19 @@ SYSCTL_UINT(_vfs_zfs, OID_AUTO, condense_pct, "Condense on-disk spacemap when it is more than this many percents" " of in-memory counterpart"); +extern uint_t zfs_remove_max_segment; + +SYSCTL_UINT(_vfs_zfs, OID_AUTO, remove_max_segment, + CTLFLAG_RWTUN, &zfs_remove_max_segment, 0, + "Largest contiguous segment ZFS will attempt to allocate when removing" + " a device"); + +extern int zfs_removal_suspend_progress; + +SYSCTL_INT(_vfs_zfs, OID_AUTO, removal_suspend_progress, + CTLFLAG_RWTUN, &zfs_removal_suspend_progress, 0, + "Ensures certain actions can happen while in the middle of a removal"); + /* * Minimum size which forces the dynamic allocator to change * it's allocation strategy. Once the space map cannot satisfy @@ -535,6 +749,12 @@ param_set_min_auto_ashift(SYSCTL_HANDLER_ARGS) return (0); } +SYSCTL_PROC(_vfs_zfs, OID_AUTO, min_auto_ashift, + CTLTYPE_UINT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, + &zfs_vdev_min_auto_ashift, sizeof (zfs_vdev_min_auto_ashift), + param_set_min_auto_ashift, "IU", + "Min ashift used when creating new top-level vdev. (LEGACY)"); + int param_set_max_auto_ashift(SYSCTL_HANDLER_ARGS) { @@ -554,6 +774,13 @@ param_set_max_auto_ashift(SYSCTL_HANDLER_ARGS) return (0); } +SYSCTL_PROC(_vfs_zfs, OID_AUTO, max_auto_ashift, + CTLTYPE_UINT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, + &zfs_vdev_max_auto_ashift, sizeof (zfs_vdev_max_auto_ashift), + param_set_max_auto_ashift, "IU", + "Max ashift used when optimizing for logical -> physical sector size on" + " new top-level vdevs. (LEGACY)"); + /* * Since the DTL space map of a vdev is not expected to have a lot of * entries, we default its block size to 4K. @@ -575,6 +802,23 @@ SYSCTL_INT(_vfs_zfs, OID_AUTO, standard_sm_blksz, CTLFLAG_RDTUN, &zfs_vdev_standard_sm_blksz, 0, "Block size for standard space map. Power of 2 greater than 4096."); +extern int vdev_validate_skip; + +SYSCTL_INT(_vfs_zfs, OID_AUTO, validate_skip, + CTLFLAG_RDTUN, &vdev_validate_skip, 0, + "Enable to bypass vdev_validate()."); + +/* vdev_mirror.c */ + +/* vdev_queue.c */ + +extern uint_t zfs_vdev_max_active; + +SYSCTL_UINT(_vfs_zfs, OID_AUTO, top_maxinflight, + CTLFLAG_RWTUN, &zfs_vdev_max_active, 0, + "The maximum number of I/Os of all types active for each device." + " (LEGACY)"); + /* zio.c */ SYSCTL_INT(_vfs_zfs_zio, OID_AUTO, exclude_metadata, diff --git a/sys/contrib/openzfs/module/zfs/arc.c b/sys/contrib/openzfs/module/zfs/arc.c index 591e2dade59e..b677f90280d7 100644 --- a/sys/contrib/openzfs/module/zfs/arc.c +++ b/sys/contrib/openzfs/module/zfs/arc.c @@ -486,13 +486,13 @@ static taskq_t *arc_flush_taskq; static uint_t zfs_arc_evict_threads = 0; /* The 7 states: */ -static arc_state_t ARC_anon; -/* */ arc_state_t ARC_mru; -static arc_state_t ARC_mru_ghost; -/* */ arc_state_t ARC_mfu; -static arc_state_t ARC_mfu_ghost; -static arc_state_t ARC_l2c_only; -static arc_state_t ARC_uncached; +arc_state_t ARC_anon; +arc_state_t ARC_mru; +arc_state_t ARC_mru_ghost; +arc_state_t ARC_mfu; +arc_state_t ARC_mfu_ghost; +arc_state_t ARC_l2c_only; +arc_state_t ARC_uncached; arc_stats_t arc_stats = { { "hits", KSTAT_DATA_UINT64 }, @@ -832,15 +832,15 @@ typedef struct arc_async_flush { #define L2ARC_FEED_TYPES 4 /* L2ARC Performance Tunables */ -static uint64_t l2arc_write_max = L2ARC_WRITE_SIZE; /* def max write size */ -static uint64_t l2arc_write_boost = L2ARC_WRITE_SIZE; /* extra warmup write */ -static uint64_t l2arc_headroom = L2ARC_HEADROOM; /* # of dev writes */ -static uint64_t l2arc_headroom_boost = L2ARC_HEADROOM_BOOST; -static uint64_t l2arc_feed_secs = L2ARC_FEED_SECS; /* interval seconds */ -static uint64_t l2arc_feed_min_ms = L2ARC_FEED_MIN_MS; /* min interval msecs */ -static int l2arc_noprefetch = B_TRUE; /* don't cache prefetch bufs */ -static int l2arc_feed_again = B_TRUE; /* turbo warmup */ -static int l2arc_norw = B_FALSE; /* no reads during writes */ +uint64_t l2arc_write_max = L2ARC_WRITE_SIZE; /* def max write size */ +uint64_t l2arc_write_boost = L2ARC_WRITE_SIZE; /* extra warmup write */ +uint64_t l2arc_headroom = L2ARC_HEADROOM; /* # of dev writes */ +uint64_t l2arc_headroom_boost = L2ARC_HEADROOM_BOOST; +uint64_t l2arc_feed_secs = L2ARC_FEED_SECS; /* interval seconds */ +uint64_t l2arc_feed_min_ms = L2ARC_FEED_MIN_MS; /* min interval msecs */ +int l2arc_noprefetch = B_TRUE; /* don't cache prefetch bufs */ +int l2arc_feed_again = B_TRUE; /* turbo warmup */ +int l2arc_norw = B_FALSE; /* no reads during writes */ static uint_t l2arc_meta_percent = 33; /* limit on headers size */ /* diff --git a/sys/contrib/openzfs/module/zfs/dmu_zfetch.c b/sys/contrib/openzfs/module/zfs/dmu_zfetch.c index 3d3a9c713568..51165d0bf723 100644 --- a/sys/contrib/openzfs/module/zfs/dmu_zfetch.c +++ b/sys/contrib/openzfs/module/zfs/dmu_zfetch.c @@ -57,19 +57,19 @@ static unsigned int zfetch_max_sec_reap = 2; /* min bytes to prefetch per stream (default 2MB) */ static unsigned int zfetch_min_distance = 2 * 1024 * 1024; /* max bytes to prefetch per stream (default 8MB) */ -static unsigned int zfetch_max_distance = 8 * 1024 * 1024; +unsigned int zfetch_max_distance = 8 * 1024 * 1024; #else /* min bytes to prefetch per stream (default 4MB) */ static unsigned int zfetch_min_distance = 4 * 1024 * 1024; /* max bytes to prefetch per stream (default 64MB) */ -static unsigned int zfetch_max_distance = 64 * 1024 * 1024; +unsigned int zfetch_max_distance = 64 * 1024 * 1024; #endif /* max bytes to prefetch indirects for per stream (default 128MB) */ -static unsigned int zfetch_max_idistance = 128 * 1024 * 1024; +unsigned int zfetch_max_idistance = 128 * 1024 * 1024; /* max request reorder distance within a stream (default 16MB) */ -static unsigned int zfetch_max_reorder = 16 * 1024 * 1024; +unsigned int zfetch_max_reorder = 16 * 1024 * 1024; /* Max log2 fraction of holes in a stream */ -static unsigned int zfetch_hole_shift = 2; +unsigned int zfetch_hole_shift = 2; typedef struct zfetch_stats { kstat_named_t zfetchstat_hits; diff --git a/sys/contrib/openzfs/module/zfs/vdev.c b/sys/contrib/openzfs/module/zfs/vdev.c index 654e034de9e1..c8d7280387a2 100644 --- a/sys/contrib/openzfs/module/zfs/vdev.c +++ b/sys/contrib/openzfs/module/zfs/vdev.c @@ -100,7 +100,7 @@ static uint_t zfs_vdev_default_ms_shift = 29; /* upper limit for metaslab size (16G) */ static uint_t zfs_vdev_max_ms_shift = 34; -static int vdev_validate_skip = B_FALSE; +int vdev_validate_skip = B_FALSE; /* * Since the DTL space map of a vdev is not expected to have a lot of diff --git a/sys/contrib/openzfs/module/zfs/vdev_queue.c b/sys/contrib/openzfs/module/zfs/vdev_queue.c index e69e5598939e..c12713b107bf 100644 --- a/sys/contrib/openzfs/module/zfs/vdev_queue.c +++ b/sys/contrib/openzfs/module/zfs/vdev_queue.c @@ -122,7 +122,7 @@ * The maximum number of i/os active to each device. Ideally, this will be >= * the sum of each queue's max_active. */ -static uint_t zfs_vdev_max_active = 1000; +uint_t zfs_vdev_max_active = 1000; /* * Per-queue limits on the number of i/os active to each device. If the diff --git a/sys/contrib/openzfs/module/zfs/vdev_removal.c b/sys/contrib/openzfs/module/zfs/vdev_removal.c index 2ce0121324ad..2f7a739da241 100644 --- a/sys/contrib/openzfs/module/zfs/vdev_removal.c +++ b/sys/contrib/openzfs/module/zfs/vdev_removal.c @@ -105,7 +105,7 @@ static const uint_t zfs_remove_max_copy_bytes = 64 * 1024 * 1024; * * See also the accessor function spa_remove_max_segment(). */ -static uint_t zfs_remove_max_segment = SPA_MAXBLOCKSIZE; +uint_t zfs_remove_max_segment = SPA_MAXBLOCKSIZE; /* * Ignore hard IO errors during device removal. When set if a device @@ -137,7 +137,7 @@ uint_t vdev_removal_max_span = 32 * 1024; * This is used by the test suite so that it can ensure that certain * actions happen while in the middle of a removal. */ -static int zfs_removal_suspend_progress = 0; +int zfs_removal_suspend_progress = 0; #define VDEV_REMOVAL_ZAP_OBJS "lzap" diff --git a/sys/contrib/openzfs/tests/zfs-tests/include/tunables.cfg b/sys/contrib/openzfs/tests/zfs-tests/include/tunables.cfg index 54b50c9dba77..127ea188f17f 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/include/tunables.cfg +++ b/sys/contrib/openzfs/tests/zfs-tests/include/tunables.cfg @@ -76,8 +76,8 @@ READ_SIT_OUT_SECS vdev.read_sit_out_secs vdev_read_sit_out_secs SIT_OUT_CHECK_INTERVAL vdev.raidz_outlier_check_interval_ms vdev_raidz_outlier_check_interval_ms SIT_OUT_INSENSITIVITY vdev.raidz_outlier_insensitivity vdev_raidz_outlier_insensitivity REBUILD_SCRUB_ENABLED rebuild_scrub_enabled zfs_rebuild_scrub_enabled -REMOVAL_SUSPEND_PROGRESS vdev.removal_suspend_progress zfs_removal_suspend_progress -REMOVE_MAX_SEGMENT vdev.remove_max_segment zfs_remove_max_segment +REMOVAL_SUSPEND_PROGRESS removal_suspend_progress zfs_removal_suspend_progress +REMOVE_MAX_SEGMENT remove_max_segment zfs_remove_max_segment RESILVER_MIN_TIME_MS resilver_min_time_ms zfs_resilver_min_time_ms RESILVER_DEFER_PERCENT resilver_defer_percent zfs_resilver_defer_percent SCAN_LEGACY scan_legacy zfs_scan_legacy diff --git a/sys/dev/ice/ice_common.c b/sys/dev/ice/ice_common.c index ad4ea4c8e7a1..b895f661bc46 100644 --- a/sys/dev/ice/ice_common.c +++ b/sys/dev/ice/ice_common.c @@ -213,6 +213,15 @@ int ice_set_mac_type(struct ice_hw *hw) case ICE_DEV_ID_E830_L_QSFP: case ICE_DEV_ID_E830C_SFP: case ICE_DEV_ID_E830_L_SFP: + case ICE_DEV_ID_E835CC_BACKPLANE: + case ICE_DEV_ID_E835CC_QSFP56: + case ICE_DEV_ID_E835CC_SFP: + case ICE_DEV_ID_E835C_BACKPLANE: + case ICE_DEV_ID_E835C_QSFP: + case ICE_DEV_ID_E835C_SFP: + case ICE_DEV_ID_E835_L_BACKPLANE: + case ICE_DEV_ID_E835_L_QSFP: + case ICE_DEV_ID_E835_L_SFP: hw->mac_type = ICE_MAC_E830; break; default: diff --git a/sys/dev/ice/ice_devids.h b/sys/dev/ice/ice_devids.h index 3f91e9dfbcaf..74712c61ae8e 100644 --- a/sys/dev/ice/ice_devids.h +++ b/sys/dev/ice/ice_devids.h @@ -62,6 +62,24 @@ #define ICE_DEV_ID_E830C_SFP 0x12DA /* Intel(R) Ethernet Controller E830-L for SFP */ #define ICE_DEV_ID_E830_L_SFP 0x12DE +/* Intel(R) Ethernet Controller E835-CC for backplane */ +#define ICE_DEV_ID_E835CC_BACKPLANE 0x1248 +/* Intel(R) Ethernet Controller E835-CC for QSFP */ +#define ICE_DEV_ID_E835CC_QSFP56 0x1249 +/* Intel(R) Ethernet Controller E835-CC for SFP */ +#define ICE_DEV_ID_E835CC_SFP 0x124A +/* Intel(R) Ethernet Controller E835-C for backplane */ +#define ICE_DEV_ID_E835C_BACKPLANE 0x1261 +/* Intel(R) Ethernet Controller E835-C for QSFP */ +#define ICE_DEV_ID_E835C_QSFP 0x1262 +/* Intel(R) Ethernet Controller E835-C for SFP */ +#define ICE_DEV_ID_E835C_SFP 0x1263 +/* Intel(R) Ethernet Controller E835-L for backplane */ +#define ICE_DEV_ID_E835_L_BACKPLANE 0x1265 +/* Intel(R) Ethernet Controller E835-L for QSFP */ +#define ICE_DEV_ID_E835_L_QSFP 0x1266 +/* Intel(R) Ethernet Controller E835-L for SFP */ +#define ICE_DEV_ID_E835_L_SFP 0x1267 /* Intel(R) Ethernet Controller E810-C for backplane */ #define ICE_DEV_ID_E810C_BACKPLANE 0x1591 /* Intel(R) Ethernet Controller E810-C for QSFP */ diff --git a/sys/dev/ice/ice_drv_info.h b/sys/dev/ice/ice_drv_info.h index 2a51a7394424..46965f4124bc 100644 --- a/sys/dev/ice/ice_drv_info.h +++ b/sys/dev/ice/ice_drv_info.h @@ -218,6 +218,45 @@ static const pci_vendor_info_t ice_vendor_info_array[] = { "Intel(R) Ethernet Network Adapter E830-XXV-2"), PVIDV(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E830_L_SFP, "Intel(R) Ethernet Connection E830-L for SFP"), + PVIDV(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835CC_BACKPLANE, + "Intel(R) Ethernet Connection E835-CC for backplane"), + PVIDV_OEM(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835CC_QSFP56, + ICE_INTEL_VENDOR_ID, 0x0001, 0, + "Intel(R) Ethernet Network Adapter E835-C-Q2"), + PVIDV_OEM(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835CC_QSFP56, + ICE_INTEL_VENDOR_ID, 0x0002, 0, + "Intel(R) Ethernet Network Adapter E835-C-Q2 for OCP 3.0"), + PVIDV_OEM(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835CC_QSFP56, + ICE_INTEL_VENDOR_ID, 0x0003, 0, + "Intel(R) Ethernet Network Adapter E835-CC-Q1"), + PVIDV_OEM(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835CC_QSFP56, + ICE_INTEL_VENDOR_ID, 0x0004, 0, + "Intel(R) Ethernet Network Adapter E835-CC-Q1 for OCP 3.0"), + PVIDV(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835CC_QSFP56, + "Intel(R) Ethernet Connection E835-CC for QSFP56"), + PVIDV_OEM(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835CC_SFP, + ICE_INTEL_VENDOR_ID, 0x0001, 0, + "Intel(R) Ethernet Network Adapter E835-XXV-2 for OCP 3.0"), + PVIDV_OEM(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835CC_SFP, + ICE_INTEL_VENDOR_ID, 0x0003, 0, + "Intel(R) Ethernet Network Adapter E835-XXV-2"), + PVIDV_OEM(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835CC_SFP, + ICE_INTEL_VENDOR_ID, 0x0004, 0, + "Intel(R) Ethernet Network Adapter E835-XXV-4 for OCP 3.0"), + PVIDV(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835CC_SFP, + "Intel(R) Ethernet Connection E835-CC for SFP"), + PVIDV(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835C_BACKPLANE, + "Intel(R) Ethernet Connection E835-C for backplane"), + PVIDV(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835C_QSFP, + "Intel(R) Ethernet Connection E835-C for QSFP"), + PVIDV(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835C_SFP, + "Intel(R) Ethernet Connection E835-C for SFP"), + PVIDV(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835_L_BACKPLANE, + "Intel(R) Ethernet Connection E835-L for backplane"), + PVIDV(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835_L_QSFP, + "Intel(R) Ethernet Connection E835-L for QSFP"), + PVIDV(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835_L_SFP, + "Intel(R) Ethernet Connection E835-L for SFP"), PVIDV(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E825C_BACKPLANE, "Intel(R) Ethernet Connection E825-C for backplane"), PVIDV(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E825C_QSFP, diff --git a/sys/dev/ixgbe/if_ix.c b/sys/dev/ixgbe/if_ix.c index 6d08bd49bc04..1d36fd11f368 100644 --- a/sys/dev/ixgbe/if_ix.c +++ b/sys/dev/ixgbe/if_ix.c @@ -192,6 +192,8 @@ static int ixgbe_if_i2c_req(if_ctx_t, struct ifi2creq *); static bool ixgbe_if_needs_restart(if_ctx_t, enum iflib_restart_event); int ixgbe_intr(void *); +static int ixgbe_if_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t data); + /************************************************************************ * Function prototypes ************************************************************************/ @@ -239,6 +241,13 @@ static void ixgbe_setup_vlan_hw_support(if_ctx_t); static void ixgbe_config_gpie(struct ixgbe_softc *); static void ixgbe_config_delay_values(struct ixgbe_softc *); +static void ixgbe_add_debug_sysctls(struct ixgbe_softc *sc); +static void ixgbe_add_debug_dump_sysctls(struct ixgbe_softc *sc); +static int ixgbe_debug_dump_ioctl(struct ixgbe_softc *sc, struct ifdrv *ifd); +static u8 ixgbe_debug_dump_print_cluster(struct ixgbe_softc *sc, + struct sbuf *sbuf, u8 cluster_id); +static int ixgbe_nvm_access_ioctl(struct ixgbe_softc *sc, struct ifdrv *ifd); + /* Sysctl handlers */ static int ixgbe_sysctl_flowcntl(SYSCTL_HANDLER_ARGS); static int ixgbe_sysctl_advertise(SYSCTL_HANDLER_ARGS); @@ -260,6 +269,9 @@ static int ixgbe_sysctl_wol_enable(SYSCTL_HANDLER_ARGS); static int ixgbe_sysctl_wufc(SYSCTL_HANDLER_ARGS); static int ixgbe_sysctl_tso_tcp_flags_mask(SYSCTL_HANDLER_ARGS); +static int ixgbe_sysctl_debug_dump_set_clusters(SYSCTL_HANDLER_ARGS); +static int ixgbe_sysctl_dump_debug_dump(SYSCTL_HANDLER_ARGS); + /* Deferred interrupt tasklets */ static void ixgbe_handle_msf(void *); static void ixgbe_handle_mod(void *); @@ -330,6 +342,7 @@ static device_method_t ixgbe_if_methods[] = { DEVMETHOD(ifdi_get_counter, ixgbe_if_get_counter), DEVMETHOD(ifdi_i2c_req, ixgbe_if_i2c_req), DEVMETHOD(ifdi_needs_restart, ixgbe_if_needs_restart), + DEVMETHOD(ifdi_priv_ioctl, ixgbe_if_priv_ioctl), #ifdef PCI_IOV DEVMETHOD(ifdi_iov_init, ixgbe_if_iov_init), DEVMETHOD(ifdi_iov_uninit, ixgbe_if_iov_uninit), @@ -1015,6 +1028,8 @@ ixgbe_if_attach_pre(if_ctx_t ctx) if (hw->mac.type == ixgbe_mac_E610) ixgbe_init_aci(hw); + sc->do_debug_dump = false; + if (hw->mac.ops.fw_recovery_mode && hw->mac.ops.fw_recovery_mode(hw)) { device_printf(dev, @@ -1395,6 +1410,248 @@ ixgbe_if_needs_restart(if_ctx_t ctx __unused, enum iflib_restart_event event) } /************************************************************************ + * ixgbe_if_priv_ioctl - Ioctl handler for driver + * + * Handler for custom driver specific ioctls + * + * return 0 on success, positive on failure + ************************************************************************/ +static int +ixgbe_if_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t data) +{ + struct ixgbe_softc *sc = iflib_get_softc(ctx); + struct ifdrv *ifd; + device_t dev = sc->dev; + + /* Make sure the command type is valid */ + switch (command) { + case SIOCSDRVSPEC: + case SIOCGDRVSPEC: + /* Accepted commands */ + break; + case SIOCGPRIVATE_0: + /* + * Although we do not support this ioctl command, it's expected + * that iflib will forward it to the IFDI_PRIV_IOCTL handler. + * Do not print a message in this case. + */ + return (ENOTSUP); + default: + /* + * If we get a different command for this function, it's + * definitely unexpected, so log a message indicating what + * command we got for debugging purposes. + */ + device_printf(dev, + "%s: unexpected ioctl command %08lx\n", + __func__, command); + return (EINVAL); + } + + ifd = (struct ifdrv *)data; + + switch (ifd->ifd_cmd) { + case IXGBE_NVM_ACCESS: + IOCTL_DEBUGOUT("ioctl: NVM ACCESS"); + return (ixgbe_nvm_access_ioctl(sc, ifd)); + case IXGBE_DEBUG_DUMP: + IOCTL_DEBUGOUT("ioctl: DEBUG DUMP"); + return (ixgbe_debug_dump_ioctl(sc, ifd)); + default: + IOCTL_DEBUGOUT1( + "ioctl: UNKNOWN SIOC(S|G)DRVSPEC (0x%X) command\n", + (int)ifd->ifd_cmd); + return (EINVAL); + } + + return (0); +} + +/************************************************************************ + * ixgbe_nvm_access_ioctl + * + * Handles an NVM access ioctl request + ************************************************************************/ +static int +ixgbe_nvm_access_ioctl(struct ixgbe_softc *sc, struct ifdrv *ifd) +{ + struct ixgbe_nvm_access_data *data; + struct ixgbe_nvm_access_cmd *cmd; + struct ixgbe_hw *hw = &sc->hw; + size_t ifd_len = ifd->ifd_len; + size_t malloc_len; + device_t dev = sc->dev; + u8 *nvm_buffer; + s32 error = 0; + + /* + * ifioctl forwards SIOCxDRVSPEC to iflib without conducting + * a privilege check. Subsequently, iflib passes the ioctl to the driver + * without verifying privileges. To prevent non-privileged threads from + * accessing this interface, perform a privilege check at this point. + */ + error = priv_check(curthread, PRIV_DRIVER); + if (error) + return (error); + + if (ifd_len < sizeof(*cmd)) { + device_printf(dev, + "%s: ifdrv length is too small. Got %zu, " + "but expected %zu\n", + __func__, ifd_len, sizeof(*cmd)); + return (EINVAL); + } + + if (ifd->ifd_data == NULL) { + device_printf(dev, "%s: No ifd data buffer.\n", + __func__); + return (EINVAL); + } + + malloc_len = max(ifd_len, sizeof(*data) + sizeof(*cmd)); + + nvm_buffer = (u8 *)malloc(malloc_len, M_IXGBE, M_ZERO | M_NOWAIT); + if (!nvm_buffer) + return (ENOMEM); + + /* Copy the NVM access command and data in from user space */ + error = copyin(ifd->ifd_data, nvm_buffer, ifd_len); + if (error) { + device_printf(dev, "%s: Failed to copy data in, error: %d\n", + __func__, error); + goto cleanup_free_nvm_buffer; + } + + /* + * The NVM command structure is immediately followed by data which + * varies in size based on the command. + */ + cmd = (struct ixgbe_nvm_access_cmd *)nvm_buffer; + data = (struct ixgbe_nvm_access_data *) + (nvm_buffer + sizeof(struct ixgbe_nvm_access_cmd)); + + /* Handle the NVM access request */ + error = ixgbe_handle_nvm_access(hw, cmd, data); + if (error) { + device_printf(dev, "%s: NVM access request failed, error %d\n", + __func__, error); + } + + /* Copy the possibly modified contents of the handled request out */ + error = copyout(nvm_buffer, ifd->ifd_data, ifd_len); + if (error) { + device_printf(dev, "%s: Copying response back to " + "user space failed, error %d\n", + __func__, error); + goto cleanup_free_nvm_buffer; + } + +cleanup_free_nvm_buffer: + free(nvm_buffer, M_IXGBE); + return (error); +} + +/************************************************************************ + * ixgbe_debug_dump_ioctl + * + * Makes debug dump of internal FW/HW data. + ************************************************************************/ +static int +ixgbe_debug_dump_ioctl(struct ixgbe_softc *sc, struct ifdrv *ifd) +{ + struct ixgbe_debug_dump_cmd *dd_cmd; + struct ixgbe_hw *hw = &sc->hw; + size_t ifd_len = ifd->ifd_len; + device_t dev = sc->dev; + s32 error = 0; + + if (!(sc->feat_en & IXGBE_FEATURE_DBG_DUMP)) + return (ENODEV); + + /* Data returned from ACI command */ + u16 ret_buf_size = 0; + u16 ret_next_cluster = 0; + u16 ret_next_table = 0; + u32 ret_next_index = 0; + + /* + * ifioctl forwards SIOCxDRVSPEC to iflib without conducting + * a privilege check. Subsequently, iflib passes the ioctl to the driver + * without verifying privileges. To prevent non-privileged threads from + * accessing this interface, perform a privilege check at this point. + */ + error = priv_check(curthread, PRIV_DRIVER); + if (error) + return (error); + + if (ifd_len < sizeof(*dd_cmd)) { + device_printf(dev, + "%s: ifdrv length is too small. Got %zu, " + "but expected %zu\n", + __func__, ifd_len, sizeof(*dd_cmd)); + return (EINVAL); + } + + if (ifd->ifd_data == NULL) { + device_printf(dev, "%s: No ifd data buffer.\n", + __func__); + return (EINVAL); + } + + dd_cmd = (struct ixgbe_debug_dump_cmd *)malloc(ifd_len, M_IXGBE, + M_NOWAIT | M_ZERO); + if (!dd_cmd) { + error = -ENOMEM; + goto out; + } + /* copy data from userspace */ + error = copyin(ifd->ifd_data, dd_cmd, ifd_len); + if (error) { + device_printf(dev, "%s: Failed to copy data in, error: %d\n", + __func__, error); + goto out; + } + + /* ACI command requires buf_size arg to be grater than 0 */ + if (dd_cmd->data_size == 0) { + device_printf(dev, "%s: data_size must be greater than 0\n", + __func__); + error = EINVAL; + goto out; + } + + /* Zero the data buffer memory space */ + memset(dd_cmd->data, 0, ifd_len - sizeof(*dd_cmd)); + + error = ixgbe_aci_get_internal_data(hw, dd_cmd->cluster_id, + dd_cmd->table_id, dd_cmd->offset, dd_cmd->data, dd_cmd->data_size, + &ret_buf_size, &ret_next_cluster, &ret_next_table, &ret_next_index); + if (error) { + device_printf(dev, + "%s: Failed to get internal FW/HW data, error: %d\n", + __func__, error); + goto out; + } + + dd_cmd->cluster_id = ret_next_cluster; + dd_cmd->table_id = ret_next_table; + dd_cmd->offset = ret_next_index; + dd_cmd->data_size = ret_buf_size; + + error = copyout(dd_cmd, ifd->ifd_data, ifd->ifd_len); + if (error) { + device_printf(dev, + "%s: Failed to copy data out, error: %d\n", + __func__, error); + } + +out: + free(dd_cmd, M_IXGBE); + + return (error); +} + +/************************************************************************ * ixgbe_add_media_types ************************************************************************/ static void @@ -2883,6 +3140,264 @@ ixgbe_sysctl_interrupt_rate_handler(SYSCTL_HANDLER_ARGS) } /* ixgbe_sysctl_interrupt_rate_handler */ /************************************************************************ + * ixgbe_debug_dump_print_cluster + ************************************************************************/ +static u8 +ixgbe_debug_dump_print_cluster(struct ixgbe_softc *sc, struct sbuf *sbuf, + u8 cluster_id) +{ + u16 data_buf_size = IXGBE_ACI_MAX_BUFFER_SIZE; + device_t dev = sc->dev; + struct ixgbe_hw *hw = &sc->hw; + const u8 reserved_buf[8] = {}; + int max_aci_calls = 1000; + int error, counter = 0; + u8 *data_buf; + + /* Input parameters / loop variables */ + u16 table_id = 0; + u32 offset = 0; + + /* Data returned from ACI command */ + u16 ret_buf_size = 0; + u16 ret_next_cluster = 0; + u16 ret_next_table = 0; + u32 ret_next_index = 0; + + data_buf = (u8 *)malloc(data_buf_size, M_IXGBE, M_NOWAIT | M_ZERO); + if (!data_buf) + return (0); + + DEBUGOUT2("%s: dumping cluster id (relative) %d\n", + __func__, cluster_id); + + do { + DEBUGOUT3("table_id 0x%04x offset 0x%08x buf_size %d\n", + table_id, offset, data_buf_size); + + error = ixgbe_aci_get_internal_data(hw, cluster_id, table_id, + offset, data_buf, data_buf_size, &ret_buf_size, + &ret_next_cluster, &ret_next_table, &ret_next_index); + if (error) { + device_printf(dev, + "%s: Failed to get internal FW/HW data, error: %d, " + "last aci status: %d\n", + __func__, error, hw->aci.last_status); + break; + } + + DEBUGOUT3("ret_table_id 0x%04x ret_offset 0x%08x " + "ret_buf_size %d\n", + ret_next_table, ret_next_index, ret_buf_size); + + /* Print cluster id */ + u32 print_cluster_id = (u32)cluster_id; + sbuf_bcat(sbuf, &print_cluster_id, sizeof(print_cluster_id)); + /* Print table id */ + u32 print_table_id = (u32)table_id; + sbuf_bcat(sbuf, &print_table_id, sizeof(print_table_id)); + /* Print table length */ + u32 print_table_length = (u32)ret_buf_size; + sbuf_bcat(sbuf, &print_table_length, + sizeof(print_table_length)); + /* Print current offset */ + u32 print_curr_offset = offset; + sbuf_bcat(sbuf, &print_curr_offset, sizeof(print_curr_offset)); + /* Print reserved bytes */ + sbuf_bcat(sbuf, reserved_buf, sizeof(reserved_buf)); + /* Print data */ + sbuf_bcat(sbuf, data_buf, ret_buf_size); + + /* Prepare for the next loop spin */ + memset(data_buf, 0, data_buf_size); + + bool last_index = (ret_next_index == 0xffffffff); + bool last_table = ((ret_next_table == 0xff || + ret_next_table == 0xffff) && + last_index); + + if (last_table) { + /* End of the cluster */ + DEBUGOUT1("End of the cluster ID %d\n", cluster_id); + break; + } else if (last_index) { + /* End of the table */ + table_id = ret_next_table; + offset = 0; + } else { + /* More data left in the table */ + offset = ret_next_index; + } + } while (++counter < max_aci_calls); + + if (counter >= max_aci_calls) + device_printf(dev, "Exceeded nr of ACI calls for cluster %d\n", + cluster_id); + + free(data_buf, M_IXGBE); + + return (++cluster_id); +} /* ixgbe_print_debug_dump_cluster */ + +/************************************************************************ + * ixgbe_sysctl_debug_dump_set_clusters + * + * Sets the cluster to dump from FW when Debug Dump requested. + ************************************************************************/ +static int +ixgbe_sysctl_debug_dump_set_clusters(SYSCTL_HANDLER_ARGS) +{ + struct ixgbe_softc *sc = (struct ixgbe_softc *)arg1; + u32 clusters = sc->debug_dump_cluster_mask; + device_t dev = sc->dev; + int error; + + error = sysctl_handle_32(oidp, &clusters, 0, req); + if ((error) || !req->newptr) + return (error); + + if (clusters & ~(IXGBE_DBG_DUMP_VALID_CLUSTERS_MASK)) { + device_printf(dev, + "%s: Unrecognized parameter: %u\n", + __func__, clusters); + sc->debug_dump_cluster_mask = + IXGBE_ACI_DBG_DUMP_CLUSTER_ID_INVALID; + return (EINVAL); + } + + sc->debug_dump_cluster_mask = clusters; + + return (0); +} /* ixgbe_sysctl_debug_dump_set_clusters */ + +/************************************************************************ + * ixgbe_sysctl_dump_debug_dump + ************************************************************************/ +static int +ixgbe_sysctl_dump_debug_dump(SYSCTL_HANDLER_ARGS) +{ + struct ixgbe_softc *sc = (struct ixgbe_softc *)arg1; + device_t dev = sc->dev; + struct sbuf *sbuf; + int error = 0; + + UNREFERENCED_PARAMETER(arg2); + + if (!sc->do_debug_dump) { + if (req->oldptr == NULL && req->newptr == NULL) { + error = SYSCTL_OUT(req, 0, 0); + return (error); + } + + char input_buf[2] = ""; + error = sysctl_handle_string(oidp, input_buf, + sizeof(input_buf), req); + if ((error) || (req->newptr == NULL)) + return (error); + + if (input_buf[0] == '1') { + if (sc->debug_dump_cluster_mask == + IXGBE_ACI_DBG_DUMP_CLUSTER_ID_INVALID) { + device_printf(dev, + "Debug Dump failed because an invalid " + "cluster was specified.\n"); + return (EINVAL); + } + + sc->do_debug_dump = true; + return (0); + } + + return (EINVAL); + } + + /* Caller just wants the upper bound for size */ + if (req->oldptr == NULL && req->newptr == NULL) { + size_t est_output_len = IXGBE_DBG_DUMP_BASE_SIZE; + if (sc->debug_dump_cluster_mask & 0x2) + est_output_len += IXGBE_DBG_DUMP_BASE_SIZE; + error = SYSCTL_OUT(req, 0, est_output_len); + return (error); + } + + sbuf = sbuf_new_for_sysctl(NULL, NULL, 128, req); + sbuf_clear_flags(sbuf, SBUF_INCLUDENUL); + + DEBUGOUT("FW Debug Dump running...\n"); + + if (sc->debug_dump_cluster_mask) { + for (u8 id = 0; id <= IXGBE_ACI_DBG_DUMP_CLUSTER_ID_MAX; id++) { + if (sc->debug_dump_cluster_mask & BIT(id)) { + DEBUGOUT1("Dumping cluster ID %u...\n", id); + ixgbe_debug_dump_print_cluster(sc, sbuf, id); + } + } + } else { + u8 next_cluster_id = 0; + do { + DEBUGOUT1("Dumping cluster ID %u...\n", + next_cluster_id); + next_cluster_id = ixgbe_debug_dump_print_cluster(sc, + sbuf, next_cluster_id); + } while (next_cluster_id != 0 && + next_cluster_id <= IXGBE_ACI_DBG_DUMP_CLUSTER_ID_MAX); + } + + sbuf_finish(sbuf); + sbuf_delete(sbuf); + + sc->do_debug_dump = false; + + return (error); +} /* ixgbe_sysctl_dump_debug_dump */ + +/************************************************************************ + * ixgbe_add_debug_dump_sysctls + ************************************************************************/ +static void +ixgbe_add_debug_dump_sysctls(struct ixgbe_softc *sc) +{ + struct sysctl_oid_list *debug_list, *dump_list; + struct sysctl_oid *dump_node; + struct sysctl_ctx_list *ctx; + device_t dev = sc->dev; + + ctx = device_get_sysctl_ctx(dev); + debug_list = SYSCTL_CHILDREN(sc->debug_sysctls); + + dump_node = SYSCTL_ADD_NODE(ctx, debug_list, OID_AUTO, "dump", + CTLFLAG_RD, NULL, "Internal FW/HW Dump"); + dump_list = SYSCTL_CHILDREN(dump_node); + + SYSCTL_ADD_PROC(ctx, dump_list, OID_AUTO, "clusters", + CTLTYPE_U32 | CTLFLAG_RW, sc, 0, + ixgbe_sysctl_debug_dump_set_clusters, "SU", + IXGBE_SYSCTL_DESC_DEBUG_DUMP_SET_CLUSTER); + + SYSCTL_ADD_PROC(ctx, dump_list, OID_AUTO, "dump", + CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, 0, + ixgbe_sysctl_dump_debug_dump, "", + IXGBE_SYSCTL_DESC_DUMP_DEBUG_DUMP); +} /* ixgbe_add_debug_dump_sysctls */ + +static void +ixgbe_add_debug_sysctls(struct ixgbe_softc *sc) +{ + struct sysctl_oid_list *ctx_list; + struct sysctl_ctx_list *ctx; + device_t dev = sc->dev; + + ctx = device_get_sysctl_ctx(dev); + ctx_list = SYSCTL_CHILDREN(device_get_sysctl_tree(dev)); + + sc->debug_sysctls = SYSCTL_ADD_NODE(ctx, ctx_list, OID_AUTO, "debug", + CTLFLAG_RD, NULL, "Debug Sysctls"); + + if (sc->feat_en & IXGBE_FEATURE_DBG_DUMP) + ixgbe_add_debug_dump_sysctls(sc); +} /* ixgbe_add_debug_sysctls */ + +/************************************************************************ * ixgbe_add_device_sysctls ************************************************************************/ static void @@ -2992,6 +3507,8 @@ ixgbe_add_device_sysctls(if_ctx_t ctx) CTLTYPE_INT | CTLFLAG_RW, sc, 0, ixgbe_sysctl_eee_state, "I", "EEE Power Save State"); } + + ixgbe_add_debug_sysctls(sc); } /* ixgbe_add_device_sysctls */ /************************************************************************ @@ -5182,6 +5699,7 @@ ixgbe_init_device_features(struct ixgbe_softc *sc) break; case ixgbe_mac_E610: sc->feat_cap |= IXGBE_FEATURE_RECOVERY_MODE; + sc->feat_cap |= IXGBE_FEATURE_DBG_DUMP; break; default: break; @@ -5203,6 +5721,9 @@ ixgbe_init_device_features(struct ixgbe_softc *sc) /* Recovery mode */ if (sc->feat_cap & IXGBE_FEATURE_RECOVERY_MODE) sc->feat_en |= IXGBE_FEATURE_RECOVERY_MODE; + /* FW Debug Dump */ + if (sc->feat_cap & IXGBE_FEATURE_DBG_DUMP) + sc->feat_en |= IXGBE_FEATURE_DBG_DUMP; /* Enabled via global sysctl... */ /* Flow Director */ diff --git a/sys/dev/ixgbe/ixgbe.h b/sys/dev/ixgbe/ixgbe.h index 844064bf8543..624b71acabea 100644 --- a/sys/dev/ixgbe/ixgbe.h +++ b/sys/dev/ixgbe/ixgbe.h @@ -46,6 +46,7 @@ #include <sys/module.h> #include <sys/sockio.h> #include <sys/eventhandler.h> +#include <sys/priv.h> #include <net/if.h> #include <net/if_var.h> @@ -475,6 +476,20 @@ struct ixgbe_softc { u32 feat_cap; u32 feat_en; u16 lse_mask; + + struct sysctl_oid *debug_sysctls; + u32 debug_dump_cluster_mask; + bool do_debug_dump; +}; + +struct ixgbe_debug_dump_cmd { + u32 offset; /* offset to read/write from table, in bytes */ + u8 cluster_id; /* also used to get next cluster id */ + u16 table_id; + u16 data_size; /* size of data field, in bytes */ + u16 reserved1; + u32 reserved2; + u8 data[]; }; /* Precision Time Sync (IEEE 1588) defines */ @@ -499,6 +514,43 @@ struct ixgbe_softc { #define IXGBE_PHY_CURRENT_TEMP 0xC820 #define IXGBE_PHY_OVERTEMP_STATUS 0xC830 +/** + * The ioctl command number used by NVM update for accessing the driver for + * NVM access commands. + */ +#define IXGBE_NVM_ACCESS \ + (((((((('E' << 4) + '1') << 4) + 'K') << 4) + 'G') << 4) | 5) + +/* + * The ioctl command number used by a userspace tool for accessing the driver + * for getting debug dump data from the firmware. + */ +#define IXGBE_DEBUG_DUMP \ + (((((((('E' << 4) + '1') << 4) + 'K') << 4) + 'G') << 4) | 6) + +/* Debug Dump related definitions */ +#define IXGBE_ACI_DBG_DUMP_CLUSTER_ID_INVALID 0xFFFFFF +#define IXGBE_ACI_DBG_DUMP_CLUSTER_ID_BASE 50 +#define IXGBE_ACI_DBG_DUMP_CLUSTER_ID_MAX 1 + +#define IXGBE_DBG_DUMP_VALID_CLUSTERS_MASK 0x3 +#define IXGBE_DBG_DUMP_BASE_SIZE (2 * 1024 * 1024) + +#define IXGBE_SYSCTL_DESC_DEBUG_DUMP_SET_CLUSTER \ +"\nSelect clusters to dump with \"dump\" sysctl" \ +"\nFlags:" \ +"\n\t 0x1 - Link" \ +"\n\t 0x2 - Full CSR Space, excluding RCW registers" \ +"\n\t" \ +"\nUse \"sysctl -x\" to view flags properly." + +#define IXGBE_SYSCTL_DESC_DUMP_DEBUG_DUMP \ +"\nWrite 1 to output a FW debug dump containing the clusters " \ +"specified by the \"clusters\" sysctl" \ +"\nThe \"-b\" flag must be used in order to dump this data " \ +"as binary data because" \ +"\nthis data is opaque and not a string." + /* Sysctl help messages; displayed with sysctl -d */ #define IXGBE_SYSCTL_DESC_ADV_SPEED \ "\nControl advertised link speed using these flags:\n" \ diff --git a/sys/dev/ixgbe/ixgbe_features.h b/sys/dev/ixgbe/ixgbe_features.h index 0cef334a185f..bee9040319d8 100644 --- a/sys/dev/ixgbe/ixgbe_features.h +++ b/sys/dev/ixgbe/ixgbe_features.h @@ -57,6 +57,7 @@ #define IXGBE_FEATURE_LEGACY_IRQ (u32)(1 << 12) #define IXGBE_FEATURE_NEEDS_CTXD (u32)(1 << 13) #define IXGBE_FEATURE_RECOVERY_MODE (u32)(1 << 15) +#define IXGBE_FEATURE_DBG_DUMP (u32)(1 << 16) /* Check for OS support. Undefine features if not included in the OS */ #ifndef PCI_IOV diff --git a/sys/dev/nvme/nvme.h b/sys/dev/nvme/nvme.h index 17c5cdb4db87..57cb37907e65 100644 --- a/sys/dev/nvme/nvme.h +++ b/sys/dev/nvme/nvme.h @@ -1507,9 +1507,7 @@ struct nvme_namespace_data { uint8_t eui64[8]; /** lba format support */ - uint32_t lbaf[16]; - - uint8_t reserved7[192]; + uint32_t lbaf[64]; uint8_t vendor_specific[3712]; } __packed __aligned(4); @@ -2175,7 +2173,7 @@ void nvme_namespace_data_swapbytes(struct nvme_namespace_data *s __unused) s->anagrpid = le32toh(s->anagrpid); s->nvmsetid = le16toh(s->nvmsetid); s->endgid = le16toh(s->endgid); - for (i = 0; i < 16; i++) + for (i = 0; i < 64; i++) s->lbaf[i] = le32toh(s->lbaf[i]); #endif } diff --git a/sys/dev/nvme/nvme_private.h b/sys/dev/nvme/nvme_private.h index 52f9e12f8f9a..52e9fcbbebcd 100644 --- a/sys/dev/nvme/nvme_private.h +++ b/sys/dev/nvme/nvme_private.h @@ -463,13 +463,13 @@ static __inline void nvme_completion_poll(struct nvme_completion_poll_status *status) { int timeout = ticks + 10 * hz; - sbintime_t delta_t = SBT_1US; + sbintime_t delta = SBT_1US; while (!atomic_load_acq_int(&status->done)) { if (timeout - ticks < 0) panic("NVME polled command failed to complete within 10s."); - pause_sbt("nvme", delta_t, 0, C_PREL(1)); - delta_t = min(SBT_1MS, delta_t * 3 / 2); + pause_sbt("nvme", delta, 0, C_PREL(1)); + delta = min(SBT_1MS, delta + delta / 2); } } diff --git a/sys/dev/vmm/vmm_mem.c b/sys/dev/vmm/vmm_mem.c index be59e37de33d..9df31c9ba133 100644 --- a/sys/dev/vmm/vmm_mem.c +++ b/sys/dev/vmm/vmm_mem.c @@ -26,10 +26,14 @@ static void vm_free_memmap(struct vm *vm, int ident); -void -vm_mem_init(struct vm_mem *mem) +int +vm_mem_init(struct vm_mem *mem, vm_offset_t lo, vm_offset_t hi) { + mem->mem_vmspace = vmmops_vmspace_alloc(lo, hi); + if (mem->mem_vmspace == NULL) + return (ENOMEM); sx_init(&mem->mem_segs_lock, "vm_mem_segs"); + return (0); } static bool @@ -93,10 +97,21 @@ vm_mem_destroy(struct vm *vm) for (int i = 0; i < VM_MAX_MEMSEGS; i++) vm_free_memseg(vm, i); + vmmops_vmspace_free(mem->mem_vmspace); + sx_xunlock(&mem->mem_segs_lock); sx_destroy(&mem->mem_segs_lock); } +struct vmspace * +vm_vmspace(struct vm *vm) +{ + struct vm_mem *mem; + + mem = vm_mem(vm); + return (mem->mem_vmspace); +} + void vm_slock_memsegs(struct vm *vm) { @@ -246,7 +261,7 @@ vm_mmap_memseg(struct vm *vm, vm_paddr_t gpa, int segid, vm_ooffset_t first, struct vm_mem *mem; struct vm_mem_seg *seg; struct vm_mem_map *m, *map; - struct vmspace *vmspace; + struct vm_map *vmmap; vm_ooffset_t last; int i, error; @@ -282,19 +297,19 @@ vm_mmap_memseg(struct vm *vm, vm_paddr_t gpa, int segid, vm_ooffset_t first, if (map == NULL) return (ENOSPC); - vmspace = vm_vmspace(vm); - error = vm_map_find(&vmspace->vm_map, seg->object, first, &gpa, - len, 0, VMFS_NO_SPACE, prot, prot, 0); + vmmap = &mem->mem_vmspace->vm_map; + error = vm_map_find(vmmap, seg->object, first, &gpa, len, 0, + VMFS_NO_SPACE, prot, prot, 0); if (error != KERN_SUCCESS) return (EFAULT); vm_object_reference(seg->object); if (flags & VM_MEMMAP_F_WIRED) { - error = vm_map_wire(&vmspace->vm_map, gpa, gpa + len, + error = vm_map_wire(vmmap, gpa, gpa + len, VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES); if (error != KERN_SUCCESS) { - vm_map_remove(&vmspace->vm_map, gpa, gpa + len); + vm_map_remove(vmmap, gpa, gpa + len); return (error == KERN_RESOURCE_SHORTAGE ? ENOMEM : EFAULT); } diff --git a/sys/dev/vmm/vmm_mem.h b/sys/dev/vmm/vmm_mem.h index 856470cf2590..f3d22058c7b8 100644 --- a/sys/dev/vmm/vmm_mem.h +++ b/sys/dev/vmm/vmm_mem.h @@ -36,6 +36,7 @@ enum { struct vm; struct vm_object; +struct vmspace; struct vm_mem_seg { size_t len; @@ -56,12 +57,15 @@ struct vm_mem { struct vm_mem_map mem_maps[VM_MAX_MEMMAPS]; struct vm_mem_seg mem_segs[VM_MAX_MEMSEGS]; struct sx mem_segs_lock; + struct vmspace *mem_vmspace; }; -void vm_mem_init(struct vm_mem *mem); +int vm_mem_init(struct vm_mem *mem, vm_offset_t lo, vm_offset_t hi); void vm_mem_cleanup(struct vm *vm); void vm_mem_destroy(struct vm *vm); +struct vmspace *vm_vmspace(struct vm *vm); + /* * APIs that modify the guest memory map require all vcpus to be frozen. */ diff --git a/sys/fs/nullfs/null.h b/sys/fs/nullfs/null.h index ad3f7779e108..7bfdc20a3f67 100644 --- a/sys/fs/nullfs/null.h +++ b/sys/fs/nullfs/null.h @@ -35,11 +35,12 @@ #ifndef FS_NULL_H #define FS_NULL_H -#define NULLM_CACHE 0x0001 - #include <sys/ck.h> #include <vm/uma.h> +#define NULLM_CACHE 0x0001 +#define NULLM_NOUNPBYPASS 0x0002 + struct null_mount { struct mount *nullm_vfs; struct vnode *nullm_lowerrootvp; /* Ref to lower root vnode */ @@ -82,6 +83,16 @@ struct vnode *null_checkvp(struct vnode *vp, char *fil, int lno); #endif extern struct vop_vector null_vnodeops; +extern struct vop_vector null_vnodeops_no_unp_bypass; + +static inline bool +null_is_nullfs_vnode(struct vnode *vp) +{ + const struct vop_vector *op; + + op = vp->v_op; + return (op == &null_vnodeops || op == &null_vnodeops_no_unp_bypass); +} extern uma_zone_t null_node_zone; diff --git a/sys/fs/nullfs/null_subr.c b/sys/fs/nullfs/null_subr.c index d7f847d449d0..a843ae44f121 100644 --- a/sys/fs/nullfs/null_subr.c +++ b/sys/fs/nullfs/null_subr.c @@ -240,7 +240,9 @@ null_nodeget(struct mount *mp, struct vnode *lowervp, struct vnode **vpp) */ xp = uma_zalloc_smr(null_node_zone, M_WAITOK); - error = getnewvnode("nullfs", mp, &null_vnodeops, &vp); + error = getnewvnode("nullfs", mp, (MOUNTTONULLMOUNT(mp)->nullm_flags & + NULLM_NOUNPBYPASS) != 0 ? &null_vnodeops_no_unp_bypass : + &null_vnodeops, &vp); if (error) { vput(lowervp); uma_zfree_smr(null_node_zone, xp); diff --git a/sys/fs/nullfs/null_vfsops.c b/sys/fs/nullfs/null_vfsops.c index 4cddf24a5745..170a3dd51cd8 100644 --- a/sys/fs/nullfs/null_vfsops.c +++ b/sys/fs/nullfs/null_vfsops.c @@ -85,6 +85,10 @@ nullfs_mount(struct mount *mp) char *target; int error, len; bool isvnunlocked; + static const char cache_opt_name[] = "cache"; + static const char nocache_opt_name[] = "nocache"; + static const char unixbypass_opt_name[] = "unixbypass"; + static const char nounixbypass_opt_name[] = "nounixbypass"; NULLFSDEBUG("nullfs_mount(mp = %p)\n", (void *)mp); @@ -116,7 +120,7 @@ nullfs_mount(struct mount *mp) /* * Unlock lower node to avoid possible deadlock. */ - if (mp->mnt_vnodecovered->v_op == &null_vnodeops && + if (null_is_nullfs_vnode(mp->mnt_vnodecovered) && VOP_ISLOCKED(mp->mnt_vnodecovered) == LK_EXCLUSIVE) { VOP_UNLOCK(mp->mnt_vnodecovered); isvnunlocked = true; @@ -150,7 +154,7 @@ nullfs_mount(struct mount *mp) /* * Check multi null mount to avoid `lock against myself' panic. */ - if (mp->mnt_vnodecovered->v_op == &null_vnodeops) { + if (null_is_nullfs_vnode(mp->mnt_vnodecovered)) { nn = VTONULL(mp->mnt_vnodecovered); if (nn == NULL || lowerrootvp == nn->null_lowervp) { NULLFSDEBUG("nullfs_mount: multi null mount?\n"); @@ -205,9 +209,10 @@ nullfs_mount(struct mount *mp) MNT_IUNLOCK(mp); } - if (vfs_getopt(mp->mnt_optnew, "cache", NULL, NULL) == 0) { + if (vfs_getopt(mp->mnt_optnew, cache_opt_name, NULL, NULL) == 0) { xmp->nullm_flags |= NULLM_CACHE; - } else if (vfs_getopt(mp->mnt_optnew, "nocache", NULL, NULL) == 0) { + } else if (vfs_getopt(mp->mnt_optnew, nocache_opt_name, NULL, + NULL) == 0) { ; } else if (null_cache_vnodes && (xmp->nullm_vfs->mnt_kern_flag & MNTK_NULL_NOCACHE) == 0) { @@ -219,6 +224,13 @@ nullfs_mount(struct mount *mp) &xmp->notify_node); } + if (vfs_getopt(mp->mnt_optnew, unixbypass_opt_name, NULL, NULL) == 0) { + ; + } else if (vfs_getopt(mp->mnt_optnew, nounixbypass_opt_name, NULL, + NULL) == 0) { + xmp->nullm_flags |= NULLM_NOUNPBYPASS; + } + if (lowerrootvp == mp->mnt_vnodecovered) { vn_lock(lowerrootvp, LK_EXCLUSIVE | LK_RETRY | LK_CANRECURSE); lowerrootvp->v_vflag |= VV_CROSSLOCK; diff --git a/sys/fs/nullfs/null_vnops.c b/sys/fs/nullfs/null_vnops.c index ec8a6b10b13f..d4baabeb40ab 100644 --- a/sys/fs/nullfs/null_vnops.c +++ b/sys/fs/nullfs/null_vnops.c @@ -278,7 +278,7 @@ null_bypass(struct vop_generic_args *ap) * that aren't. (We must always map first vp or vclean fails.) */ if (i != 0 && (*this_vp_p == NULL || - (*this_vp_p)->v_op != &null_vnodeops)) { + !null_is_nullfs_vnode(*this_vp_p))) { old_vps[i] = NULL; } else { old_vps[i] = *this_vp_p; @@ -1256,3 +1256,11 @@ struct vop_vector null_vnodeops = { .vop_copy_file_range = VOP_PANIC, }; VFS_VOP_VECTOR_REGISTER(null_vnodeops); + +struct vop_vector null_vnodeops_no_unp_bypass = { + .vop_default = &null_vnodeops, + .vop_unp_bind = vop_stdunp_bind, + .vop_unp_connect = vop_stdunp_connect, + .vop_unp_detach = vop_stdunp_detach, +}; +VFS_VOP_VECTOR_REGISTER(null_vnodeops_no_unp_bypass); diff --git a/sys/geom/part/g_part.c b/sys/geom/part/g_part.c index 4c0d0c3aa902..1e4236507fa4 100644 --- a/sys/geom/part/g_part.c +++ b/sys/geom/part/g_part.c @@ -122,13 +122,13 @@ struct g_part_alias_list { { "ntfs", G_PART_ALIAS_MS_NTFS }, { "openbsd-data", G_PART_ALIAS_OPENBSD_DATA }, { "prep-boot", G_PART_ALIAS_PREP_BOOT }, - { "solaris-boot", G_PART_ALIAS_SOLARIS_BOOT }, - { "solaris-root", G_PART_ALIAS_SOLARIS_ROOT }, - { "solaris-swap", G_PART_ALIAS_SOLARIS_SWAP }, - { "solaris-backup", G_PART_ALIAS_SOLARIS_BACKUP }, - { "solaris-var", G_PART_ALIAS_SOLARIS_VAR }, - { "solaris-home", G_PART_ALIAS_SOLARIS_HOME }, - { "solaris-altsec", G_PART_ALIAS_SOLARIS_ALTSEC }, + { "solaris-boot", G_PART_ALIAS_SOLARIS_BOOT }, + { "solaris-root", G_PART_ALIAS_SOLARIS_ROOT }, + { "solaris-swap", G_PART_ALIAS_SOLARIS_SWAP }, + { "solaris-backup", G_PART_ALIAS_SOLARIS_BACKUP }, + { "solaris-var", G_PART_ALIAS_SOLARIS_VAR }, + { "solaris-home", G_PART_ALIAS_SOLARIS_HOME }, + { "solaris-altsec", G_PART_ALIAS_SOLARIS_ALTSEC }, { "solaris-reserved", G_PART_ALIAS_SOLARIS_RESERVED }, { "u-boot-env", G_PART_ALIAS_U_BOOT_ENV }, { "vmware-reserved", G_PART_ALIAS_VMRESERVED }, diff --git a/sys/modules/aic7xxx/ahc/Makefile b/sys/modules/aic7xxx/ahc/Makefile index 3741d4fb666f..6f9bdcb1d8bd 100644 --- a/sys/modules/aic7xxx/ahc/Makefile +++ b/sys/modules/aic7xxx/ahc/Makefile @@ -1,6 +1,4 @@ SYSDIR?=${SRCTOP}/sys -.include "${SYSDIR}/conf/kern.opts.mk" - .PATH: ${SYSDIR}/dev/aic7xxx KMOD= ahc SUBDIR+= ahc_isa ahc_pci diff --git a/sys/modules/cxgb/Makefile b/sys/modules/cxgb/Makefile index 2989ad580b97..7ebdc1d51945 100644 --- a/sys/modules/cxgb/Makefile +++ b/sys/modules/cxgb/Makefile @@ -1,6 +1,3 @@ -SYSDIR?=${SRCTOP}/sys -.include "${SYSDIR}/conf/kern.opts.mk" - SUBDIR= cxgb SUBDIR+= cxgb_t3fw diff --git a/sys/modules/dpdk_lpm4/Makefile b/sys/modules/dpdk_lpm4/Makefile index ff68fac78915..9bc2693aeffb 100644 --- a/sys/modules/dpdk_lpm4/Makefile +++ b/sys/modules/dpdk_lpm4/Makefile @@ -1,6 +1,3 @@ -SYSDIR?=${SRCTOP}/sys -.include "${SYSDIR}/conf/kern.opts.mk" - .PATH: ${SYSDIR}/contrib/dpdk_rte_lpm KMOD= dpdk_lpm4 diff --git a/sys/modules/dpdk_lpm6/Makefile b/sys/modules/dpdk_lpm6/Makefile index f2248e5d1c1c..9de2c6650422 100644 --- a/sys/modules/dpdk_lpm6/Makefile +++ b/sys/modules/dpdk_lpm6/Makefile @@ -1,6 +1,3 @@ -SYSDIR?=${SRCTOP}/sys -.include "${SYSDIR}/conf/kern.opts.mk" - .PATH: ${SYSDIR}/contrib/dpdk_rte_lpm KMOD= dpdk_lpm6 diff --git a/sys/modules/fib_dxr/Makefile b/sys/modules/fib_dxr/Makefile index 7d1996ba510f..f8a28abe957a 100644 --- a/sys/modules/fib_dxr/Makefile +++ b/sys/modules/fib_dxr/Makefile @@ -1,6 +1,3 @@ -SYSDIR?=${SRCTOP}/sys -.include "${SYSDIR}/conf/kern.opts.mk" - .PATH: ${SYSDIR}/netinet KMOD= fib_dxr diff --git a/sys/modules/if_enc/Makefile b/sys/modules/if_enc/Makefile index 449d869d6a21..bd865a0216a4 100644 --- a/sys/modules/if_enc/Makefile +++ b/sys/modules/if_enc/Makefile @@ -1,6 +1,4 @@ SYSDIR?=${SRCTOP}/sys -.include "${SYSDIR}/conf/kern.opts.mk" - .PATH: ${SYSDIR}/net KMOD= if_enc diff --git a/sys/modules/if_gif/Makefile b/sys/modules/if_gif/Makefile index efcd6952a8ac..5e3fda3a51c6 100644 --- a/sys/modules/if_gif/Makefile +++ b/sys/modules/if_gif/Makefile @@ -1,6 +1,4 @@ SYSDIR?=${SRCTOP}/sys -.include "${SYSDIR}/conf/kern.opts.mk" - .PATH: ${SYSDIR}/net ${SYSDIR}/netinet ${SYSDIR}/netinet6 KMOD= if_gif diff --git a/sys/modules/if_gre/Makefile b/sys/modules/if_gre/Makefile index 9f50708a14d7..58bd03c23785 100644 --- a/sys/modules/if_gre/Makefile +++ b/sys/modules/if_gre/Makefile @@ -1,6 +1,5 @@ SYSDIR?=${SRCTOP}/sys .PATH: ${SYSDIR}/net ${SYSDIR}/netinet ${SYSDIR}/netinet6 -.include "${SYSDIR}/conf/kern.opts.mk" KMOD= if_gre SRCS= if_gre.c opt_inet.h opt_inet6.h opt_rss.h diff --git a/sys/modules/iser/Makefile b/sys/modules/iser/Makefile index 615199ec97a3..ff08ae6f346a 100644 --- a/sys/modules/iser/Makefile +++ b/sys/modules/iser/Makefile @@ -1,6 +1,4 @@ SYSDIR?=${SRCTOP}/sys -.include "${SYSDIR}/conf/kern.opts.mk" - .PATH: ${SYSDIR}/dev/iser/ KMOD= iser diff --git a/sys/modules/ktest/Makefile b/sys/modules/ktest/Makefile index 151db53417df..a3052efa9ed9 100644 --- a/sys/modules/ktest/Makefile +++ b/sys/modules/ktest/Makefile @@ -1,6 +1,3 @@ -SYSDIR?=${SRCTOP}/sys -.include "${SYSDIR}/conf/kern.opts.mk" - SUBDIR= ktest \ ktest_example \ ktest_netlink_message_writer diff --git a/sys/modules/ktest/ktest/Makefile b/sys/modules/ktest/ktest/Makefile index 3d4f1a8c2cc0..9741662ef709 100644 --- a/sys/modules/ktest/ktest/Makefile +++ b/sys/modules/ktest/ktest/Makefile @@ -1,9 +1,5 @@ PACKAGE= tests - -SYSDIR?=${SRCTOP}/sys -.include "${SYSDIR}/conf/kern.opts.mk" - -.PATH: ${SYSDIR}/tests +.PATH: ${SRCTOP}/sys/tests KMOD= ktest SRCS= ktest.c diff --git a/sys/modules/ktest/ktest_example/Makefile b/sys/modules/ktest/ktest_example/Makefile index 2b572d867aa5..aacc8f0e4ca5 100644 --- a/sys/modules/ktest/ktest_example/Makefile +++ b/sys/modules/ktest/ktest_example/Makefile @@ -1,9 +1,8 @@ PACKAGE= tests -SYSDIR?=${SRCTOP}/sys -.include "${SYSDIR}/conf/kern.opts.mk" +.include "${SRCTOP}/sys/conf/kern.opts.mk" -.PATH: ${SYSDIR}/tests +.PATH: ${SRCTOP}/sys/tests KMOD= ktest_example SRCS= ktest_example.c diff --git a/sys/modules/ktest/ktest_netlink_message_writer/Makefile b/sys/modules/ktest/ktest_netlink_message_writer/Makefile index a91c45755d0d..3f05f9b26785 100644 --- a/sys/modules/ktest/ktest_netlink_message_writer/Makefile +++ b/sys/modules/ktest/ktest_netlink_message_writer/Makefile @@ -1,8 +1,6 @@ PACKAGE= tests SYSDIR?=${SRCTOP}/sys -.include "${SYSDIR}/conf/kern.opts.mk" - .PATH: ${SYSDIR}/netlink KMOD= ktest_netlink_message_writer diff --git a/sys/modules/miiproxy/Makefile b/sys/modules/miiproxy/Makefile index 730bef4220cd..ab92ebe71b43 100644 --- a/sys/modules/miiproxy/Makefile +++ b/sys/modules/miiproxy/Makefile @@ -3,7 +3,7 @@ KMOD = miiproxy SRCS= miiproxy.c -SRCS+= bus_if.h mdio_if.h miibus_if.h opt_platform.h +SRCS+= bus_if.h device_if.h mdio_if.h miibus_if.h opt_platform.h CFLAGS+= -I${SRCTOP}/sys/dev/etherswitch .include <bsd.kmod.mk> diff --git a/sys/modules/netgraph/Makefile b/sys/modules/netgraph/Makefile index 94560d5c51d7..b2d65af16e7f 100644 --- a/sys/modules/netgraph/Makefile +++ b/sys/modules/netgraph/Makefile @@ -1,5 +1,3 @@ -# $Whistle: Makefile,v 1.5 1999/01/24 06:48:37 archie Exp $ - SYSDIR?=${SRCTOP}/sys .include "${SYSDIR}/conf/kern.opts.mk" diff --git a/sys/modules/netgraph/checksum/Makefile b/sys/modules/netgraph/checksum/Makefile index 4e2b1f547a40..bbbc7363d045 100644 --- a/sys/modules/netgraph/checksum/Makefile +++ b/sys/modules/netgraph/checksum/Makefile @@ -1,6 +1,3 @@ -SYSDIR?=${SRCTOP}/sys -.include "${SYSDIR}/conf/kern.opts.mk" - KMOD= ng_checksum SRCS= ng_checksum.c opt_inet.h opt_inet6.h diff --git a/sys/modules/netmap/Makefile b/sys/modules/netmap/Makefile index 17b52aec1893..8c114ac51538 100644 --- a/sys/modules/netmap/Makefile +++ b/sys/modules/netmap/Makefile @@ -2,9 +2,6 @@ # Compile netmap as a module, useful if you want a netmap bridge # or loadable drivers. -.include <bsd.own.mk> # FreeBSD 10 and earlier -# .include "${SYSDIR}/conf/kern.opts.mk" - .PATH: ${.CURDIR}/../../dev/netmap .PATH.h: ${.CURDIR}/../../net CFLAGS += -I${.CURDIR}/../../ -D INET -D VIMAGE diff --git a/sys/modules/opensolaris/Makefile b/sys/modules/opensolaris/Makefile index 98f52057e45e..7e2d5f9101ad 100644 --- a/sys/modules/opensolaris/Makefile +++ b/sys/modules/opensolaris/Makefile @@ -1,4 +1,4 @@ -SYSDIR?= ${SRCTOP}/sys +SYSDIR?=${SRCTOP}/sys .PATH: ${SYSDIR}/cddl/compat/opensolaris/kern .PATH: ${SYSDIR}/contrib/openzfs/module/os/freebsd/spl diff --git a/sys/modules/ow/Makefile b/sys/modules/ow/Makefile index 76fefe3e63be..7aa9d2de8183 100644 --- a/sys/modules/ow/Makefile +++ b/sys/modules/ow/Makefile @@ -1,6 +1,3 @@ -SYSDIR?=${SRCTOP}/sys -.include "${SYSDIR}/conf/kern.opts.mk" - SUBDIR = ow owc ow_temp .include <bsd.subdir.mk> diff --git a/sys/modules/qlnx/Makefile b/sys/modules/qlnx/Makefile index 2121f9d586a6..291b681c809e 100644 --- a/sys/modules/qlnx/Makefile +++ b/sys/modules/qlnx/Makefile @@ -31,9 +31,6 @@ # # -SYSDIR?=${SRCTOP}/sys -.include "${SYSDIR}/conf/kern.opts.mk" - SUBDIR=qlnxe SUBDIR+=qlnxev SUBDIR+=qlnxr diff --git a/sys/modules/rtwn/Makefile b/sys/modules/rtwn/Makefile index 9afdd2084ecb..f15cbbe8236b 100644 --- a/sys/modules/rtwn/Makefile +++ b/sys/modules/rtwn/Makefile @@ -1,7 +1,5 @@ .PATH: ${SRCTOP}/sys/dev/rtwn - -SYSDIR?=${SRCTOP}/sys -.include "${SYSDIR}/conf/kern.opts.mk" +.include "${SRCTOP}/sys/conf/kern.opts.mk" KMOD = rtwn SRCS = if_rtwn.c if_rtwn_tx.c if_rtwn_rx.c if_rtwn_beacon.c \ diff --git a/sys/modules/rtwn_pci/Makefile b/sys/modules/rtwn_pci/Makefile index ce2144121e88..3fea80d7d256 100644 --- a/sys/modules/rtwn_pci/Makefile +++ b/sys/modules/rtwn_pci/Makefile @@ -1,7 +1,5 @@ .PATH: ${SRCTOP}/sys/dev/rtwn/pci - -SYSDIR?=${SRCTOP}/sys -.include "${SYSDIR}/conf/kern.opts.mk" +.include "${SRCTOP}/sys/conf/kern.opts.mk" KMOD = if_rtwn_pci SRCS = rtwn_pci_attach.c rtwn_pci_reg.c rtwn_pci_rx.c rtwn_pci_tx.c \ diff --git a/sys/modules/rtwn_usb/Makefile b/sys/modules/rtwn_usb/Makefile index 16899b8a8c49..6a73276d088c 100644 --- a/sys/modules/rtwn_usb/Makefile +++ b/sys/modules/rtwn_usb/Makefile @@ -1,7 +1,5 @@ .PATH: ${SRCTOP}/sys/dev/rtwn/usb - -SYSDIR?=${SRCTOP}/sys -.include "${SYSDIR}/conf/kern.opts.mk" +.include "${SRCTOP}/sys/conf/kern.opts.mk" KMOD = if_rtwn_usb SRCS = rtwn_usb_attach.c rtwn_usb_ep.c rtwn_usb_reg.c rtwn_usb_rx.c \ diff --git a/sys/modules/sound/driver/Makefile b/sys/modules/sound/driver/Makefile index ff9499fdf841..02703d4b591a 100644 --- a/sys/modules/sound/driver/Makefile +++ b/sys/modules/sound/driver/Makefile @@ -1,5 +1,4 @@ -SYSDIR?=${SRCTOP}/sys -.include "${SYSDIR}/conf/kern.opts.mk" +.include "${SRCTOP}/sys/conf/kern.opts.mk" # Modules that include binary-only blobs of microcode should be selectable by # MK_SOURCELESS_UCODE option (see below). diff --git a/sys/modules/sound/sound/Makefile b/sys/modules/sound/sound/Makefile index f3978e9bd9cc..169b1a2730ec 100644 --- a/sys/modules/sound/sound/Makefile +++ b/sys/modules/sound/sound/Makefile @@ -1,5 +1,4 @@ SYSDIR?=${SRCTOP}/sys - .PATH: ${SYSDIR}/dev/sound .PATH: ${SYSDIR}/dev/sound/pcm .PATH: ${SYSDIR}/dev/sound/midi diff --git a/sys/modules/tests/fib_lookup/Makefile b/sys/modules/tests/fib_lookup/Makefile index 7d6198396911..b78d4309f145 100644 --- a/sys/modules/tests/fib_lookup/Makefile +++ b/sys/modules/tests/fib_lookup/Makefile @@ -1,6 +1,3 @@ -SYSDIR?=${SRCTOP}/sys -.include "${SYSDIR}/conf/kern.opts.mk" - .PATH: ${SYSDIR}/tests/fib_lookup KMOD= test_lookup diff --git a/sys/modules/vnic/Makefile b/sys/modules/vnic/Makefile index 7b975bfebe81..53e208328159 100644 --- a/sys/modules/vnic/Makefile +++ b/sys/modules/vnic/Makefile @@ -1,6 +1,3 @@ -SYSDIR?=${SRCTOP}/sys -.include "${SYSDIR}/conf/kern.opts.mk" - CFLAGS+= -DFDT SUBDIR = mrmlbus thunder_mdio thunder_bgx vnicpf vnicvf diff --git a/sys/modules/vnic/mrmlbus/Makefile b/sys/modules/vnic/mrmlbus/Makefile index a3581b7a79a5..a8fe9e5474e1 100644 --- a/sys/modules/vnic/mrmlbus/Makefile +++ b/sys/modules/vnic/mrmlbus/Makefile @@ -1,6 +1,3 @@ -SYSDIR?=${SRCTOP}/sys -.include "${SYSDIR}/conf/kern.opts.mk" - S= ${SRCTOP}/sys .PATH: $S/dev/vnic diff --git a/sys/modules/vnic/thunder_bgx/Makefile b/sys/modules/vnic/thunder_bgx/Makefile index 90df4b25df90..bf46c3194493 100644 --- a/sys/modules/vnic/thunder_bgx/Makefile +++ b/sys/modules/vnic/thunder_bgx/Makefile @@ -1,6 +1,3 @@ -SYSDIR?=${SRCTOP}/sys -.include "${SYSDIR}/conf/kern.opts.mk" - S= ${SRCTOP}/sys .PATH: $S/dev/vnic diff --git a/sys/modules/vnic/thunder_mdio/Makefile b/sys/modules/vnic/thunder_mdio/Makefile index 37032516f3ca..07cc583bfaf8 100644 --- a/sys/modules/vnic/thunder_mdio/Makefile +++ b/sys/modules/vnic/thunder_mdio/Makefile @@ -1,6 +1,3 @@ -SYSDIR?=${SRCTOP}/sys -.include "${SYSDIR}/conf/kern.opts.mk" - S= ${SRCTOP}/sys .PATH: $S/dev/vnic diff --git a/sys/modules/vnic/vnicpf/Makefile b/sys/modules/vnic/vnicpf/Makefile index 37cd29e6fdd8..3cd64d08a788 100644 --- a/sys/modules/vnic/vnicpf/Makefile +++ b/sys/modules/vnic/vnicpf/Makefile @@ -1,6 +1,3 @@ -SYSDIR?=${SRCTOP}/sys -.include "${SYSDIR}/conf/kern.opts.mk" - S= ${SRCTOP}/sys .PATH: $S/dev/vnic diff --git a/sys/modules/vnic/vnicvf/Makefile b/sys/modules/vnic/vnicvf/Makefile index c6ffaaa2c302..da938b7fd073 100644 --- a/sys/modules/vnic/vnicvf/Makefile +++ b/sys/modules/vnic/vnicvf/Makefile @@ -1,6 +1,3 @@ -SYSDIR?=${SRCTOP}/sys -.include "${SYSDIR}/conf/kern.opts.mk" - S= ${SRCTOP}/sys .PATH: $S/dev/vnic diff --git a/sys/netinet/tcp_lro.c b/sys/netinet/tcp_lro.c index 64efa4bf060f..9b5baf115855 100644 --- a/sys/netinet/tcp_lro.c +++ b/sys/netinet/tcp_lro.c @@ -1475,10 +1475,11 @@ tcp_lro_queue_mbuf(struct lro_ctrl *lc, struct mbuf *mb) } /* create sequence number */ - lc->lro_mbuf_data[lc->lro_mbuf_count].seq = - (((uint64_t)M_HASHTYPE_GET(mb)) << 56) | - (((uint64_t)mb->m_pkthdr.flowid) << 24) | - ((uint64_t)lc->lro_mbuf_count); + lc->lro_mbuf_data[lc->lro_mbuf_count].seq = lc->lro_mbuf_count; + if (M_HASHTYPE_ISHASH(mb)) + lc->lro_mbuf_data[lc->lro_mbuf_count].seq |= + (((uint64_t)M_HASHTYPE_GET(mb)) << 56) | + (((uint64_t)mb->m_pkthdr.flowid) << 24); /* enter mbuf */ lc->lro_mbuf_data[lc->lro_mbuf_count].mb = mb; diff --git a/sys/riscv/include/vmm.h b/sys/riscv/include/vmm.h index de7119dd534a..bc00474ed0fd 100644 --- a/sys/riscv/include/vmm.h +++ b/sys/riscv/include/vmm.h @@ -123,6 +123,29 @@ struct vm_eventinfo { int *iptr; /* reqidle cookie */ }; +#define DECLARE_VMMOPS_FUNC(ret_type, opname, args) \ + ret_type vmmops_##opname args + +DECLARE_VMMOPS_FUNC(int, modinit, (void)); +DECLARE_VMMOPS_FUNC(int, modcleanup, (void)); +DECLARE_VMMOPS_FUNC(void *, init, (struct vm *vm, struct pmap *pmap)); +DECLARE_VMMOPS_FUNC(int, gla2gpa, (void *vcpui, struct vm_guest_paging *paging, + uint64_t gla, int prot, uint64_t *gpa, int *is_fault)); +DECLARE_VMMOPS_FUNC(int, run, (void *vcpui, register_t pc, struct pmap *pmap, + struct vm_eventinfo *info)); +DECLARE_VMMOPS_FUNC(void, cleanup, (void *vmi)); +DECLARE_VMMOPS_FUNC(void *, vcpu_init, (void *vmi, struct vcpu *vcpu, + int vcpu_id)); +DECLARE_VMMOPS_FUNC(void, vcpu_cleanup, (void *vcpui)); +DECLARE_VMMOPS_FUNC(int, exception, (void *vcpui, uint64_t scause)); +DECLARE_VMMOPS_FUNC(int, getreg, (void *vcpui, int num, uint64_t *retval)); +DECLARE_VMMOPS_FUNC(int, setreg, (void *vcpui, int num, uint64_t val)); +DECLARE_VMMOPS_FUNC(int, getcap, (void *vcpui, int num, int *retval)); +DECLARE_VMMOPS_FUNC(int, setcap, (void *vcpui, int num, int val)); +DECLARE_VMMOPS_FUNC(struct vmspace *, vmspace_alloc, (vm_offset_t min, + vm_offset_t max)); +DECLARE_VMMOPS_FUNC(void, vmspace_free, (struct vmspace *vmspace)); + int vm_create(const char *name, struct vm **retvm); struct vcpu *vm_alloc_vcpu(struct vm *vm, int vcpuid); void vm_disable_vcpu_creation(struct vm *vm); @@ -212,7 +235,6 @@ vcpu_should_yield(struct vcpu *vcpu) void *vcpu_stats(struct vcpu *vcpu); void vcpu_notify_event(struct vcpu *vcpu); -struct vmspace *vm_vmspace(struct vm *vm); struct vm_mem *vm_mem(struct vm *vm); enum vm_reg_name vm_segment_name(int seg_encoding); diff --git a/sys/riscv/vmm/riscv.h b/sys/riscv/vmm/riscv.h index 870d0d6c5cd1..917a333520ed 100644 --- a/sys/riscv/vmm/riscv.h +++ b/sys/riscv/vmm/riscv.h @@ -122,29 +122,6 @@ struct hyptrap { uint64_t htinst; }; -#define DEFINE_VMMOPS_IFUNC(ret_type, opname, args) \ - ret_type vmmops_##opname args; - -DEFINE_VMMOPS_IFUNC(int, modinit, (void)) -DEFINE_VMMOPS_IFUNC(int, modcleanup, (void)) -DEFINE_VMMOPS_IFUNC(void *, init, (struct vm *vm, struct pmap *pmap)) -DEFINE_VMMOPS_IFUNC(int, gla2gpa, (void *vcpui, struct vm_guest_paging *paging, - uint64_t gla, int prot, uint64_t *gpa, int *is_fault)) -DEFINE_VMMOPS_IFUNC(int, run, (void *vcpui, register_t pc, struct pmap *pmap, - struct vm_eventinfo *info)) -DEFINE_VMMOPS_IFUNC(void, cleanup, (void *vmi)) -DEFINE_VMMOPS_IFUNC(void *, vcpu_init, (void *vmi, struct vcpu *vcpu, - int vcpu_id)) -DEFINE_VMMOPS_IFUNC(void, vcpu_cleanup, (void *vcpui)) -DEFINE_VMMOPS_IFUNC(int, exception, (void *vcpui, uint64_t scause)) -DEFINE_VMMOPS_IFUNC(int, getreg, (void *vcpui, int num, uint64_t *retval)) -DEFINE_VMMOPS_IFUNC(int, setreg, (void *vcpui, int num, uint64_t val)) -DEFINE_VMMOPS_IFUNC(int, getcap, (void *vcpui, int num, int *retval)) -DEFINE_VMMOPS_IFUNC(int, setcap, (void *vcpui, int num, int val)) -DEFINE_VMMOPS_IFUNC(struct vmspace *, vmspace_alloc, (vm_offset_t min, - vm_offset_t max)) -DEFINE_VMMOPS_IFUNC(void, vmspace_free, (struct vmspace *vmspace)) - #define dprintf(fmt, ...) struct hypctx *riscv_get_active_vcpu(void); diff --git a/sys/riscv/vmm/vmm.c b/sys/riscv/vmm/vmm.c index ec4514f70fa6..790dcc576507 100644 --- a/sys/riscv/vmm/vmm.c +++ b/sys/riscv/vmm/vmm.c @@ -92,7 +92,6 @@ struct vcpu { struct fpreg *guestfpu; /* (a,i) guest fpu state */ }; -#define vcpu_lock_initialized(v) mtx_initialized(&((v)->mtx)) #define vcpu_lock_init(v) mtx_init(&((v)->mtx), "vcpu lock", 0, MTX_SPIN) #define vcpu_lock_destroy(v) mtx_destroy(&((v)->mtx)) #define vcpu_lock(v) mtx_lock_spin(&((v)->mtx)) @@ -121,7 +120,6 @@ struct vm { bool dying; /* (o) is dying */ volatile cpuset_t suspended_cpus; /* (i) suspended vcpus */ volatile cpuset_t halted_cpus; /* (x) cpus in a hard halt */ - struct vmspace *vmspace; /* (o) guest's address space */ struct vm_mem mem; /* (i) [m+v] guest memory */ char name[VM_MAX_NAMELEN]; /* (o) virtual machine name */ struct vcpu **vcpu; /* (i) guest vcpus */ @@ -174,6 +172,7 @@ vcpu_cleanup(struct vcpu *vcpu, bool destroy) vmm_stat_free(vcpu->stats); fpu_save_area_free(vcpu->guestfpu); vcpu_lock_destroy(vcpu); + free(vcpu, M_VMM); } } @@ -285,7 +284,7 @@ vm_init(struct vm *vm, bool create) { int i; - vm->cookie = vmmops_init(vm, vmspace_pmap(vm->vmspace)); + vm->cookie = vmmops_init(vm, vmspace_pmap(vm_vmspace(vm))); MPASS(vm->cookie != NULL); CPU_ZERO(&vm->active_cpus); @@ -362,7 +361,7 @@ int vm_create(const char *name, struct vm **retvm) { struct vm *vm; - struct vmspace *vmspace; + int error; /* * If vmm.ko could not be successfully initialized then don't attempt @@ -374,14 +373,13 @@ vm_create(const char *name, struct vm **retvm) if (name == NULL || strlen(name) >= VM_MAX_NAMELEN) return (EINVAL); - vmspace = vmmops_vmspace_alloc(0, 1ul << 39); - if (vmspace == NULL) - return (ENOMEM); - vm = malloc(sizeof(struct vm), M_VMM, M_WAITOK | M_ZERO); + error = vm_mem_init(&vm->mem, 0, 1ul << 39); + if (error != 0) { + free(vm, M_VMM); + return (error); + } strcpy(vm->name, name); - vm->vmspace = vmspace; - vm_mem_init(&vm->mem); sx_init(&vm->vcpus_init_lock, "vm vcpus"); vm->sockets = 1; @@ -450,11 +448,6 @@ vm_cleanup(struct vm *vm, bool destroy) if (destroy) { vm_mem_destroy(vm); - vmmops_vmspace_free(vm->vmspace); - vm->vmspace = NULL; - - for (i = 0; i < vm->maxcpus; i++) - free(vm->vcpu[i], M_VMM); free(vm->vcpu, M_VMM); sx_destroy(&vm->vcpus_init_lock); } @@ -760,12 +753,6 @@ vcpu_notify_event(struct vcpu *vcpu) vcpu_unlock(vcpu); } -struct vmspace * -vm_vmspace(struct vm *vm) -{ - return (vm->vmspace); -} - struct vm_mem * vm_mem(struct vm *vm) { @@ -1084,7 +1071,7 @@ vm_handle_paging(struct vcpu *vcpu, bool *retu) vm = vcpu->vm; vme = &vcpu->exitinfo; - pmap = vmspace_pmap(vm->vmspace); + pmap = vmspace_pmap(vm_vmspace(vm)); addr = (vme->htval << 2) & ~(PAGE_SIZE - 1); dprintf("%s: %lx\n", __func__, addr); @@ -1107,7 +1094,7 @@ vm_handle_paging(struct vcpu *vcpu, bool *retu) if (pmap_fault(pmap, addr, ftype)) return (0); - map = &vm->vmspace->vm_map; + map = &vm_vmspace(vm)->vm_map; rv = vm_fault(map, addr, ftype, VM_FAULT_NORMAL, NULL); if (rv != KERN_SUCCESS) { printf("%s: vm_fault failed, addr %lx, ftype %d, err %d\n", @@ -1189,7 +1176,7 @@ vm_run(struct vcpu *vcpu) if (CPU_ISSET(vcpuid, &vm->suspended_cpus)) return (EINVAL); - pmap = vmspace_pmap(vm->vmspace); + pmap = vmspace_pmap(vm_vmspace(vm)); vme = &vcpu->exitinfo; evinfo.rptr = NULL; evinfo.sptr = &vm->suspend; diff --git a/sys/sys/user.h b/sys/sys/user.h index 3183f0792256..1704bc089d85 100644 --- a/sys/sys/user.h +++ b/sys/sys/user.h @@ -617,7 +617,8 @@ struct kinfo_vmobject { } kvo_type_spec; /* Type-specific union */ uint64_t kvo_me; /* Uniq handle for anon obj */ uint64_t kvo_laundry; /* Number of laundry pages. */ - uint64_t _kvo_qspare[5]; + uint64_t kvo_wired; /* Number of wired pages. */ + uint64_t _kvo_qspare[4]; uint32_t kvo_swapped; /* Number of swapped pages */ uint32_t kvo_flags; uint32_t _kvo_ispare[6]; diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c index 679b2e20e88b..b80b5cc781f7 100644 --- a/sys/vm/uma_core.c +++ b/sys/vm/uma_core.c @@ -4009,21 +4009,15 @@ restart: /* * Use the keg's policy if upper layers haven't already specified a * domain (as happens with first-touch zones). - * - * To avoid races we run the iterator with the keg lock held, but that - * means that we cannot allow the vm_domainset layer to sleep. Thus, - * clear M_WAITOK and handle low memory conditions locally. */ rr = rdomain == UMA_ANYDOMAIN; + aflags = flags; if (rr) { - aflags = (flags & ~M_WAITOK) | M_NOWAIT; if (vm_domainset_iter_policy_ref_init(&di, &keg->uk_dr, &domain, &aflags) != 0) return (NULL); - } else { - aflags = flags; + } else domain = rdomain; - } for (;;) { slab = keg_fetch_free_slab(keg, domain, rr, flags); @@ -4053,13 +4047,8 @@ restart: if ((flags & M_WAITOK) == 0) break; vm_wait_domain(domain); - } else if (vm_domainset_iter_policy(&di, &domain) != 0) { - if ((flags & M_WAITOK) != 0) { - vm_wait_doms(&keg->uk_dr.dr_policy->ds_mask, 0); - goto restart; - } + } else if (vm_domainset_iter_policy(&di, &domain) != 0) break; - } } /* @@ -5245,7 +5234,7 @@ uma_prealloc(uma_zone_t zone, int items) KEG_GET(zone, keg); slabs = howmany(items, keg->uk_ipers); while (slabs-- > 0) { - aflags = M_NOWAIT; + aflags = M_WAITOK; if (vm_domainset_iter_policy_ref_init(&di, &keg->uk_dr, &domain, &aflags) != 0) panic("%s: Domainset is empty", __func__); @@ -5266,7 +5255,8 @@ uma_prealloc(uma_zone_t zone, int items) break; } if (vm_domainset_iter_policy(&di, &domain) != 0) - vm_wait_doms(&keg->uk_dr.dr_policy->ds_mask, 0); + panic("%s: Cannot allocate from any domain", + __func__); } } } diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index 6d9ea8bf9d93..5b4517d2bf0c 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -2522,15 +2522,13 @@ vm_object_list_handler(struct sysctl_req *req, bool swap_only) continue; } mtx_unlock(&vm_object_list_mtx); + + memset(kvo, 0, sizeof(*kvo)); kvo->kvo_size = ptoa(obj->size); kvo->kvo_resident = obj->resident_page_count; kvo->kvo_ref_count = obj->ref_count; kvo->kvo_shadow_count = atomic_load_int(&obj->shadow_count); kvo->kvo_memattr = obj->memattr; - kvo->kvo_active = 0; - kvo->kvo_inactive = 0; - kvo->kvo_laundry = 0; - kvo->kvo_flags = 0; if (!swap_only) { vm_page_iter_init(&pages, obj); VM_RADIX_FOREACH(m, &pages) { @@ -2549,12 +2547,12 @@ vm_object_list_handler(struct sysctl_req *req, bool swap_only) kvo->kvo_inactive++; else if (vm_page_in_laundry(m)) kvo->kvo_laundry++; + + if (vm_page_wired(m)) + kvo->kvo_wired++; } } - kvo->kvo_vn_fileid = 0; - kvo->kvo_vn_fsid = 0; - kvo->kvo_vn_fsid_freebsd11 = 0; freepath = NULL; fullpath = ""; vp = NULL; diff --git a/sys/x86/x86/mca.c b/sys/x86/x86/mca.c index 4b40f343ac90..735efe307215 100644 --- a/sys/x86/x86/mca.c +++ b/sys/x86/x86/mca.c @@ -46,9 +46,11 @@ #include <sys/malloc.h> #include <sys/mutex.h> #include <sys/proc.h> +#include <sys/sbuf.h> #include <sys/sched.h> #include <sys/smp.h> #include <sys/sysctl.h> +#include <sys/syslog.h> #include <sys/systm.h> #include <sys/taskqueue.h> #include <machine/intr_machdep.h> @@ -135,6 +137,11 @@ SYSCTL_INT(_hw_mca, OID_AUTO, fake_bank, CTLFLAG_RW, "Bank to use for artificial MCAs (testing purpose only)"); #endif +static bool mca_uselog = false; +SYSCTL_BOOL(_hw_mca, OID_AUTO, uselog, CTLFLAG_RWTUN, &mca_uselog, 0, + "Should the system send non-fatal machine check errors to the log " + "(instead of the console)?"); + static STAILQ_HEAD(, mca_internal) mca_freelist; static int mca_freecount; static STAILQ_HEAD(, mca_internal) mca_records; @@ -147,12 +154,40 @@ static struct timeout_task mca_scan_task; static struct mtx mca_lock; static bool mca_startup_done = false; -/* Statistics on number of MCA events by type, updated atomically. */ +/* Static buffer to compose messages while in an interrupt context. */ +static char mca_msg_buf[1024]; +static struct mtx mca_msg_buf_lock; + +/* Statistics on number of MCA events by type, updated with the mca_lock. */ static uint64_t mca_stats[MCA_T_COUNT]; SYSCTL_OPAQUE(_hw_mca, OID_AUTO, stats, CTLFLAG_RD | CTLFLAG_SKIP, mca_stats, MCA_T_COUNT * sizeof(mca_stats[0]), "S", "Array of MCA events by type"); +/* Variables to track and control message rate limiting. */ +static struct timeval mca_last_log_time; +static struct timeval mca_log_interval; +static int mca_log_skipped; + +static int +sysctl_mca_log_interval(SYSCTL_HANDLER_ARGS) +{ + int error; + u_int val; + + val = mca_log_interval.tv_sec; + error = sysctl_handle_int(oidp, &val, 0, req); + if (error != 0 || req->newptr == NULL) + return (error); + mca_log_interval.tv_sec = val; + return (0); +} +SYSCTL_PROC(_hw_mca, OID_AUTO, log_interval, + CTLTYPE_UINT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, &mca_log_interval, 0, + sysctl_mca_log_interval, "IU", + "Minimum number of seconds between logging correctable MCAs" + " (0 = no limit)"); + static unsigned int mca_ia32_ctl_reg(int bank) { @@ -448,98 +483,111 @@ mca_mute(const struct mca_record *rec) /* Dump details about a single machine check. */ static void -mca_log(const struct mca_record *rec) +mca_log(enum scan_mode mode, const struct mca_record *rec, bool fatal) { + int error, numskipped; uint16_t mca_error; enum mca_stat_types event_type; + struct sbuf sb; + bool uncor, using_shared_buf; if (mca_mute(rec)) return; - if (!log_corrected && (rec->mr_status & MC_STATUS_UC) == 0 && - (!tes_supported(rec->mr_mcg_cap) || + uncor = (rec->mr_status & MC_STATUS_UC) != 0; + + if (!log_corrected && !uncor && (!tes_supported(rec->mr_mcg_cap) || ((rec->mr_status & MC_STATUS_TES_STATUS) >> 53) != 0x2)) return; - printf("MCA: Bank %d, Status 0x%016llx\n", rec->mr_bank, + /* Try to use an allocated buffer when not in an interrupt context. */ + if (mode == POLLED && sbuf_new(&sb, NULL, 512, SBUF_AUTOEXTEND) != NULL) + using_shared_buf = false; + else { + using_shared_buf = true; + mtx_lock_spin(&mca_msg_buf_lock); + sbuf_new(&sb, mca_msg_buf, sizeof(mca_msg_buf), SBUF_FIXEDLEN); + } + + sbuf_printf(&sb, "MCA: Bank %d, Status 0x%016llx\n", rec->mr_bank, (long long)rec->mr_status); - printf("MCA: Global Cap 0x%016llx, Status 0x%016llx\n", + sbuf_printf(&sb, "MCA: Global Cap 0x%016llx, Status 0x%016llx\n", (long long)rec->mr_mcg_cap, (long long)rec->mr_mcg_status); - printf("MCA: Vendor \"%s\", ID 0x%x, APIC ID %d\n", cpu_vendor, - rec->mr_cpu_id, rec->mr_apic_id); - printf("MCA: CPU %d ", rec->mr_cpu); + sbuf_printf(&sb, "MCA: Vendor \"%s\", ID 0x%x, APIC ID %d\n", + cpu_vendor, rec->mr_cpu_id, rec->mr_apic_id); + sbuf_printf(&sb, "MCA: CPU %d ", rec->mr_cpu); if (rec->mr_status & MC_STATUS_UC) - printf("UNCOR "); + sbuf_printf(&sb, "UNCOR "); else { - printf("COR "); + sbuf_printf(&sb, "COR "); if (cmci_supported(rec->mr_mcg_cap)) - printf("(%lld) ", ((long long)rec->mr_status & + sbuf_printf(&sb, "(%lld) ", ((long long)rec->mr_status & MC_STATUS_COR_COUNT) >> 38); if (tes_supported(rec->mr_mcg_cap)) { switch ((rec->mr_status & MC_STATUS_TES_STATUS) >> 53) { case 0x1: - printf("(Green) "); + sbuf_printf(&sb, "(Green) "); break; case 0x2: - printf("(Yellow) "); + sbuf_printf(&sb, "(Yellow) "); break; } } } if (rec->mr_status & MC_STATUS_EN) - printf("EN "); + sbuf_printf(&sb, "EN "); if (rec->mr_status & MC_STATUS_PCC) - printf("PCC "); + sbuf_printf(&sb, "PCC "); if (ser_supported(rec->mr_mcg_cap)) { if (rec->mr_status & MC_STATUS_S) - printf("S "); + sbuf_printf(&sb, "S "); if (rec->mr_status & MC_STATUS_AR) - printf("AR "); + sbuf_printf(&sb, "AR "); } if (rec->mr_status & MC_STATUS_OVER) - printf("OVER "); + sbuf_printf(&sb, "OVER "); mca_error = rec->mr_status & MC_STATUS_MCA_ERROR; event_type = MCA_T_COUNT; switch (mca_error) { /* Simple error codes. */ case 0x0000: - printf("no error"); + sbuf_printf(&sb, "no error"); event_type = MCA_T_NONE; break; case 0x0001: - printf("unclassified error"); + sbuf_printf(&sb, "unclassified error"); event_type = MCA_T_UNCLASSIFIED; break; case 0x0002: - printf("ucode ROM parity error"); + sbuf_printf(&sb, "ucode ROM parity error"); event_type = MCA_T_UCODE_ROM_PARITY; break; case 0x0003: - printf("external error"); + sbuf_printf(&sb, "external error"); event_type = MCA_T_EXTERNAL; break; case 0x0004: - printf("FRC error"); + sbuf_printf(&sb, "FRC error"); event_type = MCA_T_FRC; break; case 0x0005: - printf("internal parity error"); + sbuf_printf(&sb, "internal parity error"); event_type = MCA_T_INTERNAL_PARITY; break; case 0x0006: - printf("SMM handler code access violation"); + sbuf_printf(&sb, "SMM handler code access violation"); event_type = MCA_T_SMM_HANDLER; break; case 0x0400: - printf("internal timer error"); + sbuf_printf(&sb, "internal timer error"); event_type = MCA_T_INTERNAL_TIMER; break; case 0x0e0b: - printf("generic I/O error"); + sbuf_printf(&sb, "generic I/O error"); event_type = MCA_T_GENERIC_IO; if (rec->mr_cpu_vendor_id == CPU_VENDOR_INTEL && (rec->mr_status & MC_STATUS_MISCV)) { - printf(" (pci%d:%d:%d:%d)", + sbuf_printf(&sb, " (pci%d:%d:%d:%d)", (int)((rec->mr_misc & MC_MISC_PCIE_SEG) >> 32), (int)((rec->mr_misc & MC_MISC_PCIE_BUS) >> 24), (int)((rec->mr_misc & MC_MISC_PCIE_SLOT) >> 19), @@ -548,7 +596,8 @@ mca_log(const struct mca_record *rec) break; default: if ((mca_error & 0xfc00) == 0x0400) { - printf("internal error %x", mca_error & 0x03ff); + sbuf_printf(&sb, "internal error %x", + mca_error & 0x03ff); event_type = MCA_T_INTERNAL; break; } @@ -557,14 +606,16 @@ mca_log(const struct mca_record *rec) /* Memory hierarchy error. */ if ((mca_error & 0xeffc) == 0x000c) { - printf("%s memory error", mca_error_level(mca_error)); + sbuf_printf(&sb, "%s memory error", + mca_error_level(mca_error)); event_type = MCA_T_MEMORY; break; } /* TLB error. */ if ((mca_error & 0xeff0) == 0x0010) { - printf("%sTLB %s error", mca_error_ttype(mca_error), + sbuf_printf(&sb, "%sTLB %s error", + mca_error_ttype(mca_error), mca_error_level(mca_error)); event_type = MCA_T_TLB; break; @@ -572,19 +623,19 @@ mca_log(const struct mca_record *rec) /* Memory controller error. */ if ((mca_error & 0xef80) == 0x0080) { - printf("%s channel ", mca_error_mmtype(mca_error, - &event_type)); + sbuf_printf(&sb, "%s channel ", + mca_error_mmtype(mca_error, &event_type)); if ((mca_error & 0x000f) != 0x000f) - printf("%d", mca_error & 0x000f); + sbuf_printf(&sb, "%d", mca_error & 0x000f); else - printf("??"); - printf(" memory error"); + sbuf_printf(&sb, "??"); + sbuf_printf(&sb, " memory error"); break; } /* Cache error. */ if ((mca_error & 0xef00) == 0x0100) { - printf("%sCACHE %s %s error", + sbuf_printf(&sb, "%sCACHE %s %s error", mca_error_ttype(mca_error), mca_error_level(mca_error), mca_error_request(mca_error)); @@ -594,77 +645,129 @@ mca_log(const struct mca_record *rec) /* Extended memory error. */ if ((mca_error & 0xef80) == 0x0280) { - printf("%s channel ", mca_error_mmtype(mca_error, - &event_type)); + sbuf_printf(&sb, "%s channel ", + mca_error_mmtype(mca_error, &event_type)); if ((mca_error & 0x000f) != 0x000f) - printf("%d", mca_error & 0x000f); + sbuf_printf(&sb, "%d", mca_error & 0x000f); else - printf("??"); - printf(" extended memory error"); + sbuf_printf(&sb, "??"); + sbuf_printf(&sb, " extended memory error"); break; } /* Bus and/or Interconnect error. */ if ((mca_error & 0xe800) == 0x0800) { - printf("BUS%s ", mca_error_level(mca_error)); + sbuf_printf(&sb, "BUS%s ", mca_error_level(mca_error)); event_type = MCA_T_BUS; switch ((mca_error & 0x0600) >> 9) { case 0: - printf("Source"); + sbuf_printf(&sb, "Source"); break; case 1: - printf("Responder"); + sbuf_printf(&sb, "Responder"); break; case 2: - printf("Observer"); + sbuf_printf(&sb, "Observer"); break; default: - printf("???"); + sbuf_printf(&sb, "???"); break; } - printf(" %s ", mca_error_request(mca_error)); + sbuf_printf(&sb, " %s ", mca_error_request(mca_error)); switch ((mca_error & 0x000c) >> 2) { case 0: - printf("Memory"); + sbuf_printf(&sb, "Memory"); break; case 2: - printf("I/O"); + sbuf_printf(&sb, "I/O"); break; case 3: - printf("Other"); + sbuf_printf(&sb, "Other"); break; default: - printf("???"); + sbuf_printf(&sb, "???"); break; } if (mca_error & 0x0100) - printf(" timed out"); + sbuf_printf(&sb, " timed out"); break; } - printf("unknown error %x", mca_error); + sbuf_printf(&sb, "unknown error %x", mca_error); event_type = MCA_T_UNKNOWN; break; } - printf("\n"); + sbuf_printf(&sb, "\n"); if (rec->mr_status & MC_STATUS_ADDRV) { - printf("MCA: Address 0x%llx", (long long)rec->mr_addr); + sbuf_printf(&sb, "MCA: Address 0x%llx", + (long long)rec->mr_addr); if (ser_supported(rec->mr_mcg_cap) && (rec->mr_status & MC_STATUS_MISCV)) { - printf(" (Mode: %s, LSB: %d)", + sbuf_printf(&sb, " (Mode: %s, LSB: %d)", mca_addres_mode(rec->mr_misc), (int)(rec->mr_misc & MC_MISC_RA_LSB)); } - printf("\n"); + sbuf_printf(&sb, "\n"); } if (rec->mr_status & MC_STATUS_MISCV) - printf("MCA: Misc 0x%llx\n", (long long)rec->mr_misc); + sbuf_printf(&sb, "MCA: Misc 0x%llx\n", (long long)rec->mr_misc); + if (event_type < 0 || event_type >= MCA_T_COUNT) { KASSERT(0, ("%s: invalid event type (%d)", __func__, event_type)); event_type = MCA_T_UNKNOWN; } - atomic_add_64(&mca_stats[event_type], 1); + numskipped = 0; + if (!fatal && !uncor) { + /* + * Update statistics and check the rate limit for + * correctable errors. The rate limit is only applied + * after the system records a reasonable number of errors + * of the same type. The goal is to reduce the impact of + * the system seeing and attempting to log a burst of + * similar errors, which (especially when printed to the + * console) can be expensive. + */ + mtx_lock_spin(&mca_lock); + mca_stats[event_type]++; + if (mca_log_interval.tv_sec > 0 && mca_stats[event_type] > 50 && + ratecheck(&mca_last_log_time, &mca_log_interval) == 0) { + mca_log_skipped++; + mtx_unlock_spin(&mca_lock); + goto done; + } + numskipped = mca_log_skipped; + mca_log_skipped = 0; + mtx_unlock_spin(&mca_lock); + } + + error = sbuf_finish(&sb); + if (fatal || !mca_uselog) { + if (numskipped > 0) + printf("MCA: %d events skipped due to rate limit\n", + numskipped); + if (error) + printf("MCA: error logging message (sbuf error %d)\n", + error); + else + sbuf_putbuf(&sb); + } else { + if (numskipped > 0) + log(LOG_ERR, + "MCA: %d events skipped due to rate limit\n", + numskipped); + if (error) + log(LOG_ERR, + "MCA: error logging message (sbuf error %d)\n", + error); + else + log(uncor ? LOG_CRIT : LOG_ERR, "%s", sbuf_data(&sb)); + } + +done: + sbuf_delete(&sb); + if (using_shared_buf) + mtx_unlock_spin(&mca_msg_buf_lock); } static bool @@ -825,7 +928,7 @@ mca_record_entry(enum scan_mode mode, const struct mca_record *record) if (rec == NULL) { mtx_unlock_spin(&mca_lock); printf("MCA: Unable to allocate space for an event.\n"); - mca_log(record); + mca_log(mode, record, false); return; } STAILQ_REMOVE_HEAD(&mca_freelist, link); @@ -982,7 +1085,7 @@ mca_scan(enum scan_mode mode, bool *recoverablep) if (*recoverablep) mca_record_entry(mode, &rec); else - mca_log(&rec); + mca_log(mode, &rec, true); } #ifdef DEV_APIC @@ -1066,7 +1169,7 @@ mca_process_records(enum scan_mode mode) mtx_unlock_spin(&mca_lock); STAILQ_FOREACH(mca, &tmplist, link) - mca_log(&mca->rec); + mca_log(mode, &mca->rec, false); mtx_lock_spin(&mca_lock); while ((mca = STAILQ_FIRST(&tmplist)) != NULL) { @@ -1231,6 +1334,7 @@ mca_setup(uint64_t mcg_cap) mca_banks = mcg_cap & MCG_CAP_COUNT; mtx_init(&mca_lock, "mca", NULL, MTX_SPIN); + mtx_init(&mca_msg_buf_lock, "mca_msg_buf", NULL, MTX_SPIN); STAILQ_INIT(&mca_records); STAILQ_INIT(&mca_pending); mca_tq = taskqueue_create_fast("mca", M_WAITOK, diff --git a/tests/sys/mac/ipacl/Makefile b/tests/sys/mac/ipacl/Makefile index e083f6c1a69c..93b29e250ea5 100644 --- a/tests/sys/mac/ipacl/Makefile +++ b/tests/sys/mac/ipacl/Makefile @@ -6,4 +6,9 @@ ATF_TESTS_SH+= ipacl_test ${PACKAGE}FILES+= utils.subr +.for t in ${ATF_TESTS_SH} +TEST_METADATA.$t+= required_kmods="mac_ipacl" +TEST_METADATA.$t+= is_exclusive="true" +.endfor + .include <bsd.test.mk> diff --git a/tests/sys/mac/ipacl/ipacl_test.sh b/tests/sys/mac/ipacl/ipacl_test.sh index 0de1b414857b..892f4c154b66 100644 --- a/tests/sys/mac/ipacl/ipacl_test.sh +++ b/tests/sys/mac/ipacl/ipacl_test.sh @@ -40,6 +40,9 @@ ipacl_v4_body() { ipacl_test_init + prev_ipacl_ipv4="$(sysctl -n security.mac.ipacl.ipv4)" + prev_ipacl_rules="$(sysctl -n security.mac.ipacl.rules)" + epairA=$(vnet_mkepair) epairB=$(vnet_mkepair) epairC=$(vnet_mkepair) @@ -130,8 +133,9 @@ ipacl_v4_body() atf_check -s not-exit:0 -e ignore \ jexec A ifconfig ${epairA}b 203.0.113.1/24 up - # Reset rules OID. - sysctl security.mac.ipacl.rules= + # Reset sysctls. + sysctl security.mac.ipacl.rules="${prev_ipacl_rules}" + sysctl security.mac.ipacl.ipv4="${prev_ipacl_ipv4}" } ipacl_v4_cleanup() @@ -151,6 +155,9 @@ ipacl_v6_body() { ipacl_test_init + prev_ipacl_ipv6="$(sysctl -n security.mac.ipacl.ipv6)" + prev_ipacl_rules="$(sysctl -n security.mac.ipacl.rules)" + epairA=$(vnet_mkepair) epairB=$(vnet_mkepair) epairC=$(vnet_mkepair) @@ -265,8 +272,9 @@ ipacl_v6_body() atf_check -s not-exit:0 -e ignore jexec A ifconfig \ ${epairA}b inet6 2001:db8::abcd/32 up - # Reset rules OID. - sysctl security.mac.ipacl.rules= + # Reset sysctls. + sysctl security.mac.ipacl.rules="${prev_ipacl_rules}" + sysctl security.mac.ipacl.ipv6="${prev_ipacl_ipv6}" } ipacl_v6_cleanup() diff --git a/tests/sys/mac/ipacl/utils.subr b/tests/sys/mac/ipacl/utils.subr index 1d80414bafea..2fff8b1862da 100644 --- a/tests/sys/mac/ipacl/utils.subr +++ b/tests/sys/mac/ipacl/utils.subr @@ -5,10 +5,6 @@ ipacl_test_init() { vnet_init - - if ! kldstat -q -m mac_ipacl; then - atf_skip "mac_ipacl is not loaded" - fi } ipacl_test_cleanup() diff --git a/tests/sys/mac/portacl/Makefile b/tests/sys/mac/portacl/Makefile index 856a85d331d5..28c3a5cd71ce 100644 --- a/tests/sys/mac/portacl/Makefile +++ b/tests/sys/mac/portacl/Makefile @@ -8,6 +8,7 @@ TAP_TESTS_SH+= nobody_test TAP_TESTS_SH+= root_test .for t in ${TAP_TESTS_SH} +TEST_METADATA.$t+= required_kmods="mac_portacl" TEST_METADATA.$t+= required_user="root" TEST_METADATA.$t+= timeout="450" TEST_METADATA.$t+= is_exclusive="true" diff --git a/tests/sys/mac/portacl/misc.sh b/tests/sys/mac/portacl/misc.sh index a1b729c87777..4d3f18fce1c1 100644 --- a/tests/sys/mac/portacl/misc.sh +++ b/tests/sys/mac/portacl/misc.sh @@ -1,15 +1,5 @@ #!/bin/sh -sysctl security.mac.portacl >/dev/null 2>&1 -if [ $? -ne 0 ]; then - echo "1..0 # SKIP MAC_PORTACL is unavailable." - exit 0 -fi -if [ $(id -u) -ne 0 ]; then - echo "1..0 # SKIP testcases must be run as root" - exit 0 -fi - ntest=1 check_bind() { @@ -95,6 +85,7 @@ bind_test() { sysctl security.mac.portacl.rules= >/dev/null } +portacl_enabled=$(sysctl -n security.mac.portacl.enabled) reserved_high=$(sysctl -n net.inet.ip.portrange.reservedhigh) suser_exempt=$(sysctl -n security.mac.portacl.suser_exempt) port_high=$(sysctl -n security.mac.portacl.port_high) @@ -103,4 +94,5 @@ restore_settings() { sysctl -n net.inet.ip.portrange.reservedhigh=${reserved_high} >/dev/null sysctl -n security.mac.portacl.suser_exempt=${suser_exempt} >/dev/null sysctl -n security.mac.portacl.port_high=${port_high} >/dev/null + sysctl -n security.mac.portacl.enabled=${portacl_enabled} >/dev/null } diff --git a/tests/sys/mac/portacl/nobody_test.sh b/tests/sys/mac/portacl/nobody_test.sh index 7e64f68113ea..a3f2168dc81d 100644 --- a/tests/sys/mac/portacl/nobody_test.sh +++ b/tests/sys/mac/portacl/nobody_test.sh @@ -13,6 +13,7 @@ trap restore_settings EXIT INT TERM sysctl security.mac.portacl.suser_exempt=1 >/dev/null sysctl net.inet.ip.portrange.reservedhigh=78 >/dev/null +sysctl security.mac.portacl.enabled=1 >/dev/null bind_test fl fl uid nobody tcp 77 bind_test ok ok uid nobody tcp 7777 diff --git a/tests/sys/mac/portacl/root_test.sh b/tests/sys/mac/portacl/root_test.sh index daa5b147b4fa..d8898ff4f80e 100644 --- a/tests/sys/mac/portacl/root_test.sh +++ b/tests/sys/mac/portacl/root_test.sh @@ -10,6 +10,7 @@ echo "1..48" trap restore_settings EXIT INT TERM sysctl security.mac.portacl.suser_exempt=1 >/dev/null +sysctl security.mac.portacl.enabled=1 >/dev/null bind_test ok ok uid root tcp 77 bind_test ok ok uid root tcp 7777 diff --git a/tools/build/Makefile b/tools/build/Makefile index 09351900599a..fdec5f11311d 100644 --- a/tools/build/Makefile +++ b/tools/build/Makefile @@ -85,6 +85,10 @@ INCS+= stdlib.h SRCS+= reallocarray.c .endif +.if !exists(${HOST_INCLUDE_ROOT}/stdckdint.h) +INCS+= stdckdint.h +.endif + .if exists(${HOST_INCLUDE_ROOT}/sys/stat.h) _WITH_UTIMENS!= grep -c utimensat ${HOST_INCLUDE_ROOT}/sys/stat.h || true .else diff --git a/tools/build/cross-build/include/common/sys/cdefs.h b/tools/build/cross-build/include/common/sys/cdefs.h index 3f9b7866141f..faad5eccb3af 100644 --- a/tools/build/cross-build/include/common/sys/cdefs.h +++ b/tools/build/cross-build/include/common/sys/cdefs.h @@ -270,6 +270,16 @@ #define __ISO_C_VISIBLE 2011 #define __EXT1_VISIBLE 1 +/* + * Macro to test if we're using a specific version of gcc or later. + */ +#if defined(__GNUC__) +#define __GNUC_PREREQ__(ma, mi) \ + (__GNUC__ > (ma) || __GNUC__ == (ma) && __GNUC_MINOR__ >= (mi)) +#else +#define __GNUC_PREREQ__(ma, mi) 0 +#endif + /* Alignment builtins for better type checking and improved code generation. */ /* Provide fallback versions for other compilers (GCC/Clang < 10): */ #if !__has_builtin(__builtin_is_aligned) diff --git a/tools/tools/crypto/cryptocheck.c b/tools/tools/crypto/cryptocheck.c index 6506671455ac..46a364b0453c 100644 --- a/tools/tools/crypto/cryptocheck.c +++ b/tools/tools/crypto/cryptocheck.c @@ -362,9 +362,11 @@ enable_user_soft(void) size_t cursize = sizeof(curstate); if (sysctlbyname(CRYPT_SOFT_ALLOW, &curstate, &cursize, - &on, sizeof(on)) == 0) { + &on, sizeof(on)) == 0) { if (curstate == 0) atexit(reset_user_soft); + } else { + err(1, "sysctl(%s)", CRYPT_SOFT_ALLOW); } } @@ -373,7 +375,10 @@ crlookup(const char *devname) { struct crypt_find_op find; - if (strncmp(devname, "soft", 4) == 0) { + if (strncmp(devname, "soft", 4) == 0 || + strncmp(devname, "ossl", 4) == 0 || + strncmp(devname, "aesni", 5) == 0 || + strncmp(devname, "armv8crypto", 11) == 0) { enable_user_soft(); return CRYPTO_FLAG_SOFTWARE; } diff --git a/usr.bin/sockstat/main.c b/usr.bin/sockstat/main.c index 3b989c4283e4..7fedfd5b8724 100644 --- a/usr.bin/sockstat/main.c +++ b/usr.bin/sockstat/main.c @@ -103,6 +103,7 @@ static bool opt_u; /* Show Unix domain sockets */ static u_int opt_v; /* Verbose mode */ static bool opt_w; /* Automatically size the columns */ static bool is_xo_style_encoding; +static bool show_path_state = false; /* * Default protocols to use if no -P was defined. @@ -584,6 +585,7 @@ gather_sctp(void) !(local_all_loopback || foreign_all_loopback))) { RB_INSERT(socks_t, &socks, sock); + show_path_state = true; } else { free_socket(sock); } @@ -1230,40 +1232,40 @@ calculate_sock_column_widths(struct col_widths *cw, struct sock *s) { .socket = s->splice_socket }); if (sp != NULL) { len = formataddr(&sp->laddr->address, - NULL, 0); + NULL, 0); cw->splice_address = MAX( - cw->splice_address, len); + cw->splice_address, len); } } } if (opt_i) { - if (s->proto == IPPROTO_TCP || s->proto == IPPROTO_UDP) - { + if (s->proto == IPPROTO_TCP || + s->proto == IPPROTO_UDP) { len = snprintf(NULL, 0, - "%" PRIu64, s->inp_gencnt); + "%" PRIu64, s->inp_gencnt); cw->inp_gencnt = MAX(cw->inp_gencnt, len); } } if (opt_U) { if (faddr != NULL && - ((s->proto == IPPROTO_SCTP && - s->state != SCTP_CLOSED && - s->state != SCTP_BOUND && - s->state != SCTP_LISTEN) || - (s->proto == IPPROTO_TCP && - s->state != TCPS_CLOSED && - s->state != TCPS_LISTEN))) { + ((s->proto == IPPROTO_SCTP && + s->state != SCTP_CLOSED && + s->state != SCTP_BOUND && + s->state != SCTP_LISTEN) || + (s->proto == IPPROTO_TCP && + s->state != TCPS_CLOSED && + s->state != TCPS_LISTEN))) { len = snprintf(NULL, 0, "%u", - ntohs(faddr->encaps_port)); + ntohs(faddr->encaps_port)); cw->encaps = MAX(cw->encaps, len); } } if (opt_s) { if (faddr != NULL && - s->proto == IPPROTO_SCTP && - s->state != SCTP_CLOSED && - s->state != SCTP_BOUND && - s->state != SCTP_LISTEN) { + s->proto == IPPROTO_SCTP && + s->state != SCTP_CLOSED && + s->state != SCTP_BOUND && + s->state != SCTP_LISTEN) { len = strlen(sctp_path_state(faddr->state)); cw->path_state = MAX(cw->path_state, len); } @@ -1271,21 +1273,22 @@ calculate_sock_column_widths(struct col_widths *cw, struct sock *s) if (first) { if (opt_s) { if (s->proto == IPPROTO_SCTP || - s->proto == IPPROTO_TCP) { + s->proto == IPPROTO_TCP) { switch (s->proto) { case IPPROTO_SCTP: len = strlen( sctp_conn_state(s->state)); cw->conn_state = MAX( - cw->conn_state, len); + cw->conn_state, len); break; case IPPROTO_TCP: if (s->state >= 0 && s->state < TCP_NSTATES) { - len = strlen( - tcpstates[s->state]); - cw->conn_state = MAX( - cw->conn_state, len); + len = strlen( + tcpstates[s->state]); + cw->conn_state = MAX( + cw->conn_state, + len); } break; } @@ -1462,8 +1465,8 @@ display_sock(struct sock *s, struct col_widths *cw, char *buf, size_t bufsize) cw->splice_address, buf); } if (opt_i) { - if (s->proto == IPPROTO_TCP || s->proto == IPPROTO_UDP) - { + if (s->proto == IPPROTO_TCP || + s->proto == IPPROTO_UDP) { snprintf(buf, bufsize, "%" PRIu64, s->inp_gencnt); xo_emit(" {:id/%*s}", cw->inp_gencnt, buf); @@ -1472,29 +1475,29 @@ display_sock(struct sock *s, struct col_widths *cw, char *buf, size_t bufsize) } if (opt_U) { if (faddr != NULL && - ((s->proto == IPPROTO_SCTP && - s->state != SCTP_CLOSED && - s->state != SCTP_BOUND && - s->state != SCTP_LISTEN) || - (s->proto == IPPROTO_TCP && - s->state != TCPS_CLOSED && - s->state != TCPS_LISTEN))) { + ((s->proto == IPPROTO_SCTP && + s->state != SCTP_CLOSED && + s->state != SCTP_BOUND && + s->state != SCTP_LISTEN) || + (s->proto == IPPROTO_TCP && + s->state != TCPS_CLOSED && + s->state != TCPS_LISTEN))) { xo_emit(" {:encaps/%*u}", cw->encaps, - ntohs(faddr->encaps_port)); + ntohs(faddr->encaps_port)); } else if (!is_xo_style_encoding) xo_emit(" {:encaps/%*s}", cw->encaps, "??"); } - if (opt_s) { + if (opt_s && show_path_state) { if (faddr != NULL && - s->proto == IPPROTO_SCTP && - s->state != SCTP_CLOSED && - s->state != SCTP_BOUND && - s->state != SCTP_LISTEN) { + s->proto == IPPROTO_SCTP && + s->state != SCTP_CLOSED && + s->state != SCTP_BOUND && + s->state != SCTP_LISTEN) { xo_emit(" {:path-state/%-*s}", cw->path_state, - sctp_path_state(faddr->state)); + sctp_path_state(faddr->state)); } else if (!is_xo_style_encoding) xo_emit(" {:path-state/%-*s}", cw->path_state, - "??"); + "??"); } if (first) { if (opt_s) { @@ -1503,40 +1506,40 @@ display_sock(struct sock *s, struct col_widths *cw, char *buf, size_t bufsize) switch (s->proto) { case IPPROTO_SCTP: xo_emit(" {:conn-state/%-*s}", - cw->conn_state, - sctp_conn_state(s->state)); + cw->conn_state, + sctp_conn_state(s->state)); break; case IPPROTO_TCP: if (s->state >= 0 && - s->state < TCP_NSTATES) + s->state < TCP_NSTATES) xo_emit(" {:conn-state/%-*s}", - cw->conn_state, - tcpstates[s->state]); + cw->conn_state, + tcpstates[s->state]); else if (!is_xo_style_encoding) xo_emit(" {:conn-state/%-*s}", - cw->conn_state, "??"); + cw->conn_state, "??"); break; } } else if (!is_xo_style_encoding) xo_emit(" {:conn-state/%-*s}", - cw->conn_state, "??"); + cw->conn_state, "??"); } if (opt_b) { if (s->proto == IPPROTO_TCP) xo_emit(" {:bblog-state/%-*s}", - cw->bblog_state, - bblog_state(s->bblog_state)); + cw->bblog_state, + bblog_state(s->bblog_state)); else if (!is_xo_style_encoding) xo_emit(" {:bblog-state/%-*s}", - cw->bblog_state, "??"); + cw->bblog_state, "??"); } if (opt_S) { if (s->proto == IPPROTO_TCP) xo_emit(" {:stack/%-*s}", - cw->stack, s->stack); + cw->stack, s->stack); else if (!is_xo_style_encoding) xo_emit(" {:stack/%-*s}", - cw->stack, "??"); + cw->stack, "??"); } if (opt_C) { if (s->proto == IPPROTO_TCP) @@ -1544,18 +1547,30 @@ display_sock(struct sock *s, struct col_widths *cw, char *buf, size_t bufsize) else if (!is_xo_style_encoding) xo_emit(" {:cc/%-*s}", cw->cc, "??"); } + } else if (!is_xo_style_encoding) { + if (opt_s) + xo_emit(" {:conn-state/%-*s}", cw->conn_state, + "??"); + if (opt_b) + xo_emit(" {:bblog-state/%-*s}", cw->bblog_state, + "??"); + if (opt_S) + xo_emit(" {:stack/%-*s}", cw->stack, "??"); + if (opt_C) + xo_emit(" {:cc/%-*s}", cw->cc, "??"); } if (laddr != NULL) laddr = laddr->next; if (faddr != NULL) faddr = faddr->next; + xo_emit("\n"); if (!is_xo_style_encoding && (laddr != NULL || faddr != NULL)) xo_emit("{:user/%-*s} {:command/%-*s} {:pid/%*s}" - " {:fd/%*s}", cw->user, "??", cw->command, "??", - cw->pid, "??", cw->fd, "??"); + " {:fd/%*s} {:proto/%-*s}", cw->user, "??", + cw->command, "??", cw->pid, "??", cw->fd, "??", + cw->proto, "??"); first = false; } - xo_emit("\n"); } static void @@ -1613,13 +1628,15 @@ display(void) xo_emit(" {T:/%*s}", cw.fib, "FIB"); if (opt_I) xo_emit(" {T:/%-*s}", cw.splice_address, - "SPLICE ADDRESS"); + "SPLICE ADDRESS"); if (opt_i) xo_emit(" {T:/%*s}", cw.inp_gencnt, "ID"); if (opt_U) xo_emit(" {T:/%*s}", cw.encaps, "ENCAPS"); if (opt_s) { - xo_emit(" {T:/%-*s}", cw.path_state, "PATH STATE"); + if (show_path_state) + xo_emit(" {T:/%-*s}", cw.path_state, + "PATH STATE"); xo_emit(" {T:/%-*s}", cw.conn_state, "CONN STATE"); } if (opt_b) @@ -1644,15 +1661,15 @@ display(void) if (opt_n || (pwd = cap_getpwuid(cappwd, xf->xf_uid)) == NULL) xo_emit("{:user/%-*lu}", cw.user, - (u_long)xf->xf_uid); + (u_long)xf->xf_uid); else xo_emit("{:user/%-*s}", cw.user, pwd->pw_name); if (!is_xo_style_encoding) xo_emit(" {:command/%-*.10s}", cw.command, - getprocname(xf->xf_pid)); + getprocname(xf->xf_pid)); else xo_emit(" {:command/%-*s}", cw.command, - getprocname(xf->xf_pid)); + getprocname(xf->xf_pid)); xo_emit(" {:pid/%*lu}", cw.pid, (u_long)xf->xf_pid); xo_emit(" {:fd/%*d}", cw.fd, xf->xf_fd); display_sock(s, &cw, buf, bufsize); @@ -1667,8 +1684,8 @@ display(void) xo_open_instance("socket"); if (!is_xo_style_encoding) xo_emit("{:user/%-*s} {:command/%-*s} {:pid/%*s}" - " {:fd/%*s}", cw.user, "??", cw.command, "??", - cw.pid, "??", cw.fd, "??"); + " {:fd/%*s}", cw.user, "??", cw.command, "??", + cw.pid, "??", cw.fd, "??"); display_sock(s, &cw, buf, bufsize); xo_close_instance("socket"); } @@ -1680,8 +1697,8 @@ display(void) xo_open_instance("socket"); if (!is_xo_style_encoding) xo_emit("{:user/%-*s} {:command/%-*s} {:pid/%*s}" - " {:fd/%*s}", cw.user, "??", cw.command, "??", - cw.pid, "??", cw.fd, "??"); + " {:fd/%*s}", cw.user, "??", cw.command, "??", + cw.pid, "??", cw.fd, "??"); display_sock(s, &cw, buf, bufsize); xo_close_instance("socket"); } diff --git a/usr.bin/sockstat/sockstat.1 b/usr.bin/sockstat/sockstat.1 index dabb3042bfd4..d14eb967ad0f 100644 --- a/usr.bin/sockstat/sockstat.1 +++ b/usr.bin/sockstat/sockstat.1 @@ -25,7 +25,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd October 7, 2025 +.Dd October 9, 2025 .Dt SOCKSTAT 1 .Os .Sh NAME @@ -205,6 +205,7 @@ is specified (only for SCTP or TCP). The path state if .Fl s is specified (only for SCTP). +This column is only shown when there is at least one path state shown. .It Li CONN STATE The connection state if .Fl s diff --git a/usr.bin/sockstat/tests/Makefile b/usr.bin/sockstat/tests/Makefile index 9971bca2d474..5412e9d842aa 100644 --- a/usr.bin/sockstat/tests/Makefile +++ b/usr.bin/sockstat/tests/Makefile @@ -1,5 +1,6 @@ ATF_TESTS_C+= sockstat_test -SRCS.sockstat_test= sockstat_test.c ../sockstat.c +SRCS.sockstat_test= sockstat_test.c sockstat.c +.PATH: ${.CURDIR:H} LIBADD= xo diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c index 7a7c83fe1ac8..9b4d3a25ee07 100644 --- a/usr.bin/vmstat/vmstat.c +++ b/usr.bin/vmstat/vmstat.c @@ -1465,6 +1465,7 @@ display_object(struct kinfo_vmobject *kvo) xo_emit("{:active/%5ju} ", (uintmax_t)kvo->kvo_active); xo_emit("{:inactive/%5ju} ", (uintmax_t)kvo->kvo_inactive); xo_emit("{:laundry/%5ju} ", (uintmax_t)kvo->kvo_laundry); + xo_emit("{:wired/%5ju} ", (uintmax_t)kvo->kvo_wired); xo_emit("{:refcount/%3d} ", kvo->kvo_ref_count); xo_emit("{:shadowcount/%3d} ", kvo->kvo_shadow_count); @@ -1568,7 +1569,8 @@ doobjstat(void) return; } xo_emit("{T:RES/%5s} {T:ACT/%5s} {T:INACT/%5s} {T:LAUND/%5s} " - "{T:REF/%3s} {T:SHD/%3s} {T:CM/%2s} {T:TP/%3s} {T:PATH/%s}\n"); + "{T:WIRED/%5s} {T:REF/%3s} {T:SHD/%3s} {T:CM/%2s} {T:TP/%3s} " + "{T:PATH/%s}\n"); xo_open_list("object"); for (i = 0; i < cnt; i++) display_object(&kvo[i]); diff --git a/usr.sbin/acpi/acpidump/acpi.c b/usr.sbin/acpi/acpidump/acpi.c index 63613d5a4707..026795118832 100644 --- a/usr.sbin/acpi/acpidump/acpi.c +++ b/usr.sbin/acpi/acpidump/acpi.c @@ -1913,16 +1913,19 @@ acpi_handle_ivrs_ivmd_type(ACPI_IVRS_MEMORY *addr) static void acpi_handle_ivrs_ivmd(ACPI_IVRS_MEMORY *addr) { + UINT16 x16; + printf("\tMem Type=%#x(%s) ", addr->Header.Type, acpi_handle_ivrs_ivmd_type(addr)); switch (addr->Header.Type) { case ACPI_IVRS_TYPE_MEMORY2: - printf("Id=%#06x PCISeg=%#x ", addr->Header.DeviceId, - *(UINT16 *)&addr->Reserved); + memcpy(&x16, &addr->Reserved, sizeof(x16)); + printf("Id=%#06x PCISeg=%#x ", addr->Header.DeviceId, x16); break; case ACPI_IVRS_TYPE_MEMORY3: + memcpy(&x16, &addr->Reserved, sizeof(x16)); printf("Id=%#06x-%#06x PCISeg=%#x", addr->Header.DeviceId, - addr->AuxData, *(UINT16 *)&addr->Reserved); + addr->AuxData, x16); break; } printf("Start=%#18jx Length=%#jx Flags=", diff --git a/usr.sbin/bsdinstall/bsdinstall.8 b/usr.sbin/bsdinstall/bsdinstall.8 index 6175d26b4fd3..ee141e1d4296 100644 --- a/usr.sbin/bsdinstall/bsdinstall.8 +++ b/usr.sbin/bsdinstall/bsdinstall.8 @@ -247,7 +247,7 @@ Extracts the distributions listed in .Ev DISTRIBUTIONS into .Ev BSDINSTALL_CHROOT . -.It Cm pkgbase Op Fl --jail +.It Cm pkgbase Op Fl -jail Fetch and install base system packages to .Ev BSDINSTALL_CHROOT . Packages are fetched according to repository configuration in @@ -256,7 +256,7 @@ if set, or .Lk pkg.freebsd.org otherwise. If the -.Fl --jail +.Fl -jail option is passed, no kernel is installed, and the .Dq jail variant of each package set will be selected where applicable. diff --git a/usr.sbin/ctld/ctld.cc b/usr.sbin/ctld/ctld.cc index 10c12f25068e..331c029e282e 100644 --- a/usr.sbin/ctld/ctld.cc +++ b/usr.sbin/ctld/ctld.cc @@ -814,6 +814,11 @@ portal_group::open_sockets(struct conf &oldconf) } for (portal_up &portal : pg_portals) { + if (!portal->prepare()) { + cumulated_error++; + continue; + } + /* * Try to find already open portal and reuse the * listening socket. We don't care about what portal diff --git a/usr.sbin/ctld/ctld.hh b/usr.sbin/ctld/ctld.hh index cc88e6eb590e..3bf18f6a32c0 100644 --- a/usr.sbin/ctld/ctld.hh +++ b/usr.sbin/ctld/ctld.hh @@ -151,6 +151,7 @@ struct portal { p_protocol(protocol) {} virtual ~portal() = default; + virtual bool prepare() { return true; } bool reuse_socket(portal &oldp); bool init_socket(); virtual bool init_socket_options(int s __unused) { return true; } diff --git a/usr.sbin/ctld/nvmf.cc b/usr.sbin/ctld/nvmf.cc index d1240bfa4f6c..eb116903f5c1 100644 --- a/usr.sbin/ctld/nvmf.cc +++ b/usr.sbin/ctld/nvmf.cc @@ -34,11 +34,8 @@ struct nvmf_io_portal final : public nvmf_portal { nvmf_io_portal(struct portal_group *pg, const char *listen, - portal_protocol protocol, freebsd::addrinfo_up ai, - const struct nvmf_association_params &aparams, - nvmf_association_up na) : - nvmf_portal(pg, listen, protocol, std::move(ai), aparams, - std::move(na)) {} + portal_protocol protocol, freebsd::addrinfo_up ai) : + nvmf_portal(pg, listen, protocol, std::move(ai)) {} void handle_connection(freebsd::fd_up fd, const char *host, const struct sockaddr *client_sa) override; @@ -63,8 +60,6 @@ struct nvmf_transport_group final : public portal_group { override; private: - struct nvmf_association_params init_aparams(portal_protocol protocol); - static uint16_t last_port_id; }; @@ -143,48 +138,55 @@ parse_number(const nvlist_t *nvl, const char *key, uint64_t def, uint64_t minv, return def; } -struct nvmf_association_params -nvmf_transport_group::init_aparams(portal_protocol protocol) +bool +nvmf_portal::prepare() { - struct nvmf_association_params params; - memset(¶ms, 0, sizeof(params)); + memset(&p_aparams, 0, sizeof(p_aparams)); /* Options shared between discovery and I/O associations. */ - const nvlist_t *nvl = pg_options.get(); - params.tcp.header_digests = parse_bool(nvl, "HDGST", false); - params.tcp.data_digests = parse_bool(nvl, "DDGST", false); - uint64_t value = parse_number(nvl, "MAXH2CDATA", DEFAULT_MAXH2CDATA, - 4096, UINT32_MAX); + freebsd::nvlist_up nvl = portal_group()->options(); + p_aparams.tcp.header_digests = parse_bool(nvl.get(), "HDGST", false); + p_aparams.tcp.data_digests = parse_bool(nvl.get(), "DDGST", false); + uint64_t value = parse_number(nvl.get(), "MAXH2CDATA", + DEFAULT_MAXH2CDATA, 4096, UINT32_MAX); if (value % 4 != 0) { log_warnx("Invalid value \"%ju\" for option MAXH2CDATA", (uintmax_t)value); value = DEFAULT_MAXH2CDATA; } - params.tcp.maxh2cdata = value; + p_aparams.tcp.maxh2cdata = value; - switch (protocol) { + switch (protocol()) { case portal_protocol::NVME_TCP: - params.sq_flow_control = parse_bool(nvl, "SQFC", false); - params.dynamic_controller_model = true; - params.max_admin_qsize = parse_number(nvl, "max_admin_qsize", - NVME_MAX_ADMIN_ENTRIES, NVME_MIN_ADMIN_ENTRIES, - NVME_MAX_ADMIN_ENTRIES); - params.max_io_qsize = parse_number(nvl, "max_io_qsize", + p_aparams.sq_flow_control = parse_bool(nvl.get(), "SQFC", + false); + p_aparams.dynamic_controller_model = true; + p_aparams.max_admin_qsize = parse_number(nvl.get(), + "max_admin_qsize", NVME_MAX_ADMIN_ENTRIES, + NVME_MIN_ADMIN_ENTRIES, NVME_MAX_ADMIN_ENTRIES); + p_aparams.max_io_qsize = parse_number(nvl.get(), "max_io_qsize", NVME_MAX_IO_ENTRIES, NVME_MIN_IO_ENTRIES, NVME_MAX_IO_ENTRIES); - params.tcp.pda = 0; + p_aparams.tcp.pda = 0; break; case portal_protocol::NVME_DISCOVERY_TCP: - params.sq_flow_control = false; - params.dynamic_controller_model = true; - params.max_admin_qsize = NVME_MAX_ADMIN_ENTRIES; - params.tcp.pda = 0; + p_aparams.sq_flow_control = false; + p_aparams.dynamic_controller_model = true; + p_aparams.max_admin_qsize = NVME_MAX_ADMIN_ENTRIES; + p_aparams.tcp.pda = 0; break; default: __assert_unreachable(); } - return params; + p_association.reset(nvmf_allocate_association(NVMF_TRTYPE_TCP, true, + &p_aparams)); + if (!p_association) { + log_warn("Failed to create NVMe controller association"); + return false; + } + + return true; } portal_group_up @@ -209,15 +211,12 @@ bool nvmf_transport_group::add_portal(const char *value, portal_protocol protocol) { freebsd::addrinfo_up ai; - enum nvmf_trtype trtype; switch (protocol) { case portal_protocol::NVME_TCP: - trtype = NVMF_TRTYPE_TCP; ai = parse_addr_port(value, "4420"); break; case portal_protocol::NVME_DISCOVERY_TCP: - trtype = NVMF_TRTYPE_TCP; ai = parse_addr_port(value, "8009"); break; default: @@ -230,14 +229,6 @@ nvmf_transport_group::add_portal(const char *value, portal_protocol protocol) return false; } - struct nvmf_association_params aparams = init_aparams(protocol); - nvmf_association_up association(nvmf_allocate_association(trtype, true, - &aparams)); - if (!association) { - log_warn("Failed to create NVMe controller association"); - return false; - } - /* * XXX: getaddrinfo(3) may return multiple addresses; we should turn * those into multiple portals. @@ -246,10 +237,10 @@ nvmf_transport_group::add_portal(const char *value, portal_protocol protocol) portal_up portal; if (protocol == portal_protocol::NVME_DISCOVERY_TCP) { portal = std::make_unique<nvmf_discovery_portal>(this, value, - protocol, std::move(ai), aparams, std::move(association)); + protocol, std::move(ai)); } else { portal = std::make_unique<nvmf_io_portal>(this, value, - protocol, std::move(ai), aparams, std::move(association)); + protocol, std::move(ai)); need_tcp_transport = true; } diff --git a/usr.sbin/ctld/nvmf.hh b/usr.sbin/ctld/nvmf.hh index 0b4f8d45adfd..6f34a2858ef9 100644 --- a/usr.sbin/ctld/nvmf.hh +++ b/usr.sbin/ctld/nvmf.hh @@ -38,13 +38,12 @@ using nvmf_qpair_up = std::unique_ptr<nvmf_qpair, nvmf_qpair_deleter>; struct nvmf_portal : public portal { nvmf_portal(struct portal_group *pg, const char *listen, - portal_protocol protocol, freebsd::addrinfo_up ai, - const struct nvmf_association_params &aparams, - nvmf_association_up na) : - portal(pg, listen, protocol, std::move(ai)), - p_aparams(aparams), p_association(std::move(na)) {} + portal_protocol protocol, freebsd::addrinfo_up ai) : + portal(pg, listen, protocol, std::move(ai)) {} virtual ~nvmf_portal() override = default; + virtual bool prepare() override; + const struct nvmf_association_params *aparams() const { return &p_aparams; } @@ -58,11 +57,8 @@ private: struct nvmf_discovery_portal final : public nvmf_portal { nvmf_discovery_portal(struct portal_group *pg, const char *listen, - portal_protocol protocol, freebsd::addrinfo_up ai, - const struct nvmf_association_params &aparams, - nvmf_association_up na) : - nvmf_portal(pg, listen, protocol, std::move(ai), aparams, - std::move(na)) {} + portal_protocol protocol, freebsd::addrinfo_up ai) : + nvmf_portal(pg, listen, protocol, std::move(ai)) {} void handle_connection(freebsd::fd_up fd, const char *host, const struct sockaddr *client_sa) override; diff --git a/usr.sbin/jail/jail.8 b/usr.sbin/jail/jail.8 index d44b7f66a64e..9aed9b671b9e 100644 --- a/usr.sbin/jail/jail.8 +++ b/usr.sbin/jail/jail.8 @@ -23,7 +23,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd September 15, 2025 +.Dd October 8, 2025 .Dt JAIL 8 .Os .Sh NAME @@ -705,8 +705,8 @@ The super-user is enabled by default. Allow privileged processes in the jail to manipulate filesystem extended attributes in the system namespace. .It Va allow.adjtime -Allow privileged processes in the jail to slowly adjusting global operating system -time. +Allow privileged processes in the jail to slowly adjusting global operating +system time. For example through utilities like .Xr ntpd 8 . .It Va allow.settime @@ -1009,7 +1009,7 @@ jail is removed. .It Va ip4.addr In addition to the IP addresses that are passed to the kernel, an interface, netmask and additional parameters (as supported by -.Xr ifconfig 8 Ns ) +.Xr ifconfig 8 ) may also be specified, in the form .Dq Ar interface Ns | Ns Ar ip-address Ns / Ns Ar netmask param ... . If an interface is given before the IP address, an alias for the address @@ -1023,11 +1023,12 @@ adding the IP alias. .It Va ip6.addr In addition to the IP addresses that are passed to the kernel, an interface, prefix and additional parameters (as supported by -.Xr ifconfig 8 Ns ) +.Xr ifconfig 8 ) may also be specified, in the form .Dq Ar interface Ns | Ns Ar ip-address Ns / Ns Ar prefix param ... . .It Va vnet.interface -A list of network interfaces to give to a vnet-enabled jail after is it created. +A comma separated list of network interfaces to give to a vnet-enabled jail +after is it created. The interfaces will automatically be released when the jail is removed. .It Va zfs.dataset A list of ZFS datasets to be attached to the jail. diff --git a/usr.sbin/nfsuserd/nfsuserd.c b/usr.sbin/nfsuserd/nfsuserd.c index 29d816934600..058253beaf95 100644 --- a/usr.sbin/nfsuserd/nfsuserd.c +++ b/usr.sbin/nfsuserd/nfsuserd.c @@ -421,8 +421,12 @@ main(int argc, char *argv[]) /* Get the group list for this user. */ ngroup = NGROUPS; if (getgrouplist(pwd->pw_name, pwd->pw_gid, grps, - &ngroup) < 0) - syslog(LOG_ERR, "Group list too small"); + &ngroup) < 0) { + syslog(LOG_ERR, + "Group list of user '%s' too big", + pwd->pw_name); + ngroup = NGROUPS; + } nid.nid_ngroup = ngroup; nid.nid_grps = grps; } else { @@ -621,8 +625,12 @@ nfsuserdsrv(struct svc_req *rqstp, SVCXPRT *transp) /* Get the group list for this user. */ ngroup = NGROUPS; if (getgrouplist(pwd->pw_name, pwd->pw_gid, - grps, &ngroup) < 0) - syslog(LOG_ERR, "Group list too small"); + grps, &ngroup) < 0) { + syslog(LOG_ERR, + "Group list of user '%s' too big", + pwd->pw_name); + ngroup = NGROUPS; + } nid.nid_ngroup = ngroup; nid.nid_grps = grps; } else { diff --git a/usr.sbin/pw/pwupd.c b/usr.sbin/pw/pwupd.c index 89c1553c8c92..845a607ab1cb 100644 --- a/usr.sbin/pw/pwupd.c +++ b/usr.sbin/pw/pwupd.c @@ -119,7 +119,7 @@ pw_update(struct passwd * pwd, char const * user) */ if (pw_mkdb(pw != NULL ? pw->pw_name : NULL) == -1) { pw_fini(); - err(1, "pw_mkdb()"); + errx(1, "pw_mkdb()"); } free(pw); pw_fini(); diff --git a/usr.sbin/rpc.tlsservd/rpc.tlsservd.c b/usr.sbin/rpc.tlsservd/rpc.tlsservd.c index f07385a2baa7..fb0501b2db4c 100644 --- a/usr.sbin/rpc.tlsservd/rpc.tlsservd.c +++ b/usr.sbin/rpc.tlsservd/rpc.tlsservd.c @@ -168,7 +168,12 @@ main(int argc, char **argv) rpctls_verbose = false; ncpu = (u_int)sysconf(_SC_NPROCESSORS_ONLN); +#ifdef notnow rpctls_maxthreads = ncpu > 1 ? ncpu / 2 : 1; +#else + /* XXX For now, until fixed properly!! */ + rpctls_maxthreads = 1; +#endif while ((ch = getopt_long(argc, argv, "2C:D:dhl:N:n:mp:r:uvWw", longopts, NULL)) != -1) { @@ -199,6 +204,8 @@ main(int argc, char **argv) if (rpctls_maxthreads < 1 || rpctls_maxthreads > ncpu) errx(1, "maximum threads must be between 1 and " "number of CPUs (%d)", ncpu); + /* XXX For now, until fixed properly!! */ + rpctls_maxthreads = 1; break; case 'n': hostname[0] = '@'; diff --git a/usr.sbin/unbound/setup/local-unbound-setup.sh b/usr.sbin/unbound/setup/local-unbound-setup.sh index d57d74952fc7..25cfef48b6f0 100755 --- a/usr.sbin/unbound/setup/local-unbound-setup.sh +++ b/usr.sbin/unbound/setup/local-unbound-setup.sh @@ -261,6 +261,7 @@ gen_unbound_conf() { if [ "${use_tls}" = "yes" ] ; then echo " tls-cert-bundle: /etc/ssl/cert.pem" fi + echo " so-sndbuf: 0" echo "" if [ -f "${forward_conf}" ] ; then echo "include: ${forward_conf}" |