diff --git a/UPDATING b/UPDATING index bd314d07df12..122b0600e827 100644 --- a/UPDATING +++ b/UPDATING @@ -113,7 +113,9 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 12.x IS SLOW: 20180719: New uid:gid added, ntpd:ntpd (123:123). Be sure to run mergemaster or take steps to update /etc/passwd before doing installworld on - existing systems. Also, rc.d/ntpd now starts ntpd(8) as user ntpd + existing systems. Do not skip the "mergemaster -Fp" step before + installworld, as described in the update procedures near the bottom + of this document. Also, rc.d/ntpd now starts ntpd(8) as user ntpd if the new mac_ntpd(4) policy is available, unless ntpd_flags or the ntp config file contain options that change file/dir locations. When such options (e.g., "statsdir" or "crypto") are used, ntpd can diff --git a/bin/dd/misc.c b/bin/dd/misc.c index dfe83fd1ef9a..405448eb1cb0 100644 --- a/bin/dd/misc.c +++ b/bin/dd/misc.c @@ -111,7 +111,7 @@ progress(void) { static int outlen; char si[4 + 1 + 2 + 1]; /* 123 NUL */ - char iec[4 + 1 + 2 + 1]; /* 123 NUL */ + char iec[4 + 1 + 3 + 1]; /* 123 NUL */ char persec[4 + 1 + 2 + 1]; /* 123 NUL */ char *buf; double secs; @@ -121,11 +121,11 @@ progress(void) HN_DECIMAL | HN_DIVISOR_1000); humanize_number(iec, sizeof(iec), (int64_t)st.bytes, "B", HN_AUTOSCALE, HN_DECIMAL | HN_IEC_PREFIXES); - humanize_number(persec, sizeof(iec), (int64_t)(st.bytes / secs), "B", + humanize_number(persec, sizeof(persec), (int64_t)(st.bytes / secs), "B", HN_AUTOSCALE, HN_DECIMAL | HN_DIVISOR_1000); asprintf(&buf, " %'ju bytes (%s, %s) transferred %.3fs, %s/s", (uintmax_t)st.bytes, si, iec, secs, persec); - outlen = fprintf(stderr, "%-*s\r", outlen, buf); + outlen = fprintf(stderr, "%-*s\r", outlen, buf) - 1; fflush(stderr); free(buf); need_progress = 0; diff --git a/bin/rm/Makefile b/bin/rm/Makefile index e0d27134825a..b044ba86e55e 100644 --- a/bin/rm/Makefile +++ b/bin/rm/Makefile @@ -1,10 +1,15 @@ # @(#)Makefile 8.1 (Berkeley) 5/31/93 # $FreeBSD$ +.include + PACKAGE=runtime PROG= rm LINKS= ${BINDIR}/rm ${BINDIR}/unlink MLINKS= rm.1 unlink.1 +HAS_TESTS= +SUBDIR.${MK_TESTS}+= tests + .include diff --git a/bin/rm/rm.1 b/bin/rm/rm.1 index 192b1652bc5e..295082b07cf2 100644 --- a/bin/rm/rm.1 +++ b/bin/rm/rm.1 @@ -32,7 +32,7 @@ .\" @(#)rm.1 8.5 (Berkeley) 12/5/94 .\" $FreeBSD$ .\" -.Dd November 7, 2015 +.Dd September 12, 2018 .Dt RM 1 .Os .Sh NAME @@ -45,6 +45,7 @@ .Op Fl dIPRrvWx .Ar .Nm unlink +.Op Fl - .Ar file .Sh DESCRIPTION The @@ -154,6 +155,9 @@ No options may be supplied in this simple mode of operation, which performs an .Xr unlink 2 operation on the passed argument. +However, the usual option-end delimiter, +.Fl - , +may optionally precede the argument. .Sh EXIT STATUS The .Nm @@ -201,11 +205,12 @@ directory hierarchy: .Pp .Dl $ rm -rf foobar .Pp -Either of these commands will remove the file +Any of these commands will remove the file .Pa -f : .Bd -literal -offset indent $ rm -- -f $ rm ./-f +$ unlink -f .Ed .Sh COMPATIBILITY The diff --git a/bin/rm/rm.c b/bin/rm/rm.c index 0aa110248d46..ba69ece1151e 100644 --- a/bin/rm/rm.c +++ b/bin/rm/rm.c @@ -101,13 +101,12 @@ main(int argc, char *argv[]) else ++p; if (strcmp(p, "unlink") == 0) { - while (getopt(argc, argv, "") != -1) + if (argc == 2) + rm_file(&argv[1]); + else if (argc == 3 && strcmp(argv[1], "--") == 0) + rm_file(&argv[2]); + else usage(); - argc -= optind; - argv += optind; - if (argc != 1) - usage(); - rm_file(&argv[0]); exit(eval); } @@ -634,7 +633,7 @@ usage(void) (void)fprintf(stderr, "%s\n%s\n", "usage: rm [-f | -i] [-dIPRrvWx] file ...", - " unlink file"); + " unlink [--] file"); exit(EX_USAGE); } diff --git a/bin/rm/tests/Makefile b/bin/rm/tests/Makefile new file mode 100644 index 000000000000..aa0984b529d5 --- /dev/null +++ b/bin/rm/tests/Makefile @@ -0,0 +1,5 @@ +# $FreeBSD$ + +ATF_TESTS_SH+= rm_test + +.include diff --git a/bin/rm/tests/Makefile.depend b/bin/rm/tests/Makefile.depend new file mode 100644 index 000000000000..f80275d86ab1 --- /dev/null +++ b/bin/rm/tests/Makefile.depend @@ -0,0 +1,11 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + + +.include + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/bin/rm/tests/rm_test.sh b/bin/rm/tests/rm_test.sh new file mode 100755 index 000000000000..31ee64961a97 --- /dev/null +++ b/bin/rm/tests/rm_test.sh @@ -0,0 +1,45 @@ +# +# Copyright 2018 Yuri Pankov +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ +# + +atf_test_case unlink_dash_filename +unlink_dash_filename_head() +{ + atf_set "descr" "unlink correctly handles -filename" +} +unlink_dash_filename_body() +{ + touch -- foo bar -foo -bar + atf_check -s exit:0 unlink foo + atf_check -s exit:0 unlink -- bar + atf_check -s exit:0 unlink -foo + atf_check -s exit:0 unlink -- -bar +} + +atf_init_test_cases() +{ + atf_add_test_case unlink_dash_filename +} diff --git a/contrib/libarchive/NEWS b/contrib/libarchive/NEWS index 9527e662a86e..45b40b499a69 100644 --- a/contrib/libarchive/NEWS +++ b/contrib/libarchive/NEWS @@ -1,3 +1,13 @@ +Sep 03, 2018: libarchive 3.3.3 released + +Jul 19, 2018: Avoid super-linear slowdown on malformed mtree files + +Jan 27, 2018: Many fixes for building with Visual Studio + +Oct 19, 2017: NO_OVERWRITE doesn't change existing directory attributes + +Aug 12, 2017: New support for Zstandard read and write filters + Jul 09, 2017: libarchive 3.3.2 released Mar 16, 2017: NFSv4 ACL support for Linux (librichacl) diff --git a/contrib/libarchive/README.md b/contrib/libarchive/README.md index be6c13b3f03d..b48142191f2f 100644 --- a/contrib/libarchive/README.md +++ b/contrib/libarchive/README.md @@ -99,6 +99,7 @@ The library also detects and handles any of the following before evaluating the * lzma, lzip, and xz compression * lz4 compression * lzop compression + * zstandard compression The library can create archives in any of the following formats: * POSIX ustar @@ -125,6 +126,7 @@ When creating archives, the result can be filtered with any of the following: * lzma, lzip, and xz compression * lz4 compression * lzop compression + * zstandard compression ## Notes about the Library Design @@ -159,7 +161,7 @@ questions we are asked about libarchive: * On read, compression and format are always detected automatically. -* The same API is used for all formats; in particular, it's very +* The same API is used for all formats; it should be very easy for software using libarchive to transparently handle any of libarchive's archiving formats. diff --git a/contrib/libarchive/cpio/test/test_basic.c b/contrib/libarchive/cpio/test/test_basic.c index ffeff5acb0f4..afee337d14c5 100644 --- a/contrib/libarchive/cpio/test/test_basic.c +++ b/contrib/libarchive/cpio/test/test_basic.c @@ -144,49 +144,79 @@ DEFINE_TEST(test_basic) /* File with 10 bytes content. */ assertMakeFile("file", 0644, "1234567890"); fprintf(filelist, "file\n"); - if (is_LargeInode("file")) + if (is_LargeInode("file")) { strncat(result, - "bsdcpio: file: large inode number truncated: " - "Numerical result out of range\n", + "bsdcpio: file: large inode number truncated: ", sizeof(result) - strlen(result) -1); + strncat(result, + strerror(ERANGE), + sizeof(result) - strlen(result) -1); + strncat(result, + "\n", + sizeof(result) - strlen(result) -1); + } /* hardlink to above file. */ assertMakeHardlink("linkfile", "file"); fprintf(filelist, "linkfile\n"); - if (is_LargeInode("linkfile")) + if (is_LargeInode("linkfile")) { strncat(result, - "bsdcpio: linkfile: large inode number truncated: " - "Numerical result out of range\n", + "bsdcpio: linkfile: large inode number truncated: ", sizeof(result) - strlen(result) -1); + strncat(result, + strerror(ERANGE), + sizeof(result) - strlen(result) -1); + strncat(result, + "\n", + sizeof(result) - strlen(result) -1); + } /* Symlink to above file. */ if (canSymlink()) { assertMakeSymlink("symlink", "file"); fprintf(filelist, "symlink\n"); - if (is_LargeInode("symlink")) + if (is_LargeInode("symlink")) { strncat(result, - "bsdcpio: symlink: large inode number truncated: " - "Numerical result out of range\n", + "bsdcpio: symlink: large inode number truncated: ", sizeof(result) - strlen(result) -1); + strncat(result, + strerror(ERANGE), + sizeof(result) - strlen(result) -1); + strncat(result, + "\n", + sizeof(result) - strlen(result) -1); + } } /* Another file with different permissions. */ assertMakeFile("file2", 0777, "1234567890"); fprintf(filelist, "file2\n"); - if (is_LargeInode("file2")) + if (is_LargeInode("file2")) { strncat(result, - "bsdcpio: file2: large inode number truncated: " - "Numerical result out of range\n", + "bsdcpio: file2: large inode number truncated: ", sizeof(result) - strlen(result) -1); + strncat(result, + strerror(ERANGE), + sizeof(result) - strlen(result) -1); + strncat(result, + "\n", + sizeof(result) - strlen(result) -1); + } /* Directory. */ assertMakeDir("dir", 0775); fprintf(filelist, "dir\n"); - if (is_LargeInode("dir")) + if (is_LargeInode("dir")) { strncat(result, - "bsdcpio: dir: large inode number truncated: " - "Numerical result out of range\n", + "bsdcpio: dir: large inode number truncated: ", sizeof(result) - strlen(result) -1); + strncat(result, + strerror(ERANGE), + sizeof(result) - strlen(result) -1); + strncat(result, + "\n", + sizeof(result) - strlen(result) -1); + } strncat(result, "2 blocks\n", sizeof(result) - strlen(result) -1); /* All done. */ diff --git a/contrib/libarchive/cpio/test/test_format_newc.c b/contrib/libarchive/cpio/test/test_format_newc.c index cb8d7cf71330..8ef5657b45ba 100644 --- a/contrib/libarchive/cpio/test/test_format_newc.c +++ b/contrib/libarchive/cpio/test/test_format_newc.c @@ -124,26 +124,42 @@ DEFINE_TEST(test_format_newc) /* Setup result message. */ memset(result, 0, sizeof(result)); - if (is_LargeInode("file1")) + if (is_LargeInode("file1")) { strncat(result, - "bsdcpio: file1: large inode number truncated: " - "Numerical result out of range\n", + "bsdcpio: file1: large inode number truncated: ", sizeof(result) - strlen(result) -1); - if (canSymlink() && is_LargeInode("symlink")) + strncat(result, strerror(ERANGE), + sizeof(result) - strlen(result) -1); + strncat(result, "\n", + sizeof(result) - strlen(result) -1); + } + if (canSymlink() && is_LargeInode("symlink")) { strncat(result, - "bsdcpio: symlink: large inode number truncated: " - "Numerical result out of range\n", + "bsdcpio: symlink: large inode number truncated: ", sizeof(result) - strlen(result) -1); - if (is_LargeInode("dir")) + strncat(result, strerror(ERANGE), + sizeof(result) - strlen(result) -1); + strncat(result, "\n", + sizeof(result) - strlen(result) -1); + } + if (is_LargeInode("dir")) { strncat(result, - "bsdcpio: dir: large inode number truncated: " - "Numerical result out of range\n", + "bsdcpio: dir: large inode number truncated: ", sizeof(result) - strlen(result) -1); - if (is_LargeInode("hardlink")) + strncat(result, strerror(ERANGE), + sizeof(result) - strlen(result) -1); + strncat(result, "\n", + sizeof(result) - strlen(result) -1); + } + if (is_LargeInode("hardlink")) { strncat(result, - "bsdcpio: hardlink: large inode number truncated: " - "Numerical result out of range\n", + "bsdcpio: hardlink: large inode number truncated: ", sizeof(result) - strlen(result) -1); + strncat(result, strerror(ERANGE), + sizeof(result) - strlen(result) -1); + strncat(result, "\n", + sizeof(result) - strlen(result) -1); + } /* Record some facts about what we just created: */ now = time(NULL); /* They were all created w/in last two seconds. */ diff --git a/contrib/libarchive/libarchive/archive.h b/contrib/libarchive/libarchive/archive.h index 46938ad20cdf..06ab234a59f0 100644 --- a/contrib/libarchive/libarchive/archive.h +++ b/contrib/libarchive/libarchive/archive.h @@ -36,7 +36,7 @@ * assert that ARCHIVE_VERSION_NUMBER >= 2012108. */ /* Note: Compiler will complain if this does not match archive_entry.h! */ -#define ARCHIVE_VERSION_NUMBER 3003002 +#define ARCHIVE_VERSION_NUMBER 3003003 #include #include /* for wchar_t */ @@ -155,7 +155,7 @@ __LA_DECL int archive_version_number(void); /* * Textual name/version of the library, useful for version displays. */ -#define ARCHIVE_VERSION_ONLY_STRING "3.3.2" +#define ARCHIVE_VERSION_ONLY_STRING "3.3.3" #define ARCHIVE_VERSION_STRING "libarchive " ARCHIVE_VERSION_ONLY_STRING __LA_DECL const char * archive_version_string(void); diff --git a/contrib/libarchive/libarchive/archive_cryptor.c b/contrib/libarchive/libarchive/archive_cryptor.c index ced52fd7062a..71967c9d46f0 100644 --- a/contrib/libarchive/libarchive/archive_cryptor.c +++ b/contrib/libarchive/libarchive/archive_cryptor.c @@ -153,7 +153,7 @@ aes_ctr_encrypt_counter(archive_crypto_ctx *ctx) CCCryptorStatus r; r = CCCryptorReset(ref, NULL); - if (r != kCCSuccess) + if (r != kCCSuccess && r != kCCUnimplemented) return -1; r = CCCryptorUpdate(ref, ctx->nonce, AES_BLOCK_SIZE, ctx->encr_buf, AES_BLOCK_SIZE, NULL); diff --git a/contrib/libarchive/libarchive/archive_entry.h b/contrib/libarchive/libarchive/archive_entry.h index affde2579831..82539b35147b 100644 --- a/contrib/libarchive/libarchive/archive_entry.h +++ b/contrib/libarchive/libarchive/archive_entry.h @@ -30,7 +30,7 @@ #define ARCHIVE_ENTRY_H_INCLUDED /* Note: Compiler will complain if this does not match archive.h! */ -#define ARCHIVE_VERSION_NUMBER 3003002 +#define ARCHIVE_VERSION_NUMBER 3003003 /* * Note: archive_entry.h is for use outside of libarchive; the diff --git a/contrib/libarchive/libarchive/archive_pack_dev.c b/contrib/libarchive/libarchive/archive_pack_dev.c index 098881b678cd..53bddd790a30 100644 --- a/contrib/libarchive/libarchive/archive_pack_dev.c +++ b/contrib/libarchive/libarchive/archive_pack_dev.c @@ -57,6 +57,9 @@ __RCSID("$NetBSD$"); #ifdef HAVE_SYS_STAT_H #include #endif +#ifdef HAVE_SYS_SYSMACROS_H +#include +#endif #ifdef HAVE_UNISTD_H #include #endif diff --git a/contrib/llvm/tools/lld/ELF/Config.h b/contrib/llvm/tools/lld/ELF/Config.h index 53f0852fa98f..2a488c3a1189 100644 --- a/contrib/llvm/tools/lld/ELF/Config.h +++ b/contrib/llvm/tools/lld/ELF/Config.h @@ -183,6 +183,7 @@ struct Configuration { bool ZHazardplt; bool ZIfuncnoplt; bool ZInitfirst; + bool ZInterpose; bool ZKeepTextSectionPrefix; bool ZNodelete; bool ZNodlopen; diff --git a/contrib/llvm/tools/lld/ELF/Driver.cpp b/contrib/llvm/tools/lld/ELF/Driver.cpp index b8be526d9424..66417b0178ce 100644 --- a/contrib/llvm/tools/lld/ELF/Driver.cpp +++ b/contrib/llvm/tools/lld/ELF/Driver.cpp @@ -846,6 +846,7 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) { Config->ZHazardplt = hasZOption(Args, "hazardplt"); Config->ZIfuncnoplt = hasZOption(Args, "ifunc-noplt"); Config->ZInitfirst = hasZOption(Args, "initfirst"); + Config->ZInterpose = hasZOption(Args, "interpose"); Config->ZKeepTextSectionPrefix = getZFlag( Args, "keep-text-section-prefix", "nokeep-text-section-prefix", false); Config->ZNodelete = hasZOption(Args, "nodelete"); diff --git a/contrib/llvm/tools/lld/ELF/SyntheticSections.cpp b/contrib/llvm/tools/lld/ELF/SyntheticSections.cpp index 8b02a14c93c2..ce659e50e81a 100644 --- a/contrib/llvm/tools/lld/ELF/SyntheticSections.cpp +++ b/contrib/llvm/tools/lld/ELF/SyntheticSections.cpp @@ -1266,6 +1266,8 @@ template void DynamicSection::finalizeContents() { DtFlags |= DF_SYMBOLIC; if (Config->ZInitfirst) DtFlags1 |= DF_1_INITFIRST; + if (Config->ZInterpose) + DtFlags1 |= DF_1_INTERPOSE; if (Config->ZNodelete) DtFlags1 |= DF_1_NODELETE; if (Config->ZNodlopen) diff --git a/contrib/llvm/tools/lld/docs/ld.lld.1 b/contrib/llvm/tools/lld/docs/ld.lld.1 index 67591f2bbcac..b51608c7e959 100644 --- a/contrib/llvm/tools/lld/docs/ld.lld.1 +++ b/contrib/llvm/tools/lld/docs/ld.lld.1 @@ -3,7 +3,7 @@ .\" .\" This man page documents only lld's ELF linking support, obtained originally .\" from FreeBSD. -.Dd August 22, 2018 +.Dd September 14, 2018 .Dt LD.LLD 1 .Os .Sh NAME @@ -462,6 +462,12 @@ environments. Sets the .Dv DF_1_INITFIRST flag to indicate the module should be initialized first. +.It Cm interpose +Set the +.Dv DF_1_INTERPOSE +flag to indicate that the object is an interposer. +Runtime linkers perform symbol resolution by first searching the application, +followed by interposers, and then any other dependencies. .It Cm muldefs Do not error if a symbol is defined multiple times. The first definition will be used. diff --git a/contrib/ofed/infiniband-diags/src/ibdiag_common.c b/contrib/ofed/infiniband-diags/src/ibdiag_common.c index d668b7ef0557..ddaee8c5b559 100644 --- a/contrib/ofed/infiniband-diags/src/ibdiag_common.c +++ b/contrib/ofed/infiniband-diags/src/ibdiag_common.c @@ -84,8 +84,7 @@ static const struct ibdiag_opt *opts_map[256]; static const char *get_build_version(void) { - return "BUILD VERSION: " IBDIAG_VERSION " Build date: " __DATE__ " " - __TIME__; + return "BUILD VERSION: " IBDIAG_VERSION; } static void pretty_print(int start, int width, const char *str) diff --git a/contrib/tcpdump/tcpdump.c b/contrib/tcpdump/tcpdump.c index d08c33ee6eb8..31adfed016a6 100644 --- a/contrib/tcpdump/tcpdump.c +++ b/contrib/tcpdump/tcpdump.c @@ -2069,6 +2069,9 @@ main(int argc, char **argv) #else cansandbox = (cansandbox && ndo->ndo_nflag); #endif /* HAVE_CASPER */ + cansandbox = (cansandbox && (pcap_fileno(pd) != -1 || + RFileName != NULL)); + if (cansandbox && cap_enter() < 0 && errno != ENOSYS) error("unable to enter the capability mode"); #endif /* HAVE_CAPSICUM */ diff --git a/etc/Makefile b/etc/Makefile index 0fa9ec64245e..71283a973eaa 100644 --- a/etc/Makefile +++ b/etc/Makefile @@ -121,7 +121,6 @@ distribution: ${_+_}cd ${.CURDIR}/mtree; ${MAKE} install ${_+_}cd ${SRCTOP}/share/termcap; ${MAKE} etc-termcap ${_+_}cd ${SRCTOP}/usr.sbin/rmt; ${MAKE} etc-rmt - ${_+_}cd ${.CURDIR}/pam.d; ${MAKE} install .if ${MK_UNBOUND} != "no" if [ ! -e ${DESTDIR}/etc/unbound ]; then \ ${INSTALL_SYMLINK} ../var/unbound ${DESTDIR}/etc/unbound; \ diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist index 35107e8dc0c7..24bad91a0fdf 100644 --- a/etc/mtree/BSD.tests.dist +++ b/etc/mtree/BSD.tests.dist @@ -34,6 +34,8 @@ .. pwait .. + rm + .. rmdir .. sh diff --git a/lib/Makefile b/lib/Makefile index da30e8403a21..4332aa13a70c 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -70,6 +70,8 @@ SUBDIR= ${SUBDIR_BOOTSTRAP} \ libpathconv \ libpcap \ libpjdlog \ + libpmc \ + libpmcstat \ ${_libproc} \ libprocstat \ libregex \ @@ -198,9 +200,6 @@ _libdl= libdl .endif SUBDIR.${MK_OPENSSL}+= libmp -.if (${COMPILER_TYPE} == "clang" || (${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 60100 && ${MACHINE_CPUARCH} != "riscv")) -SUBDIR.${MK_PMC}+= libpmc libpmcstat -.endif SUBDIR.${MK_RADIUS_SUPPORT}+= libradius SUBDIR.${MK_SENDMAIL}+= libmilter libsm libsmdb libsmutil SUBDIR.${MK_TELNET}+= libtelnet diff --git a/lib/libpam/Makefile b/lib/libpam/Makefile index fa73b95b140d..95d922880813 100644 --- a/lib/libpam/Makefile +++ b/lib/libpam/Makefile @@ -25,7 +25,7 @@ # $FreeBSD$ # The modules link in libpam. They build the static modules as well. -SUBDIR+= libpam modules +SUBDIR+= libpam modules pam.d SUBDIR_DEPEND_modules= libpam SUBDIR+= static_libpam SUBDIR_DEPEND_static_libpam= modules diff --git a/etc/pam.d/Makefile b/lib/libpam/pam.d/Makefile similarity index 50% rename from etc/pam.d/Makefile rename to lib/libpam/pam.d/Makefile index 195274fae541..62c6ff16830d 100644 --- a/etc/pam.d/Makefile +++ b/lib/libpam/pam.d/Makefile @@ -4,9 +4,8 @@ NO_OBJ= -FILESGROUPS= FILES - -FILES= README \ +CONFGROUPS= CONFS +CONFS= README \ cron \ imap \ login \ @@ -15,34 +14,28 @@ FILES= README \ sshd su system \ xdm -FILESDIR= /etc/pam.d -FILESMODE= 644 +CONFDIR= /etc/pam.d +CONFSMODE_README= 444 .if ${MK_AT} != "no" -FILESGROUPS+= AT +CONFGROUPS+= AT AT+= atrun ATPACKAGE+= at -ATDIR= ${FILESDIR} -ATMODE= ${FILESMODE} .endif .if ${MK_FTP} != "no" -FILESGROUPS+= FTP +CONFGROUPS+= FTP FTP+= ftpd FTPPACKAGE+= ftp -FTPDIR= ${FILESDIR} -FTPMODE= ${FILESMODE} -LINKS= ${FILESDIR}/ftpd ${FILESDIR}/ftp + +afterinstallconfig: + ${INSTALL_LINK} ${TAG_ARGS} ${DESTDIR}${CONFDIR}/ftpd ${DESTDIR}${CONFDIR}/ftp .endif .if ${MK_TELNET} != "no" -FILESGROUPS+= TELNET +CONFGROUPS+= TELNET TELNET+= telnetd TELNETPACKAGE+= telnet -TELNETDIR= ${FILESDIR} -TELNETMODE= ${FILESMODE} .endif -FILESMODE_README= 444 - .include diff --git a/etc/pam.d/README b/lib/libpam/pam.d/README similarity index 100% rename from etc/pam.d/README rename to lib/libpam/pam.d/README diff --git a/etc/pam.d/atrun b/lib/libpam/pam.d/atrun similarity index 100% rename from etc/pam.d/atrun rename to lib/libpam/pam.d/atrun diff --git a/etc/pam.d/convert.pl b/lib/libpam/pam.d/convert.pl similarity index 100% rename from etc/pam.d/convert.pl rename to lib/libpam/pam.d/convert.pl diff --git a/etc/pam.d/cron b/lib/libpam/pam.d/cron similarity index 100% rename from etc/pam.d/cron rename to lib/libpam/pam.d/cron diff --git a/etc/pam.d/ftpd b/lib/libpam/pam.d/ftpd similarity index 100% rename from etc/pam.d/ftpd rename to lib/libpam/pam.d/ftpd diff --git a/etc/pam.d/imap b/lib/libpam/pam.d/imap similarity index 100% rename from etc/pam.d/imap rename to lib/libpam/pam.d/imap diff --git a/etc/pam.d/login b/lib/libpam/pam.d/login similarity index 100% rename from etc/pam.d/login rename to lib/libpam/pam.d/login diff --git a/etc/pam.d/other b/lib/libpam/pam.d/other similarity index 100% rename from etc/pam.d/other rename to lib/libpam/pam.d/other diff --git a/etc/pam.d/passwd b/lib/libpam/pam.d/passwd similarity index 100% rename from etc/pam.d/passwd rename to lib/libpam/pam.d/passwd diff --git a/etc/pam.d/pop3 b/lib/libpam/pam.d/pop3 similarity index 100% rename from etc/pam.d/pop3 rename to lib/libpam/pam.d/pop3 diff --git a/etc/pam.d/sshd b/lib/libpam/pam.d/sshd similarity index 100% rename from etc/pam.d/sshd rename to lib/libpam/pam.d/sshd diff --git a/etc/pam.d/su b/lib/libpam/pam.d/su similarity index 100% rename from etc/pam.d/su rename to lib/libpam/pam.d/su diff --git a/etc/pam.d/system b/lib/libpam/pam.d/system similarity index 100% rename from etc/pam.d/system rename to lib/libpam/pam.d/system diff --git a/etc/pam.d/telnetd b/lib/libpam/pam.d/telnetd similarity index 100% rename from etc/pam.d/telnetd rename to lib/libpam/pam.d/telnetd diff --git a/etc/pam.d/xdm b/lib/libpam/pam.d/xdm similarity index 100% rename from etc/pam.d/xdm rename to lib/libpam/pam.d/xdm diff --git a/lib/libpmc/Makefile b/lib/libpmc/Makefile index 48e94a2a078c..f40ba3b28271 100644 --- a/lib/libpmc/Makefile +++ b/lib/libpmc/Makefile @@ -7,7 +7,7 @@ SRCS= libpmc.c pmclog.c libpmc_pmu_util.c libpmc_json.cc INCS= pmc.h pmclog.h pmcformat.h CFLAGS+= -I${.CURDIR} -CWARNFLAGS.gcc+= -Wno-shadow +CWARNFLAGS.gcc+= -Wno-shadow -Wno-cast-align .if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386" diff --git a/lib/libpmc/libpmc_pmu_util.c b/lib/libpmc/libpmc_pmu_util.c index 7aaf6f2a5b18..583a2d36bc74 100644 --- a/lib/libpmc/libpmc_pmu_util.c +++ b/lib/libpmc/libpmc_pmu_util.c @@ -237,6 +237,7 @@ pmu_parse_event(struct pmu_event_desc *ped, const char *eventin) return (ENOMEM); r = event; bzero(ped, sizeof(*ped)); + ped->ped_period = DEFAULT_SAMPLE_COUNT; ped->ped_umask = -1; while ((kvp = strsep(&event, ",")) != NULL) { key = strsep(&kvp, "="); diff --git a/lib/libusb/libusb10.c b/lib/libusb/libusb10.c index 407237feb71a..09f4795afaa1 100644 --- a/lib/libusb/libusb10.c +++ b/lib/libusb/libusb10.c @@ -114,6 +114,19 @@ libusb_set_nonblocking(int f) fcntl(f, F_SETFL, flags); } +static void +libusb10_wakeup_event_loop(libusb_context *ctx) +{ + uint8_t dummy = 0; + int err; + + err = write(ctx->ctrl_pipe[1], &dummy, sizeof(dummy)); + if (err < (int)sizeof(dummy)) { + /* ignore error, if any */ + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "Waking up event loop failed!"); + } +} + int libusb_init(libusb_context **context) { @@ -484,7 +497,6 @@ libusb_open(libusb_device *dev, libusb_device_handle **devh) { libusb_context *ctx = dev->ctx; struct libusb20_device *pdev = dev->os_priv; - uint8_t dummy; int err; if (devh == NULL) @@ -506,12 +518,8 @@ libusb_open(libusb_device *dev, libusb_device_handle **devh) POLLOUT | POLLRDNORM | POLLWRNORM); /* make sure our event loop detects the new device */ - dummy = 0; - err = write(ctx->ctrl_pipe[1], &dummy, sizeof(dummy)); - if (err < (int)sizeof(dummy)) { - /* ignore error, if any */ - DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_open write failed!"); - } + libusb10_wakeup_event_loop(ctx); + *devh = pdev; return (0); @@ -564,8 +572,6 @@ libusb_close(struct libusb20_device *pdev) { libusb_context *ctx; struct libusb_device *dev; - uint8_t dummy; - int err; if (pdev == NULL) return; /* be NULL safe */ @@ -581,12 +587,7 @@ libusb_close(struct libusb20_device *pdev) libusb_unref_device(dev); /* make sure our event loop detects the closed device */ - dummy = 0; - err = write(ctx->ctrl_pipe[1], &dummy, sizeof(dummy)); - if (err < (int)sizeof(dummy)) { - /* ignore error, if any */ - DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_close write failed!"); - } + libusb10_wakeup_event_loop(ctx); } libusb_device * @@ -1314,7 +1315,6 @@ libusb10_submit_transfer_sub(struct libusb20_device *pdev, uint8_t endpoint) int buffsize; int maxframe; int temp; - uint8_t dummy; dev = libusb_get_device(pdev); @@ -1415,10 +1415,8 @@ libusb10_submit_transfer_sub(struct libusb20_device *pdev, uint8_t endpoint) failure: libusb10_complete_transfer(pxfer0, sxfer, LIBUSB_TRANSFER_ERROR); - /* make sure our event loop spins the done handler */ - dummy = 0; - err = write(dev->ctx->ctrl_pipe[1], &dummy, sizeof(dummy)); + libusb10_wakeup_event_loop(dev->ctx); } /* The following function must be called unlocked */ @@ -1459,6 +1457,8 @@ libusb_submit_transfer(struct libusb_transfer *uxfer) (libusb20_tr_get_priv_sc1(pxfer0) == sxfer) || (libusb20_tr_get_priv_sc1(pxfer1) == sxfer)) { err = LIBUSB_ERROR_BUSY; + } else if (dev->device_is_gone != 0) { + err = LIBUSB_ERROR_NO_DEVICE; } else { /* set pending state */ @@ -1490,6 +1490,7 @@ libusb_cancel_transfer(struct libusb_transfer *uxfer) struct libusb20_transfer *pxfer1; struct libusb_super_transfer *sxfer; struct libusb_device *dev; + struct libusb_device_handle *devh; uint8_t endpoint; int retval; @@ -1497,12 +1498,12 @@ libusb_cancel_transfer(struct libusb_transfer *uxfer) return (LIBUSB_ERROR_INVALID_PARAM); /* check if not initialised */ - if (uxfer->dev_handle == NULL) + if ((devh = uxfer->dev_handle) == NULL) return (LIBUSB_ERROR_NOT_FOUND); endpoint = uxfer->endpoint; - dev = libusb_get_device(uxfer->dev_handle); + dev = libusb_get_device(devh); DPRINTF(dev->ctx, LIBUSB_DEBUG_FUNCTION, "libusb_cancel_transfer enter"); @@ -1513,8 +1514,8 @@ libusb_cancel_transfer(struct libusb_transfer *uxfer) CTX_LOCK(dev->ctx); - pxfer0 = libusb10_get_transfer(uxfer->dev_handle, endpoint, 0); - pxfer1 = libusb10_get_transfer(uxfer->dev_handle, endpoint, 1); + pxfer0 = libusb10_get_transfer(devh, endpoint, 0); + pxfer1 = libusb10_get_transfer(devh, endpoint, 1); if (sxfer->state != LIBUSB_SUPER_XFER_ST_PEND) { /* only update the transfer status */ @@ -1526,23 +1527,38 @@ libusb_cancel_transfer(struct libusb_transfer *uxfer) sxfer->entry.tqe_prev = NULL; libusb10_complete_transfer(NULL, sxfer, LIBUSB_TRANSFER_CANCELLED); + /* make sure our event loop spins the done handler */ + libusb10_wakeup_event_loop(dev->ctx); } else if (pxfer0 == NULL || pxfer1 == NULL) { /* not started */ retval = LIBUSB_ERROR_NOT_FOUND; } else if (libusb20_tr_get_priv_sc1(pxfer0) == sxfer) { libusb10_complete_transfer(pxfer0, sxfer, LIBUSB_TRANSFER_CANCELLED); - libusb20_tr_stop(pxfer0); - /* make sure the queue doesn't stall */ - libusb10_submit_transfer_sub( - uxfer->dev_handle, endpoint); + if (dev->device_is_gone != 0) { + /* clear transfer pointer */ + libusb20_tr_set_priv_sc1(pxfer0, NULL); + /* make sure our event loop spins the done handler */ + libusb10_wakeup_event_loop(dev->ctx); + } else { + libusb20_tr_stop(pxfer0); + /* make sure the queue doesn't stall */ + libusb10_submit_transfer_sub(devh, endpoint); + } } else if (libusb20_tr_get_priv_sc1(pxfer1) == sxfer) { libusb10_complete_transfer(pxfer1, sxfer, LIBUSB_TRANSFER_CANCELLED); - libusb20_tr_stop(pxfer1); - /* make sure the queue doesn't stall */ - libusb10_submit_transfer_sub( - uxfer->dev_handle, endpoint); + /* check if handle is still active */ + if (dev->device_is_gone != 0) { + /* clear transfer pointer */ + libusb20_tr_set_priv_sc1(pxfer1, NULL); + /* make sure our event loop spins the done handler */ + libusb10_wakeup_event_loop(dev->ctx); + } else { + libusb20_tr_stop(pxfer1); + /* make sure the queue doesn't stall */ + libusb10_submit_transfer_sub(devh, endpoint); + } } else { /* not started */ retval = LIBUSB_ERROR_NOT_FOUND; @@ -1571,6 +1587,35 @@ libusb10_cancel_all_transfer(libusb_device *dev) } } +UNEXPORTED void +libusb10_cancel_all_transfer_locked(struct libusb20_device *pdev, struct libusb_device *dev) +{ + struct libusb_super_transfer *sxfer; + unsigned x; + + for (x = 0; x != LIBUSB_NUM_SW_ENDPOINTS; x++) { + struct libusb20_transfer *xfer; + + xfer = libusb20_tr_get_pointer(pdev, x); + if (xfer == NULL) + continue; + if (libusb20_tr_pending(xfer) == 0) + continue; + sxfer = libusb20_tr_get_priv_sc1(xfer); + if (sxfer == NULL) + continue; + /* complete pending transfer */ + libusb10_complete_transfer(xfer, sxfer, LIBUSB_TRANSFER_ERROR); + } + + while ((sxfer = TAILQ_FIRST(&dev->tr_head))) { + TAILQ_REMOVE(&dev->tr_head, sxfer, entry); + + /* complete pending transfer */ + libusb10_complete_transfer(NULL, sxfer, LIBUSB_TRANSFER_ERROR); + } +} + uint16_t libusb_cpu_to_le16(uint16_t x) { diff --git a/lib/libusb/libusb10.h b/lib/libusb/libusb10.h index e516de17b1e9..c3deb562c6d4 100644 --- a/lib/libusb/libusb10.h +++ b/lib/libusb/libusb10.h @@ -41,22 +41,24 @@ #define HOTPLUG_LOCK(ctx) pthread_mutex_lock(&(ctx)->hotplug_lock) #define HOTPLUG_UNLOCK(ctx) pthread_mutex_unlock(&(ctx)->hotplug_lock) -#define DPRINTF(ctx, dbg, format, args...) do { \ - if ((ctx)->debug == dbg) { \ - switch (dbg) { \ - case LIBUSB_DEBUG_FUNCTION: \ - printf("LIBUSB_FUNCTION: " \ - format "\n", ## args); \ - break; \ - case LIBUSB_DEBUG_TRANSFER: \ - printf("LIBUSB_TRANSFER: " \ - format "\n", ## args); \ - break; \ - default: \ - break; \ - } \ - } \ -} while(0) +#define DPRINTF(ctx, dbg, format, ...) do { \ + switch (dbg) { \ + case LIBUSB_DEBUG_FUNCTION: \ + if ((ctx)->debug & LIBUSB_DEBUG_FUNCTION) { \ + printf("LIBUSB_FUNCTION: " \ + format "\n", ## __VA_ARGS__); \ + } \ + break; \ + case LIBUSB_DEBUG_TRANSFER: \ + if ((ctx)->debug & LIBUSB_DEBUG_TRANSFER) { \ + printf("LIBUSB_TRANSFER: " \ + format "\n", ## __VA_ARGS__); \ + } \ + break; \ + default: \ + break; \ + } \ +} while (0) /* internal structures */ @@ -116,6 +118,8 @@ struct libusb_context { struct libusb_device { int refcnt; + int device_is_gone; + uint32_t claimed_interfaces; struct libusb_super_pollfd dev_poll; @@ -134,5 +138,6 @@ extern struct libusb_context *usbi_default_context; void libusb10_add_pollfd(libusb_context *ctx, struct libusb_super_pollfd *pollfd, struct libusb20_device *pdev, int fd, short events); void libusb10_remove_pollfd(libusb_context *ctx, struct libusb_super_pollfd *pollfd); void libusb10_cancel_all_transfer(libusb_device *dev); +void libusb10_cancel_all_transfer_locked(struct libusb20_device *pdev, struct libusb_device *dev); #endif /* __LIBUSB10_H__ */ diff --git a/lib/libusb/libusb10_io.c b/lib/libusb/libusb10_io.c index e25b6a37d77d..13c9e786c00e 100644 --- a/lib/libusb/libusb10_io.c +++ b/lib/libusb/libusb10_io.c @@ -161,17 +161,19 @@ libusb10_handle_events_sub(struct libusb_context *ctx, struct timeval *tv) if (ppdev[i] != NULL) { dev = libusb_get_device(ppdev[i]); - if (fds[i].revents == 0) - err = 0; /* nothing to do */ - else + if (fds[i].revents != 0) { err = libusb20_dev_process(ppdev[i]); - if (err) { - /* cancel all transfers - device is gone */ - libusb10_cancel_all_transfer(dev); + if (err) { + /* set device is gone */ + dev->device_is_gone = 1; - /* remove USB device from polling loop */ - libusb10_remove_pollfd(dev->ctx, &dev->dev_poll); + /* remove USB device from polling loop */ + libusb10_remove_pollfd(dev->ctx, &dev->dev_poll); + + /* cancel all pending transfers */ + libusb10_cancel_all_transfer_locked(ppdev[i], dev); + } } CTX_UNLOCK(ctx); libusb_unref_device(dev); @@ -180,10 +182,8 @@ libusb10_handle_events_sub(struct libusb_context *ctx, struct timeval *tv) } else { uint8_t dummy; - while (1) { - if (read(fds[i].fd, &dummy, 1) != 1) - break; - } + while (read(fds[i].fd, &dummy, 1) == 1) + ; } } @@ -489,13 +489,26 @@ libusb_control_transfer(libusb_device_handle *devh, return (actlen); } +static libusb_context * +libusb10_get_context_by_device_handle(libusb_device_handle *devh) +{ + libusb_context *ctx; + + if (devh != NULL) + ctx = libusb_get_device(devh)->ctx; + else + ctx = NULL; + + return (GET_CONTEXT(ctx)); +} + static void libusb10_do_transfer_cb(struct libusb_transfer *transfer) { libusb_context *ctx; int *pdone; - ctx = GET_CONTEXT(NULL); + ctx = libusb10_get_context_by_device_handle(transfer->dev_handle); DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "sync I/O done"); @@ -585,7 +598,8 @@ libusb_bulk_transfer(libusb_device_handle *devh, libusb_context *ctx; int ret; - ctx = GET_CONTEXT(NULL); + ctx = libusb10_get_context_by_device_handle(devh); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_bulk_transfer enter"); ret = libusb10_do_transfer(devh, endpoint, data, length, transferred, @@ -603,7 +617,8 @@ libusb_interrupt_transfer(libusb_device_handle *devh, libusb_context *ctx; int ret; - ctx = GET_CONTEXT(NULL); + ctx = libusb10_get_context_by_device_handle(devh); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_interrupt_transfer enter"); ret = libusb10_do_transfer(devh, endpoint, data, length, transferred, diff --git a/sbin/geom/core/geom.8 b/sbin/geom/core/geom.8 index ab960ff9e07b..298fc2b1d4fd 100644 --- a/sbin/geom/core/geom.8 +++ b/sbin/geom/core/geom.8 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 5, 2011 +.Dd September 14, 2018 .Dt GEOM 8 .Os .Sh NAME @@ -52,6 +52,11 @@ .Ar class .Cm unload .Op Fl v +.Nm +.Fl p +.Ar provider-name +.Nm +.Fl t .Sh DESCRIPTION The .Nm @@ -103,6 +108,15 @@ This command is only available if the given class is loaded as a kernel module. .El .Pp +Additional options include: +.Bl -tag -width ".Cm status" +.It Fl p Ar provider-name +Print detailed information about the geom which provides +.Ar provider-name . +.It Fl t +Display geoms hierarchy as a tree. +.El +.Pp Class-specific commands are implemented as shared libraries which are stored in .Pa /lib/geom/ diff --git a/sbin/geom/core/geom.c b/sbin/geom/core/geom.c index b6142d78e957..e6d6d789908f 100644 --- a/sbin/geom/core/geom.c +++ b/sbin/geom/core/geom.c @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -65,9 +66,13 @@ static uint32_t *version = NULL; static int verbose = 0; static struct g_command *class_commands = NULL; -#define GEOM_CLASS_CMDS 0x01 -#define GEOM_STD_CMDS 0x02 +#define GEOM_CLASS_CMDS 0x01 +#define GEOM_STD_CMDS 0x02 + +#define GEOM_CLASS_WIDTH 10 + static struct g_command *find_command(const char *cmdstr, int flags); +static void list_one_geom_by_provider(const char *provider_name); static int std_available(const char *name); static void std_help(struct gctl_req *req, unsigned flags); @@ -146,6 +151,8 @@ usage(void) if (class_name == NULL) { fprintf(stderr, "usage: geom [options]\n"); + fprintf(stderr, " geom -p \n"); + fprintf(stderr, " geom -t\n"); exit(EXIT_FAILURE); } else { struct g_command *cmd; @@ -650,9 +657,186 @@ get_class(int *argc, char ***argv) usage(); } +static struct ggeom * +find_geom_by_provider(struct gmesh *mesh, const char *name) +{ + struct gclass *classp; + struct ggeom *gp; + struct gprovider *pp; + + LIST_FOREACH(classp, &mesh->lg_class, lg_class) { + LIST_FOREACH(gp, &classp->lg_geom, lg_geom) { + LIST_FOREACH(pp, &gp->lg_provider, lg_provider) { + if (strcmp(pp->lg_name, name) == 0) + return (gp); + } + } + } + + return (NULL); +} + +static int +compute_tree_width_geom(struct gmesh *mesh, struct ggeom *gp, int indent) +{ + struct gclass *classp2; + struct ggeom *gp2; + struct gconsumer *cp2; + struct gprovider *pp; + int max_width, width; + + max_width = width = indent + strlen(gp->lg_name); + + LIST_FOREACH(pp, &gp->lg_provider, lg_provider) { + LIST_FOREACH(classp2, &mesh->lg_class, lg_class) { + LIST_FOREACH(gp2, &classp2->lg_geom, lg_geom) { + LIST_FOREACH(cp2, + &gp2->lg_consumer, lg_consumer) { + if (pp != cp2->lg_provider) + continue; + width = compute_tree_width_geom(mesh, + gp2, indent + 2); + if (width > max_width) + max_width = width; + } + } + } + } + + return (max_width); +} + +static int +compute_tree_width(struct gmesh *mesh) +{ + struct gclass *classp; + struct ggeom *gp; + int max_width, width; + + max_width = width = 0; + + LIST_FOREACH(classp, &mesh->lg_class, lg_class) { + LIST_FOREACH(gp, &classp->lg_geom, lg_geom) { + if (!LIST_EMPTY(&gp->lg_consumer)) + continue; + width = compute_tree_width_geom(mesh, gp, 0); + if (width > max_width) + max_width = width; + } + } + + return (max_width); +} + +static void +show_tree_geom(struct gmesh *mesh, struct ggeom *gp, int indent, int width) +{ + struct gclass *classp2; + struct ggeom *gp2; + struct gconsumer *cp2; + struct gprovider *pp; + + if (LIST_EMPTY(&gp->lg_provider)) { + printf("%*s%-*.*s %-*.*s\n", indent, "", + width - indent, width - indent, gp->lg_name, + GEOM_CLASS_WIDTH, GEOM_CLASS_WIDTH, gp->lg_class->lg_name); + return; + } + + LIST_FOREACH(pp, &gp->lg_provider, lg_provider) { + printf("%*s%-*.*s %-*.*s %s\n", indent, "", + width - indent, width - indent, gp->lg_name, + GEOM_CLASS_WIDTH, GEOM_CLASS_WIDTH, gp->lg_class->lg_name, + pp->lg_name); + + LIST_FOREACH(classp2, &mesh->lg_class, lg_class) { + LIST_FOREACH(gp2, &classp2->lg_geom, lg_geom) { + LIST_FOREACH(cp2, + &gp2->lg_consumer, lg_consumer) { + if (pp != cp2->lg_provider) + continue; + show_tree_geom(mesh, gp2, + indent + 2, width); + } + } + } + } +} + +static void +show_tree(void) +{ + struct gmesh mesh; + struct gclass *classp; + struct ggeom *gp; + int error, width; + + error = geom_gettree(&mesh); + if (error != 0) + errc(EXIT_FAILURE, error, "Cannot get GEOM tree"); + + width = compute_tree_width(&mesh); + + printf("%-*.*s %-*.*s %s\n", + width, width, "Geom", + GEOM_CLASS_WIDTH, GEOM_CLASS_WIDTH, "Class", + "Provider"); + + LIST_FOREACH(classp, &mesh.lg_class, lg_class) { + LIST_FOREACH(gp, &classp->lg_geom, lg_geom) { + if (!LIST_EMPTY(&gp->lg_consumer)) + continue; + show_tree_geom(&mesh, gp, 0, width); + } + } +} + int main(int argc, char *argv[]) { + char *provider_name; + bool tflag; + int ch; + + provider_name = NULL; + tflag = false; + + if (strcmp(getprogname(), "geom") == 0) { + while ((ch = getopt(argc, argv, "hp:t")) != -1) { + switch (ch) { + case 'p': + provider_name = strdup(optarg); + if (provider_name == NULL) + err(1, "strdup"); + break; + case 't': + tflag = true; + break; + case 'h': + default: + usage(); + } + } + + /* + * Don't adjust argc and argv, it would break get_class(). + */ + } + + if (tflag && provider_name != NULL) { + errx(EXIT_FAILURE, + "At most one of -P and -t may be specified."); + } + + if (provider_name != NULL) { + list_one_geom_by_provider(provider_name); + return (0); + } + + if (tflag) { + show_tree(); + return (0); + } get_class(&argc, &argv); run_command(argc, argv); @@ -767,6 +951,25 @@ list_one_geom(struct ggeom *gp) printf("\n"); } +static void +list_one_geom_by_provider(const char *provider_name) +{ + struct gmesh mesh; + struct ggeom *gp; + int error; + + error = geom_gettree(&mesh); + if (error != 0) + errc(EXIT_FAILURE, error, "Cannot get GEOM tree"); + + gp = find_geom_by_provider(&mesh, provider_name); + if (gp == NULL) + errx(EXIT_FAILURE, "Cannot find provider '%s'.", provider_name); + + printf("Geom class: %s\n", gp->lg_class->lg_name); + list_one_geom(gp); +} + static void std_help(struct gctl_req *req __unused, unsigned flags __unused) { diff --git a/sbin/reboot/reboot.c b/sbin/reboot/reboot.c index 28b84ff25bce..4dcade7611c2 100644 --- a/sbin/reboot/reboot.c +++ b/sbin/reboot/reboot.c @@ -73,7 +73,7 @@ main(int argc, char *argv[]) u_int pageins; const char *user, *kernel = NULL; - if (strcmp(getprogname(), "halt") == 0) { + if (strstr(getprogname(), "halt") != NULL) { dohalt = 1; howto = RB_HALT; } else diff --git a/sbin/umount/umount.c b/sbin/umount/umount.c index 9e8c71d0f1f6..b936c9dc174a 100644 --- a/sbin/umount/umount.c +++ b/sbin/umount/umount.c @@ -136,10 +136,6 @@ main(int argc, char *argv[]) if ((fflag & MNT_FORCE) != 0 && (fflag & MNT_NONBUSY) != 0) err(1, "-f and -n are mutually exclusive"); - /* Start disks transferring immediately. */ - if ((fflag & (MNT_FORCE | MNT_NONBUSY)) == 0 && nfsforce == 0) - sync(); - if ((argc == 0 && !all) || (argc != 0 && all)) usage(); diff --git a/share/man/man4/ig4.4 b/share/man/man4/ig4.4 index 9237b96635d7..3ca88dee8016 100644 --- a/share/man/man4/ig4.4 +++ b/share/man/man4/ig4.4 @@ -24,12 +24,12 @@ .\" .\" $FreeBSD$ .\" -.Dd October 03, 2016 +.Dd September 13, 2018 .Dt IG4 4 .Os .Sh NAME .Nm ig4 -.Nd Intel(R) fourth generation mobile CPU integrated I2C driver +.Nd Synopsys DesignWare I2C Controller .Sh SYNOPSIS To compile this driver into the kernel, place the following lines into the kernel configuration file: @@ -49,9 +49,9 @@ The driver provides access to peripherals attached to an I2C controller. .Sh HARDWARE .Nm -supports the I2C controllers found in fourth generation Intel(R) Core(TM) -processors based on the mobile U-processor line for intelligent systems. -This includes the i7-4650U, i5-4300U, i3-4010U, and 2980U. +supports the I2C controllers based on Synopsys DesignWare IP that can be found +in Intel(R) Core(TM) processors starting from the fourth generation, Intel(R) +Bay Trail, Apollo Lake SoC families, and some AMD systems. .Sh SYSCTL VARIABLES These .Xr sysctl 8 diff --git a/share/man/man5/src.conf.5 b/share/man/man5/src.conf.5 index 628a0e7d38e8..8a0104171975 100644 --- a/share/man/man5/src.conf.5 +++ b/share/man/man5/src.conf.5 @@ -1,6 +1,6 @@ .\" DO NOT EDIT-- this file is @generated by tools/build/options/makeman. .\" $FreeBSD$ -.Dd August 28, 2018 +.Dd September 13, 2018 .Dt SRC.CONF 5 .Os .Sh NAME @@ -1534,10 +1534,10 @@ by proxy. .It Va WITHOUT_RBOOTD Set to not build or install .Xr rbootd 8 . -.It Va WITH_REPRODUCIBLE_BUILD -Set to exclude build metadata (such as the build time, user, or host) -from the kernel, boot loaders, and uname output, so that builds produce -bit-for-bit identical output. +.It Va WITHOUT_REPRODUCIBLE_BUILD +Set to include build metadata (such as the build time, user, and host) +in the kernel, boot loaders, and uname output. +Successive builds will not be bit-for-bit identical. .It Va WITHOUT_RESCUE Set to not build .Xr rescue 8 . diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk index ac76994b2c75..7667b97bdf2f 100644 --- a/share/mk/src.opts.mk +++ b/share/mk/src.opts.mk @@ -159,6 +159,7 @@ __DEFAULT_YES_OPTIONS = \ QUOTAS \ RADIUS_SUPPORT \ RBOOTD \ + REPRODUCIBLE_BUILD \ RESCUE \ ROUTED \ SENDMAIL \ @@ -201,7 +202,6 @@ __DEFAULT_NO_OPTIONS = \ NAND \ OFED_EXTRA \ OPENLDAP \ - REPRODUCIBLE_BUILD \ RPCBIND_WARMSTART_SUPPORT \ SHARED_TOOLCHAIN \ SORT_THREADS \ diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index e1f148be16fa..d9b6e0a04d5a 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -131,6 +131,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #ifdef SMP #include #endif @@ -2661,3 +2662,43 @@ outb_(u_short port, u_char data) } #endif /* KDB */ + +#undef memset +#undef memmove +#undef memcpy + +void *memset_std(void *buf, int c, size_t len); +void *memset_erms(void *buf, int c, size_t len); +DEFINE_IFUNC(, void *, memset, (void *, int, size_t), static) +{ + + return ((cpu_stdext_feature & CPUID_STDEXT_ERMS) != 0 ? + memset_erms : memset_std); +} + +void *memmove_std(void * _Nonnull dst, const void * _Nonnull src, size_t len); +void *memmove_erms(void * _Nonnull dst, const void * _Nonnull src, size_t len); +DEFINE_IFUNC(, void *, memmove, (void * _Nonnull, const void * _Nonnull, size_t), static) +{ + + return ((cpu_stdext_feature & CPUID_STDEXT_ERMS) != 0 ? + memmove_erms : memmove_std); +} + +void *memcpy_std(void * _Nonnull dst, const void * _Nonnull src, size_t len); +void *memcpy_erms(void * _Nonnull dst, const void * _Nonnull src, size_t len); +DEFINE_IFUNC(, void *, memcpy, (void * _Nonnull, const void * _Nonnull, size_t), static) +{ + + return ((cpu_stdext_feature & CPUID_STDEXT_ERMS) != 0 ? + memcpy_erms : memcpy_std); +} + +void pagezero_std(void *addr); +void pagezero_erms(void *addr); +DEFINE_IFUNC(, void , pagezero, (void *), static) +{ + + return ((cpu_stdext_feature & CPUID_STDEXT_ERMS) != 0 ? + pagezero_erms : pagezero_std); +} diff --git a/sys/amd64/amd64/support.S b/sys/amd64/amd64/support.S index 714f100a9749..e683b24162ec 100644 --- a/sys/amd64/amd64/support.S +++ b/sys/amd64/amd64/support.S @@ -41,7 +41,7 @@ .text /* Address: %rdi */ -ENTRY(pagezero) +ENTRY(pagezero_std) PUSH_FRAME_POINTER movq $PAGE_SIZE/8,%rcx xorl %eax,%eax @@ -49,7 +49,17 @@ ENTRY(pagezero) stosq POP_FRAME_POINTER ret -END(pagezero) +END(pagezero_std) + +ENTRY(pagezero_erms) + PUSH_FRAME_POINTER + movq $PAGE_SIZE,%rcx + xorl %eax,%eax + rep + stosb + POP_FRAME_POINTER + ret +END(pagezero_erms) /* * pagecopy(%rdi=from, %rsi=to) @@ -96,7 +106,7 @@ END(sse2_pagezero) * Adapted from bcopy written by: * ws@tools.de (Wolfgang Solfrank, TooLs GmbH) +49-228-985800 */ -ENTRY(memmove) +ENTRY(memmove_std) PUSH_FRAME_POINTER movq %rdi,%r9 movq %rdx,%rcx @@ -142,7 +152,37 @@ ENTRY(memmove) movq %r9,%rax POP_FRAME_POINTER ret -END(memmove) +END(memmove_std) + +ENTRY(memmove_erms) + PUSH_FRAME_POINTER + movq %rdi,%r9 + movq %rdx,%rcx + + movq %rdi,%rax + subq %rsi,%rax + cmpq %rcx,%rax /* overlapping && src < dst? */ + jb 1f + + rep + movsb + movq %r9,%rax + POP_FRAME_POINTER + ret + +1: + addq %rcx,%rdi /* copy backwards */ + addq %rcx,%rsi + decq %rdi + decq %rsi + std + rep + movsb + cld + movq %r9,%rax + POP_FRAME_POINTER + ret +END(memmove_erms) /* * memcpy(dst, src, len) @@ -150,7 +190,7 @@ END(memmove) * * Note: memcpy does not support overlapping copies */ -ENTRY(memcpy) +ENTRY(memcpy_std) PUSH_FRAME_POINTER movq %rdi,%rax movq %rdx,%rcx @@ -167,13 +207,23 @@ ENTRY(memcpy) movsb POP_FRAME_POINTER ret -END(memcpy) +END(memcpy_std) + +ENTRY(memcpy_erms) + PUSH_FRAME_POINTER + movq %rdi,%rax + movq %rdx,%rcx + rep + movsb + POP_FRAME_POINTER + ret +END(memcpy_erms) /* * memset(dst, c, len) * rdi, rsi, rdx */ -ENTRY(memset) +ENTRY(memset_std) PUSH_FRAME_POINTER movq %rdi,%r9 movq %rdx,%rcx @@ -195,7 +245,19 @@ ENTRY(memset) movq %r9,%rax POP_FRAME_POINTER ret -END(memset) +END(memset_std) + +ENTRY(memset_erms) + PUSH_FRAME_POINTER + movq %rdi,%r9 + movq %rdx,%rcx + movb %sil,%al + rep + stosb + movq %r9,%rax + POP_FRAME_POINTER + ret +END(memset_erms) /* fillw(pat, base, cnt) */ /* %rdi,%rsi, %rdx */ diff --git a/sys/amd64/conf/GENERIC b/sys/amd64/conf/GENERIC index 3d1056189ebe..f2d4d0d37222 100644 --- a/sys/amd64/conf/GENERIC +++ b/sys/amd64/conf/GENERIC @@ -25,6 +25,7 @@ makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols makeoptions WITH_CTF=1 # Run ctfconvert(1) for DTrace support options SCHED_ULE # ULE scheduler +options NUMA # Non-Uniform Memory Architecture support options PREEMPTION # Enable kernel thread preemption options VIMAGE # Subsystem virtualization, e.g. VNET options INET # InterNETworking diff --git a/sys/amd64/conf/MINIMAL b/sys/amd64/conf/MINIMAL index 010148ff2d86..011400f3967f 100644 --- a/sys/amd64/conf/MINIMAL +++ b/sys/amd64/conf/MINIMAL @@ -39,6 +39,7 @@ makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols makeoptions WITH_CTF=1 # Run ctfconvert(1) for DTrace support options SCHED_ULE # ULE scheduler +options NUMA # Non-Uniform Memory Architecture support options PREEMPTION # Enable kernel thread preemption options INET # InterNETworking options INET6 # IPv6 communications protocols diff --git a/sys/arm/conf/std.armv6 b/sys/arm/conf/std.armv6 index 2f6f9c93af4f..52685a9b13bf 100644 --- a/sys/arm/conf/std.armv6 +++ b/sys/arm/conf/std.armv6 @@ -41,6 +41,8 @@ options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions options PRINTF_BUFR_SIZE=128 # Prevent printf output being interspersed. options KBD_INSTALL_CDEV # install a CDEV entry in /dev options HWPMC_HOOKS # Necessary kernel hooks for hwpmc(4) +options CAPABILITY_MODE # Capsicum capability mode +options CAPABILITIES # Capsicum capabilites options FREEBSD_BOOT_LOADER # Process metadata passed from loader(8) options VFP # Enable floating point hardware support options MAC # Support for Mandatory Access Control (MAC) diff --git a/sys/arm/conf/std.armv7 b/sys/arm/conf/std.armv7 index 5754f4780fea..c3ab6852e615 100644 --- a/sys/arm/conf/std.armv7 +++ b/sys/arm/conf/std.armv7 @@ -41,6 +41,8 @@ options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions options PRINTF_BUFR_SIZE=128 # Prevent printf output being interspersed. options KBD_INSTALL_CDEV # install a CDEV entry in /dev options HWPMC_HOOKS # Necessary kernel hooks for hwpmc(4) +options CAPABILITY_MODE # Capsicum capability mode +options CAPABILITIES # Capsicum capabilites options FREEBSD_BOOT_LOADER # Process metadata passed from loader(8) options VFP # Enable floating point hardware support options MAC # Support for Mandatory Access Control (MAC) diff --git a/sys/arm64/conf/GENERIC-MMCCAM b/sys/arm64/conf/GENERIC-MMCCAM index 0d1e91cd58c8..ab45fcb8168d 100644 --- a/sys/arm64/conf/GENERIC-MMCCAM +++ b/sys/arm64/conf/GENERIC-MMCCAM @@ -9,6 +9,7 @@ #NO_UNIVERSE include GENERIC +ident GENERIC-MMCCAM # Add CAMDEBUG stuff options CAMDEBUG diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c index 2bc065e12509..37aa9bb3dc96 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c @@ -538,9 +538,14 @@ typedef struct arc_state { */ int zfs_arc_meta_prune = 10000; unsigned long zfs_arc_dnode_limit_percent = 10; -int zfs_arc_meta_strategy = ARC_STRATEGY_META_BALANCED; +int zfs_arc_meta_strategy = ARC_STRATEGY_META_ONLY; int zfs_arc_meta_adjust_restarts = 4096; +SYSCTL_INT(_vfs_zfs, OID_AUTO, arc_meta_strategy, CTLFLAG_RWTUN, + &zfs_arc_meta_strategy, 0, + "ARC metadata reclamation strategy " + "(0 = metadata only, 1 = balance data and metadata)"); + /* The 6 states: */ static arc_state_t ARC_anon; static arc_state_t ARC_mru; diff --git a/sys/compat/x86bios/x86bios.c b/sys/compat/x86bios/x86bios.c index d9917383d13d..542f04cc0b0d 100644 --- a/sys/compat/x86bios/x86bios.c +++ b/sys/compat/x86bios/x86bios.c @@ -656,17 +656,24 @@ static __inline void x86bios_unmap_mem(void) { - free(x86bios_map, M_DEVBUF); - if (x86bios_ivt != NULL) + if (x86bios_map != NULL) { + free(x86bios_map, M_DEVBUF); + x86bios_map = NULL; + } + if (x86bios_ivt != NULL) { #ifdef X86BIOS_NATIVE_ARCH pmap_unmapbios((vm_offset_t)x86bios_ivt, X86BIOS_IVT_SIZE); #else free(x86bios_ivt, M_DEVBUF); + x86bios_ivt = NULL; #endif + } if (x86bios_rom != NULL) pmap_unmapdev((vm_offset_t)x86bios_rom, X86BIOS_ROM_SIZE); - if (x86bios_seg != NULL) + if (x86bios_seg != NULL) { contigfree(x86bios_seg, X86BIOS_SEG_SIZE, M_DEVBUF); + x86bios_seg = NULL; + } } static __inline int @@ -674,7 +681,9 @@ x86bios_map_mem(void) { x86bios_map = malloc(sizeof(*x86bios_map) * X86BIOS_PAGES, M_DEVBUF, - M_WAITOK | M_ZERO); + M_NOWAIT | M_ZERO); + if (x86bios_map == NULL) + goto fail; #ifdef X86BIOS_NATIVE_ARCH x86bios_ivt = pmap_mapbios(X86BIOS_IVT_BASE, X86BIOS_IVT_SIZE); @@ -688,7 +697,9 @@ x86bios_map_mem(void) rounddown(x86bios_rom_phys, X86BIOS_PAGE_SIZE); else #else - x86bios_ivt = malloc(X86BIOS_IVT_SIZE, M_DEVBUF, M_ZERO | M_WAITOK); + x86bios_ivt = malloc(X86BIOS_IVT_SIZE, M_DEVBUF, M_NOWAIT | M_ZERO); + if (x86bios_ivt == NULL) + goto fail; #endif x86bios_rom_phys = X86BIOS_ROM_BASE; @@ -703,8 +714,10 @@ x86bios_map_mem(void) goto fail; #endif - x86bios_seg = contigmalloc(X86BIOS_SEG_SIZE, M_DEVBUF, M_WAITOK, + x86bios_seg = contigmalloc(X86BIOS_SEG_SIZE, M_DEVBUF, M_NOWAIT, X86BIOS_RAM_BASE, x86bios_rom_phys, X86BIOS_PAGE_SIZE, 0); + if (x86bios_seg == NULL) + goto fail; x86bios_seg_phys = vtophys(x86bios_seg); x86bios_set_pages((vm_offset_t)x86bios_ivt, X86BIOS_IVT_BASE, diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64 index 33bf1b281eaf..76e9e8e36479 100644 --- a/sys/conf/files.arm64 +++ b/sys/conf/files.arm64 @@ -33,14 +33,14 @@ arm/allwinner/aw_nmi.c optional aw_nmi fdt \ compile-with "${NORMAL_C} -I$S/gnu/dts/include" arm/allwinner/aw_rsb.c optional aw_rsb fdt arm/allwinner/aw_rtc.c optional aw_rtc fdt -arm/allwinner/aw_sid.c optional aw_sid fdt +arm/allwinner/aw_sid.c optional aw_sid nvmem fdt arm/allwinner/aw_spi.c optional aw_spi fdt arm/allwinner/aw_syscon.c optional aw_syscon ext_resources syscon fdt -arm/allwinner/aw_thermal.c optional aw_thermal fdt +arm/allwinner/aw_thermal.c optional aw_thermal nvmem fdt arm/allwinner/aw_usbphy.c optional ehci aw_usbphy fdt arm/allwinner/aw_wdog.c optional aw_wdog fdt arm/allwinner/axp81x.c optional axp81x fdt -arm/allwinner/if_awg.c optional awg ext_resources syscon fdt +arm/allwinner/if_awg.c optional awg ext_resources syscon aw_sid nvmem fdt # Allwinner clock driver arm/allwinner/clkng/aw_ccung.c optional aw_ccu fdt diff --git a/sys/conf/kern.opts.mk b/sys/conf/kern.opts.mk index 0a229822607c..b5663dc6509a 100644 --- a/sys/conf/kern.opts.mk +++ b/sys/conf/kern.opts.mk @@ -42,6 +42,7 @@ __DEFAULT_YES_OPTIONS = \ MODULE_DRM2 \ NETGRAPH \ PF \ + REPRODUCIBLE_BUILD \ SOURCELESS_HOST \ SOURCELESS_UCODE \ TESTS \ @@ -53,8 +54,7 @@ __DEFAULT_NO_OPTIONS = \ KERNEL_RETPOLINE \ NAND \ OFED \ - RATELIMIT \ - REPRODUCIBLE_BUILD + RATELIMIT # Some options are totally broken on some architectures. We disable # them. If you need to enable them on an experimental basis, you diff --git a/sys/conf/kern.post.mk b/sys/conf/kern.post.mk index 0c5cfe04f329..046080f42f1c 100644 --- a/sys/conf/kern.post.mk +++ b/sys/conf/kern.post.mk @@ -382,7 +382,7 @@ config.o env.o hints.o vers.o vnode_if.o: ${NORMAL_CTFCONVERT} .if ${MK_REPRODUCIBLE_BUILD} != "no" -REPRO_FLAG="-r" +REPRO_FLAG="-R" .endif vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP} MAKE="${MAKE}" sh $S/conf/newvers.sh ${REPRO_FLAG} ${KERN_IDENT} diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh index 9e83b6379f51..ce32cf2950af 100644 --- a/sys/conf/newvers.sh +++ b/sys/conf/newvers.sh @@ -46,7 +46,7 @@ TYPE="FreeBSD" REVISION="12.0" -BRANCH="ALPHA5" +BRANCH="ALPHA6" if [ -n "${BRANCH_OVERRIDE}" ]; then BRANCH=${BRANCH_OVERRIDE} fi diff --git a/sys/dev/cpuctl/cpuctl.c b/sys/dev/cpuctl/cpuctl.c index 33ac83eb731a..4f91b4fbbf28 100644 --- a/sys/dev/cpuctl/cpuctl.c +++ b/sys/dev/cpuctl/cpuctl.c @@ -362,7 +362,7 @@ update_intel(int cpu, cpuctl_update_args_t *args, struct thread *td) set_cpu(cpu, td); critical_enter(); - ret = ucode_intel_load(ptr, true); + ret = ucode_intel_load(ptr, true, NULL, NULL); critical_exit(); restore_cpu(oldcpu, is_bound, td); diff --git a/sys/dev/cxgbe/iw_cxgbe/cm.c b/sys/dev/cxgbe/iw_cxgbe/cm.c index 9eab1750bb11..f3978a41d768 100644 --- a/sys/dev/cxgbe/iw_cxgbe/cm.c +++ b/sys/dev/cxgbe/iw_cxgbe/cm.c @@ -2524,8 +2524,10 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) struct c4iw_dev *dev = to_c4iw_dev(cm_id->device); struct c4iw_ep *ep = NULL; struct ifnet *nh_ifp; /* Logical egress interface */ +#ifdef VIMAGE struct rdma_cm_id *rdma_id = (struct rdma_cm_id*)cm_id->context; struct vnet *vnet = rdma_id->route.addr.dev_addr.net; +#endif CTR2(KTR_IW_CXGBE, "%s:ccB %p", __func__, cm_id); diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index d6bf50121a15..60bdff978b69 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -3954,7 +3954,7 @@ get_params__post_init(struct adapter *sc) sc->toecaps = 0; param[0] = FW_PARAM_DEV(NTID); - rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 6, param, val); + rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, param, val); if (rc != 0) { device_printf(sc->dev, "failed to query HASHFILTER parameters: %d.\n", rc); diff --git a/sys/dev/hwpmc/hwpmc_mod.c b/sys/dev/hwpmc/hwpmc_mod.c index 4d7a4535d27b..20df37d24bd6 100644 --- a/sys/dev/hwpmc/hwpmc_mod.c +++ b/sys/dev/hwpmc/hwpmc_mod.c @@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -3942,9 +3943,16 @@ pmc_syscall_handler(struct thread *td, void *syscall_args) pmc->pm_flags = pa.pm_flags; /* XXX set lower bound on sampling for process counters */ - if (PMC_IS_SAMPLING_MODE(mode)) - pmc->pm_sc.pm_reloadcount = pa.pm_count; - else + if (PMC_IS_SAMPLING_MODE(mode)) { + /* + * Don't permit requested sample rate to be less than 1000 + */ + if (pa.pm_count < 1000) + log(LOG_WARNING, + "pmcallocate: passed sample rate %ju - setting to 1000\n", + (uintmax_t)pa.pm_count); + pmc->pm_sc.pm_reloadcount = MAX(1000, pa.pm_count); + } else pmc->pm_sc.pm_initial = pa.pm_count; /* switch thread to CPU 'cpu' */ @@ -4460,9 +4468,16 @@ pmc_syscall_handler(struct thread *td, void *syscall_args) break; } - if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm))) - pm->pm_sc.pm_reloadcount = sc.pm_count; - else + if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm))) { + /* + * Don't permit requested sample rate to be less than 1000 + */ + if (sc.pm_count < 1000) + log(LOG_WARNING, + "pmcsetcount: passed sample rate %ju - setting to 1000\n", + (uintmax_t)sc.pm_count); + pm->pm_sc.pm_reloadcount = MAX(1000, sc.pm_count); + } else pm->pm_sc.pm_initial = sc.pm_count; } break; diff --git a/sys/dev/ichiic/ig4_pci.c b/sys/dev/ichiic/ig4_pci.c index 7bb8590aa1ef..eed7d651bfde 100644 --- a/sys/dev/ichiic/ig4_pci.c +++ b/sys/dev/ichiic/ig4_pci.c @@ -80,6 +80,8 @@ static int ig4iic_pci_detach(device_t dev); #define PCI_CHIP_SKYLAKE_I2C_3 0x9d638086 #define PCI_CHIP_SKYLAKE_I2C_4 0x9d648086 #define PCI_CHIP_SKYLAKE_I2C_5 0x9d658086 +#define PCI_CHIP_KABYLAKE_I2C_0 0xa1608086 +#define PCI_CHIP_KABYLAKE_I2C_1 0xa1618086 #define PCI_CHIP_APL_I2C_0 0x5aac8086 #define PCI_CHIP_APL_I2C_1 0x5aae8086 #define PCI_CHIP_APL_I2C_2 0x5ab08086 @@ -110,6 +112,8 @@ static struct ig4iic_pci_device ig4iic_pci_devices[] = { { PCI_CHIP_SKYLAKE_I2C_3, "Intel Sunrise Point-LP I2C Controller-3", IG4_SKYLAKE}, { PCI_CHIP_SKYLAKE_I2C_4, "Intel Sunrise Point-LP I2C Controller-4", IG4_SKYLAKE}, { PCI_CHIP_SKYLAKE_I2C_5, "Intel Sunrise Point-LP I2C Controller-5", IG4_SKYLAKE}, + { PCI_CHIP_KABYLAKE_I2C_0, "Intel Sunrise Point-LP I2C Controller-0", IG4_SKYLAKE}, + { PCI_CHIP_KABYLAKE_I2C_1, "Intel Sunrise Point-LP I2C Controller-1", IG4_SKYLAKE}, { PCI_CHIP_APL_I2C_0, "Intel Apollo Lake I2C Controller-0", IG4_APL}, { PCI_CHIP_APL_I2C_1, "Intel Apollo Lake I2C Controller-1", IG4_APL}, { PCI_CHIP_APL_I2C_2, "Intel Apollo Lake I2C Controller-2", IG4_APL}, diff --git a/sys/dev/xen/privcmd/privcmd.c b/sys/dev/xen/privcmd/privcmd.c index 246390e3b7c2..e09886f42adb 100644 --- a/sys/dev/xen/privcmd/privcmd.c +++ b/sys/dev/xen/privcmd/privcmd.c @@ -232,9 +232,21 @@ privcmd_ioctl(struct cdev *dev, unsigned long cmd, caddr_t arg, struct ioctl_privcmd_hypercall *hcall; hcall = (struct ioctl_privcmd_hypercall *)arg; - +#ifdef __amd64__ + /* + * The hypervisor page table walker will refuse to access + * user-space pages if SMAP is enabled, so temporary disable it + * while performing the hypercall. + */ + if (cpu_stdext_feature & CPUID_STDEXT_SMAP) + stac(); +#endif error = privcmd_hypercall(hcall->op, hcall->arg[0], hcall->arg[1], hcall->arg[2], hcall->arg[3], hcall->arg[4]); +#ifdef __amd64__ + if (cpu_stdext_feature & CPUID_STDEXT_SMAP) + clac(); +#endif if (error >= 0) { hcall->retval = error; error = 0; diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index 2a73a7221488..f4302d466651 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -839,7 +839,8 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp) break; case PT_INTERP: /* Path to interpreter */ - if (phdr[i].p_filesz > MAXPATHLEN) { + if (phdr[i].p_filesz < 2 || + phdr[i].p_filesz > MAXPATHLEN) { uprintf("Invalid PT_INTERP\n"); error = ENOEXEC; goto ret; @@ -870,6 +871,11 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp) } else { interp = __DECONST(char *, imgp->image_header) + phdr[i].p_offset; + if (interp[interp_name_len - 1] != '\0') { + uprintf("Invalid PT_INTERP\n"); + error = ENOEXEC; + goto ret; + } } break; case PT_GNU_STACK: diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 09f665e8f3fb..00392ee3a072 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -527,6 +527,8 @@ vn_rdwr(enum uio_rw rw, struct vnode *vp, void *base, int len, off_t offset, struct vn_io_fault_args args; int error, lock_flags; + if (offset < 0 && vp->v_type != VCHR) + return (EINVAL); auio.uio_iov = &aiov; auio.uio_iovcnt = 1; aiov.iov_base = base; diff --git a/sys/net/vnet.h b/sys/net/vnet.h index 514519a327b1..b4168750e026 100644 --- a/sys/net/vnet.h +++ b/sys/net/vnet.h @@ -273,7 +273,7 @@ extern struct sx vnet_sxlock; /* struct _hack is to stop this from being used with static data */ #define VNET_DEFINE(t, n) \ struct _hack; t VNET_NAME(n) __section(VNET_SETNAME) __used -#if defined(KLD_MODULE) && defined(__aarch64__) +#if defined(KLD_MODULE) && (defined(__aarch64__) || defined(__riscv)) /* * As with DPCPU_DEFINE_STATIC we are unable to mark this data as static * in modules on some architectures. diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c index 53aa20bad928..20369d3444c4 100644 --- a/sys/netinet/tcp_stacks/rack.c +++ b/sys/netinet/tcp_stacks/rack.c @@ -5400,14 +5400,6 @@ rack_do_syn_recv(struct mbuf *m, struct tcphdr *th, struct socket *so, } if (thflags & TH_RST) return (rack_process_rst(m, th, so, tp)); - /* - * RFC5961 Section 4.2 Send challenge ACK for any SYN in - * synchronized state. - */ - if (thflags & TH_SYN) { - rack_challenge_ack(m, th, tp, &ret_val); - return (ret_val); - } /* * RFC 1323 PAWS: If we have a timestamp reply on this segment and * it's less than ts_recent, drop it. @@ -5478,6 +5470,16 @@ rack_do_syn_recv(struct mbuf *m, struct tcphdr *th, struct socket *so, * FIN-WAIT-1 */ tp->t_starttime = ticks; + if (IS_FASTOPEN(tp->t_flags) && tp->t_tfo_pending) { + tcp_fastopen_decrement_counter(tp->t_tfo_pending); + tp->t_tfo_pending = NULL; + + /* + * Account for the ACK of our SYN prior to + * regular ACK processing below. + */ + tp->snd_una++; + } if (tp->t_flags & TF_NEEDFIN) { tcp_state_change(tp, TCPS_FIN_WAIT_1); tp->t_flags &= ~TF_NEEDFIN; @@ -5485,16 +5487,6 @@ rack_do_syn_recv(struct mbuf *m, struct tcphdr *th, struct socket *so, tcp_state_change(tp, TCPS_ESTABLISHED); TCP_PROBE5(accept__established, NULL, tp, mtod(m, const char *), tp, th); - if (IS_FASTOPEN(tp->t_flags) && tp->t_tfo_pending) { - tcp_fastopen_decrement_counter(tp->t_tfo_pending); - tp->t_tfo_pending = NULL; - - /* - * Account for the ACK of our SYN prior to regular - * ACK processing below. - */ - tp->snd_una++; - } /* * TFO connections call cc_conn_init() during SYN * processing. Calling it again here for such connections @@ -6924,16 +6916,6 @@ rack_output(struct tcpcb *tp) if (tp->t_flags & TF_TOE) return (tcp_offload_output(tp)); #endif - - /* - * For TFO connections in SYN_RECEIVED, only allow the initial - * SYN|ACK and those sent by the retransmit timer. - */ - if (IS_FASTOPEN(tp->t_flags) && - (tp->t_state == TCPS_SYN_RECEIVED) && - SEQ_GT(tp->snd_max, tp->snd_una) && /* initial SYN|ACK sent */ - (rack->r_ctl.rc_resend == NULL)) /* not a retransmit */ - return (0); #ifdef INET6 if (rack->r_state) { /* Use the cache line loaded if possible */ @@ -6975,6 +6957,17 @@ rack_output(struct tcpcb *tp) } rack->r_wanted_output = 0; rack->r_timer_override = 0; + /* + * For TFO connections in SYN_SENT or SYN_RECEIVED, + * only allow the initial SYN or SYN|ACK and those sent + * by the retransmit timer. + */ + if (IS_FASTOPEN(tp->t_flags) && + ((tp->t_state == TCPS_SYN_RECEIVED) || + (tp->t_state == TCPS_SYN_SENT)) && + SEQ_GT(tp->snd_max, tp->snd_una) && /* initial SYN or SYN|ACK sent */ + (tp->t_rxtshift == 0)) /* not a retransmit */ + return (0); /* * Determine length of data that should be transmitted, and flags * that will be used. If there is some data or critical controls @@ -7353,8 +7346,10 @@ rack_output(struct tcpcb *tp) (((flags & TH_SYN) && (tp->t_rxtshift > 0)) || ((tp->t_state == TCPS_SYN_SENT) && (tp->t_tfo_client_cookie_len == 0)) || - (flags & TH_RST))) + (flags & TH_RST))) { + sack_rxmit = 0; len = 0; + } /* Without fast-open there should never be data sent on a SYN */ if ((flags & TH_SYN) && (!IS_FASTOPEN(tp->t_flags))) len = 0; diff --git a/sys/riscv/conf/GENERIC b/sys/riscv/conf/GENERIC index 2975ecbec413..b712260d5361 100644 --- a/sys/riscv/conf/GENERIC +++ b/sys/riscv/conf/GENERIC @@ -30,7 +30,7 @@ makeoptions WITHOUT_MODULES="usb otusfw mwlfw ispfw mwlfw ralfw rtwnfw" options SCHED_ULE # ULE scheduler options PREEMPTION # Enable kernel thread preemption -# options VIMAGE # Subsystem virtualization, e.g. VNET +options VIMAGE # Subsystem virtualization, e.g. VNET options INET # InterNETworking options INET6 # IPv6 communications protocols options TCP_HHOOK # hhook(9) framework for TCP diff --git a/sys/riscv/riscv/elf_machdep.c b/sys/riscv/riscv/elf_machdep.c index 974397cf22c6..f3f589b6f14f 100644 --- a/sys/riscv/riscv/elf_machdep.c +++ b/sys/riscv/riscv/elf_machdep.c @@ -330,11 +330,9 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data, break; case R_RISCV_RELATIVE: - val = relocbase + addend; - before64 = *where; - if (*where != val) - *where = val; + + *where = elf_relocaddr(lf, relocbase + addend); if (debug_kld) printf("%p %c %-24s %016lx -> %016lx\n", diff --git a/sys/sys/pcpu.h b/sys/sys/pcpu.h index d2084b77b3df..19bc4a8b9076 100644 --- a/sys/sys/pcpu.h +++ b/sys/sys/pcpu.h @@ -84,7 +84,7 @@ extern uintptr_t dpcpu_off[]; /* struct _hack is to stop this from being used with the static keyword. */ #define DPCPU_DEFINE(t, n) \ struct _hack; t DPCPU_NAME(n) __section(DPCPU_SETNAME) __used -#if defined(KLD_MODULE) && defined(__aarch64__) +#if defined(KLD_MODULE) && (defined(__aarch64__) || defined(__riscv)) /* * On some architectures the compiler will use PC-relative load to * find the address of DPCPU data with the static keyword. We then diff --git a/sys/x86/include/ucode.h b/sys/x86/include/ucode.h index d9c860d20ca8..5c8868108930 100644 --- a/sys/x86/include/ucode.h +++ b/sys/x86/include/ucode.h @@ -58,7 +58,8 @@ struct ucode_intel_extsig_table { } entries[0]; }; -int ucode_intel_load(void *data, bool unsafe); +int ucode_intel_load(void *data, bool unsafe, + uint64_t *nrevp, uint64_t *orevp); size_t ucode_load_bsp(uintptr_t free); void ucode_load_ap(int cpu); void ucode_reload(void); diff --git a/sys/x86/x86/local_apic.c b/sys/x86/x86/local_apic.c index 92e71977da4f..75a3adb90bdc 100644 --- a/sys/x86/x86/local_apic.c +++ b/sys/x86/x86/local_apic.c @@ -855,7 +855,8 @@ native_lapic_intrcnt(void *dummy __unused) STAILQ_FOREACH(pc, &cpuhead, pc_allcpu) { la = &lapics[pc->pc_apic_id]; - KASSERT(la->la_present, ("missing APIC structure")); + if (!la->la_present) + continue; snprintf(buf, sizeof(buf), "cpu%d:timer", pc->pc_cpuid); intrcnt_add(buf, &la->la_timer_count); diff --git a/sys/x86/x86/msi.c b/sys/x86/x86/msi.c index 1c5502cedde6..971b07d7c46f 100644 --- a/sys/x86/x86/msi.c +++ b/sys/x86/x86/msi.c @@ -331,7 +331,6 @@ msi_init(void) } #endif - MPASS(num_io_irqs > 0); first_msi_irq = max(MINIMUM_MSI_INT, num_io_irqs); num_io_irqs = first_msi_irq + NUM_MSI_INTS; diff --git a/sys/x86/x86/ucode.c b/sys/x86/x86/ucode.c index e1229a8401ec..50a5cbe4462b 100644 --- a/sys/x86/x86/ucode.c +++ b/sys/x86/x86/ucode.c @@ -59,7 +59,7 @@ static int ucode_intel_verify(struct ucode_intel_header *hdr, static struct ucode_ops { const char *vendor; - int (*load)(void *, bool); + int (*load)(void *, bool, uint64_t *, uint64_t *); void *(*match)(uint8_t *, size_t *); } loaders[] = { { @@ -72,35 +72,46 @@ static struct ucode_ops { /* Selected microcode update data. */ static void *early_ucode_data; static void *ucode_data; +static struct ucode_ops *ucode_loader; -static char errbuf[128]; - -static void __printflike(1, 2) -log_err(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - vsnprintf(errbuf, sizeof(errbuf), fmt, ap); - va_end(ap); -} +/* Variables used for reporting success or failure. */ +enum { + NO_ERROR, + NO_MATCH, + VERIFICATION_FAILED, +} ucode_error = NO_ERROR; +static uint64_t ucode_nrev, ucode_orev; static void -print_err(void *arg __unused) +log_msg(void *arg __unused) { - if (errbuf[0] != '\0') - printf("microcode load error: %s\n", errbuf); + if (ucode_nrev != 0) { + printf("CPU microcode: updated from %#jx to %#jx\n", + (uintmax_t)ucode_orev, (uintmax_t)ucode_nrev); + return; + } + + switch (ucode_error) { + case NO_MATCH: + printf("CPU microcode: no matching update found\n"); + break; + case VERIFICATION_FAILED: + printf("CPU microcode: microcode verification failed\n"); + break; + default: + break; + } } -SYSINIT(ucode_print_err, SI_SUB_CPU, SI_ORDER_FIRST, print_err, NULL); +SYSINIT(ucode_log, SI_SUB_CPU, SI_ORDER_FIRST, log_msg, NULL); int -ucode_intel_load(void *data, bool unsafe) +ucode_intel_load(void *data, bool unsafe, uint64_t *nrevp, uint64_t *orevp) { - uint64_t rev0, rev1; + uint64_t nrev, orev; uint32_t cpuid[4]; - rev0 = rdmsr(MSR_BIOS_SIGN); + orev = rdmsr(MSR_BIOS_SIGN) >> 32; /* * Perform update. Flush caches first to work around seemingly @@ -118,8 +129,15 @@ ucode_intel_load(void *data, bool unsafe) */ do_cpuid(0, cpuid); - rev1 = rdmsr(MSR_BIOS_SIGN); - if (rev1 <= rev0) + /* + * Verify that the microcode revision changed. + */ + nrev = rdmsr(MSR_BIOS_SIGN) >> 32; + if (nrevp != NULL) + *nrevp = nrev; + if (orevp != NULL) + *orevp = orev; + if (nrev <= orev) return (EEXIST); return (0); } @@ -130,36 +148,26 @@ ucode_intel_verify(struct ucode_intel_header *hdr, size_t resid) uint32_t cksum, *data, size; int i; - if (resid < sizeof(struct ucode_intel_header)) { - log_err("truncated update header"); + if (resid < sizeof(struct ucode_intel_header)) return (1); - } size = hdr->total_size; if (size == 0) size = UCODE_INTEL_DEFAULT_DATA_SIZE + sizeof(struct ucode_intel_header); - if (hdr->header_version != 1) { - log_err("unexpected header version %u", hdr->header_version); + if (hdr->header_version != 1) return (1); - } - if (size % 16 != 0) { - log_err("unexpected update size %u", hdr->total_size); + if (size % 16 != 0) return (1); - } - if (resid < size) { - log_err("truncated update"); + if (resid < size) return (1); - } cksum = 0; data = (uint32_t *)hdr; for (i = 0; i < size / sizeof(uint32_t); i++) cksum += data[i]; - if (cksum != 0) { - log_err("checksum failed"); + if (cksum != 0) return (1); - } return (0); } @@ -182,8 +190,10 @@ ucode_intel_match(uint8_t *data, size_t *len) for (resid = *len; resid > 0; data += total_size, resid -= total_size) { hdr = (struct ucode_intel_header *)data; - if (ucode_intel_verify(hdr, resid) != 0) + if (ucode_intel_verify(hdr, resid) != 0) { + ucode_error = VERIFICATION_FAILED; break; + } data_size = hdr->data_size; total_size = hdr->total_size; @@ -264,7 +274,7 @@ ucode_load_ap(int cpu) #endif if (ucode_data != NULL) - (void)ucode_intel_load(ucode_data, false); + (void)ucode_loader->load(ucode_data, false, NULL, NULL); } static void * @@ -308,11 +318,12 @@ ucode_load_bsp(uintptr_t free) uint32_t regs[4]; char vendor[13]; } cpuid; - struct ucode_ops *loader; uint8_t *addr, *fileaddr, *match; char *type; + uint64_t nrev, orev; caddr_t file; - size_t i, len, ucode_len; + size_t i, len; + int error; KASSERT(free % PAGE_SIZE == 0, ("unaligned boundary %p", (void *)free)); @@ -320,17 +331,16 @@ ucode_load_bsp(uintptr_t free) cpuid.regs[0] = cpuid.regs[1]; cpuid.regs[1] = cpuid.regs[3]; cpuid.vendor[12] = '\0'; - for (i = 0, loader = NULL; i < nitems(loaders); i++) + for (i = 0; i < nitems(loaders); i++) if (strcmp(cpuid.vendor, loaders[i].vendor) == 0) { - loader = &loaders[i]; + ucode_loader = &loaders[i]; break; } - if (loader == NULL) + if (ucode_loader == NULL) return (0); file = 0; fileaddr = match = NULL; - ucode_len = 0; for (;;) { file = preload_search_next_name(file); if (file == 0) @@ -341,7 +351,7 @@ ucode_load_bsp(uintptr_t free) fileaddr = preload_fetch_addr(file); len = preload_fetch_size(file); - match = loader->match(fileaddr, &len); + match = ucode_loader->match(fileaddr, &len); if (match != NULL) { addr = map_ucode(free, len); /* We can't use memcpy() before ifunc resolution. */ @@ -349,18 +359,19 @@ ucode_load_bsp(uintptr_t free) addr[i] = ((volatile uint8_t *)match)[i]; match = addr; - if (loader->load(match, false) == 0) { - ucode_data = match; - ucode_len = len; - early_ucode_data = ucode_data; - break; + error = ucode_loader->load(match, false, &nrev, &orev); + if (error == 0) { + ucode_data = early_ucode_data = match; + ucode_nrev = nrev; + ucode_orev = orev; + return (len); } unmap_ucode(free, len); } } - if (fileaddr != NULL && ucode_data == NULL) - log_err("no matching update found"); - return (ucode_len); + if (fileaddr != NULL && ucode_error == NO_ERROR) + ucode_error = NO_MATCH; + return (0); } /* diff --git a/sys/x86/xen/hvm.c b/sys/x86/xen/hvm.c index 24b5f1d2e72e..6983a20ecf82 100644 --- a/sys/x86/xen/hvm.c +++ b/sys/x86/xen/hvm.c @@ -163,6 +163,12 @@ xen_hvm_init_hypercall_stubs(enum xen_hvm_init_type init_type) { uint32_t regs[4]; + /* Legacy PVH will get here without the cpuid leaf being set. */ + if (cpuid_base == 0) + cpuid_base = xen_hvm_cpuid_base(); + if (cpuid_base == 0) + return (ENXIO); + if (xen_domain() && init_type == XEN_HVM_INIT_LATE) { /* * If the domain type is already set we can assume that the @@ -173,10 +179,6 @@ xen_hvm_init_hypercall_stubs(enum xen_hvm_init_type init_type) return 0; } - cpuid_base = xen_hvm_cpuid_base(); - if (cpuid_base == 0) - return (ENXIO); - if (init_type == XEN_HVM_INIT_LATE) hypervisor_version(); @@ -419,6 +421,9 @@ xen_hvm_cpu_init(void) */ KASSERT(cpuid_base != 0, ("Invalid base Xen CPUID leaf")); cpuid_count(cpuid_base + 4, 0, regs); + KASSERT((regs[0] & XEN_HVM_CPUID_VCPU_ID_PRESENT) || + !xen_pv_domain(), + ("Xen PV domain without vcpu_id in cpuid")); PCPU_SET(vcpu_id, (regs[0] & XEN_HVM_CPUID_VCPU_ID_PRESENT) ? regs[1] : PCPU_GET(acpi_id)); diff --git a/sys/x86/xen/pv.c b/sys/x86/xen/pv.c index 3f85b156d828..4505907172c0 100644 --- a/sys/x86/xen/pv.c +++ b/sys/x86/xen/pv.c @@ -204,6 +204,7 @@ hammer_time_xen_legacy(start_info_t *si, uint64_t xenstack) uint64_t *PT3 = (u_int64_t *)(xenstack + PAGE_SIZE); uint64_t *PT2 = (u_int64_t *)(xenstack + 2 * PAGE_SIZE); int i; + char *kenv; xen_domain_type = XEN_PV_DOMAIN; vm_guest = VM_GUEST_XEN; @@ -252,6 +253,15 @@ hammer_time_xen_legacy(start_info_t *si, uint64_t xenstack) } load_cr3(((uint64_t)&PT4[0]) - KERNBASE); + /* + * Init an empty static kenv using a free page. The contents will be + * filled from the parse_preload_data hook. + */ + kenv = (void *)(physfree + KERNBASE); + physfree += PAGE_SIZE; + bzero(kenv, PAGE_SIZE); + init_static_kenv(kenv, PAGE_SIZE); + /* Set the hooks for early functions that diverge from bare metal */ init_ops = xen_legacy_init_ops; apic_ops = xen_apic_ops; diff --git a/sys/x86/xen/pvcpu_enum.c b/sys/x86/xen/pvcpu_enum.c index e647a6fe8e9d..4c4bcec186bb 100644 --- a/sys/x86/xen/pvcpu_enum.c +++ b/sys/x86/xen/pvcpu_enum.c @@ -193,54 +193,67 @@ xenpv_setup_io(void) { if (xen_initial_domain()) { - int i, ret; - - /* Map MADT */ - madt_physaddr = acpi_find_table(ACPI_SIG_MADT); - madt = acpi_map_table(madt_physaddr, ACPI_SIG_MADT); - madt_length = madt->Header.Length; - - /* Try to initialize ACPI so that we can access the FADT. */ - i = acpi_Startup(); - if (ACPI_FAILURE(i)) { - printf("MADT: ACPI Startup failed with %s\n", - AcpiFormatException(i)); - printf("Try disabling either ACPI or apic support.\n"); - panic("Using MADT but ACPI doesn't work"); - } - - /* Run through the table to see if there are any overrides. */ - madt_walk_table(madt_parse_ints, NULL); - /* - * If there was not an explicit override entry for the SCI, - * force it to use level trigger and active-low polarity. + * NB: we could iterate over the MADT IOAPIC entries in order + * to figure out the exact number of IOAPIC interrupts, but + * this is legacy code so just keep using the previous + * behaviour and assume a maximum of 256 interrupts. */ - if (!madt_found_sci_override) { - printf( - "MADT: Forcing active-low polarity and level trigger for SCI\n"); - ret = xen_register_pirq(AcpiGbl_FADT.SciInterrupt, - INTR_TRIGGER_LEVEL, INTR_POLARITY_LOW); - if (ret != 0) - panic("Unable to register SCI IRQ"); - } - - /* Register legacy ISA IRQs */ - for (i = 1; i < 16; i++) { - if (intr_lookup_source(i) != NULL) - continue; - ret = xen_register_pirq(i, INTR_TRIGGER_EDGE, - INTR_POLARITY_LOW); - if (ret != 0 && bootverbose) - printf("Unable to register legacy IRQ#%d: %d\n", - i, ret); - } + num_io_irqs = max(MINIMUM_MSI_INT - 1, num_io_irqs); acpi_SetDefaultIntrModel(ACPI_INTR_APIC); } return (0); } +void +xenpv_register_pirqs(struct pic *pic __unused) +{ + unsigned int i; + int ret; + + /* Map MADT */ + madt_physaddr = acpi_find_table(ACPI_SIG_MADT); + madt = acpi_map_table(madt_physaddr, ACPI_SIG_MADT); + madt_length = madt->Header.Length; + + /* Try to initialize ACPI so that we can access the FADT. */ + ret = acpi_Startup(); + if (ACPI_FAILURE(ret)) { + printf("MADT: ACPI Startup failed with %s\n", + AcpiFormatException(ret)); + printf("Try disabling either ACPI or apic support.\n"); + panic("Using MADT but ACPI doesn't work"); + } + + /* Run through the table to see if there are any overrides. */ + madt_walk_table(madt_parse_ints, NULL); + + /* + * If there was not an explicit override entry for the SCI, + * force it to use level trigger and active-low polarity. + */ + if (!madt_found_sci_override) { + printf( +"MADT: Forcing active-low polarity and level trigger for SCI\n"); + ret = xen_register_pirq(AcpiGbl_FADT.SciInterrupt, + INTR_TRIGGER_LEVEL, INTR_POLARITY_LOW); + if (ret != 0) + panic("Unable to register SCI IRQ"); + } + + /* Register legacy ISA IRQs */ + for (i = 1; i < 16; i++) { + if (intr_lookup_source(i) != NULL) + continue; + ret = xen_register_pirq(i, INTR_TRIGGER_EDGE, + INTR_POLARITY_LOW); + if (ret != 0 && bootverbose) + printf("Unable to register legacy IRQ#%u: %d\n", i, + ret); + } +} + static void xenpv_register(void *dummy __unused) { @@ -249,19 +262,3 @@ xenpv_register(void *dummy __unused) } } SYSINIT(xenpv_register, SI_SUB_TUNABLES - 1, SI_ORDER_FIRST, xenpv_register, NULL); - -/* - * Setup per-CPU vCPU IDs - */ -static void -xenpv_set_ids(void *dummy) -{ - struct pcpu *pc; - int i; - - CPU_FOREACH(i) { - pc = pcpu_find(i); - pc->pc_vcpu_id = i; - } -} -SYSINIT(xenpv_set_ids, SI_SUB_CPU, SI_ORDER_MIDDLE, xenpv_set_ids, NULL); diff --git a/sys/x86/xen/xen_apic.c b/sys/x86/xen/xen_apic.c index 09ba28f9e46b..7d254ef3f734 100644 --- a/sys/x86/xen/xen_apic.c +++ b/sys/x86/xen/xen_apic.c @@ -592,6 +592,6 @@ xen_setup_cpus(void) apic_ops.ipi_vectored = xen_pv_lapic_ipi_vectored; } -/* We need to setup IPIs before APs are started */ -SYSINIT(xen_setup_cpus, SI_SUB_SMP-1, SI_ORDER_FIRST, xen_setup_cpus, NULL); +/* Switch to using PV IPIs as soon as the vcpu_id is set. */ +SYSINIT(xen_setup_cpus, SI_SUB_SMP, SI_ORDER_SECOND, xen_setup_cpus, NULL); #endif /* SMP */ diff --git a/sys/x86/xen/xen_intr.c b/sys/x86/xen/xen_intr.c index 559f3192255a..c1cb0707cde9 100644 --- a/sys/x86/xen/xen_intr.c +++ b/sys/x86/xen/xen_intr.c @@ -178,6 +178,9 @@ struct pic xen_intr_pic = { * physical interrupt sources. */ struct pic xen_intr_pirq_pic = { +#ifdef __amd64__ + .pic_register_sources = xenpv_register_pirqs, +#endif .pic_enable_source = xen_intr_pirq_enable_source, .pic_disable_source = xen_intr_pirq_disable_source, .pic_eoi_source = xen_intr_pirq_eoi_source, @@ -656,7 +659,8 @@ xen_intr_init(void *dummy __unused) xen_intr_pirq_eoi_map_enabled = true; intr_register_pic(&xen_intr_pic); - intr_register_pic(&xen_intr_pirq_pic); + if (xen_pv_domain() && xen_initial_domain()) + intr_register_pic(&xen_intr_pirq_pic); if (bootverbose) printf("Xen interrupt system initialized\n"); diff --git a/sys/xen/xen_intr.h b/sys/xen/xen_intr.h index eb3436d601b8..4aa4a9a8b8ea 100644 --- a/sys/xen/xen_intr.h +++ b/sys/xen/xen_intr.h @@ -274,4 +274,14 @@ int xen_intr_add_handler(const char *name, driver_filter_t filter, int xen_intr_get_evtchn_from_port(evtchn_port_t port, xen_intr_handle_t *handlep); +/** + * Register the IO-APIC PIRQs when running in legacy PVH Dom0 mode. + * + * \param pic PIC instance. + * + * NB: this should be removed together with the support for legacy PVH mode. + */ +struct pic; +void xenpv_register_pirqs(struct pic *pic); + #endif /* _XEN_INTR_H_ */ diff --git a/tests/sys/netinet/Makefile b/tests/sys/netinet/Makefile index 9e1150ebf61b..97376fcfe2bc 100644 --- a/tests/sys/netinet/Makefile +++ b/tests/sys/netinet/Makefile @@ -3,6 +3,8 @@ TESTSDIR= ${TESTSBASE}/sys/netinet BINDIR= ${TESTSDIR} +ATF_TESTS_C= reuseport_lb + ATF_TESTS_SH= fibs_test PROGS= udp_dontroute tcp_user_cookie diff --git a/tests/sys/netinet/reuseport_lb.c b/tests/sys/netinet/reuseport_lb.c new file mode 100644 index 000000000000..e80e54463c57 --- /dev/null +++ b/tests/sys/netinet/reuseport_lb.c @@ -0,0 +1,242 @@ +/*- + * Copyright (c) 2018 The FreeBSD Foundation + * + * This software was developed by Mark Johnston under sponsorship from + * the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include + +#include + +#include +#include +#include +#include + +#include + +/* + * Given an array of non-blocking listening sockets configured in a LB group + * for "addr", try connecting to "addr" in a loop and verify that connections + * are roughly balanced across the sockets. + */ +static void +lb_simple_accept_loop(int domain, const struct sockaddr *addr, int sds[], + size_t nsds, int nconns) +{ + size_t i; + int *acceptcnt; + int csd, error, excnt, sd; + + /* + * We expect each listening socket to accept roughly nconns/nsds + * connections, but allow for some error. + */ + excnt = nconns / nsds / 8; + acceptcnt = calloc(nsds, sizeof(*acceptcnt)); + ATF_REQUIRE_MSG(acceptcnt != NULL, "calloc() failed: %s", + strerror(errno)); + + while (nconns-- > 0) { + sd = socket(domain, SOCK_STREAM, 0); + ATF_REQUIRE_MSG(sd >= 0, "socket() failed: %s", + strerror(errno)); + + error = connect(sd, addr, addr->sa_len); + ATF_REQUIRE_MSG(error == 0, "connect() failed: %s", + strerror(errno)); + + /* + * Poll the listening sockets. + */ + do { + for (i = 0; i < nsds; i++) { + csd = accept(sds[i], NULL, NULL); + if (csd < 0) { + ATF_REQUIRE_MSG(errno == EWOULDBLOCK || + errno == EAGAIN, + "accept() failed: %s", + strerror(errno)); + continue; + } + + error = close(csd); + ATF_REQUIRE_MSG(error == 0, + "close() failed: %s", strerror(errno)); + + acceptcnt[i]++; + break; + } + } while (i == nsds); + + error = close(sd); + ATF_REQUIRE_MSG(error == 0, "close() failed: %s", + strerror(errno)); + } + + for (i = 0; i < nsds; i++) + ATF_REQUIRE_MSG(acceptcnt[i] > excnt, "uneven balancing"); +} + +static int +lb_listen_socket(int domain, int flags) +{ + size_t one; + int error, sd; + + sd = socket(domain, SOCK_STREAM | flags, 0); + ATF_REQUIRE_MSG(sd >= 0, "socket() failed: %s", strerror(errno)); + + one = 1; + error = setsockopt(sd, SOL_SOCKET, SO_REUSEPORT_LB, &one, sizeof(one)); + ATF_REQUIRE_MSG(error == 0, "setsockopt(SO_REUSEPORT_LB) failed: %s", + strerror(errno)); + + return (sd); +} + +ATF_TC_WITHOUT_HEAD(basic_ipv4); +ATF_TC_BODY(basic_ipv4, tc) +{ + struct sockaddr_in addr; + socklen_t slen; + size_t i; + const int nconns = 16384; + int error, sds[16]; + uint16_t port; + + sds[0] = lb_listen_socket(PF_INET, SOCK_NONBLOCK); + + memset(&addr, 0, sizeof(addr)); + addr.sin_len = sizeof(addr); + addr.sin_family = AF_INET; + addr.sin_port = htons(0); + addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + error = bind(sds[0], (const struct sockaddr *)&addr, sizeof(addr)); + ATF_REQUIRE_MSG(error == 0, "bind() failed: %s", strerror(errno)); + error = listen(sds[0], 1); + ATF_REQUIRE_MSG(error == 0, "listen() failed: %s", strerror(errno)); + + slen = sizeof(addr); + error = getsockname(sds[0], (struct sockaddr *)&addr, &slen); + ATF_REQUIRE_MSG(error == 0, "getsockname() failed: %s", + strerror(errno)); + ATF_REQUIRE_MSG(slen == sizeof(addr), "sockaddr size changed"); + port = addr.sin_port; + + memset(&addr, 0, sizeof(addr)); + addr.sin_len = sizeof(addr); + addr.sin_family = AF_INET; + addr.sin_port = port; + addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + for (i = 1; i < nitems(sds); i++) { + sds[i] = lb_listen_socket(PF_INET, SOCK_NONBLOCK); + + error = bind(sds[i], (const struct sockaddr *)&addr, + sizeof(addr)); + ATF_REQUIRE_MSG(error == 0, "bind() failed: %s", + strerror(errno)); + error = listen(sds[i], 1); + ATF_REQUIRE_MSG(error == 0, "listen() failed: %s", + strerror(errno)); + } + + lb_simple_accept_loop(PF_INET, (struct sockaddr *)&addr, sds, + nitems(sds), nconns); + for (i = 0; i < nitems(sds); i++) { + error = close(sds[i]); + ATF_REQUIRE_MSG(error == 0, "close() failed: %s", + strerror(errno)); + } +} + +ATF_TC_WITHOUT_HEAD(basic_ipv6); +ATF_TC_BODY(basic_ipv6, tc) +{ + const struct in6_addr loopback6 = IN6ADDR_LOOPBACK_INIT; + struct sockaddr_in6 addr; + socklen_t slen; + size_t i; + const int nconns = 16384; + int error, sds[16]; + uint16_t port; + + sds[0] = lb_listen_socket(PF_INET6, SOCK_NONBLOCK); + + memset(&addr, 0, sizeof(addr)); + addr.sin6_len = sizeof(addr); + addr.sin6_family = AF_INET6; + addr.sin6_port = htons(0); + addr.sin6_addr = loopback6; + error = bind(sds[0], (const struct sockaddr *)&addr, sizeof(addr)); + ATF_REQUIRE_MSG(error == 0, "bind() failed: %s", strerror(errno)); + error = listen(sds[0], 1); + ATF_REQUIRE_MSG(error == 0, "listen() failed: %s", strerror(errno)); + + slen = sizeof(addr); + error = getsockname(sds[0], (struct sockaddr *)&addr, &slen); + ATF_REQUIRE_MSG(error == 0, "getsockname() failed: %s", + strerror(errno)); + ATF_REQUIRE_MSG(slen == sizeof(addr), "sockaddr size changed"); + port = addr.sin6_port; + + memset(&addr, 0, sizeof(addr)); + addr.sin6_len = sizeof(addr); + addr.sin6_family = AF_INET6; + addr.sin6_port = port; + addr.sin6_addr = loopback6; + for (i = 1; i < nitems(sds); i++) { + sds[i] = lb_listen_socket(PF_INET6, SOCK_NONBLOCK); + + error = bind(sds[i], (const struct sockaddr *)&addr, + sizeof(addr)); + ATF_REQUIRE_MSG(error == 0, "bind() failed: %s", + strerror(errno)); + error = listen(sds[i], 1); + ATF_REQUIRE_MSG(error == 0, "listen() failed: %s", + strerror(errno)); + } + + lb_simple_accept_loop(PF_INET6, (struct sockaddr *)&addr, sds, + nitems(sds), nconns); + for (i = 0; i < nitems(sds); i++) { + error = close(sds[i]); + ATF_REQUIRE_MSG(error == 0, "close() failed: %s", + strerror(errno)); + } +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, basic_ipv4); + ATF_TP_ADD_TC(tp, basic_ipv6); + + return (atf_no_error()); +} diff --git a/tools/build/options/WITHOUT_REPRODUCIBLE_BUILD b/tools/build/options/WITHOUT_REPRODUCIBLE_BUILD new file mode 100644 index 000000000000..015a6432ccd5 --- /dev/null +++ b/tools/build/options/WITHOUT_REPRODUCIBLE_BUILD @@ -0,0 +1,4 @@ +.\" $FreeBSD$ +Set to include build metadata (such as the build time, user, and host) +in the kernel, boot loaders, and uname output. +Successive builds will not be bit-for-bit identical. diff --git a/usr.bin/bsdcat/Makefile b/usr.bin/bsdcat/Makefile index 78780effd700..097e9e471649 100644 --- a/usr.bin/bsdcat/Makefile +++ b/usr.bin/bsdcat/Makefile @@ -6,7 +6,7 @@ _LIBARCHIVEDIR= ${SRCTOP}/contrib/libarchive _LIBARCHIVECONFDIR= ${SRCTOP}/lib/libarchive PROG= bsdcat -BSDCAT_VERSION_STRING= 3.3.2 +BSDCAT_VERSION_STRING= 3.3.3 .PATH: ${_LIBARCHIVEDIR}/cat SRCS= bsdcat.c cmdline.c diff --git a/usr.bin/cpio/Makefile b/usr.bin/cpio/Makefile index 666bb88ffb19..43bde411265a 100644 --- a/usr.bin/cpio/Makefile +++ b/usr.bin/cpio/Makefile @@ -6,7 +6,7 @@ _LIBARCHIVEDIR= ${SRCTOP}/contrib/libarchive _LIBARCHIVECONFDIR= ${SRCTOP}/lib/libarchive PROG= bsdcpio -BSDCPIO_VERSION_STRING= 3.3.2 +BSDCPIO_VERSION_STRING= 3.3.3 .PATH: ${_LIBARCHIVEDIR}/cpio SRCS= cpio.c cmdline.c diff --git a/usr.bin/objcopy/Makefile b/usr.bin/objcopy/Makefile index 5fc78a0186d9..87472a4cd848 100644 --- a/usr.bin/objcopy/Makefile +++ b/usr.bin/objcopy/Makefile @@ -10,7 +10,7 @@ ELFCOPYDIR= ${ELFTCDIR}/elfcopy PROG= objcopy objcopy.1: elfcopy.1 sed -e 's/\.Dt ELFCOPY 1/.Dt OBJCOPY 1/' \ - -e 's/\.Nm elfcopy/.Nm objcopy/' < ${.ALLSRC} > ${.TARGET} + -e '/\.Nm elfcopy ,/d' < ${.ALLSRC} > ${.TARGET} CLEANFILES+= objcopy.1 SRCS= archive.c ascii.c binary.c main.c pe.c sections.c segments.c symbols.c diff --git a/usr.bin/tar/Makefile b/usr.bin/tar/Makefile index ad50f7d475e1..93786a054e44 100644 --- a/usr.bin/tar/Makefile +++ b/usr.bin/tar/Makefile @@ -4,7 +4,7 @@ _LIBARCHIVEDIR= ${SRCTOP}/contrib/libarchive PROG= bsdtar -BSDTAR_VERSION_STRING= 3.3.2 +BSDTAR_VERSION_STRING= 3.3.3 .PATH: ${_LIBARCHIVEDIR}/tar SRCS= bsdtar.c \ diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile index 20a101eaef5b..25e3265b6992 100644 --- a/usr.sbin/Makefile +++ b/usr.sbin/Makefile @@ -59,6 +59,9 @@ SUBDIR= adduser \ nologin \ pciconf \ periodic \ + pmcannotate \ + pmccontrol \ + pmcstat \ pnfsdscopymr \ pnfsdsfile \ pnfsdskill \ @@ -185,11 +188,8 @@ SUBDIR.${MK_OPENSSL}+= keyserv SUBDIR.${MK_PC_SYSINSTALL}+= pc-sysinstall SUBDIR.${MK_PF}+= ftp-proxy SUBDIR.${MK_PKGBOOTSTRAP}+= pkg -.if (${COMPILER_TYPE} == "clang" || (${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 60100 && ${MACHINE_CPUARCH} != "riscv")) +.if ${COMPILER_FEATURES:Mc++11} SUBDIR.${MK_PMC}+= pmc -SUBDIR.${MK_PMC}+= pmcannotate -SUBDIR.${MK_PMC}+= pmccontrol -SUBDIR.${MK_PMC}+= pmcstat .endif SUBDIR.${MK_PMC}+= pmcstudy SUBDIR.${MK_PORTSNAP}+= portsnap