From owner-dev-commits-src-main@freebsd.org Mon Aug 23 01:32:35 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B42436615DF; Mon, 23 Aug 2021 01:32:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtF9H4hfRz3v4Z; Mon, 23 Aug 2021 01:32:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8914533AB; Mon, 23 Aug 2021 01:32:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17N1WZs8042496; Mon, 23 Aug 2021 01:32:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17N1WZrs042495; Mon, 23 Aug 2021 01:32:35 GMT (envelope-from git) Date: Mon, 23 Aug 2021 01:32:35 GMT Message-Id: <202108230132.17N1WZrs042495@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Martin Matuska Subject: git: ddce862ad859 - main - libarchive: import changes from upstream MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mm X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ddce862ad8594542e1fa1af9ffae7264e12ffd27 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 01:32:35 -0000 The branch main has been updated by mm: URL: https://cgit.FreeBSD.org/src/commit/?id=ddce862ad8594542e1fa1af9ffae7264e12ffd27 commit ddce862ad8594542e1fa1af9ffae7264e12ffd27 Merge: 62e1a437f328 9aa547618472 Author: Martin Matuska AuthorDate: 2021-08-23 00:54:15 +0000 Commit: Martin Matuska CommitDate: 2021-08-23 01:07:36 +0000 libarchive: import changes from upstream Libarchive 3.5.2 New features: PR #1502: Support for PWB and v7 binary cpio formats PR #1509: Support of deflate algorithm in symbolic link decompression for ZIP archives Important bugfixes: IS #1044: fix extraction of hardlinks to symlinks PR #1480: Fix truncation of size values during 7zip archive extraction on 32bit architectures PR #1504: fix rar header skiming PR #1514: ZIP excessive disk read - fix location of central directory PR #1520: fix double-free in CAB reader PR #1521: Fixed leak of rar before ending with error PR #1530: Handle short writes from archive_write_callback PR #1532: 7zip: Use compression settings from file also for file header IS #1566: do not follow symlinks when processing the fixup list MFC after: 2 weeks Relnotes: yes contrib/libarchive/NEWS | 2 + contrib/libarchive/README.md | 3 + contrib/libarchive/cat/bsdcat_platform.h | 2 +- contrib/libarchive/cpio/bsdcpio.1 | 7 + contrib/libarchive/cpio/cmdline.c | 4 +- contrib/libarchive/cpio/cpio.c | 23 +- contrib/libarchive/cpio/cpio.h | 1 + contrib/libarchive/cpio/test/test_basic.c | 2 + contrib/libarchive/libarchive/archive.h | 8 +- .../libarchive/archive_disk_acl_freebsd.c | 20 +- contrib/libarchive/libarchive/archive_entry.h | 2 +- contrib/libarchive/libarchive/archive_pathmatch.c | 4 + contrib/libarchive/libarchive/archive_private.h | 7 + contrib/libarchive/libarchive/archive_random.c | 8 +- .../libarchive/archive_read_disk_posix.c | 66 ++- .../libarchive/libarchive/archive_read_extract2.c | 2 +- .../libarchive/archive_read_set_options.3 | 9 + .../libarchive/archive_read_support_filter_rpm.c | 2 +- .../libarchive/archive_read_support_filter_uu.c | 2 +- .../libarchive/archive_read_support_format_7zip.c | 14 +- .../libarchive/archive_read_support_format_cab.c | 1 - .../libarchive/archive_read_support_format_cpio.c | 18 + .../libarchive/archive_read_support_format_mtree.c | 8 +- .../libarchive/archive_read_support_format_rar.c | 14 +- .../libarchive/archive_read_support_format_rar5.c | 1 + .../libarchive/archive_read_support_format_tar.c | 6 +- .../libarchive/archive_read_support_format_zip.c | 154 ++---- .../libarchive/archive_version_details.c | 2 +- contrib/libarchive/libarchive/archive_write.c | 23 +- .../libarchive/archive_write_disk_posix.c | 63 ++- .../libarchive/libarchive/archive_write_format.3 | 18 +- .../libarchive/archive_write_set_format.c | 4 +- .../libarchive/archive_write_set_format_7zip.c | 7 +- .../libarchive/archive_write_set_format_by_name.c | 4 +- .../libarchive/archive_write_set_format_cpio.c | 494 +---------------- .../archive_write_set_format_cpio_binary.c | 610 +++++++++++++++++++++ .../libarchive/archive_write_set_format_cpio_odc.c | 500 +++++++++++++++++ .../archive_write_set_format_filter_by_ext.c | 2 +- .../libarchive/archive_write_set_options.3 | 14 +- contrib/libarchive/libarchive/cpio.5 | 200 ++++--- contrib/libarchive/libarchive/libarchive-formats.5 | 37 +- contrib/libarchive/libarchive/libarchive.3 | 2 +- .../libarchive/test/test_archive_pathmatch.c | 4 + .../libarchive/libarchive/test/test_compat_lzma.c | 2 +- .../test/test_read_disk_directory_traversals.c | 13 +- .../libarchive/test/test_read_format_zip.c | 27 + .../test/test_read_format_zip_7z_deflate.zip.uu | 361 ++++++++++++ .../libarchive/libarchive/test/test_short_writes.c | 216 ++++++++ .../libarchive/libarchive/test/test_sparse_basic.c | 4 +- .../libarchive/test/test_write_disk_appledouble.c | 8 +- .../libarchive/test/test_write_disk_fixup.c | 81 +++ .../libarchive/test/test_write_disk_hardlink.c | 49 +- .../test/test_write_disk_hfs_compression.c | 8 +- .../libarchive/test/test_write_disk_mac_metadata.c | 8 +- .../test/test_write_disk_no_hfs_compression.c | 8 +- .../libarchive/test/test_write_format_cpio.c | 16 +- .../libarchive/test/test_write_format_cpio_empty.c | 2 +- .../libarchive/test/test_write_format_cpio_odc.c | 2 +- .../test/test_write_format_zip_compression_store.c | 2 +- .../test/test_write_format_zip_empty_zip64.c | 2 +- .../libarchive/test/test_write_format_zip_file.c | 2 +- .../test/test_write_format_zip_file_zip64.c | 2 +- .../libarchive/test/test_write_read_format_zip.c | 2 +- contrib/libarchive/libarchive/xxhash.c | 6 +- .../libarchive/tar/test/test_option_safe_writes.c | 2 +- contrib/libarchive/test_utils/test_main.c | 4 +- lib/libarchive/Makefile | 2 + lib/libarchive/config_freebsd.h | 1 + lib/libarchive/tests/Makefile | 3 + 69 files changed, 2401 insertions(+), 806 deletions(-) diff --cc contrib/libarchive/README.md index 56cd723daa47,000000000000..d5ef70c2191d mode 100644,000000..100644 --- a/contrib/libarchive/README.md +++ b/contrib/libarchive/README.md @@@ -1,224 -1,0 +1,227 @@@ +# Welcome to libarchive! + +The libarchive project develops a portable, efficient C library that +can read and write streaming archives in a variety of formats. It +also includes implementations of the common `tar`, `cpio`, and `zcat` +command-line tools that use the libarchive library. + +## Questions? Issues? + +* http://www.libarchive.org is the home for ongoing + libarchive development, including documentation, + and links to the libarchive mailing lists. +* To report an issue, use the issue tracker at + https://github.com/libarchive/libarchive/issues +* To submit an enhancement to libarchive, please + submit a pull request via GitHub: https://github.com/libarchive/libarchive/pulls + +## Contents of the Distribution + +This distribution bundle includes the following major components: + +* **libarchive**: a library for reading and writing streaming archives +* **tar**: the 'bsdtar' program is a full-featured 'tar' implementation built on libarchive +* **cpio**: the 'bsdcpio' program is a different interface to essentially the same functionality +* **cat**: the 'bsdcat' program is a simple replacement tool for zcat, bzcat, xzcat, and such +* **examples**: Some small example programs that you may find useful. +* **examples/minitar**: a compact sample demonstrating use of libarchive. +* **contrib**: Various items sent to me by third parties; please contact the authors with any questions. + +The top-level directory contains the following information files: + +* **NEWS** - highlights of recent changes +* **COPYING** - what you can do with this +* **INSTALL** - installation instructions +* **README** - this file +* **CMakeLists.txt** - input for "cmake" build tool, see INSTALL +* **configure** - configuration script, see INSTALL for details. If your copy of the source lacks a `configure` script, you can try to construct it by running the script in `build/autogen.sh` (or use `cmake`). + +The following files in the top-level directory are used by the 'configure' script: +* `Makefile.am`, `aclocal.m4`, `configure.ac` - used to build this distribution, only needed by maintainers +* `Makefile.in`, `config.h.in` - templates used by configure script + +## Documentation + +In addition to the informational articles and documentation +in the online [libarchive Wiki](https://github.com/libarchive/libarchive/wiki), +the distribution also includes a number of manual pages: + + * bsdtar.1 explains the use of the bsdtar program + * bsdcpio.1 explains the use of the bsdcpio program + * bsdcat.1 explains the use of the bsdcat program + * libarchive.3 gives an overview of the library as a whole + * archive_read.3, archive_write.3, archive_write_disk.3, and + archive_read_disk.3 provide detailed calling sequences for the read + and write APIs + * archive_entry.3 details the "struct archive_entry" utility class + * archive_internals.3 provides some insight into libarchive's + internal structure and operation. + * libarchive-formats.5 documents the file formats supported by the library + * cpio.5, mtree.5, and tar.5 provide detailed information about these + popular archive formats, including hard-to-find details about + modern cpio and tar variants. + +The manual pages above are provided in the 'doc' directory in +a number of different formats. + +You should also read the copious comments in `archive.h` and the +source code for the sample programs for more details. Please let us +know about any errors or omissions you find. + +## Supported Formats + +Currently, the library automatically detects and reads the following formats: + * Old V7 tar archives + * POSIX ustar + * GNU tar format (including GNU long filenames, long link names, and sparse files) + * Solaris 9 extended tar format (including ACLs) + * POSIX pax interchange format + * POSIX octet-oriented cpio + * SVR4 ASCII cpio + * Binary cpio (big-endian or little-endian) ++ * PWB binary cpio + * ISO9660 CD-ROM images (with optional Rockridge or Joliet extensions) + * ZIP archives (with uncompressed or "deflate" compressed entries, including support for encrypted Zip archives) + * ZIPX archives (with support for bzip2, ppmd8, lzma and xz compressed entries) + * GNU and BSD 'ar' archives + * 'mtree' format + * 7-Zip archives + * Microsoft CAB format + * LHA and LZH archives + * RAR and RAR 5.0 archives (with some limitations due to RAR's proprietary status) + * XAR archives + +The library also detects and handles any of the following before evaluating the archive: + * uuencoded files + * files with RPM wrapper + * gzip compression + * bzip2 compression + * compress/LZW compression + * lzma, lzip, and xz compression + * lz4 compression + * lzop compression + * zstandard compression + +The library can create archives in any of the following formats: + * POSIX ustar + * POSIX pax interchange format + * "restricted" pax format, which will create ustar archives except for + entries that require pax extensions (for long filenames, ACLs, etc). + * Old GNU tar format + * Old V7 tar format + * POSIX octet-oriented cpio + * SVR4 "newc" cpio ++ * Binary cpio (little-endian) ++ * PWB binary cpio + * shar archives + * ZIP archives (with uncompressed or "deflate" compressed entries) + * GNU and BSD 'ar' archives + * 'mtree' format + * ISO9660 format + * 7-Zip archives + * XAR archives + +When creating archives, the result can be filtered with any of the following: + * uuencode + * gzip compression + * bzip2 compression + * compress/LZW compression + * lzma, lzip, and xz compression + * lz4 compression + * lzop compression + * zstandard compression + +## Notes about the Library Design + +The following notes address many of the most common +questions we are asked about libarchive: + +* This is a heavily stream-oriented system. That means that + it is optimized to read or write the archive in a single + pass from beginning to end. For example, this allows + libarchive to process archives too large to store on disk + by processing them on-the-fly as they are read from or + written to a network or tape drive. This also makes + libarchive useful for tools that need to produce + archives on-the-fly (such as webservers that provide + archived contents of a users account). + +* In-place modification and random access to the contents + of an archive are not directly supported. For some formats, + this is not an issue: For example, tar.gz archives are not + designed for random access. In some other cases, libarchive + can re-open an archive and scan it from the beginning quickly + enough to provide the needed abilities even without true + random access. Of course, some applications do require true + random access; those applications should consider alternatives + to libarchive. + +* The library is designed to be extended with new compression and + archive formats. The only requirement is that the format be + readable or writable as a stream and that each archive entry be + independent. There are articles on the libarchive Wiki explaining + how to extend libarchive. + +* On read, compression and format are always detected automatically. + +* 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. + +* Libarchive's automatic support for decompression can be used + without archiving by explicitly selecting the "raw" and "empty" + formats. + +* I've attempted to minimize static link pollution. If you don't + explicitly invoke a particular feature (such as support for a + particular compression or format), it won't get pulled in to + statically-linked programs. In particular, if you don't explicitly + enable a particular compression or decompression support, you won't + need to link against the corresponding compression or decompression + libraries. This also reduces the size of statically-linked + binaries in environments where that matters. + +* The library is generally _thread safe_ depending on the platform: + it does not define any global variables of its own. However, some + platforms do not provide fully thread-safe versions of key C library + functions. On those platforms, libarchive will use the non-thread-safe + functions. Patches to improve this are of great interest to us. + +* In particular, libarchive's modules to read or write a directory + tree do use `chdir()` to optimize the directory traversals. This + can cause problems for programs that expect to do disk access from + multiple threads. Of course, those modules are completely + optional and you can use the rest of libarchive without them. + +* The library is _not_ thread aware, however. It does no locking + or thread management of any kind. If you create a libarchive + object and need to access it from multiple threads, you will + need to provide your own locking. + +* On read, the library accepts whatever blocks you hand it. + Your read callback is free to pass the library a byte at a time + or mmap the entire archive and give it to the library at once. + On write, the library always produces correctly-blocked output. + +* The object-style approach allows you to have multiple archive streams + open at once. bsdtar uses this in its "@archive" extension. + +* The archive itself is read/written using callback functions. + You can read an archive directly from an in-memory buffer or + write it to a socket, if you wish. There are some utility + functions to provide easy-to-use "open file," etc, capabilities. + +* The read/write APIs are designed to allow individual entries + to be read or written to any data source: You can create + a block of data in memory and add it to a tar archive without + first writing a temporary file. You can also read an entry from + an archive and write the data directly to a socket. If you want + to read/write entries to disk, there are convenience functions to + make this especially easy. + +* Note: The "pax interchange format" is a POSIX standard extended tar + format that should be used when the older _ustar_ format is not + appropriate. It has many advantages over other tar formats + (including the legacy GNU tar format) and is widely supported by + current tar implementations. + diff --cc contrib/libarchive/cpio/cpio.c index 3d5a6a837407,000000000000..847c92d31449 mode 100644,000000..100644 --- a/contrib/libarchive/cpio/cpio.c +++ b/contrib/libarchive/cpio/cpio.c @@@ -1,1506 -1,0 +1,1517 @@@ +/*- + * Copyright (c) 2003-2007 Tim Kientzle + * All rights reserved. + * + * 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 + * in this position and unchanged. + * 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(S) ``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(S) 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 "cpio_platform.h" +__FBSDID("$FreeBSD$"); + +#include +#include +#include + +#ifdef HAVE_SYS_MKDEV_H +#include +#endif +#ifdef HAVE_SYS_STAT_H +#include +#endif +#ifdef HAVE_SYS_TIME_H +#include +#endif +#ifdef HAVE_ERRNO_H +#include +#endif +#ifdef HAVE_FCNTL_H +#include +#endif +#ifdef HAVE_GRP_H +#include +#endif +#ifdef HAVE_LOCALE_H +#include +#endif +#ifdef HAVE_PWD_H +#include +#endif +#ifdef HAVE_SIGNAL_H +#include +#endif +#ifdef HAVE_STDARG_H +#include +#endif +#ifdef HAVE_STDINT_H +#include +#endif +#include +#ifdef HAVE_STDLIB_H +#include +#endif +#ifdef HAVE_STRING_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif +#ifdef HAVE_TIME_H +#include +#endif + +#include "cpio.h" +#include "err.h" +#include "line_reader.h" +#include "passphrase.h" + +/* Fixed size of uname/gname caches. */ +#define name_cache_size 101 + +#ifndef O_BINARY +#define O_BINARY 0 +#endif + +struct name_cache { + int probes; + int hits; + size_t size; + struct { + id_t id; + char *name; + } cache[name_cache_size]; +}; + +static int extract_data(struct archive *, struct archive *); +const char * cpio_i64toa(int64_t); +static const char *cpio_rename(const char *name); +static int entry_to_archive(struct cpio *, struct archive_entry *); +static int file_to_archive(struct cpio *, const char *); +static void free_cache(struct name_cache *cache); +static void list_item_verbose(struct cpio *, struct archive_entry *); +static void long_help(void) __LA_DEAD; +static const char *lookup_gname(struct cpio *, gid_t gid); +static int lookup_gname_helper(struct cpio *, + const char **name, id_t gid); +static const char *lookup_uname(struct cpio *, uid_t uid); +static int lookup_uname_helper(struct cpio *, + const char **name, id_t uid); +static void mode_in(struct cpio *) __LA_DEAD; +static void mode_list(struct cpio *) __LA_DEAD; +static void mode_out(struct cpio *); +static void mode_pass(struct cpio *, const char *); +static const char *remove_leading_slash(const char *); +static int restore_time(struct cpio *, struct archive_entry *, + const char *, int fd); +static void usage(void) __LA_DEAD; +static void version(void) __LA_DEAD; +static const char * passphrase_callback(struct archive *, void *); +static void passphrase_free(char *); + +int +main(int argc, char *argv[]) +{ + static char buff[16384]; + struct cpio _cpio; /* Allocated on stack. */ + struct cpio *cpio; + const char *errmsg; + char *tptr; + int uid, gid; + int opt, t; + + cpio = &_cpio; + memset(cpio, 0, sizeof(*cpio)); + cpio->buff = buff; + cpio->buff_size = sizeof(buff); + +#if defined(HAVE_SIGACTION) && defined(SIGPIPE) + { /* Ignore SIGPIPE signals. */ + struct sigaction sa; + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + sa.sa_handler = SIG_IGN; + sigaction(SIGPIPE, &sa, NULL); + } +#endif + + /* Set lafe_progname before calling lafe_warnc. */ + lafe_setprogname(*argv, "bsdcpio"); + +#if HAVE_SETLOCALE + if (setlocale(LC_ALL, "") == NULL) + lafe_warnc(0, "Failed to set default locale"); +#endif + + cpio->uid_override = -1; + cpio->gid_override = -1; + cpio->argv = argv; + cpio->argc = argc; + cpio->mode = '\0'; + cpio->verbose = 0; + cpio->compress = '\0'; + cpio->extract_flags = ARCHIVE_EXTRACT_NO_AUTODIR; + cpio->extract_flags |= ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER; + cpio->extract_flags |= ARCHIVE_EXTRACT_SECURE_SYMLINKS; + cpio->extract_flags |= ARCHIVE_EXTRACT_SECURE_NODOTDOT; + cpio->extract_flags |= ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS; + cpio->extract_flags |= ARCHIVE_EXTRACT_PERM; + cpio->extract_flags |= ARCHIVE_EXTRACT_FFLAGS; + cpio->extract_flags |= ARCHIVE_EXTRACT_ACL; +#if !defined(_WIN32) && !defined(__CYGWIN__) + if (geteuid() == 0) + cpio->extract_flags |= ARCHIVE_EXTRACT_OWNER; +#endif + cpio->bytes_per_block = 512; + cpio->filename = NULL; + + cpio->matching = archive_match_new(); + if (cpio->matching == NULL) + lafe_errc(1, 0, "Out of memory"); + + while ((opt = cpio_getopt(cpio)) != -1) { + switch (opt) { + case '0': /* GNU convention: --null, -0 */ + cpio->option_null = 1; + break; ++ case '6': /* in/out: assume/create 6th edition (PWB) format */ ++ cpio->option_pwb = 1; ++ break; ++ case '7': /* out: create archive using 7th Edition binary format */ ++ cpio->format = "bin"; ++ break; + case 'A': /* NetBSD/OpenBSD */ + cpio->option_append = 1; + break; + case 'a': /* POSIX 1997 */ + cpio->option_atime_restore = 1; + break; + case 'B': /* POSIX 1997 */ + cpio->bytes_per_block = 5120; + break; + case OPTION_B64ENCODE: + cpio->add_filter = opt; + break; + case 'C': /* NetBSD/OpenBSD */ + errno = 0; + tptr = NULL; + t = (int)strtol(cpio->argument, &tptr, 10); + if (errno || t <= 0 || *(cpio->argument) == '\0' || + tptr == NULL || *tptr != '\0') { + lafe_errc(1, 0, "Invalid blocksize: %s", + cpio->argument); + } + cpio->bytes_per_block = t; + break; + case 'c': /* POSIX 1997 */ + cpio->format = "odc"; + break; + case 'd': /* POSIX 1997 */ + cpio->extract_flags &= ~ARCHIVE_EXTRACT_NO_AUTODIR; + break; + case 'E': /* NetBSD/OpenBSD */ + if (archive_match_include_pattern_from_file( + cpio->matching, cpio->argument, + cpio->option_null) != ARCHIVE_OK) + lafe_errc(1, 0, "Error : %s", + archive_error_string(cpio->matching)); + break; + case 'F': /* NetBSD/OpenBSD/GNU cpio */ + cpio->filename = cpio->argument; + break; + case 'f': /* POSIX 1997 */ + if (archive_match_exclude_pattern(cpio->matching, + cpio->argument) != ARCHIVE_OK) + lafe_errc(1, 0, "Error : %s", + archive_error_string(cpio->matching)); + break; + case OPTION_GRZIP: + cpio->compress = opt; + break; + case 'H': /* GNU cpio (also --format) */ + cpio->format = cpio->argument; + break; + case 'h': + long_help(); + break; + case 'I': /* NetBSD/OpenBSD */ + cpio->filename = cpio->argument; + break; + case 'i': /* POSIX 1997 */ + if (cpio->mode != '\0') + lafe_errc(1, 0, + "Cannot use both -i and -%c", cpio->mode); + cpio->mode = opt; + break; + case 'J': /* GNU tar, others */ + cpio->compress = opt; + break; + case 'j': /* GNU tar, others */ + cpio->compress = opt; + break; + case OPTION_INSECURE: + cpio->extract_flags &= ~ARCHIVE_EXTRACT_SECURE_SYMLINKS; + cpio->extract_flags &= ~ARCHIVE_EXTRACT_SECURE_NODOTDOT; + cpio->extract_flags &= ~ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS; + break; + case 'L': /* GNU cpio */ + cpio->option_follow_links = 1; + break; + case 'l': /* POSIX 1997 */ + cpio->option_link = 1; + break; + case OPTION_LRZIP: + case OPTION_LZ4: + case OPTION_LZMA: /* GNU tar, others */ + case OPTION_LZOP: /* GNU tar, others */ + case OPTION_ZSTD: + cpio->compress = opt; + break; + case 'm': /* POSIX 1997 */ + cpio->extract_flags |= ARCHIVE_EXTRACT_TIME; + break; + case 'n': /* GNU cpio */ + cpio->option_numeric_uid_gid = 1; + break; + case OPTION_NO_PRESERVE_OWNER: /* GNU cpio */ + cpio->extract_flags &= ~ARCHIVE_EXTRACT_OWNER; + break; + case 'O': /* GNU cpio */ + cpio->filename = cpio->argument; + break; + case 'o': /* POSIX 1997 */ + if (cpio->mode != '\0') + lafe_errc(1, 0, + "Cannot use both -o and -%c", cpio->mode); + cpio->mode = opt; + break; + case 'p': /* POSIX 1997 */ + if (cpio->mode != '\0') + lafe_errc(1, 0, + "Cannot use both -p and -%c", cpio->mode); + cpio->mode = opt; + cpio->extract_flags &= ~ARCHIVE_EXTRACT_SECURE_NODOTDOT; + cpio->extract_flags &= ~ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS; + break; + case OPTION_PASSPHRASE: + cpio->passphrase = cpio->argument; + break; + case OPTION_PRESERVE_OWNER: + cpio->extract_flags |= ARCHIVE_EXTRACT_OWNER; + break; + case OPTION_QUIET: /* GNU cpio */ + cpio->quiet = 1; + break; + case 'R': /* GNU cpio, also --owner */ + /* TODO: owner_parse should return uname/gname + * also; use that to set [ug]name_override. */ + errmsg = owner_parse(cpio->argument, &uid, &gid); + if (errmsg) { + lafe_warnc(-1, "%s", errmsg); + usage(); + } + if (uid != -1) { + cpio->uid_override = uid; + cpio->uname_override = NULL; + } + if (gid != -1) { + cpio->gid_override = gid; + cpio->gname_override = NULL; + } + break; + case 'r': /* POSIX 1997 */ + cpio->option_rename = 1; + break; + case 't': /* POSIX 1997 */ + cpio->option_list = 1; + break; + case 'u': /* POSIX 1997 */ + cpio->extract_flags + &= ~ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER; + break; + case OPTION_UUENCODE: + cpio->add_filter = opt; + break; + case 'v': /* POSIX 1997 */ + cpio->verbose++; + break; + case 'V': /* GNU cpio */ + cpio->dot++; + break; + case OPTION_VERSION: /* GNU convention */ + version(); + break; +#if 0 + /* + * cpio_getopt() handles -W specially, so it's not + * available here. + */ + case 'W': /* Obscure, but useful GNU convention. */ + break; +#endif + case 'y': /* tar convention */ + cpio->compress = opt; + break; + case 'Z': /* tar convention */ + cpio->compress = opt; + break; + case 'z': /* tar convention */ + cpio->compress = opt; + break; + default: + usage(); + } + } + + /* + * Sanity-check args, error out on nonsensical combinations. + */ + /* -t implies -i if no mode was specified. */ + if (cpio->option_list && cpio->mode == '\0') + cpio->mode = 'i'; + /* -t requires -i */ + if (cpio->option_list && cpio->mode != 'i') + lafe_errc(1, 0, "Option -t requires -i"); + /* -n requires -it */ + if (cpio->option_numeric_uid_gid && !cpio->option_list) + lafe_errc(1, 0, "Option -n requires -it"); + /* Can only specify format when writing */ + if (cpio->format != NULL && cpio->mode != 'o') + lafe_errc(1, 0, "Option --format requires -o"); + /* -l requires -p */ + if (cpio->option_link && cpio->mode != 'p') + lafe_errc(1, 0, "Option -l requires -p"); + /* -v overrides -V */ + if (cpio->dot && cpio->verbose) + cpio->dot = 0; + /* TODO: Flag other nonsensical combinations. */ + + switch (cpio->mode) { + case 'o': - /* TODO: Implement old binary format in libarchive, - use that here. */ - if (cpio->format == NULL) - cpio->format = "odc"; /* Default format */ - ++ if (cpio->format == NULL) { ++ if (cpio->option_pwb) ++ cpio->format = "pwb"; ++ else ++ cpio->format = "cpio"; ++ } + mode_out(cpio); + break; + case 'i': + while (*cpio->argv != NULL) { + if (archive_match_include_pattern(cpio->matching, + *cpio->argv) != ARCHIVE_OK) + lafe_errc(1, 0, "Error : %s", + archive_error_string(cpio->matching)); + --cpio->argc; + ++cpio->argv; + } + if (cpio->option_list) + mode_list(cpio); + else + mode_in(cpio); + break; + case 'p': + if (*cpio->argv == NULL || **cpio->argv == '\0') + lafe_errc(1, 0, + "-p mode requires a target directory"); + mode_pass(cpio, *cpio->argv); + break; + default: + lafe_errc(1, 0, + "Must specify at least one of -i, -o, or -p"); + } + + archive_match_free(cpio->matching); + free_cache(cpio->gname_cache); + free_cache(cpio->uname_cache); + free(cpio->destdir); + passphrase_free(cpio->ppbuff); + return (cpio->return_value); +} + +static void +usage(void) +{ + const char *p; + + p = lafe_getprogname(); + + fprintf(stderr, "Brief Usage:\n"); + fprintf(stderr, " List: %s -it < archive\n", p); + fprintf(stderr, " Extract: %s -i < archive\n", p); + fprintf(stderr, " Create: %s -o < filenames > archive\n", p); + fprintf(stderr, " Help: %s --help\n", p); + exit(1); +} + +static const char *long_help_msg = + "First option must be a mode specifier:\n" + " -i Input -o Output -p Pass\n" + "Common Options:\n" + " -v Verbose filenames -V one dot per file\n" + "Create: %p -o [options] < [list of files] > [archive]\n" + " -J,-y,-z,--lzma Compress archive with xz/bzip2/gzip/lzma\n" - " --format {odc|newc|ustar} Select archive format\n" ++ " --format {pwb|bin|odc|newc|ustar} Select archive format\n" + "List: %p -it < [archive]\n" + "Extract: %p -i [options] < [archive]\n"; + + +/* + * Note that the word 'bsdcpio' will always appear in the first line + * of output. + * + * In particular, /bin/sh scripts that need to test for the presence + * of bsdcpio can use the following template: + * + * if (cpio --help 2>&1 | grep bsdcpio >/dev/null 2>&1 ) then \ + * echo bsdcpio; else echo not bsdcpio; fi + */ +static void +long_help(void) +{ + const char *prog; + const char *p; + + prog = lafe_getprogname(); + + fflush(stderr); + + p = (strcmp(prog,"bsdcpio") != 0) ? "(bsdcpio)" : ""; + printf("%s%s: manipulate archive files\n", prog, p); + + for (p = long_help_msg; *p != '\0'; p++) { + if (*p == '%') { + if (p[1] == 'p') { + fputs(prog, stdout); + p++; + } else + putchar('%'); + } else + putchar(*p); + } + version(); +} + +static void +version(void) +{ + fprintf(stdout,"bsdcpio %s - %s \n", + BSDCPIO_VERSION_STRING, + archive_version_details()); + exit(0); +} + +static void +mode_out(struct cpio *cpio) +{ + struct archive_entry *entry, *spare; + struct lafe_line_reader *lr; + const char *p; + int r; + + if (cpio->option_append) + lafe_errc(1, 0, "Append mode not yet supported."); + + cpio->archive_read_disk = archive_read_disk_new(); + if (cpio->archive_read_disk == NULL) + lafe_errc(1, 0, "Failed to allocate archive object"); + if (cpio->option_follow_links) + archive_read_disk_set_symlink_logical(cpio->archive_read_disk); + else + archive_read_disk_set_symlink_physical(cpio->archive_read_disk); + archive_read_disk_set_standard_lookup(cpio->archive_read_disk); + + cpio->archive = archive_write_new(); + if (cpio->archive == NULL) + lafe_errc(1, 0, "Failed to allocate archive object"); + switch (cpio->compress) { + case OPTION_GRZIP: + r = archive_write_add_filter_grzip(cpio->archive); + break; + case 'J': + r = archive_write_add_filter_xz(cpio->archive); + break; + case OPTION_LRZIP: + r = archive_write_add_filter_lrzip(cpio->archive); + break; + case OPTION_LZ4: + r = archive_write_add_filter_lz4(cpio->archive); + break; + case OPTION_LZMA: + r = archive_write_add_filter_lzma(cpio->archive); + break; + case OPTION_LZOP: + r = archive_write_add_filter_lzop(cpio->archive); + break; + case OPTION_ZSTD: + r = archive_write_add_filter_zstd(cpio->archive); + break; + case 'j': case 'y': + r = archive_write_add_filter_bzip2(cpio->archive); + break; + case 'z': + r = archive_write_add_filter_gzip(cpio->archive); + break; + case 'Z': + r = archive_write_add_filter_compress(cpio->archive); + break; + default: + r = archive_write_add_filter_none(cpio->archive); + break; + } + if (r < ARCHIVE_WARN) + lafe_errc(1, 0, "Requested compression not available"); + switch (cpio->add_filter) { + case 0: + r = ARCHIVE_OK; + break; + case OPTION_B64ENCODE: + r = archive_write_add_filter_b64encode(cpio->archive); + break; + case OPTION_UUENCODE: + r = archive_write_add_filter_uuencode(cpio->archive); + break; + } + if (r < ARCHIVE_WARN) + lafe_errc(1, 0, "Requested filter not available"); + r = archive_write_set_format_by_name(cpio->archive, cpio->format); + if (r != ARCHIVE_OK) + lafe_errc(1, 0, "%s", archive_error_string(cpio->archive)); + archive_write_set_bytes_per_block(cpio->archive, cpio->bytes_per_block); + cpio->linkresolver = archive_entry_linkresolver_new(); + archive_entry_linkresolver_set_strategy(cpio->linkresolver, + archive_format(cpio->archive)); + if (cpio->passphrase != NULL) + r = archive_write_set_passphrase(cpio->archive, + cpio->passphrase); + else + r = archive_write_set_passphrase_callback(cpio->archive, cpio, + &passphrase_callback); + if (r != ARCHIVE_OK) + lafe_errc(1, 0, "%s", archive_error_string(cpio->archive)); + + /* + * The main loop: Copy each file into the output archive. + */ + r = archive_write_open_filename(cpio->archive, cpio->filename); + if (r != ARCHIVE_OK) + lafe_errc(1, 0, "%s", archive_error_string(cpio->archive)); + lr = lafe_line_reader("-", cpio->option_null); + while ((p = lafe_line_reader_next(lr)) != NULL) + file_to_archive(cpio, p); + lafe_line_reader_free(lr); + + /* + * The hardlink detection may have queued up a couple of entries + * that can now be flushed. + */ + entry = NULL; + archive_entry_linkify(cpio->linkresolver, &entry, &spare); + while (entry != NULL) { + entry_to_archive(cpio, entry); + archive_entry_free(entry); + entry = NULL; + archive_entry_linkify(cpio->linkresolver, &entry, &spare); + } + + r = archive_write_close(cpio->archive); + if (cpio->dot) *** 2629 LINES SKIPPED *** From owner-dev-commits-src-main@freebsd.org Mon Aug 23 05:07:21 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DCF196632C7; Mon, 23 Aug 2021 05:07:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtKx55h6Kz3pBn; Mon, 23 Aug 2021 05:07:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9BF3163BB; Mon, 23 Aug 2021 05:07:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17N57LwH023306; Mon, 23 Aug 2021 05:07:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17N57LRj023305; Mon, 23 Aug 2021 05:07:21 GMT (envelope-from git) Date: Mon, 23 Aug 2021 05:07:21 GMT Message-Id: <202108230507.17N57LRj023305@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Piotr Pawel Stefaniak Subject: git: af2f01643184 - main - diff: don't output carriage returns that were stripped on input MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pstef X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: af2f0164318455433db95adce07af829285b78ad Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 05:07:21 -0000 The branch main has been updated by pstef: URL: https://cgit.FreeBSD.org/src/commit/?id=af2f0164318455433db95adce07af829285b78ad commit af2f0164318455433db95adce07af829285b78ad Author: Piotr Pawel Stefaniak AuthorDate: 2021-08-22 16:05:59 +0000 Commit: Piotr Pawel Stefaniak CommitDate: 2021-08-23 05:04:28 +0000 diff: don't output carriage returns that were stripped on input --strip-trailing-cr worked as intended for comparison between files, but the characters were still present in final output. --- usr.bin/diff/diffreg.c | 11 ++++++++++- usr.bin/diff/tests/Makefile | 3 ++- usr.bin/diff/tests/diff_test.sh | 10 ++++++++++ usr.bin/diff/tests/strip_o.out | 7 +++++++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c index 651ec88df909..113b7b621256 100644 --- a/usr.bin/diff/diffreg.c +++ b/usr.bin/diff/diffreg.c @@ -1273,7 +1273,16 @@ fetch(long *f, int a, int b, FILE *lb, int ch, int oldfile, int flags) } col = 0; for (j = 0, lastc = '\0'; j < nc; j++, lastc = c) { - if ((c = getc(lb)) == EOF) { + c = getc(lb); + if (flags & D_STRIPCR && c == '\r') { + if ((c = getc(lb)) == '\n') + j++; + else { + ungetc(c, lb); + c = '\r'; + } + } + if (c == EOF) { if (diff_format == D_EDIT || diff_format == D_REVERSE || diff_format == D_NREVERSE) diff --git a/usr.bin/diff/tests/Makefile b/usr.bin/diff/tests/Makefile index 78744d3bed8e..303a37911fbd 100644 --- a/usr.bin/diff/tests/Makefile +++ b/usr.bin/diff/tests/Makefile @@ -26,7 +26,8 @@ ${PACKAGE}FILES+= \ header.out \ header_ns.out \ ifdef.out \ - group-format.out + group-format.out \ + strip_o.out NETBSD_ATF_TESTS_SH+= netbsd_diff_test diff --git a/usr.bin/diff/tests/diff_test.sh b/usr.bin/diff/tests/diff_test.sh index cd893091d016..b8b7fe1d8068 100755 --- a/usr.bin/diff/tests/diff_test.sh +++ b/usr.bin/diff/tests/diff_test.sh @@ -9,6 +9,7 @@ atf_test_case group_format atf_test_case side_by_side atf_test_case brief_format atf_test_case b230049 +atf_test_case stripcr_o atf_test_case b252515 atf_test_case Bflag atf_test_case Nflag @@ -68,6 +69,14 @@ b230049_body() b230049_a.in b230049_b.in } +stripcr_o_body() +{ + printf 'a\nX\nc\n' > stripcr_o_X.in + printf 'a\r\nY\r\nc\r\n' > stripcr_o_Y.in + atf_check -o "file:$(atf_get_srcdir)/strip_o.out" -s eq:1 \ + diff -L1 -L2 -u --strip-trailing-cr stripcr_o_X.in stripcr_o_Y.in +} + b252515_body() { printf 'a b\n' > b252515_a.in @@ -267,6 +276,7 @@ atf_init_test_cases() atf_add_test_case side_by_side atf_add_test_case brief_format atf_add_test_case b230049 + atf_add_test_case stripcr_o atf_add_test_case b252515 atf_add_test_case Bflag atf_add_test_case Nflag diff --git a/usr.bin/diff/tests/strip_o.out b/usr.bin/diff/tests/strip_o.out new file mode 100644 index 000000000000..47bbfbd4e921 --- /dev/null +++ b/usr.bin/diff/tests/strip_o.out @@ -0,0 +1,7 @@ +--- 1 ++++ 2 +@@ -1,3 +1,3 @@ + a +-X ++Y + c From owner-dev-commits-src-main@freebsd.org Mon Aug 23 05:07:22 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E5A34663A82; Mon, 23 Aug 2021 05:07:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtKx661WWz3pKp; Mon, 23 Aug 2021 05:07:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B5FD96352; Mon, 23 Aug 2021 05:07:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17N57M3R023330; Mon, 23 Aug 2021 05:07:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17N57ML9023329; Mon, 23 Aug 2021 05:07:22 GMT (envelope-from git) Date: Mon, 23 Aug 2021 05:07:22 GMT Message-Id: <202108230507.17N57ML9023329@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Piotr Pawel Stefaniak Subject: git: f8e50dd2c67b - main - Register /usr/tests/usr.bin/diff3 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pstef X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f8e50dd2c67baea2bbd75f94218911d5a4d39597 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 05:07:23 -0000 The branch main has been updated by pstef: URL: https://cgit.FreeBSD.org/src/commit/?id=f8e50dd2c67baea2bbd75f94218911d5a4d39597 commit f8e50dd2c67baea2bbd75f94218911d5a4d39597 Author: Piotr Pawel Stefaniak AuthorDate: 2021-08-22 10:08:39 +0000 Commit: Piotr Pawel Stefaniak CommitDate: 2021-08-23 05:04:28 +0000 Register /usr/tests/usr.bin/diff3 I wasn't able to make check to run diff3 tests, but kevans figured out that I was missing diff3 in mtree. --- etc/mtree/BSD.tests.dist | 2 ++ 1 file changed, 2 insertions(+) diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist index f7965dac2884..b21256c8563c 100644 --- a/etc/mtree/BSD.tests.dist +++ b/etc/mtree/BSD.tests.dist @@ -996,6 +996,8 @@ .. diff .. + diff3 + .. dirname .. du From owner-dev-commits-src-main@freebsd.org Mon Aug 23 05:07:25 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 616D3663A86; Mon, 23 Aug 2021 05:07:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtKx91Nj8z3pNN; Mon, 23 Aug 2021 05:07:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 06DFA5ED1; Mon, 23 Aug 2021 05:07:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17N57OSY023378; Mon, 23 Aug 2021 05:07:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17N57O2O023377; Mon, 23 Aug 2021 05:07:24 GMT (envelope-from git) Date: Mon, 23 Aug 2021 05:07:24 GMT Message-Id: <202108230507.17N57O2O023377@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Piotr Pawel Stefaniak Subject: git: 702dda4368dc - main - diff3: improve style MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pstef X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 702dda4368dc2d07e8898fcfdddb12d730e6c174 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 05:07:25 -0000 The branch main has been updated by pstef: URL: https://cgit.FreeBSD.org/src/commit/?id=702dda4368dc2d07e8898fcfdddb12d730e6c174 commit 702dda4368dc2d07e8898fcfdddb12d730e6c174 Author: Piotr Pawel Stefaniak AuthorDate: 2021-08-20 21:50:20 +0000 Commit: Piotr Pawel Stefaniak CommitDate: 2021-08-23 05:04:28 +0000 diff3: improve style --- usr.bin/diff3/diff3.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/usr.bin/diff3/diff3.c b/usr.bin/diff3/diff3.c index 80d4a202728f..18daa54b2360 100644 --- a/usr.bin/diff3/diff3.c +++ b/usr.bin/diff3/diff3.c @@ -126,7 +126,7 @@ static int cline[3]; /* # of the last-read line in each file (0-2) */ */ static int last[4]; static int Aflag, eflag, iflag, mflag, Tflag; -static int oflag; /* indicates whether to mark overlaps (-E or -X)*/ +static int oflag; /* indicates whether to mark overlaps (-E or -X) */ static int strip_cr; static char *f1mark, *f2mark, *f3mark; @@ -170,9 +170,9 @@ static struct option longopts[] = { static void usage(void) { - fprintf(stderr, "usage: diff3 [-3aAeEimTxX] [-L lable1] [-L label2] " - "[ -L label3] file1 file2 file3\n"); - exit (2); + fprintf(stderr, "usage: diff3 [-3aAeEimTxX] [-L label1] [-L label2] " + "[-L label3] file1 file2 file3\n"); + exit(2); } static int @@ -186,7 +186,7 @@ readin(int fd, struct diff **dd) f = fdopen(fd, "r"); if (f == NULL) err(2, "fdopen"); - for (i=0; (p = getchange(f)); i++) { + for (i = 0; (p = getchange(f)); i++) { if (i >= szchanges - 1) increase(); a = b = (int)strtoimax(p, &p, 10); @@ -196,7 +196,7 @@ readin(int fd, struct diff **dd) } kind = *p++; c = d = (int)strtoimax(p, &p, 10); - if (*p==',') { + if (*p == ',') { p++; d = (int)strtoimax(p, &p, 10); } @@ -212,8 +212,8 @@ readin(int fd, struct diff **dd) (*dd)[i].new.to = d; } if (i) { - (*dd)[i].old.from = (*dd)[i-1].old.to; - (*dd)[i].new.from = (*dd)[i-1].new.to; + (*dd)[i].old.from = (*dd)[i - 1].old.to; + (*dd)[i].new.from = (*dd)[i - 1].new.to; } fclose(f); return (i); @@ -222,9 +222,9 @@ readin(int fd, struct diff **dd) static int diffexec(const char *diffprog, char **diffargv, int fd[]) { - int pid, pd; + int pd; - switch (pid = pdfork(&pd, PD_CLOEXEC)) { + switch (pdfork(&pd, PD_CLOEXEC)) { case 0: close(fd[0]); if (dup2(fd[1], STDOUT_FILENO) == -1) @@ -396,7 +396,7 @@ prange(struct range *rold) printf("%da\n", rold->from - 1); else { printf("%d", rold->from); - if (rold->to > rold->from+1) + if (rold->to > rold->from + 1) printf(",%d", rold->to - 1); printf("c\n"); } @@ -433,7 +433,7 @@ skip(int i, int from, const char *pr) if ((line = get_line(fp[i], &j)) == NULL) errx(EXIT_FAILURE, "logic error"); if (pr != NULL) - printf("%s%s", Tflag == 1? "\t" : pr, line); + printf("%s%s", Tflag == 1 ? "\t" : pr, line); cline[i]++; } return ((int) n); @@ -455,13 +455,13 @@ duplicate(struct range *r1, struct range *r2) skip(0, r1->from, NULL); skip(1, r2->from, NULL); nchar = 0; - for (nline=0; nline < r1->to - r1->from; nline++) { + for (nline = 0; nline < r1->to - r1->from; nline++) { do { c = getc(fp[0]); d = getc(fp[1]); if (c == -1 && d == -1) break; - if (c == -1 || d== -1) + if (c == -1 || d == -1) errx(EXIT_FAILURE, "logic error"); nchar++; if (c != d) { @@ -482,6 +482,7 @@ repos(int nchar) for (i = 0; i < 2; i++) (void)fseek(fp[i], (long)-nchar, SEEK_CUR); } + /* * collect an editing script for later regurgitation */ @@ -514,7 +515,7 @@ edscript(int n) if (!oflag || !overlap[n]) { prange(&de[n].old); } else { - printf("%da\n", de[n].old.to -1); + printf("%da\n", de[n].old.to - 1); if (Aflag) { printf("%s\n", f2mark); fseek(fp[1], de[n].old.from, SEEK_SET); @@ -529,8 +530,9 @@ edscript(int n) printf("=======\n"); } fseek(fp[2], (long)de[n].new.from, SEEK_SET); - for (k = de[n].new.to - de[n].new.from; k > 0; k-= j) { + for (k = de[n].new.to - de[n].new.from; k > 0; k -= j) { size_t r; + j = k > BUFSIZ ? BUFSIZ : k; r = fread(block, 1, j, fp[2]); if (r == 0) { @@ -759,7 +761,7 @@ main(int argc, char **argv) for (i = 0; i < nke; i++) { status = e[i].data; if (WIFEXITED(status) && WEXITSTATUS(status) >= 2) - errx(2, "diff exited abormally"); + errx(2, "diff exited abnormally"); else if (WIFSIGNALED(status)) errx(2, "diff killed by signal %d", WTERMSIG(status)); From owner-dev-commits-src-main@freebsd.org Mon Aug 23 05:07:26 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6BAB5663762; Mon, 23 Aug 2021 05:07:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtKxB2J0tz3pSG; Mon, 23 Aug 2021 05:07:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 35BED63BC; Mon, 23 Aug 2021 05:07:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17N57QuB023409; Mon, 23 Aug 2021 05:07:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17N57QDG023408; Mon, 23 Aug 2021 05:07:26 GMT (envelope-from git) Date: Mon, 23 Aug 2021 05:07:26 GMT Message-Id: <202108230507.17N57QDG023408@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Piotr Pawel Stefaniak Subject: git: e8ff95356cea - main - diff3.1: update manual page to match code MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pstef X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e8ff95356ceaaa941251056e9d0a4211bf428e06 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 05:07:26 -0000 The branch main has been updated by pstef: URL: https://cgit.FreeBSD.org/src/commit/?id=e8ff95356ceaaa941251056e9d0a4211bf428e06 commit e8ff95356ceaaa941251056e9d0a4211bf428e06 Author: Piotr Pawel Stefaniak AuthorDate: 2021-08-20 22:50:05 +0000 Commit: Piotr Pawel Stefaniak CommitDate: 2021-08-23 05:04:28 +0000 diff3.1: update manual page to match code --- usr.bin/diff3/diff3.1 | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/usr.bin/diff3/diff3.1 b/usr.bin/diff3/diff3.1 index 84985632b8b8..cc4bdf1c8836 100644 --- a/usr.bin/diff3/diff3.1 +++ b/usr.bin/diff3/diff3.1 @@ -38,7 +38,11 @@ .Nd 3-way differential file comparison .Sh SYNOPSIS .Nm diff3 -.Op Fl 3aEeXx +.Op Fl 3aEeiXx +.Op Fl Fl diff-program Ar program +.Op Fl L | Fl Fl label Ar label1 +.Op Fl L | Fl Fl label Ar label2 +.Op Fl L | Fl Fl label Ar label3 .Ar file1 file2 file3 .Sh DESCRIPTION The @@ -60,15 +64,16 @@ new versions. .Pp The options are as follows: .Bl -tag -width "-E, -X" -.It Fl 3 +.It Fl 3 , Fl Fl easy-only Produces an output script suitable for .Xr ed 1 with changes specific only to .Ar file3 . -.It Fl a +.It Fl a , Fl Fl text Treat all files as ASCII. -.It Fl E , X +.It Fl E , Fl Fl show-overlap +.It Fl X Similar to .Fl e and @@ -77,7 +82,7 @@ respectively, but treat overlapping changes (i.e., changes that would be noted with ==== in the normal listing) differently. The overlapping lines from both files will be inserted by the edit script, bracketed by "<<<<<<" and ">>>>>>" lines. -.It Fl e +.It Fl e , Fl Fl ed Produces output in a form suitable as an input script for the .Xr ed 1 utility. @@ -99,11 +104,27 @@ and It is useful for backing out changes specific to .Ar file2 only. -.It Fl x +.It Fl i +Appends 'w' and 'q' +.Xr ed 1 +commands. +.It Fl L , Fl Fl label +Defines labels to print instead of file names +.Ar file1 , +.Ar file2 +and +.Ar file3 . +.It Fl x, Fl Fl overlap-only Produces an output script suitable for .Xr ed 1 with changes specific only to all three versions. +.It Fl Fl diff-program Ar program +Use +.Ar program +instead of the default +.Xr diff 1 +to compare files. .El .Pp The From owner-dev-commits-src-main@freebsd.org Mon Aug 23 05:07:24 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6097F663A84; Mon, 23 Aug 2021 05:07:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtKx80K4cz3pHr; Mon, 23 Aug 2021 05:07:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DB15860E6; Mon, 23 Aug 2021 05:07:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17N57NW7023354; Mon, 23 Aug 2021 05:07:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17N57NPE023353; Mon, 23 Aug 2021 05:07:23 GMT (envelope-from git) Date: Mon, 23 Aug 2021 05:07:23 GMT Message-Id: <202108230507.17N57NPE023353@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Piotr Pawel Stefaniak Subject: git: 7f7b03f3897f - main - diff3: sync with upstream MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pstef X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7f7b03f3897f0196e3cc7a3b71c7359cc206ba61 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 05:07:24 -0000 The branch main has been updated by pstef: URL: https://cgit.FreeBSD.org/src/commit/?id=7f7b03f3897f0196e3cc7a3b71c7359cc206ba61 commit 7f7b03f3897f0196e3cc7a3b71c7359cc206ba61 Author: Piotr Pawel Stefaniak AuthorDate: 2021-08-20 21:35:24 +0000 Commit: Piotr Pawel Stefaniak CommitDate: 2021-08-23 05:04:28 +0000 diff3: sync with upstream * replace realloc calls with reallocarray calls * fix merging of files that lack newlines Obtained from: OpenBSD --- usr.bin/diff3/diff3.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/usr.bin/diff3/diff3.c b/usr.bin/diff3/diff3.c index 03cd24283a13..80d4a202728f 100644 --- a/usr.bin/diff3/diff3.c +++ b/usr.bin/diff3/diff3.c @@ -459,6 +459,8 @@ duplicate(struct range *r1, struct range *r2) do { c = getc(fp[0]); d = getc(fp[1]); + if (c == -1 && d == -1) + break; if (c == -1 || d== -1) errx(EXIT_FAILURE, "logic error"); nchar++; @@ -528,10 +530,17 @@ edscript(int n) } fseek(fp[2], (long)de[n].new.from, SEEK_SET); for (k = de[n].new.to - de[n].new.from; k > 0; k-= j) { + size_t r; j = k > BUFSIZ ? BUFSIZ : k; - if (fread(block, 1, j, fp[2]) != j) + r = fread(block, 1, j, fp[2]); + if (r == 0) { + if (feof(fp[2])) + break; errx(2, "logic error"); - fwrite(block, 1, j, stdout); + } + if (r != j) + j = r; + (void)fwrite(block, 1, j, stdout); } if (!oflag || !overlap[n]) printf(".\n"); @@ -557,22 +566,22 @@ increase(void) newsz = szchanges == 0 ? 64 : 2 * szchanges; incr = newsz - szchanges; - p = realloc(d13, newsz * sizeof(struct diff)); + p = reallocarray(d13, newsz, sizeof(struct diff)); if (p == NULL) err(1, NULL); memset(p + szchanges, 0, incr * sizeof(struct diff)); d13 = p; - p = realloc(d23, newsz * sizeof(struct diff)); + p = reallocarray(d23, newsz, sizeof(struct diff)); if (p == NULL) err(1, NULL); memset(p + szchanges, 0, incr * sizeof(struct diff)); d23 = p; - p = realloc(de, newsz * sizeof(struct diff)); + p = reallocarray(de, newsz, sizeof(struct diff)); if (p == NULL) err(1, NULL); memset(p + szchanges, 0, incr * sizeof(struct diff)); de = p; - q = realloc(overlap, newsz * sizeof(char)); + q = reallocarray(overlap, newsz, sizeof(char)); if (q == NULL) err(1, NULL); memset(q + szchanges, 0, incr * sizeof(char)); From owner-dev-commits-src-main@freebsd.org Mon Aug 23 05:07:27 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A8561663442; Mon, 23 Aug 2021 05:07:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtKxC3nHzz3p89; Mon, 23 Aug 2021 05:07:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4B74A627B; Mon, 23 Aug 2021 05:07:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17N57ROt023433; Mon, 23 Aug 2021 05:07:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17N57RX6023432; Mon, 23 Aug 2021 05:07:27 GMT (envelope-from git) Date: Mon, 23 Aug 2021 05:07:27 GMT Message-Id: <202108230507.17N57RX6023432@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Piotr Pawel Stefaniak Subject: git: 54a3415cb69e - main - diff3: implement --strip-trailing-cr MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pstef X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 54a3415cb69e1ea0e6533ca3fc168deba64f249f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 05:07:27 -0000 The branch main has been updated by pstef: URL: https://cgit.FreeBSD.org/src/commit/?id=54a3415cb69e1ea0e6533ca3fc168deba64f249f commit 54a3415cb69e1ea0e6533ca3fc168deba64f249f Author: Piotr Pawel Stefaniak AuthorDate: 2021-08-21 00:28:58 +0000 Commit: Piotr Pawel Stefaniak CommitDate: 2021-08-23 05:04:28 +0000 diff3: implement --strip-trailing-cr Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D31626 --- usr.bin/diff3/diff3.1 | 3 +++ usr.bin/diff3/diff3.c | 9 ++++++++- usr.bin/diff3/tests/1cr.txt | 6 ++++++ usr.bin/diff3/tests/Makefile | 1 + usr.bin/diff3/tests/diff3_test.sh | 3 +++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/usr.bin/diff3/diff3.1 b/usr.bin/diff3/diff3.1 index cc4bdf1c8836..22e04b6af5e8 100644 --- a/usr.bin/diff3/diff3.1 +++ b/usr.bin/diff3/diff3.1 @@ -40,6 +40,7 @@ .Nm diff3 .Op Fl 3aEeiXx .Op Fl Fl diff-program Ar program +.Op Fl Fl strip-trailing-cr .Op Fl L | Fl Fl label Ar label1 .Op Fl L | Fl Fl label Ar label2 .Op Fl L | Fl Fl label Ar label3 @@ -125,6 +126,8 @@ Use instead of the default .Xr diff 1 to compare files. +.It Fl Fl strip-trailing-cr +Strip trailing carriage return on input files. .El .Pp The diff --git a/usr.bin/diff3/diff3.c b/usr.bin/diff3/diff3.c index 18daa54b2360..122243a9448f 100644 --- a/usr.bin/diff3/diff3.c +++ b/usr.bin/diff3/diff3.c @@ -264,6 +264,12 @@ get_line(FILE *b, size_t *n) if ((len = getline(&buf, &bufsize, b)) < 0) return (NULL); + if (strip_cr && len >= 2 && strcmp("\r\n", &(buf[len - 2])) == 0) { + buf[len - 2] = '\n'; + buf[len - 1] = '\0'; + len--; + } + if (n != NULL) *n = len; @@ -599,7 +605,7 @@ main(int argc, char **argv) char *labels[] = { NULL, NULL, NULL }; const char *diffprog = DIFF_PATH; char *file1, *file2, *file3; - char *diffargv[6]; + char *diffargv[7]; int diffargc = 0; int fd13[2], fd23[2]; int pd13, pd23; @@ -657,6 +663,7 @@ main(int argc, char **argv) break; case STRIPCR_OPT: strip_cr = 1; + diffargv[diffargc++] = __DECONST(char *, "--strip-trailing-cr"); break; } } diff --git a/usr.bin/diff3/tests/1cr.txt b/usr.bin/diff3/tests/1cr.txt new file mode 100644 index 000000000000..c24bf241e68a --- /dev/null +++ b/usr.bin/diff3/tests/1cr.txt @@ -0,0 +1,6 @@ +This is a more complete test +which multiple lines +and a few typ0s to fix +also I plan to add few lines + and to remove +other lines diff --git a/usr.bin/diff3/tests/Makefile b/usr.bin/diff3/tests/Makefile index dd75be1ca02a..2ec7fbaab564 100644 --- a/usr.bin/diff3/tests/Makefile +++ b/usr.bin/diff3/tests/Makefile @@ -6,6 +6,7 @@ ATF_TESTS_SH= diff3_test ${PACKAGE}FILES+= \ 1.txt \ + 1cr.txt \ 2.txt \ 3.txt \ 1.out \ diff --git a/usr.bin/diff3/tests/diff3_test.sh b/usr.bin/diff3/tests/diff3_test.sh index 6c479de2e9c0..f4b5adf95700 100755 --- a/usr.bin/diff3/tests/diff3_test.sh +++ b/usr.bin/diff3/tests/diff3_test.sh @@ -8,6 +8,9 @@ diff3_body() atf_check -o file:$(atf_get_srcdir)/1.out \ diff3 $(atf_get_srcdir)/1.txt $(atf_get_srcdir)/2.txt $(atf_get_srcdir)/3.txt + atf_check -o file:$(atf_get_srcdir)/1.out \ + diff3 --strip-trailing-cr $(atf_get_srcdir)/1cr.txt $(atf_get_srcdir)/2.txt $(atf_get_srcdir)/3.txt + atf_check -o file:$(atf_get_srcdir)/2.out \ diff3 -e $(atf_get_srcdir)/1.txt $(atf_get_srcdir)/2.txt $(atf_get_srcdir)/3.txt From owner-dev-commits-src-main@freebsd.org Mon Aug 23 07:23:12 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4B83D665B12; Mon, 23 Aug 2021 07:23:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtNxr1HTvz4vZw; Mon, 23 Aug 2021 07:23:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1535310373; Mon, 23 Aug 2021 07:23:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17N7NBpM009441; Mon, 23 Aug 2021 07:23:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17N7NB5w009440; Mon, 23 Aug 2021 07:23:11 GMT (envelope-from git) Date: Mon, 23 Aug 2021 07:23:11 GMT Message-Id: <202108230723.17N7NB5w009440@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: 72a92f91f466 - main - nfsstat(1): Fix a typo in an error message MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 72a92f91f466fdb73071ec28982b9f4d4cf9b672 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 07:23:12 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=72a92f91f466fdb73071ec28982b9f4d4cf9b672 commit 72a92f91f466fdb73071ec28982b9f4d4cf9b672 Author: Gordon Bergling AuthorDate: 2021-08-23 07:21:28 +0000 Commit: Gordon Bergling CommitDate: 2021-08-23 07:21:28 +0000 nfsstat(1): Fix a typo in an error message - s/priviledged/privileged/ MFC after: 1 week --- usr.bin/nfsstat/nfsstat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.bin/nfsstat/nfsstat.c b/usr.bin/nfsstat/nfsstat.c index 72a2c08963cf..e2d747634bcc 100644 --- a/usr.bin/nfsstat/nfsstat.c +++ b/usr.bin/nfsstat/nfsstat.c @@ -182,7 +182,7 @@ main(int argc, char **argv) mntbuf->f_mntfromname, mntbuf->f_mntonname, buf); else if (errno == EPERM) - errx(1, "Only priviledged users" + errx(1, "Only privileged users" " can use the -m option"); } mntbuf++; From owner-dev-commits-src-main@freebsd.org Mon Aug 23 13:25:22 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B8BE766B1EB; Mon, 23 Aug 2021 13:25:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtXzk4Rcyz3q8l; Mon, 23 Aug 2021 13:25:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8098E14E5A; Mon, 23 Aug 2021 13:25:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NDPM1i092447; Mon, 23 Aug 2021 13:25:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NDPMGv092446; Mon, 23 Aug 2021 13:25:22 GMT (envelope-from git) Date: Mon, 23 Aug 2021 13:25:22 GMT Message-Id: <202108231325.17NDPMGv092446@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 766a7c73e92a - main - arm64: add read_frequently, read_mostluy and exclusive_cache_line to linker script MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 766a7c73e92aee0fc1a2059919015000e8cbfa05 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 13:25:22 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=766a7c73e92aee0fc1a2059919015000e8cbfa05 commit 766a7c73e92aee0fc1a2059919015000e8cbfa05 Author: Mateusz Guzik AuthorDate: 2021-08-23 09:44:23 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 13:22:17 +0000 arm64: add read_frequently, read_mostluy and exclusive_cache_line to linker script Reviewed by: andrew Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D31643 --- sys/conf/ldscript.arm64 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sys/conf/ldscript.arm64 b/sys/conf/ldscript.arm64 index 3c4b77034725..e73f8ed8e65e 100644 --- a/sys/conf/ldscript.arm64 +++ b/sys/conf/ldscript.arm64 @@ -82,6 +82,21 @@ SECTIONS *(.data) *(.gnu.linkonce.d*) } + . = ALIGN(128); + .data.read_frequently : + { + *(SORT_BY_ALIGNMENT(.data.read_frequently)) + } + .data.read_mostly : + { + *(.data.read_mostly) + } + . = ALIGN(128); + .data.exclusive_cache_line : + { + *(.data.exclusive_cache_line) + } + . = ALIGN(128); .data1 : { *(.data1) } . = ALIGN(32 / 8); _start_ctors = .; From owner-dev-commits-src-main@freebsd.org Mon Aug 23 13:25:23 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D1C1E66B50A; Mon, 23 Aug 2021 13:25:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtXzl59fbz3pmk; Mon, 23 Aug 2021 13:25:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9AE4614A68; Mon, 23 Aug 2021 13:25:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NDPNOK092473; Mon, 23 Aug 2021 13:25:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NDPNwp092472; Mon, 23 Aug 2021 13:25:23 GMT (envelope-from git) Date: Mon, 23 Aug 2021 13:25:23 GMT Message-Id: <202108231325.17NDPNwp092472@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: d47afcb2039f - main - arm64: retire bzero MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d47afcb2039f1b0f524f176fe6577359ca4edab1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 13:25:23 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=d47afcb2039f1b0f524f176fe6577359ca4edab1 commit d47afcb2039f1b0f524f176fe6577359ca4edab1 Author: Mateusz Guzik AuthorDate: 2021-08-23 09:46:01 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 13:22:44 +0000 arm64: retire bzero Reviewed by: andrew Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D31644 --- sys/arm64/arm64/bzero.S | 206 ------------------------------------------------ sys/conf/files.arm64 | 1 - 2 files changed, 207 deletions(-) diff --git a/sys/arm64/arm64/bzero.S b/sys/arm64/arm64/bzero.S deleted file mode 100644 index 6c7f1fef1494..000000000000 --- a/sys/arm64/arm64/bzero.S +++ /dev/null @@ -1,206 +0,0 @@ -/*- - * Copyright (C) 2016 Cavium Inc. - * All rights reserved. - * - * Developed by Semihalf. - * - * 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 "assym.inc" - - /* - * void bzero(void *p, size_t size) - * - * x0 - p - * x1 - size - */ -ENTRY(bzero) - cbz x1, ending - - /* - * x5 is number of cache lines to zero - calculated later and - * will become non-zero if buffer is long enough to zero by - * cache lines (and if it is allowed.) - * We need to zero it before proceeding with buffers of size - * smaller than 16 bytes - otherwise the x5 will not be - * calculated and will retain random value. - * "normal" is used for buffers <= 16 bytes and to align buffer - * to cache line for buffers bigger than cache line; non-0 x5 - * after "normal" has completed indicates that it has been used - * to align buffer to cache line and now zero by cache lines will - * be performed, and x5 is amount of cache lines to loop through. - */ - mov x5, xzr - - /* No use of cache assisted zero for buffers with size <= 16 */ - cmp x1, #0x10 - b.le normal - - /* - * Load size of line that will be cleaned by dc zva call. - * 0 means that the instruction is not allowed - */ - ldr x7, =dczva_line_size - ldr x7, [x7] - cbz x7, normal - - /* - * Buffer must be larger than cache line for using cache zeroing - * (and cache line aligned but this is checked after jump) - */ - cmp x1, x7 - b.lt normal - - /* - * Calculate number of bytes to cache aligned address (x4) nad - * number of full cache lines (x5). x6 is final address to zero. - */ - sub x2, x7, #0x01 - mov x3, -1 - eor x3, x3, x2 - add x4, x0, x2 - and x4, x4, x3 - subs x4, x4, x0 - b.eq normal - - /* Calculate number of "lines" in buffer */ - sub x5, x1, x4 - rbit x2, x7 - clz x2, x2 - lsr x5, x5, x2 - - /* - * If number of cache lines is 0, we will not be able to zero - * by cache lines, so go normal way. - */ - cbz x5, normal - /* x6 is final address to zero */ - add x6, x0, x1 - - /* - * We are here because x5 is non-0 so normal will be used to - * align buffer before cache zeroing. x4 holds number of bytes - * needed for alignment. - */ - mov x1, x4 - - /* When jumping here: x0 holds pointer, x1 holds size */ -normal: - /* - * Get buffer offset into 16 byte aligned address; 0 means pointer - * is aligned. - */ - ands x2, x0, #0x0f - b.eq aligned_to_16 - /* Calculate one-byte loop runs to 8 byte aligned address. */ - ands x2, x2, #0x07 - mov x3, #0x08 - sub x2, x3, x2 - /* x2 is number of bytes missing for alignment, x1 is buffer size */ - cmp x1, x2 - csel x2, x1, x2, le - sub x1, x1, x2 - - /* - * Byte by byte copy will copy at least enough bytes to align - * pointer and at most "size". - */ -align: - strb wzr, [x0], #0x01 - subs x2, x2, #0x01 - b.ne align - - /* Now pointer is aligned to 8 bytes */ - cmp x1, #0x10 - b.lt lead_out - /* - * Check if copy of another 8 bytes is needed to align to 16 byte - * address and do it - */ - tbz x0, #0x03, aligned_to_16 - str xzr, [x0], #0x08 - sub x1, x1, #0x08 - - /* While jumping here: x0 is 16 byte alligned address, x1 is size */ -aligned_to_16: - /* If size is less than 16 bytes, use lead_out to copy what remains */ - cmp x1, #0x10 - b.lt lead_out - - lsr x2, x1, #0x04 -zero_by_16: - stp xzr, xzr, [x0], #0x10 - subs x2, x2, #0x01 - b.ne zero_by_16 - - /* - * Lead out requires addresses to be aligned to 8 bytes. It is used to - * zero buffers with sizes < 16 and what can not be zeroed by - * zero_by_16 loop. - */ - ands x1, x1, #0x0f - b.eq lead_out_end -lead_out: - tbz x1, #0x03, lead_out_dword - str xzr, [x0], #0x08 -lead_out_dword: - tbz x1, #0x02, lead_out_word - str wzr, [x0], #0x04 -lead_out_word: - tbz x1, #0x01, lead_out_byte - strh wzr, [x0], #0x02 -lead_out_byte: - tbz x1, #0x00, lead_out_end - strb wzr, [x0], #0x01 - -lead_out_end: - /* - * If x5 is non-zero, this means that normal has been used as - * a lead in to align buffer address to cache size - */ - cbz x5, ending - - /* - * Here x5 holds number of lines to zero; x6 is final address of - * buffer. x0 is cache line aligned pointer. x7 is cache line size - * in bytes - */ -cache_line_zero: - dc zva, x0 - add x0, x0, x7 - subs x5, x5, #0x01 - b.ne cache_line_zero - - /* Need to zero remaining bytes? */ - subs x1, x6, x0 - b.ne normal - -ending: - ret - -END(bzero) - diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64 index ed3625df0c23..202a911ad8ca 100644 --- a/sys/conf/files.arm64 +++ b/sys/conf/files.arm64 @@ -33,7 +33,6 @@ arm64/arm64/bus_machdep.c standard arm64/arm64/bus_space_asm.S standard arm64/arm64/busdma_bounce.c standard arm64/arm64/busdma_machdep.c standard -arm64/arm64/bzero.S standard arm64/arm64/clock.c standard arm64/arm64/copyinout.S standard arm64/arm64/cpu_errata.c standard From owner-dev-commits-src-main@freebsd.org Mon Aug 23 13:25:26 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B82E266B0F6; Mon, 23 Aug 2021 13:25:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtXzp2sDkz3pmv; Mon, 23 Aug 2021 13:25:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E316514E5B; Mon, 23 Aug 2021 13:25:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NDPPsx092530; Mon, 23 Aug 2021 13:25:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NDPP9Y092529; Mon, 23 Aug 2021 13:25:25 GMT (envelope-from git) Date: Mon, 23 Aug 2021 13:25:25 GMT Message-Id: <202108231325.17NDPP9Y092529@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: b2d2a5903518 - main - arm: flip memclr to use memset MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b2d2a5903518668aa22fb906b021f99d2952c08c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 13:25:26 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=b2d2a5903518668aa22fb906b021f99d2952c08c commit b2d2a5903518668aa22fb906b021f99d2952c08c Author: Mateusz Guzik AuthorDate: 2021-07-19 13:46:03 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 13:23:42 +0000 arm: flip memclr to use memset Reviewed by: andrew Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D31217 --- sys/libkern/arm/memclr.S | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/libkern/arm/memclr.S b/sys/libkern/arm/memclr.S index 2883d3f23104..0f01b0b6ad5e 100644 --- a/sys/libkern/arm/memclr.S +++ b/sys/libkern/arm/memclr.S @@ -32,11 +32,13 @@ __FBSDID("$FreeBSD$"); * This implements * void __aeabi_memclr4(void *dest, size_t len) * by calling: - * void bzero(dest, len) + * void *memset(dest, 0, len) */ ENTRY_NP(__aeabi_memclr4) EENTRY_NP(__aeabi_memclr8) - b bzero + mov r2, r1 + mov r1, #0 + b memset EEND(__aeabi_memclr8) END(__aeabi_memclr4) From owner-dev-commits-src-main@freebsd.org Mon Aug 23 13:25:25 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 23B9F66B275; Mon, 23 Aug 2021 13:25:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtXzn0Ky5z3q18; Mon, 23 Aug 2021 13:25:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D772F1522B; Mon, 23 Aug 2021 13:25:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NDPOhU092497; Mon, 23 Aug 2021 13:25:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NDPO9g092496; Mon, 23 Aug 2021 13:25:24 GMT (envelope-from git) Date: Mon, 23 Aug 2021 13:25:24 GMT Message-Id: <202108231325.17NDPO9g092496@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 1652d2ff09ea - main - arm64: retire bcmp MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1652d2ff09ea5599ab4fc647038878f24f07f719 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 13:25:25 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=1652d2ff09ea5599ab4fc647038878f24f07f719 commit 1652d2ff09ea5599ab4fc647038878f24f07f719 Author: Mateusz Guzik AuthorDate: 2021-08-23 09:46:28 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 13:23:20 +0000 arm64: retire bcmp Reviewed by: andrew Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D31645 --- sys/conf/files.arm64 | 1 - 1 file changed, 1 deletion(-) diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64 index 202a911ad8ca..bae23b17cc40 100644 --- a/sys/conf/files.arm64 +++ b/sys/conf/files.arm64 @@ -9,7 +9,6 @@ kern/pic_if.m optional intrng kern/subr_devmap.c standard kern/subr_intr.c optional intrng kern/subr_physmem.c standard -libkern/bcmp.c standard libkern/memcmp.c standard \ compile-with "${NORMAL_C:N-fsanitize*}" libkern/memset.c standard \ From owner-dev-commits-src-main@freebsd.org Mon Aug 23 13:25:27 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3F1BA66B349; Mon, 23 Aug 2021 13:25:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtXzq16RYz3q91; Mon, 23 Aug 2021 13:25:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0F3F814EC9; Mon, 23 Aug 2021 13:25:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NDPQnf092554; Mon, 23 Aug 2021 13:25:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NDPQFE092553; Mon, 23 Aug 2021 13:25:26 GMT (envelope-from git) Date: Mon, 23 Aug 2021 13:25:26 GMT Message-Id: <202108231325.17NDPQFE092553@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: a12111562116 - main - arm: retire bzero MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a1211156211634ab713c7e910fdc70485b7c9193 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 13:25:27 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=a1211156211634ab713c7e910fdc70485b7c9193 commit a1211156211634ab713c7e910fdc70485b7c9193 Author: Mateusz Guzik AuthorDate: 2021-07-19 13:46:20 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 13:23:42 +0000 arm: retire bzero Same as bcopy. Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/arm/arm/support.S | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/sys/arm/arm/support.S b/sys/arm/arm/support.S index 9390b03f62a3..bd2a3ad07805 100644 --- a/sys/arm/arm/support.S +++ b/sys/arm/arm/support.S @@ -104,11 +104,6 @@ __FBSDID("$FreeBSD$"); * On exit: * r0 - dest address */ -/* LINTSTUB: Func: void bzero(void *, size_t) */ -ENTRY(bzero) - mov r3, #0x00 - b do_memset -END(bzero) /* LINTSTUB: Func: void *memset(void *, int, size_t) */ ENTRY(memset) and r3, r1, #0xff /* We deal with bytes */ @@ -213,8 +208,7 @@ do_memset: strbge r3, [ip], #0x01 /* Set another byte */ strbgt r3, [ip] /* and a third */ RET /* Exit */ -EEND(memset) -END(bzero) +END(memset) ENTRY(memcmp) mov ip, r0 From owner-dev-commits-src-main@freebsd.org Mon Aug 23 13:34:16 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2424166B7EC; Mon, 23 Aug 2021 13:34:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtYB00WZfz3rx9; Mon, 23 Aug 2021 13:34:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id ED3D614A7F; Mon, 23 Aug 2021 13:34:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NDYFEU005866; Mon, 23 Aug 2021 13:34:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NDYFKp005865; Mon, 23 Aug 2021 13:34:15 GMT (envelope-from git) Date: Mon, 23 Aug 2021 13:34:15 GMT Message-Id: <202108231334.17NDYFKp005865@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 7fd856ba07b1 - main - vfs: s/__unused/__diagused in crossmp_* MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7fd856ba07b1cfc35eb9b0faad25c3ba4963bf83 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 13:34:16 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=7fd856ba07b1cfc35eb9b0faad25c3ba4963bf83 commit 7fd856ba07b1cfc35eb9b0faad25c3ba4963bf83 Author: Mateusz Guzik AuthorDate: 2021-08-23 10:10:38 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 13:23:42 +0000 vfs: s/__unused/__diagused in crossmp_* Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/kern/vfs_lookup.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index a83cc6bb8b74..28d7ada0f434 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -97,9 +97,9 @@ static int crossmp_vop_lock1(struct vop_lock1_args *ap) { struct vnode *vp; - struct lock *lk __unused; - const char *file __unused; - int flags, line __unused; + struct lock *lk __diagused; + const char *file __diagused; + int flags, line __diagused; vp = ap->a_vp; lk = vp->v_vnlock; @@ -123,7 +123,7 @@ static int crossmp_vop_unlock(struct vop_unlock_args *ap) { struct vnode *vp; - struct lock *lk __unused; + struct lock *lk __diagused; vp = ap->a_vp; lk = vp->v_vnlock; From owner-dev-commits-src-main@freebsd.org Mon Aug 23 13:34:17 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6C06366BB3C; Mon, 23 Aug 2021 13:34:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtYB120Rkz3rnF; Mon, 23 Aug 2021 13:34:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1F42015149; Mon, 23 Aug 2021 13:34:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NDYHmO005890; Mon, 23 Aug 2021 13:34:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NDYHm1005889; Mon, 23 Aug 2021 13:34:17 GMT (envelope-from git) Date: Mon, 23 Aug 2021 13:34:17 GMT Message-Id: <202108231334.17NDYHm1005889@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: b65ad70195d8 - main - cache: retire cache_fast_revlookup sysctl MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b65ad70195d874ac28e6e65d2fd8acf5d9a79236 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 13:34:17 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=b65ad70195d874ac28e6e65d2fd8acf5d9a79236 commit b65ad70195d874ac28e6e65d2fd8acf5d9a79236 Author: Mateusz Guzik AuthorDate: 2021-08-23 13:29:42 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 13:31:44 +0000 cache: retire cache_fast_revlookup sysctl Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/kern/vfs_cache.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index 199da865e39c..732dbbe53cef 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -253,6 +253,8 @@ SDT_PROBE_DEFINE3(vfs, fplookup, lookup, done, "struct nameidata", "int", "bool" SDT_PROBE_DECLARE(vfs, namei, lookup, entry); SDT_PROBE_DECLARE(vfs, namei, lookup, return); +static char __read_frequently cache_fast_lookup_enabled = true; + /* * This structure describes the elements in the cache of recent * names looked up by namei. @@ -443,10 +445,6 @@ static u_long __exclusive_cache_line numcache;/* number of cache entries allocat struct nchstats nchstats; /* cache effectiveness statistics */ -static bool __read_frequently cache_fast_revlookup = true; -SYSCTL_BOOL(_vfs, OID_AUTO, cache_fast_revlookup, CTLFLAG_RW, - &cache_fast_revlookup, 0, ""); - static bool __read_mostly cache_rename_add = true; SYSCTL_BOOL(_vfs, OID_AUTO, cache_rename_add, CTLFLAG_RW, &cache_rename_add, 0, ""); @@ -3440,7 +3438,7 @@ vn_fullpath_any_smr(struct vnode *vp, struct vnode *rdir, char *buf, VFS_SMR_ASSERT_ENTERED(); - if (!cache_fast_revlookup) { + if (!atomic_load_char(&cache_fast_lookup_enabled)) { vfs_smr_exit(); return (-1); } @@ -3845,7 +3843,6 @@ DB_SHOW_COMMAND(vpath, db_show_vpath) #endif static int cache_fast_lookup = 1; -static char __read_frequently cache_fast_lookup_enabled = true; #define CACHE_FPL_FAILED -2020 From owner-dev-commits-src-main@freebsd.org Mon Aug 23 13:44:38 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8D4CD66BD2D; Mon, 23 Aug 2021 13:44:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtYPy3PfSz3vjZ; Mon, 23 Aug 2021 13:44:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5CE951549A; Mon, 23 Aug 2021 13:44:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NDiciG019583; Mon, 23 Aug 2021 13:44:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NDicXM019582; Mon, 23 Aug 2021 13:44:38 GMT (envelope-from git) Date: Mon, 23 Aug 2021 13:44:38 GMT Message-Id: <202108231344.17NDicXM019582@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: bc5304a00623 - main - Add arm64 ifunc support in static binaries MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: bc5304a006238115291e7568583632889dffbab9 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 13:44:38 -0000 The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=bc5304a006238115291e7568583632889dffbab9 commit bc5304a006238115291e7568583632889dffbab9 Author: Andrew Turner AuthorDate: 2021-08-20 08:22:48 +0000 Commit: Andrew Turner CommitDate: 2021-08-23 13:39:09 +0000 Add arm64 ifunc support in static binaries Add support for the R_AARCH64_IRELATIVE relocation type in static binaries on arm64. This is based on the powerpc code, updating it to use the arm64 resolver ABI, and use the arm64 relocation type. Tested by: brd Reviewed by: kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31641 --- lib/csu/aarch64/Makefile | 3 ++- lib/csu/aarch64/crt1_c.c | 4 +++- lib/csu/aarch64/reloc.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/lib/csu/aarch64/Makefile b/lib/csu/aarch64/Makefile index 666bf569b786..e4c9029fcacc 100644 --- a/lib/csu/aarch64/Makefile +++ b/lib/csu/aarch64/Makefile @@ -2,7 +2,8 @@ .PATH: ${.CURDIR:H}/common -CFLAGS+= -DCRT_IRELOC_SUPPRESS +CFLAGS+= -I${.CURDIR} +CFLAGS+= -DCRT_IRELOC_RELA CRT1OBJS+= crt1_s.o diff --git a/lib/csu/aarch64/crt1_c.c b/lib/csu/aarch64/crt1_c.c index d8c2156ffc21..9b3ffbff22d0 100644 --- a/lib/csu/aarch64/crt1_c.c +++ b/lib/csu/aarch64/crt1_c.c @@ -57,8 +57,10 @@ __start(int argc, char *argv[], char *env[], void (*cleanup)(void)) if (&_DYNAMIC != NULL) atexit(cleanup); - else + else { + process_irelocs(); _init_tls(); + } #ifdef GCRT atexit(_mcleanup); diff --git a/lib/csu/aarch64/reloc.c b/lib/csu/aarch64/reloc.c new file mode 100644 index 000000000000..f3dbf3e3b570 --- /dev/null +++ b/lib/csu/aarch64/reloc.c @@ -0,0 +1,46 @@ +/*- + * Copyright (c) 2019 Leandro Lupori + * Copyright (c) 2021 The FreeBSD Foundation + * + * Portions of this software were developed by Andrew Turner + * 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. + * + * 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$"); + +static void +crt1_handle_rela(const Elf_Rela *r) +{ + typedef Elf_Addr (*ifunc_resolver_t)( + uint64_t, uint64_t, uint64_t, uint64_t, + uint64_t, uint64_t, uint64_t, uint64_t); + Elf_Addr *ptr, *where, target; + + switch (ELF_R_TYPE(r->r_info)) { + case R_AARCH64_IRELATIVE: + ptr = (Elf_Addr *)r->r_addend; + where = (Elf_Addr *)r->r_offset; + target = ((ifunc_resolver_t)ptr)(0, 0, 0, 0, 0, 0, 0, 0); + *where = target; + break; + } +} From owner-dev-commits-src-main@freebsd.org Mon Aug 23 13:51:52 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0FE7E66BCC0; Mon, 23 Aug 2021 13:51:52 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from omta002.cacentral1.a.cloudfilter.net (omta002.cacentral1.a.cloudfilter.net [3.97.99.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtYZH5zwQz4RRY; Mon, 23 Aug 2021 13:51:51 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from shw-obgw-4003a.ext.cloudfilter.net ([10.228.9.183]) by cmsmtp with ESMTP id I8fbm5uL24bInIAMbmHVlt; Mon, 23 Aug 2021 13:51:45 +0000 Received: from spqr.komquats.com ([70.66.148.124]) by cmsmtp with ESMTPA id IAMamjck1qeviIAMamF6GY; Mon, 23 Aug 2021 13:51:45 +0000 X-Authority-Analysis: v=2.4 cv=B4F8bMhM c=1 sm=1 tr=0 ts=6123a7f1 a=Cwc3rblV8FOMdVN/wOAqyQ==:117 a=Cwc3rblV8FOMdVN/wOAqyQ==:17 a=kj9zAlcOel0A:10 a=MhDmnRu9jo8A:10 a=6I5d2MoRAAAA:8 a=YxBL1-UpAAAA:8 a=EkcXrb_YAAAA:8 a=p8d-jTAGzcGgB6t1mYAA:9 a=CjuIK1q_8ugA:10 a=IjZwj45LgO3ly-622nXo:22 a=Ia-lj3WSrqcvXOmTRaiG:22 a=LK5xJRSDVpKd5WXXoEvA:22 Received: from slippy.cwsent.com (slippy [10.1.1.91]) by spqr.komquats.com (Postfix) with ESMTPS id 4CF0930C; Mon, 23 Aug 2021 06:51:43 -0700 (PDT) Received: from slippy (localhost [127.0.0.1]) by slippy.cwsent.com (8.16.1/8.16.1) with ESMTP id 17NDphg3006806; Mon, 23 Aug 2021 06:51:43 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Message-Id: <202108231351.17NDphg3006806@slippy.cwsent.com> X-Mailer: exmh version 2.9.0 11/07/2018 with nmh-1.7.1 Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.cschubert.com/ To: Mateusz Guzik cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: b65ad70195d8 - main - cache: retire cache_fast_revlookup sysctl In-reply-to: <202108231334.17NDYHm1005889@gitrepo.freebsd.org> References: <202108231334.17NDYHm1005889@gitrepo.freebsd.org> Comments: In-reply-to Mateusz Guzik message dated "Mon, 23 Aug 2021 13:34:17 +0000." Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Mon, 23 Aug 2021 06:51:43 -0700 X-CMAE-Envelope: MS4xfPyTv4nB3oVS8uE9dDc9VdQMIGiu7HVabGntFmk7bA1a4ZU46Rj47S4+X68a89XC7qabidjfEAp0Y3LLdM1/HyDCM8yUdiZuWYFA2w3dr5Nt2I7w3wBh 33fVO+n5TChbUziro3v7AeYPWPq0P1uV51Igz34aKbYC1xd8jVJMW9vD+GA+/jtul+m41pSEhyGcN1+zaOpXEBqPM5TXVlwU11KYDQcSQ4ABaiUgAEwVuoZK HlK27ZinqzdOf/vnnKIbdvVRm9kcQQORTRJirc+kCwldsibO9bn95HzIoJ22tg9T7QqDcHPHi4j1lR0h5L4ylaD1BdLYVR0YfjHzL0gt9NM= X-Rspamd-Queue-Id: 4GtYZH5zwQz4RRY X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 13:51:52 -0000 In message <202108231334.17NDYHm1005889@gitrepo.freebsd.org>, Mateusz Guzik wri tes: > The branch main has been updated by mjg: > > URL: https://cgit.FreeBSD.org/src/commit/?id=b65ad70195d874ac28e6e65d2fd8acf5 > d9a79236 > > commit b65ad70195d874ac28e6e65d2fd8acf5d9a79236 > Author: Mateusz Guzik > AuthorDate: 2021-08-23 13:29:42 +0000 > Commit: Mateusz Guzik > CommitDate: 2021-08-23 13:31:44 +0000 > > cache: retire cache_fast_revlookup sysctl Why? > > Sponsored by: Rubicon Communications, LLC ("Netgate") > --- > sys/kern/vfs_cache.c | 9 +++------ > 1 file changed, 3 insertions(+), 6 deletions(-) > > diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c > index 199da865e39c..732dbbe53cef 100644 > --- a/sys/kern/vfs_cache.c > +++ b/sys/kern/vfs_cache.c > @@ -253,6 +253,8 @@ SDT_PROBE_DEFINE3(vfs, fplookup, lookup, done, "struct na > meidata", "int", "bool" > SDT_PROBE_DECLARE(vfs, namei, lookup, entry); > SDT_PROBE_DECLARE(vfs, namei, lookup, return); > > +static char __read_frequently cache_fast_lookup_enabled = true; > + > /* > * This structure describes the elements in the cache of recent > * names looked up by namei. > @@ -443,10 +445,6 @@ static u_long __exclusive_cache_line numcache;/* num > ber of cache entries allocat > > struct nchstats nchstats; /* cache effectiveness statisti > cs */ > > -static bool __read_frequently cache_fast_revlookup = true; > -SYSCTL_BOOL(_vfs, OID_AUTO, cache_fast_revlookup, CTLFLAG_RW, > - &cache_fast_revlookup, 0, ""); > - > static bool __read_mostly cache_rename_add = true; > SYSCTL_BOOL(_vfs, OID_AUTO, cache_rename_add, CTLFLAG_RW, > &cache_rename_add, 0, ""); > @@ -3440,7 +3438,7 @@ vn_fullpath_any_smr(struct vnode *vp, struct vnode *rdi > r, char *buf, > > VFS_SMR_ASSERT_ENTERED(); > > - if (!cache_fast_revlookup) { > + if (!atomic_load_char(&cache_fast_lookup_enabled)) { > vfs_smr_exit(); > return (-1); > } > @@ -3845,7 +3843,6 @@ DB_SHOW_COMMAND(vpath, db_show_vpath) > #endif > > static int cache_fast_lookup = 1; > -static char __read_frequently cache_fast_lookup_enabled = true; > > #define CACHE_FPL_FAILED -2020 > > -- Cheers, Cy Schubert FreeBSD UNIX: Web: https://FreeBSD.org NTP: Web: https://nwtime.org The need of the many outweighs the greed of the few. From owner-dev-commits-src-main@freebsd.org Mon Aug 23 14:45:28 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 93DD066CE06; Mon, 23 Aug 2021 14:45:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtZm83NwJz4gk9; Mon, 23 Aug 2021 14:45:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5C51F1614B; Mon, 23 Aug 2021 14:45:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NEjS1o099145; Mon, 23 Aug 2021 14:45:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NEjSKw099144; Mon, 23 Aug 2021 14:45:28 GMT (envelope-from git) Date: Mon, 23 Aug 2021 14:45:28 GMT Message-Id: <202108231445.17NEjSKw099144@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Piotr Pawel Stefaniak Subject: git: 3cbf98e2bee9 - main - diff: read whole files to determine if they are ASCII text MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pstef X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3cbf98e2bee91db9ed9118ff557e02cdd449f49a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 14:45:28 -0000 The branch main has been updated by pstef: URL: https://cgit.FreeBSD.org/src/commit/?id=3cbf98e2bee91db9ed9118ff557e02cdd449f49a commit 3cbf98e2bee91db9ed9118ff557e02cdd449f49a Author: Piotr Pawel Stefaniak AuthorDate: 2021-08-22 19:57:13 +0000 Commit: Piotr Pawel Stefaniak CommitDate: 2021-08-23 14:09:05 +0000 diff: read whole files to determine if they are ASCII text Before this change, only the first BUFSIZE bytes were checked. Reviewed by: bapt (previous version) Differential Revision: https://reviews.freebsd.org/D31639 --- usr.bin/diff/diffreg.c | 59 +++++++++++++++++++++++++---------------- usr.bin/diff/tests/diff_test.sh | 14 ++++++++++ 2 files changed, 50 insertions(+), 23 deletions(-) diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c index 113b7b621256..e728441c2cb2 100644 --- a/usr.bin/diff/diffreg.c +++ b/usr.bin/diff/diffreg.c @@ -180,6 +180,8 @@ struct context_vec { int d; /* end line in new file */ }; +enum readhash { RH_BINARY, RH_OK, RH_EOF }; + #define MIN_PAD 1 static FILE *opentemp(const char *); static void output(char *, FILE *, char *, FILE *, int); @@ -188,7 +190,7 @@ static void range(int, int, const char *); static void uni_range(int, int); static void dump_context_vec(FILE *, FILE *, int); static void dump_unified_vec(FILE *, FILE *, int); -static void prepare(int, FILE *, size_t, int); +static bool prepare(int, FILE *, size_t, int); static void prune(void); static void equiv(struct line *, int, struct line *, int, int *); static void unravel(int); @@ -206,7 +208,7 @@ static int search(int *, int, int); static int skipline(FILE *); static int isqrt(int); static int stone(int *, int, int *, int *, int); -static int readhash(FILE *, int); +static enum readhash readhash(FILE *, int, unsigned *); static int files_differ(FILE *, FILE *, int); static char *match_function(const long *, int, FILE *); static char *preadline(int, size_t, off_t); @@ -380,14 +382,16 @@ diffreg(char *file1, char *file2, int flags, int capsicum) status |= 1; goto closem; } - if ((flags & D_FORCEASCII) == 0 && - (!asciifile(f1) || !asciifile(f2))) { + if ((flags & D_FORCEASCII) != 0) { + (void)prepare(0, f1, stb1.st_size, flags); + (void)prepare(1, f2, stb2.st_size, flags); + } else if (!asciifile(f1) || !asciifile(f2) || + !prepare(0, f1, stb1.st_size, flags) || + !prepare(1, f2, stb2.st_size, flags)) { rval = D_BINARY; status |= 1; goto closem; } - prepare(0, f1, stb1.st_size, flags); - prepare(1, f2, stb2.st_size, flags); prune(); sort(sfile[0], slen[0]); @@ -511,12 +515,13 @@ splice(char *dir, char *path) return (buf); } -static void +static bool prepare(int i, FILE *fd, size_t filesize, int flags) { struct line *p; - int h; - size_t sz, j; + unsigned h; + size_t sz, j = 0; + enum readhash r; rewind(fd); @@ -525,15 +530,23 @@ prepare(int i, FILE *fd, size_t filesize, int flags) sz = 100; p = xcalloc(sz + 3, sizeof(*p)); - for (j = 0; (h = readhash(fd, flags));) { - if (j == sz) { - sz = sz * 3 / 2; - p = xreallocarray(p, sz + 3, sizeof(*p)); + while ((r = readhash(fd, flags, &h)) != RH_EOF) + switch (r) { + case RH_EOF: /* otherwise clang complains */ + case RH_BINARY: + return (false); + case RH_OK: + if (j == sz) { + sz = sz * 3 / 2; + p = xreallocarray(p, sz + 3, sizeof(*p)); + } + p[++j].value = h; } - p[++j].value = h; - } + len[i] = j; file[i] = p; + + return (true); } static void @@ -1350,8 +1363,8 @@ fetch(long *f, int a, int b, FILE *lb, int ch, int oldfile, int flags) /* * Hash function taken from Robert Sedgewick, Algorithms in C, 3d ed., p 578. */ -static int -readhash(FILE *f, int flags) +static enum readhash +readhash(FILE *f, int flags, unsigned *hash) { int i, t, space; unsigned sum; @@ -1360,6 +1373,9 @@ readhash(FILE *f, int flags) space = 0; for (i = 0;;) { switch (t = getc(f)) { + case '\0': + if ((flags & D_FORCEASCII) == 0) + return (RH_BINARY); case '\r': if (flags & D_STRIPCR) { t = getc(f); @@ -1387,18 +1403,15 @@ readhash(FILE *f, int flags) continue; case EOF: if (i == 0) - return (0); + return (RH_EOF); /* FALLTHROUGH */ case '\n': break; } break; } - /* - * There is a remote possibility that we end up with a zero sum. - * Zero is used as an EOF marker, so return 1 instead. - */ - return (sum == 0 ? 1 : sum); + *hash = sum; + return (RH_OK); } static int diff --git a/usr.bin/diff/tests/diff_test.sh b/usr.bin/diff/tests/diff_test.sh index b8b7fe1d8068..4f73b23d686a 100755 --- a/usr.bin/diff/tests/diff_test.sh +++ b/usr.bin/diff/tests/diff_test.sh @@ -18,6 +18,7 @@ atf_test_case conflicting_format atf_test_case label atf_test_case report_identical atf_test_case non_regular_file +atf_test_case binary simple_body() { @@ -265,6 +266,18 @@ non_regular_file_body() diff --label A --label B -u A B } +binary_body() +{ + # the NUL byte has to be after at least BUFSIZ bytes to trick asciifile() + yes 012345678901234567890123456789012345678901234567890 | head -n 174 > A + cp A B + printf '\n\0\n' >> A + printf '\nx\n' >> B + + atf_check -o inline:"Binary files A and B differ\n" -s exit:1 diff A B + atf_check -o inline:"176c\nx\n.\n" -s exit:1 diff -ae A B +} + atf_init_test_cases() { atf_add_test_case simple @@ -285,4 +298,5 @@ atf_init_test_cases() atf_add_test_case label atf_add_test_case report_identical atf_add_test_case non_regular_file + atf_add_test_case binary } From owner-dev-commits-src-main@freebsd.org Mon Aug 23 16:12:39 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EA89566CD73; Mon, 23 Aug 2021 16:12:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gtchl41YCz3Nyb; Mon, 23 Aug 2021 16:12:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6480E176C5; Mon, 23 Aug 2021 16:12:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NGCd13019150; Mon, 23 Aug 2021 16:12:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NGCdxt019149; Mon, 23 Aug 2021 16:12:39 GMT (envelope-from git) Date: Mon, 23 Aug 2021 16:12:39 GMT Message-Id: <202108231612.17NGCdxt019149@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 44056f9a7278 - main - riscv: retire bcmp MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 44056f9a72786b24a1ff83649b5a13141be1de84 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 16:12:40 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=44056f9a72786b24a1ff83649b5a13141be1de84 commit 44056f9a72786b24a1ff83649b5a13141be1de84 Author: Mateusz Guzik AuthorDate: 2021-08-23 15:29:32 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 16:11:18 +0000 riscv: retire bcmp Unused since ba96f37758412151 ("Use __builtin for various mem* and b* (e.g. bzero) routines.") Reviewed by: mhorne Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/conf/files.riscv | 1 - 1 file changed, 1 deletion(-) diff --git a/sys/conf/files.riscv b/sys/conf/files.riscv index d46d520bd0b7..c5eef10f3519 100644 --- a/sys/conf/files.riscv +++ b/sys/conf/files.riscv @@ -21,7 +21,6 @@ kern/subr_devmap.c standard kern/subr_dummy_vdso_tc.c standard kern/subr_intr.c standard kern/subr_physmem.c standard -libkern/bcmp.c standard libkern/bcopy.c standard libkern/ffs.c standard libkern/ffsl.c standard From owner-dev-commits-src-main@freebsd.org Mon Aug 23 16:12:40 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C7D3166D93F; Mon, 23 Aug 2021 16:12:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gtchm538gz3Nyj; Mon, 23 Aug 2021 16:12:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8E495176C6; Mon, 23 Aug 2021 16:12:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NGCeSc019175; Mon, 23 Aug 2021 16:12:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NGCeSM019174; Mon, 23 Aug 2021 16:12:40 GMT (envelope-from git) Date: Mon, 23 Aug 2021 16:12:40 GMT Message-Id: <202108231612.17NGCeSM019174@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 451756d1baa8 - main - powerpc: retire bcmp MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 451756d1baa8c4e4d1f282dd7bbc05e09cd9d5e5 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 16:12:40 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=451756d1baa8c4e4d1f282dd7bbc05e09cd9d5e5 commit 451756d1baa8c4e4d1f282dd7bbc05e09cd9d5e5 Author: Mateusz Guzik AuthorDate: 2021-08-23 15:35:28 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 16:11:56 +0000 powerpc: retire bcmp Unused since ba96f37758412151 ("Use __builtin for various mem* and b* (e.g. bzero) routines.") Reviewed by: jhibbits Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/conf/files.powerpc | 1 - 1 file changed, 1 deletion(-) diff --git a/sys/conf/files.powerpc b/sys/conf/files.powerpc index a57367a23017..5d10740ce41d 100644 --- a/sys/conf/files.powerpc +++ b/sys/conf/files.powerpc @@ -117,7 +117,6 @@ kern/syscalls.c optional ktr kern/subr_sfbuf.c standard libkern/ashldi3.c optional powerpc | powerpcspe libkern/ashrdi3.c optional powerpc | powerpcspe -libkern/bcmp.c standard libkern/bcopy.c standard libkern/cmpdi2.c optional powerpc | powerpcspe libkern/divdi3.c optional powerpc | powerpcspe From owner-dev-commits-src-main@freebsd.org Mon Aug 23 16:12:41 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DD47766D6FA; Mon, 23 Aug 2021 16:12:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gtchn5lYgz3P5y; Mon, 23 Aug 2021 16:12:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AB4E917445; Mon, 23 Aug 2021 16:12:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NGCfnK019199; Mon, 23 Aug 2021 16:12:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NGCfYu019198; Mon, 23 Aug 2021 16:12:41 GMT (envelope-from git) Date: Mon, 23 Aug 2021 16:12:41 GMT Message-Id: <202108231612.17NGCfYu019198@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 362c5920da56 - main - Remove libkern/bcmp.c MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 362c5920da56964516ea77e29692857c05c096f7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 16:12:42 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=362c5920da56964516ea77e29692857c05c096f7 commit 362c5920da56964516ea77e29692857c05c096f7 Author: Mateusz Guzik AuthorDate: 2021-08-23 15:40:57 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 16:12:12 +0000 Remove libkern/bcmp.c The kernel was migrated to memcmp in ba96f37758412151 ("Use __builtin for various mem* and b* (e.g. bzero) routines.") and there are no remaining architectures using the file. Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/libkern/bcmp.c | 146 ----------------------------------------------------- sys/sys/systm.h | 1 - 2 files changed, 147 deletions(-) diff --git a/sys/libkern/bcmp.c b/sys/libkern/bcmp.c deleted file mode 100644 index 40ef39953c86..000000000000 --- a/sys/libkern/bcmp.c +++ /dev/null @@ -1,146 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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 - -typedef const void *cvp; -typedef const unsigned char *ustring; -typedef unsigned long ul; -typedef const unsigned long *culp; - -/* - * bcmp -- vax cmpc3 instruction - */ -int -(bcmp)(const void *b1, const void *b2, size_t length) -{ -#if BYTE_ORDER == LITTLE_ENDIAN - /* - * The following code is endian specific. Changing it from - * little-endian to big-endian is fairly trivial, but making - * it do both is more difficult. - * - * Note that this code will reference the entire longword which - * includes the final byte to compare. I don't believe this is - * a problem since AFAIK, objects are not protected at smaller - * than longword boundaries. - */ - int shl, shr, len = length; - ustring p1 = b1, p2 = b2; - ul va, vb; - - if (len == 0) - return (0); - - /* - * align p1 to a longword boundary - */ - while ((long)p1 & (sizeof(long) - 1)) { - if (*p1++ != *p2++) - return (1); - if (--len <= 0) - return (0); - } - - /* - * align p2 to longword boundary and calculate the shift required to - * align p1 and p2 - */ - shr = (long)p2 & (sizeof(long) - 1); - if (shr != 0) { - p2 -= shr; /* p2 now longword aligned */ - shr <<= 3; /* offset in bits */ - shl = (sizeof(long) << 3) - shr; - - va = *(culp)p2; - p2 += sizeof(long); - - while ((len -= sizeof(long)) >= 0) { - vb = *(culp)p2; - p2 += sizeof(long); - if (*(culp)p1 != (va >> shr | vb << shl)) - return (1); - p1 += sizeof(long); - va = vb; - } - /* - * At this point, len is between -sizeof(long) and -1, - * representing 0 .. sizeof(long)-1 bytes remaining. - */ - if (!(len += sizeof(long))) - return (0); - - len <<= 3; /* remaining length in bits */ - /* - * The following is similar to the `if' condition - * inside the above while loop. The ?: is necessary - * to avoid accessing the longword after the longword - * containing the last byte to be compared. - */ - return ((((va >> shr | ((shl < len) ? *(culp)p2 << shl : 0)) ^ - *(culp)p1) & ((1L << len) - 1)) != 0); - } else { - /* p1 and p2 have common alignment so no shifting needed */ - while ((len -= sizeof(long)) >= 0) { - if (*(culp)p1 != *(culp)p2) - return (1); - p1 += sizeof(long); - p2 += sizeof(long); - } - - /* - * At this point, len is between -sizeof(long) and -1, - * representing 0 .. sizeof(long)-1 bytes remaining. - */ - if (!(len += sizeof(long))) - return (0); - - return (((*(culp)p1 ^ *(culp)p2) - & ((1L << (len << 3)) - 1)) != 0); - } -#else - const char *p1, *p2; - - if (length == 0) - return(0); - p1 = b1; - p2 = b2; - do - if (*p1++ != *p2++) - break; - while (--length); - return(length); -#endif -} diff --git a/sys/sys/systm.h b/sys/sys/systm.h index da20492966cd..1be8f1ac49be 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -344,7 +344,6 @@ void hexdump(const void *ptr, int length, const char *hdr, int flags); void bcopy(const void * _Nonnull from, void * _Nonnull to, size_t len); void bzero(void * _Nonnull buf, size_t len); void explicit_bzero(void * _Nonnull, size_t); -int bcmp(const void *b1, const void *b2, size_t len); void *memset(void * _Nonnull buf, int c, size_t len); void *memcpy(void * _Nonnull to, const void * _Nonnull from, size_t len); From owner-dev-commits-src-main@freebsd.org Mon Aug 23 17:29:53 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6D83D66EB64; Mon, 23 Aug 2021 17:29:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtfPs2j4zz4WB4; Mon, 23 Aug 2021 17:29:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3B58718695; Mon, 23 Aug 2021 17:29:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NHTrH3013020; Mon, 23 Aug 2021 17:29:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NHTrW4013019; Mon, 23 Aug 2021 17:29:53 GMT (envelope-from git) Date: Mon, 23 Aug 2021 17:29:53 GMT Message-Id: <202108231729.17NHTrW4013019@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kevin Bowling Subject: git: 5de5419b5e86 - main - ixgbe: Avoid sbuf_trim(9) in sysctl handler MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5de5419b5e8685ab2261edaafe6fdb6fc36e8bbc Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 17:29:53 -0000 The branch main has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=5de5419b5e8685ab2261edaafe6fdb6fc36e8bbc commit 5de5419b5e8685ab2261edaafe6fdb6fc36e8bbc Author: Kevin Bowling AuthorDate: 2021-08-23 16:21:39 +0000 Commit: Kevin Bowling CommitDate: 2021-08-23 17:28:59 +0000 ixgbe: Avoid sbuf_trim(9) in sysctl handler This was an error, we cannot use sbuf_trim(9) in the ixgbe_sbuf_fw_version function because it also gets called in the context of sbuf_new_for_sysctl(9). sbuf(9) explains the interaction with drain functions as used by sbuf_new_for_sysctl(9). Reviewed by: imp Fixes: 7660e4ea5cb7 MFC after: 1 day Differential Revision: https://reviews.freebsd.org/D31633 --- sys/dev/ixgbe/if_ix.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/sys/dev/ixgbe/if_ix.c b/sys/dev/ixgbe/if_ix.c index 8e14a008e09b..91bf7e4dd218 100644 --- a/sys/dev/ixgbe/if_ix.c +++ b/sys/dev/ixgbe/if_ix.c @@ -4694,27 +4694,33 @@ ixgbe_sbuf_fw_version(struct ixgbe_hw *hw, struct sbuf *buf) struct ixgbe_nvm_version nvm_ver = {0}; uint16_t phyfw = 0; int status; + const char *space = ""; ixgbe_get_oem_prod_version(hw, &nvm_ver); /* OEM's NVM version */ ixgbe_get_orom_version(hw, &nvm_ver); /* Option ROM */ ixgbe_get_etk_id(hw, &nvm_ver); /* eTrack identifies a build in Intel's SCM */ status = ixgbe_get_phy_firmware_version(hw, &phyfw); - if (nvm_ver.oem_valid) - sbuf_printf(buf, "NVM OEM V%d.%d R%d ", nvm_ver.oem_major, + if (nvm_ver.oem_valid) { + sbuf_printf(buf, "NVM OEM V%d.%d R%d", nvm_ver.oem_major, nvm_ver.oem_minor, nvm_ver.oem_release); + space = " "; + } - if (nvm_ver.or_valid) - sbuf_printf(buf, "Option ROM V%d-b%d-p%d ", nvm_ver.or_major, - nvm_ver.or_build, nvm_ver.or_patch); + if (nvm_ver.or_valid) { + sbuf_printf(buf, "%sOption ROM V%d-b%d-p%d", + space, nvm_ver.or_major, nvm_ver.or_build, nvm_ver.or_patch); + space = " "; + } - if (nvm_ver.etk_id != ((NVM_VER_INVALID << NVM_ETK_SHIFT) | NVM_VER_INVALID)) - sbuf_printf(buf, "eTrack 0x%08x ", nvm_ver.etk_id); + if (nvm_ver.etk_id != ((NVM_VER_INVALID << NVM_ETK_SHIFT) | + NVM_VER_INVALID)) { + sbuf_printf(buf, "%seTrack 0x%08x", space, nvm_ver.etk_id); + space = " "; + } if (phyfw != 0 && status == IXGBE_SUCCESS) - sbuf_printf(buf, "PHY FW V%d ", phyfw); - - sbuf_trim(buf); + sbuf_printf(buf, "%sPHY FW V%d", space, phyfw); } /* ixgbe_sbuf_fw_version */ /************************************************************************ From owner-dev-commits-src-main@freebsd.org Mon Aug 23 18:38:11 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1AE9966FBB9; Mon, 23 Aug 2021 18:38:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gtgwg03Rvz4tqx; Mon, 23 Aug 2021 18:38:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DD29A193DF; Mon, 23 Aug 2021 18:38:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NIcAub005962; Mon, 23 Aug 2021 18:38:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NIcAhM005961; Mon, 23 Aug 2021 18:38:10 GMT (envelope-from git) Date: Mon, 23 Aug 2021 18:38:10 GMT Message-Id: <202108231838.17NIcAhM005961@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: ebc52eabdcc5 - main - mips: retire bcmp MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ebc52eabdcc5971fee8eaf7e565cd5d970acbdbc Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 18:38:11 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=ebc52eabdcc5971fee8eaf7e565cd5d970acbdbc commit ebc52eabdcc5971fee8eaf7e565cd5d970acbdbc Author: Mateusz Guzik AuthorDate: 2021-08-23 16:25:19 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 18:38:04 +0000 mips: retire bcmp Unused since ba96f37758412151 ("Use __builtin for various mem* and b* (e.g. bzero) routines.") Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/mips/mips/support.S | 80 ------------------------------------------------- 1 file changed, 80 deletions(-) diff --git a/sys/mips/mips/support.S b/sys/mips/mips/support.S index 13a2d32a156c..4cf1f750fdad 100644 --- a/sys/mips/mips/support.S +++ b/sys/mips/mips/support.S @@ -473,86 +473,6 @@ smallclr: nop END(bzero) - -/* - * bcmp(s1, s2, n) - */ -LEAF(bcmp) - .set noreorder - blt a2, 16, smallcmp # is it worth any trouble? - xor v0, a0, a1 # compare low two bits of addresses - and v0, v0, 3 - PTR_SUBU a3, zero, a1 # compute # bytes to word align address - bne v0, zero, unalignedcmp # not possible to align addresses - and a3, a3, 3 - - beq a3, zero, 1f - PTR_SUBU a2, a2, a3 # subtract from remaining count - move v0, v1 # init v0,v1 so unmodified bytes match - LWHI v0, 0(a0) # read 1, 2, or 3 bytes - LWHI v1, 0(a1) - PTR_ADDU a1, a1, a3 - bne v0, v1, nomatch - PTR_ADDU a0, a0, a3 -1: - and a3, a2, ~3 # compute number of whole words left - PTR_SUBU a2, a2, a3 # which has to be >= (16-3) & ~3 - PTR_ADDU a3, a3, a0 # compute ending address -2: - lw v0, 0(a0) # compare words - lw v1, 0(a1) - PTR_ADDU a0, a0, 4 - bne v0, v1, nomatch - PTR_ADDU a1, a1, 4 - bne a0, a3, 2b - nop - b smallcmp # finish remainder - nop -unalignedcmp: - beq a3, zero, 2f - PTR_SUBU a2, a2, a3 # subtract from remaining count - PTR_ADDU a3, a3, a0 # compute ending address -1: - lbu v0, 0(a0) # compare bytes until a1 word aligned - lbu v1, 0(a1) - PTR_ADDU a0, a0, 1 - bne v0, v1, nomatch - PTR_ADDU a1, a1, 1 - bne a0, a3, 1b - nop -2: - and a3, a2, ~3 # compute number of whole words left - PTR_SUBU a2, a2, a3 # which has to be >= (16-3) & ~3 - PTR_ADDU a3, a3, a0 # compute ending address -3: - LWHI v0, 0(a0) # compare words a0 unaligned, a1 aligned - LWLO v0, 3(a0) - lw v1, 0(a1) - PTR_ADDU a0, a0, 4 - bne v0, v1, nomatch - PTR_ADDU a1, a1, 4 - bne a0, a3, 3b - nop -smallcmp: - ble a2, zero, match - PTR_ADDU a3, a2, a0 # compute ending address -1: - lbu v0, 0(a0) - lbu v1, 0(a1) - PTR_ADDU a0, a0, 1 - bne v0, v1, nomatch - PTR_ADDU a1, a1, 1 - bne a0, a3, 1b - nop -match: - j ra - move v0, zero -nomatch: - j ra - li v0, 1 -END(bcmp) - - /* * bit = ffs(value) */ From owner-dev-commits-src-main@freebsd.org Mon Aug 23 18:38:12 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 361C866FD18; Mon, 23 Aug 2021 18:38:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gtgwh12L2z4tkq; Mon, 23 Aug 2021 18:38:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0AEEE193E0; Mon, 23 Aug 2021 18:38:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NIcBHU005986; Mon, 23 Aug 2021 18:38:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NIcBX0005985; Mon, 23 Aug 2021 18:38:11 GMT (envelope-from git) Date: Mon, 23 Aug 2021 18:38:11 GMT Message-Id: <202108231838.17NIcBX0005985@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 8e4f67f17ff2 - main - i386: retire bcmp MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8e4f67f17ff27371c6d06c4143807e293f07c51e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 18:38:12 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=8e4f67f17ff27371c6d06c4143807e293f07c51e commit 8e4f67f17ff27371c6d06c4143807e293f07c51e Author: Mateusz Guzik AuthorDate: 2021-08-23 16:27:17 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 18:38:04 +0000 i386: retire bcmp Unused since ba96f37758412151 ("Use __builtin for various mem* and b* (e.g. bzero) routines.") Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/i386/i386/support.s | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/sys/i386/i386/support.s b/sys/i386/i386/support.s index b29354c47455..2fc02a67b600 100644 --- a/sys/i386/i386/support.s +++ b/sys/i386/i386/support.s @@ -232,31 +232,6 @@ ENTRY(memcpy) ret END(memcpy) -ENTRY(bcmp) - pushl %edi - pushl %esi - movl 12(%esp),%edi - movl 16(%esp),%esi - movl 20(%esp),%edx - - movl %edx,%ecx - shrl $2,%ecx - repe - cmpsl - jne 1f - - movl %edx,%ecx - andl $3,%ecx - repe - cmpsb -1: - setne %al - movsbl %al,%eax - popl %esi - popl %edi - ret -END(bcmp) - /* * Handling of special 386 registers and descriptor tables etc */ From owner-dev-commits-src-main@freebsd.org Mon Aug 23 18:38:13 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7FD7666FBBA; Mon, 23 Aug 2021 18:38:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gtgwj2KY3z4trC; Mon, 23 Aug 2021 18:38:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2C01F191B2; Mon, 23 Aug 2021 18:38:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NIcDDc006012; Mon, 23 Aug 2021 18:38:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NIcDtC006011; Mon, 23 Aug 2021 18:38:13 GMT (envelope-from git) Date: Mon, 23 Aug 2021 18:38:13 GMT Message-Id: <202108231838.17NIcDtC006011@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: e0545190ef5c - main - i386: retire bzero MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e0545190ef5c1268bdf9ed7f4d04bc5cd4ec19cf Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 18:38:13 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=e0545190ef5c1268bdf9ed7f4d04bc5cd4ec19cf commit e0545190ef5c1268bdf9ed7f4d04bc5cd4ec19cf Author: Mateusz Guzik AuthorDate: 2021-08-23 16:15:29 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 18:38:05 +0000 i386: retire bzero Unused since ba96f37758412151 ("Use __builtin for various mem* and b* (e.g. bzero) routines.") Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/i386/i386/support.s | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/sys/i386/i386/support.s b/sys/i386/i386/support.s index 2fc02a67b600..4130affbba5c 100644 --- a/sys/i386/i386/support.s +++ b/sys/i386/i386/support.s @@ -40,26 +40,6 @@ .text -/* - * bcopy family - * void bzero(void *buf, u_int len) - */ -ENTRY(bzero) - pushl %edi - movl 8(%esp),%edi - movl 12(%esp),%ecx - xorl %eax,%eax - shrl $2,%ecx - rep - stosl - movl 12(%esp),%ecx - andl $3,%ecx - rep - stosb - popl %edi - ret -END(bzero) - ENTRY(sse2_pagezero) pushl %ebx movl 8(%esp),%ecx From owner-dev-commits-src-main@freebsd.org Mon Aug 23 18:38:15 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 583F266FB53; Mon, 23 Aug 2021 18:38:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gtgwk5S0Yz4tyN; Mon, 23 Aug 2021 18:38:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 58770193E1; Mon, 23 Aug 2021 18:38:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NIcEVn006043; Mon, 23 Aug 2021 18:38:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NIcEqB006042; Mon, 23 Aug 2021 18:38:14 GMT (envelope-from git) Date: Mon, 23 Aug 2021 18:38:14 GMT Message-Id: <202108231838.17NIcEqB006042@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: c69cc8d10180 - main - riscv: retire bzero MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c69cc8d10180e667dc7701f700e4975e627514ef Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 18:38:15 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=c69cc8d10180e667dc7701f700e4975e627514ef commit c69cc8d10180e667dc7701f700e4975e627514ef Author: Mateusz Guzik AuthorDate: 2021-08-23 16:16:32 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 18:38:05 +0000 riscv: retire bzero Unused since ba96f37758412151 ("Use __builtin for various mem* and b* (e.g. bzero) routines.") Reviewed by: mhorne Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/riscv/riscv/machdep.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/sys/riscv/riscv/machdep.c b/sys/riscv/riscv/machdep.c index 841bfeda891e..b7fb142a59b4 100644 --- a/sys/riscv/riscv/machdep.c +++ b/sys/riscv/riscv/machdep.c @@ -979,14 +979,3 @@ initriscv(struct riscv_bootparams *rvbp) TSEXIT(); } - -#undef bzero -void -bzero(void *buf, size_t len) -{ - uint8_t *p; - - p = buf; - while(len-- > 0) - *p++ = 0; -} From owner-dev-commits-src-main@freebsd.org Mon Aug 23 18:38:16 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 052F766FBBC; Mon, 23 Aug 2021 18:38:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gtgwl4TfLz4thN; Mon, 23 Aug 2021 18:38:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 715B2193E2; Mon, 23 Aug 2021 18:38:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NIcFhL006067; Mon, 23 Aug 2021 18:38:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NIcFkw006066; Mon, 23 Aug 2021 18:38:15 GMT (envelope-from git) Date: Mon, 23 Aug 2021 18:38:15 GMT Message-Id: <202108231838.17NIcFkw006066@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 11cb9a096c50 - main - powerpc: retire bzero MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 11cb9a096c505b5bc41b489aa9351a10a555e1d7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 18:38:16 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=11cb9a096c505b5bc41b489aa9351a10a555e1d7 commit 11cb9a096c505b5bc41b489aa9351a10a555e1d7 Author: Mateusz Guzik AuthorDate: 2021-08-23 16:19:03 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 18:38:05 +0000 powerpc: retire bzero Unused since ba96f37758412151 ("Use __builtin for various mem* and b* (e.g. bzero) routines.") Reviewed by: jhibbits Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/powerpc/powerpc/machdep.c | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/sys/powerpc/powerpc/machdep.c b/sys/powerpc/powerpc/machdep.c index 4e8b6089beea..f35469f4051c 100644 --- a/sys/powerpc/powerpc/machdep.c +++ b/sys/powerpc/powerpc/machdep.c @@ -836,44 +836,6 @@ DB_SHOW_COMMAND(frame, db_show_frame) } #endif -#undef bzero -void -bzero(void *buf, size_t len) -{ - caddr_t p; - - p = buf; - - while (((vm_offset_t) p & (sizeof(u_long) - 1)) && len) { - *p++ = 0; - len--; - } - - while (len >= sizeof(u_long) * 8) { - *(u_long*) p = 0; - *((u_long*) p + 1) = 0; - *((u_long*) p + 2) = 0; - *((u_long*) p + 3) = 0; - len -= sizeof(u_long) * 8; - *((u_long*) p + 4) = 0; - *((u_long*) p + 5) = 0; - *((u_long*) p + 6) = 0; - *((u_long*) p + 7) = 0; - p += sizeof(u_long) * 8; - } - - while (len >= sizeof(u_long)) { - *(u_long*) p = 0; - len -= sizeof(u_long); - p += sizeof(u_long); - } - - while (len) { - *p++ = 0; - len--; - } -} - /* __stack_chk_fail_local() is called in secure-plt (32-bit). */ #if !defined(__powerpc64__) extern void __stack_chk_fail(void); From owner-dev-commits-src-main@freebsd.org Mon Aug 23 18:38:18 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7C3BC66FE49; Mon, 23 Aug 2021 18:38:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gtgwp0CpKz4trb; Mon, 23 Aug 2021 18:38:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AFA7A19602; Mon, 23 Aug 2021 18:38:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NIcHW9006117; Mon, 23 Aug 2021 18:38:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NIcHYR006116; Mon, 23 Aug 2021 18:38:17 GMT (envelope-from git) Date: Mon, 23 Aug 2021 18:38:17 GMT Message-Id: <202108231838.17NIcHYR006116@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: e72e16c55df4 - main - Remove bzero declaration MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e72e16c55df48194c354e82bd31415529c7a92a9 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 18:38:18 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=e72e16c55df48194c354e82bd31415529c7a92a9 commit e72e16c55df48194c354e82bd31415529c7a92a9 Author: Mateusz Guzik AuthorDate: 2021-08-23 16:20:53 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 18:38:05 +0000 Remove bzero declaration The kernel was migrated to memset in ba96f37758412151 ("Use __builtin for various mem* and b* (e.g. bzero) routines.") and there are no remaining architectures using the file. malloc is augmented to prevent KMSAN from breaking. Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/sys/malloc.h | 2 +- sys/sys/systm.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/sys/sys/malloc.h b/sys/sys/malloc.h index 3d88460a751e..b83d78a18444 100644 --- a/sys/sys/malloc.h +++ b/sys/sys/malloc.h @@ -233,7 +233,7 @@ void *malloc(size_t size, struct malloc_type *type, int flags) __malloc_like _malloc_item = malloc(_size, type, (flags) &~ M_ZERO); \ if (((flags) & M_WAITOK) != 0 || \ __predict_true(_malloc_item != NULL)) \ - bzero(_malloc_item, _size); \ + memset(_malloc_item, 0, _size); \ } else { \ _malloc_item = malloc(_size, type, flags); \ } \ diff --git a/sys/sys/systm.h b/sys/sys/systm.h index 1be8f1ac49be..17d1e8933997 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -342,7 +342,6 @@ void hexdump(const void *ptr, int length, const char *hdr, int flags); #define ovbcopy(f, t, l) bcopy((f), (t), (l)) void bcopy(const void * _Nonnull from, void * _Nonnull to, size_t len); -void bzero(void * _Nonnull buf, size_t len); void explicit_bzero(void * _Nonnull, size_t); void *memset(void * _Nonnull buf, int c, size_t len); From owner-dev-commits-src-main@freebsd.org Mon Aug 23 18:38:17 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9323E66FE48; Mon, 23 Aug 2021 18:38:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gtgwm5k26z4tyb; Mon, 23 Aug 2021 18:38:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9384319594; Mon, 23 Aug 2021 18:38:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NIcGwH006093; Mon, 23 Aug 2021 18:38:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NIcGft006092; Mon, 23 Aug 2021 18:38:16 GMT (envelope-from git) Date: Mon, 23 Aug 2021 18:38:16 GMT Message-Id: <202108231838.17NIcGft006092@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: a4c33d65f2f3 - main - mips: retire bzero MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a4c33d65f2f3d0f16e5824b320e226b0c9ba31af Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 18:38:17 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=a4c33d65f2f3d0f16e5824b320e226b0c9ba31af commit a4c33d65f2f3d0f16e5824b320e226b0c9ba31af Author: Mateusz Guzik AuthorDate: 2021-08-23 16:26:02 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 18:38:05 +0000 mips: retire bzero Unused since ba96f37758412151 ("Use __builtin for various mem* and b* (e.g. bzero) routines.") Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/mips/mips/support.S | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sys/mips/mips/support.S b/sys/mips/mips/support.S index 4cf1f750fdad..9fd5b919d89e 100644 --- a/sys/mips/mips/support.S +++ b/sys/mips/mips/support.S @@ -440,10 +440,9 @@ memsetsmallclr: END(memset) /* - * bzero(s1, n) + * blkclr(s1, n) */ -LEAF(bzero) -XLEAF(blkclr) +LEAF(blkclr) .set noreorder blt a1, 12, smallclr # small amount to clear? PTR_SUBU a3, zero, a0 # compute # bytes to word align address @@ -471,7 +470,7 @@ smallclr: 2: j ra nop -END(bzero) +END(blkclr) /* * bit = ffs(value) From owner-dev-commits-src-main@freebsd.org Mon Aug 23 19:37:16 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1784167066F; Mon, 23 Aug 2021 19:37:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtjDr0CwCz3km3; Mon, 23 Aug 2021 19:37:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E020719E55; Mon, 23 Aug 2021 19:37:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NJbFL1086604; Mon, 23 Aug 2021 19:37:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NJbFjt086603; Mon, 23 Aug 2021 19:37:15 GMT (envelope-from git) Date: Mon, 23 Aug 2021 19:37:15 GMT Message-Id: <202108231937.17NJbFjt086603@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 159258afb50a - main - altq: Fix panics on rmc_restart() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 159258afb50ad57f7ed27fe86ded83a7b3a26f90 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 19:37:16 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=159258afb50ad57f7ed27fe86ded83a7b3a26f90 commit 159258afb50ad57f7ed27fe86ded83a7b3a26f90 Author: Kristof Provost AuthorDate: 2021-08-21 11:42:27 +0000 Commit: Kristof Provost CommitDate: 2021-08-23 19:35:41 +0000 altq: Fix panics on rmc_restart() rmc_restart() is called from a timer, but can trigger traffic. This means the curvnet context will not be set. Use the vnet associated with the interface we're currently processing to set it. We also have to enter net_epoch here, for the same reason. Reviewed by: mjg MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D31642 --- sys/net/altq/altq_rmclass.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys/net/altq/altq_rmclass.c b/sys/net/altq/altq_rmclass.c index a6ede6feebe2..a9af314cd48a 100644 --- a/sys/net/altq/altq_rmclass.c +++ b/sys/net/altq/altq_rmclass.c @@ -1554,10 +1554,13 @@ rmc_restart(void *arg) { struct rm_class *cl = arg; struct rm_ifdat *ifd = cl->ifdat_; + struct epoch_tracker et; int s; s = splnet(); + NET_EPOCH_ENTER(et); IFQ_LOCK(ifd->ifq_); + CURVNET_SET(ifd->ifq_->altq_ifp->if_vnet); if (cl->sleeping_) { cl->sleeping_ = 0; cl->undertime_.tv_sec = 0; @@ -1567,7 +1570,9 @@ rmc_restart(void *arg) (ifd->restart)(ifd->ifq_); } } + CURVNET_RESTORE(); IFQ_UNLOCK(ifd->ifq_); + NET_EPOCH_EXIT(et); splx(s); } From owner-dev-commits-src-main@freebsd.org Mon Aug 23 20:26:40 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 21E79670D75 for ; Mon, 23 Aug 2021 20:26:40 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtkKq0czVz4TRW for ; Mon, 23 Aug 2021 20:26:39 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: by mail-wr1-f42.google.com with SMTP id e5so11419632wrp.8 for ; Mon, 23 Aug 2021 13:26:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=FrYH8P6eg3z9609Ub5AvqXLyXhlhwTB9nqbOpNimJuA=; b=HzBK6/m/TjRegRIhFYsu4gOsia/tJj/0Sd1qy6bOy60ZTS0YG2jamx1FoW9hFJqtHd 1/iXJ8AelcKGW/FcOQUY+hEkslB4TxsAVvazkOu1a1ocG4W459KQKqYCm89Gjl6CjMEa YDOSPHD73QAZH8ihFn4XfngH6ARSsXme9Syb8U8Hxaaifch7pyxIAVPd3YDjH2q47ouD fHdb1vTebco3APDdUfZO6h+h/BpqUD/KfW1a14rTTsLHhE4bzHecAZ+YOjKLNR2P7BrO AnUUnX8noErA39PaTHQbNo/B7CwznCE16QkRgJs6uvUR03P1RVnKUYO2yw0Yo26O2rXS 2QQg== X-Gm-Message-State: AOAM533J+riEXXD11dY/LUDcCfrAByAaVt/YPfKcCZcqXyY/NhdEAPp8 Q8CKSYMZLaDaDvlZuYX0w9QmNnSkEDT0odWf X-Google-Smtp-Source: ABdhPJxe0i3drzll0YQbdIKYtEr5CuQP9AJg+jW0r2w9p7hyCpyqiGWvcfPTYsWtHZ7K3ENJ/JCdkA== X-Received: by 2002:a5d:54ca:: with SMTP id x10mr15569311wrv.101.1629750392197; Mon, 23 Aug 2021 13:26:32 -0700 (PDT) Received: from smtpclient.apple (global-5-143.nat-2.net.cam.ac.uk. [131.111.5.143]) by smtp.gmail.com with ESMTPSA id n8sm200545wmq.18.2021.08.23.13.26.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Aug 2021 13:26:31 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.100.0.2.22\)) Subject: Re: git: 5ee2c35751ef - main - truncate(1): Add hole-punching support From: Jessica Clarke In-Reply-To: <202108191031.17JAViPg067471@gitrepo.freebsd.org> Date: Mon, 23 Aug 2021 21:26:31 +0100 Cc: "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" Content-Transfer-Encoding: quoted-printable Message-Id: <87C913E0-77D4-49BE-816C-E0F3BAA18BC2@freebsd.org> References: <202108191031.17JAViPg067471@gitrepo.freebsd.org> To: Ka Ho Ng X-Mailer: Apple Mail (2.3654.100.0.2.22) X-Rspamd-Queue-Id: 4GtkKq0czVz4TRW X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of jrtc27@jrtc27.com designates 209.85.221.42 as permitted sender) smtp.mailfrom=jrtc27@jrtc27.com X-Spamd-Result: default: False [-2.49 / 15.00]; TO_DN_EQ_ADDR_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; MV_CASE(0.50)[]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17]; RCVD_COUNT_THREE(0.00)[3]; NEURAL_HAM_SHORT(-1.00)[-1.000]; FORGED_SENDER(0.30)[jrtc27@freebsd.org,jrtc27@jrtc27.com]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; MID_RHS_MATCH_FROM(0.00)[]; FROM_NEQ_ENVFROM(0.00)[jrtc27@freebsd.org,jrtc27@jrtc27.com]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-0.999]; FREEFALL_USER(0.00)[jrtc27]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; NEURAL_HAM_LONG(-0.99)[-0.990]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[dev-commits-src-main@freebsd.org]; DMARC_NA(0.00)[freebsd.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[209.85.221.42:from]; RWL_MAILSPIKE_POSSIBLE(0.00)[209.85.221.42:from]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[dev-commits-src-main] X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 20:26:40 -0000 On 19 Aug 2021, at 11:31, Ka Ho Ng wrote: >=20 > The branch main has been updated by khng: >=20 > URL: = https://cgit.FreeBSD.org/src/commit/?id=3D5ee2c35751ef5d131222423bf3e25073= f997c337 >=20 > commit 5ee2c35751ef5d131222423bf3e25073f997c337 > Author: Ka Ho Ng > AuthorDate: 2021-08-19 10:30:41 +0000 > Commit: Ka Ho Ng > CommitDate: 2021-08-19 10:30:41 +0000 >=20 > truncate(1): Add hole-punching support >=20 > This commit adds hole-punching support to the truncate(1) utility. = If > the option -d is specified, truncate(1) performs zeroing, and if > possible hole-punching in case the operation is supported by the > underlying file system of the specified files. >=20 > Sponsored by: The FreeBSD Foundation > Reviewed by: kib > Differential Revision: https://reviews.freebsd.org/D31556 This broke cross-building from macOS and Linux since truncate is a bootstrap tool there and these FreeBSD-specific features don=E2=80=99t = exist. Please disable these features when built as a bootstrap tool (see bin/cat for an example). Jess From owner-dev-commits-src-main@freebsd.org Tue Aug 24 09:18:18 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 75121653BA5; Tue, 24 Aug 2021 09:18:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gv3SB22wqz4d5c; Tue, 24 Aug 2021 09:18:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2CF8F25BCF; Tue, 24 Aug 2021 09:18:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17O9IIL6086535; Tue, 24 Aug 2021 09:18:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17O9IIWL086534; Tue, 24 Aug 2021 09:18:18 GMT (envelope-from git) Date: Tue, 24 Aug 2021 09:18:18 GMT Message-Id: <202108240918.17O9IIWL086534@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ka Ho Ng Subject: git: 5425ba833257 - main - truncate(1): Fix cross-build CI failure due to missing fspacectl MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5425ba8332571e57f9fe623346cb9d83293264d4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 09:18:18 -0000 The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=5425ba8332571e57f9fe623346cb9d83293264d4 commit 5425ba8332571e57f9fe623346cb9d83293264d4 Author: Ka Ho Ng AuthorDate: 2021-08-24 08:26:04 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-24 09:08:28 +0000 truncate(1): Fix cross-build CI failure due to missing fspacectl For other platforms, fspacectl(2) is absent. This commit masks out the calls to fspacectl(2) and replace them with a ENODEV errno. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31619 --- tools/build/Makefile | 5 +++++ tools/build/fcntl.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ tools/build/fspacectl.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+) diff --git a/tools/build/Makefile b/tools/build/Makefile index 948a5f9dfdb2..3b49eb44475e 100644 --- a/tools/build/Makefile +++ b/tools/build/Makefile @@ -88,6 +88,11 @@ INCS+= strings.h SRCS+= explicit_bzero.c .endif +_WITH_FSPACECTL!= grep -c fspacectl ${HOST_INCLUDE_ROOT}/fcntl.h || true +.if ${_WITH_FSPACECTL} == 0 +INCS+= fcntl.h +SRCS+= fspacectl.c +.endif .if exists(${HOST_INCLUDE_ROOT}/capsicum_helpers.h) _WITH_CAPH_ENTER!= grep -c caph_enter ${HOST_INCLUDE_ROOT}/capsicum_helpers.h || true diff --git a/tools/build/fcntl.h b/tools/build/fcntl.h new file mode 100644 index 000000000000..3f88a4bf73d3 --- /dev/null +++ b/tools/build/fcntl.h @@ -0,0 +1,48 @@ +/*- + * Copyright (c) 2016 Jilles Tjoelker + * All rights reserved. + * + * 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$ + */ + +#ifndef _LEGACY_SYS_FCNTL_H_ +#define _LEGACY_SYS_FCNTL_H_ + +#include_next + +struct spacectl_range { + off_t r_offset; + off_t r_len; +}; + +#define SPACECTL_DEALLOC 1 + +#define SPACECTL_F_SUPPORTED 0 + +__BEGIN_DECLS +int fspacectl(int, int, const struct spacectl_range *, int, + struct spacectl_range *); +__END_DECLS + +#endif /* !_LEGACY_SYS_STAT_H_ */ diff --git a/tools/build/fspacectl.c b/tools/build/fspacectl.c new file mode 100644 index 000000000000..c17802c51e01 --- /dev/null +++ b/tools/build/fspacectl.c @@ -0,0 +1,44 @@ +/*- + * Copyright (c) 2021 The FreeBSD Foundation + * + * This software was developed by Ka Ho Ng + * 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 + +/* + * This is currently a stub implementation of fspacectl(2). + */ +int +fspacectl(int fd, int cmd, const struct spacectl_range *rqsr, int flags, + struct spacectl_range *rmsr) +{ + errno = ENOSYS; + return (-1); +} \ No newline at end of file From owner-dev-commits-src-main@freebsd.org Tue Aug 24 09:18:19 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8875E653D0B; Tue, 24 Aug 2021 09:18:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gv3SC33JLz4d3v; Tue, 24 Aug 2021 09:18:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4FE1525B42; Tue, 24 Aug 2021 09:18:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17O9IJMT086559; Tue, 24 Aug 2021 09:18:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17O9IJ9V086558; Tue, 24 Aug 2021 09:18:19 GMT (envelope-from git) Date: Tue, 24 Aug 2021 09:18:19 GMT Message-Id: <202108240918.17O9IJ9V086558@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ka Ho Ng Subject: git: 1eaa36523cb9 - main - fspacectl(2): Clarifies the return values MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1eaa36523cb921e90d61b20531ed525aba0cfe7e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 09:18:19 -0000 The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=1eaa36523cb921e90d61b20531ed525aba0cfe7e commit 1eaa36523cb921e90d61b20531ed525aba0cfe7e Author: Ka Ho Ng AuthorDate: 2021-08-24 09:04:02 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-24 09:08:28 +0000 fspacectl(2): Clarifies the return values rmacklem@ spotted two things in the system call: - Upon returning from a successful operation, vop_stddeallocate can update rmsr.r_offset to a value greater than file size. This behavior, although being harmless, can be confusing. - The EINVAL return value for rqsr.r_offset + rqsr.r_len > OFF_MAX is undocumented. This commit has the following changes: - vop_stddeallocate and shm_deallocate to bound the the affected area further by the file size. - The EINVAL case for rqsr.r_offset + rqsr.r_len > OFF_MAX is documented. - The fspacectl(2), vn_deallocate(9) and VOP_DEALLOCATE(9)'s return len is explicitly documented the be the value 0, and the return offset is restricted to be the smallest of off + len and current file size suggested by kib@. This semantic allows callers to interact better with potential file size growth after the call. Sponsored by: The FreeBSD Foundation Reviewed by: imp, kib Differential Revision: https://reviews.freebsd.org/D31604 --- lib/libc/sys/fspacectl.2 | 27 ++++++++++++++++++++++----- share/man/man9/VOP_DEALLOCATE.9 | 8 ++++++++ share/man/man9/vn_deallocate.9 | 8 ++++++++ sys/kern/uipc_shm.c | 11 +++++++++-- sys/kern/vfs_default.c | 8 ++++++-- 5 files changed, 53 insertions(+), 9 deletions(-) diff --git a/lib/libc/sys/fspacectl.2 b/lib/libc/sys/fspacectl.2 index 2f581d1c1fb8..0e369785b883 100644 --- a/lib/libc/sys/fspacectl.2 +++ b/lib/libc/sys/fspacectl.2 @@ -27,7 +27,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd August 4, 2021 +.Dd August 18, 2021 .Dt FSPACECTL 2 .Os .Sh NAME @@ -67,6 +67,17 @@ argument is non-NULL, the .Fa spacectl_range structure it points to is updated to contain the unprocessed operation range after the system call returns. +.Pp +For a successful completion without an unprocessed part in the requested +operation range, +.Fa "rmsr->r_len" +is updated to be the value 0, and +.Fa "rmsr->r_offset" +is updated to be the smallest of +.Fa "rqsr->r_offset" + +.Fa "rqsr->r_len" ; +and the end-of-file offset. +The file descriptor's file offset is not used or modified by the system call. Both .Fa rqsr and @@ -92,9 +103,9 @@ Zero a region in the file specified by the .Fa rqsr argument. The -.Va "rqsr->r_offset" +.Fa "rqsr->r_offset" has to be a value greater than or equal to 0, and the -.Va "rqsr->r_len" +.Fa "rqsr->r_len" has to be a value greater than 0. .Pp If the file system supports hole-punching, @@ -132,11 +143,17 @@ If the argument is .Dv SPACECTL_DEALLOC , either the -.Fa "range->r_offset" +.Fa "rqsr->r_offset" argument was less than zero, or the -.Fa "range->r_len" +.Fa "rqsr->r_len" argument was less than or equal to zero. .It Bq Er EINVAL +The value of +.Fa "rqsr->r_offset" + +.Fa "rqsr->r_len" +is greater than +.Dv OFF_MAX . +.It Bq Er EINVAL An invalid or unsupported flag is included in .Fa flags . .It Bq Er EINVAL diff --git a/share/man/man9/VOP_DEALLOCATE.9 b/share/man/man9/VOP_DEALLOCATE.9 index dbfe048f2235..2ec915c6fef3 100644 --- a/share/man/man9/VOP_DEALLOCATE.9 +++ b/share/man/man9/VOP_DEALLOCATE.9 @@ -74,6 +74,14 @@ and are updated to reflect the portion of the range that still needs to be zeroed/deallocated on return. Partial result is considered a successful operation. +For a successful completion without an unprocessed portion of the range, +.Fa *len +is updated to be the value 0, and +.Fa *offset +is updated to be the smallest of +.Fa *offset + +.Fa *len +passed to the call and the end-of-file offset. .Sh LOCKS The vnode should be locked on entry and will still be locked on exit. .Sh RETURN VALUES diff --git a/share/man/man9/vn_deallocate.9 b/share/man/man9/vn_deallocate.9 index 29edcd57ff5d..08f4e92ec597 100644 --- a/share/man/man9/vn_deallocate.9 +++ b/share/man/man9/vn_deallocate.9 @@ -95,6 +95,14 @@ Attempt to bypass buffer cache. and .Fa *length are updated to reflect the unprocessed operation range of the call. +For a successful completion, +.Fa *length +is updated to be the value 0, and +.Fa *offset +is updated to be the smallest of +.Fa *offset + +.Fa *length +passed to the call and the end-of-file offset. .Sh RETURN VALUES Upon successful completion, the value 0 is returned; otherwise the appropriate error is returned. diff --git a/sys/kern/uipc_shm.c b/sys/kern/uipc_shm.c index 16d1e22a898b..60815ef24c26 100644 --- a/sys/kern/uipc_shm.c +++ b/sys/kern/uipc_shm.c @@ -1905,6 +1905,8 @@ shm_deallocate(struct shmfd *shmfd, off_t *offset, off_t *length, int flags) off = *offset; len = *length; KASSERT(off + len <= (vm_ooffset_t)OFF_MAX, ("off + len overflows")); + if (off + len > shmfd->shm_size) + len = shmfd->shm_size - off; object = shmfd->shm_object; startofs = off & PAGE_MASK; endofs = (off + len) & PAGE_MASK; @@ -1913,6 +1915,13 @@ shm_deallocate(struct shmfd *shmfd, off_t *offset, off_t *length, int flags) pi = OFF_TO_IDX(off + PAGE_MASK); error = 0; + /* Handle the case when offset is beyond shm size */ + if ((off_t)len < 0) { + *offset = shmfd->shm_size; + *length = 0; + return (0); + } + VM_OBJECT_WLOCK(object); if (startofs != 0) { @@ -1974,8 +1983,6 @@ shm_fspacectl(struct file *fp, int cmd, off_t *offset, off_t *length, int flags, break; } error = shm_deallocate(shmfd, &off, &len, flags); - if (error != 0) - break; *offset = off; *length = len; break; diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index d9328cd39b00..d5df9cd8bf7b 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -1138,14 +1138,13 @@ vop_stddeallocate(struct vop_deallocate_args *ap) vp = ap->a_vp; offset = *ap->a_offset; - len = *ap->a_len; cred = ap->a_cred; error = VOP_GETATTR(vp, &va, cred); if (error) return (error); - len = omin(OFF_MAX - offset, *ap->a_len); + len = omin((off_t)va.va_size - offset, *ap->a_len); while (len > 0) { noff = offset; error = vn_bmap_seekhole_locked(vp, FIOSEEKDATA, &noff, cred); @@ -1185,6 +1184,11 @@ vop_stddeallocate(struct vop_deallocate_args *ap) if (should_yield()) break; } + /* Handle the case when offset is beyond EOF */ + if (len < 0) { + offset += len; + len = 0; + } out: *ap->a_offset = offset; *ap->a_len = len; From owner-dev-commits-src-main@freebsd.org Tue Aug 24 09:18:20 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B3684653D13; Tue, 24 Aug 2021 09:18:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gv3SD4Qhxz4d5k; Tue, 24 Aug 2021 09:18:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 758B425D40; Tue, 24 Aug 2021 09:18:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17O9IKQW086583; Tue, 24 Aug 2021 09:18:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17O9IK11086582; Tue, 24 Aug 2021 09:18:20 GMT (envelope-from git) Date: Tue, 24 Aug 2021 09:18:20 GMT Message-Id: <202108240918.17O9IK11086582@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ka Ho Ng Subject: git: 1a4c5061fc5b - main - param: Bump __FreeBSD_version to 1400031 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1a4c5061fc5ba8f2eee41456a6873547915f268a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 09:18:20 -0000 The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=1a4c5061fc5ba8f2eee41456a6873547915f268a commit 1a4c5061fc5ba8f2eee41456a6873547915f268a Author: Ka Ho Ng AuthorDate: 2021-08-24 09:13:00 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-24 09:13:00 +0000 param: Bump __FreeBSD_version to 1400031 Commit 1eaa36523cb9 introduces backward compatible changes to fspacectl(2), vn_deallocate(9) and VOP_DEALLOCATE(9). rmsr.r_offset and *offset is updated to contain meaningful value upon returning from the call. Sponsored by: The FreeBSD Foundation --- sys/sys/param.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/sys/param.h b/sys/sys/param.h index 5ab48dce2a74..82787b4552af 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -76,7 +76,7 @@ * cannot include sys/param.h and should only be updated here. */ #undef __FreeBSD_version -#define __FreeBSD_version 1400030 +#define __FreeBSD_version 1400031 /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From owner-dev-commits-src-main@freebsd.org Tue Aug 24 09:24:32 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0F2BC653ECB; Tue, 24 Aug 2021 09:24:32 +0000 (UTC) (envelope-from khng@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gv3bM6fPKz4fqL; Tue, 24 Aug 2021 09:24:31 +0000 (UTC) (envelope-from khng@FreeBSD.org) Received: from dac1f024b.dhcp.in.dimsumlabs.com (unknown [IPv6:2001:470:fbdc:6066:bc48:c3eb:8afc:1748]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: khng/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 0D802272F8; Tue, 24 Aug 2021 09:24:30 +0000 (UTC) (envelope-from khng@FreeBSD.org) Subject: Re: git: 1a4c5061fc5b - main - param: Bump __FreeBSD_version to 1400031 From: Ka Ho Ng To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org References: <202108240918.17O9IK11086582@gitrepo.freebsd.org> Message-ID: <1754c408-7e5b-d661-3f01-445d200415d2@FreeBSD.org> Date: Tue, 24 Aug 2021 17:24:27 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <202108240918.17O9IK11086582@gitrepo.freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 09:24:32 -0000 On 2021/8/24 5:18 PM, Ka Ho Ng wrote: > The branch main has been updated by khng: > > URL: https://cgit.FreeBSD.org/src/commit/?id=1a4c5061fc5ba8f2eee41456a6873547915f268a > > commit 1a4c5061fc5ba8f2eee41456a6873547915f268a > Author: Ka Ho Ng > AuthorDate: 2021-08-24 09:13:00 +0000 > Commit: Ka Ho Ng > CommitDate: 2021-08-24 09:13:00 +0000 > > param: Bump __FreeBSD_version to 1400031 > > Commit 1eaa36523cb9 introduces backward compatible changes to > fspacectl(2), vn_deallocate(9) and VOP_DEALLOCATE(9). > rmsr.r_offset and *offset is updated to contain meaningful value upon > returning from the call. > > Sponsored by: The FreeBSD Foundation > --- > sys/sys/param.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/sys/sys/param.h b/sys/sys/param.h > index 5ab48dce2a74..82787b4552af 100644 > --- a/sys/sys/param.h > +++ b/sys/sys/param.h > @@ -76,7 +76,7 @@ > * cannot include sys/param.h and should only be updated here. > */ > #undef __FreeBSD_version > -#define __FreeBSD_version 1400030 > +#define __FreeBSD_version 1400031 > > /* > * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, > Despite that, file system modules implementing VOP_DEALLOCATE(9) need to update *ap->a_offset to omin(*offset + *length, file_sz). Ka Ho From owner-dev-commits-src-main@freebsd.org Tue Aug 24 09:59:46 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A161365435D; Tue, 24 Aug 2021 09:59:46 +0000 (UTC) (envelope-from khng@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gv4N23xP8z4pq5; Tue, 24 Aug 2021 09:59:46 +0000 (UTC) (envelope-from khng@FreeBSD.org) Received: from dac1f024b.dhcp.in.dimsumlabs.com (unknown [IPv6:2001:470:fbdc:6066:bc48:c3eb:8afc:1748]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: khng/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 9CCFD27548; Tue, 24 Aug 2021 09:59:45 +0000 (UTC) (envelope-from khng@FreeBSD.org) Subject: Re: git: 5425ba833257 - main - truncate(1): Fix cross-build CI failure due to missing fspacectl From: Ka Ho Ng To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org References: <202108240918.17O9IIWL086534@gitrepo.freebsd.org> Message-ID: <7448352e-2ab8-477a-801e-21eb26743ab2@FreeBSD.org> Date: Tue, 24 Aug 2021 17:59:43 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <202108240918.17O9IIWL086534@gitrepo.freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 09:59:46 -0000 On 2021/8/24 5:18 PM, Ka Ho Ng wrote: > The branch main has been updated by khng: > > URL: https://cgit.FreeBSD.org/src/commit/?id=5425ba8332571e57f9fe623346cb9d83293264d4 > > commit 5425ba8332571e57f9fe623346cb9d83293264d4 > Author: Ka Ho Ng > AuthorDate: 2021-08-24 08:26:04 +0000 > Commit: Ka Ho Ng > CommitDate: 2021-08-24 09:08:28 +0000 > > truncate(1): Fix cross-build CI failure due to missing fspacectl > > For other platforms, fspacectl(2) is absent. This commit masks out the > calls to fspacectl(2) and replace them with a ENODEV errno. > > Sponsored by: The FreeBSD Foundation > Differential Revision: https://reviews.freebsd.org/D31619 > --- > tools/build/Makefile | 5 +++++ > tools/build/fcntl.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ > tools/build/fspacectl.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 97 insertions(+) > > diff --git a/tools/build/Makefile b/tools/build/Makefile > index 948a5f9dfdb2..3b49eb44475e 100644 > --- a/tools/build/Makefile > +++ b/tools/build/Makefile > @@ -88,6 +88,11 @@ INCS+= strings.h > SRCS+= explicit_bzero.c > .endif > > +_WITH_FSPACECTL!= grep -c fspacectl ${HOST_INCLUDE_ROOT}/fcntl.h || true > +.if ${_WITH_FSPACECTL} == 0 > +INCS+= fcntl.h > +SRCS+= fspacectl.c > +.endif > > .if exists(${HOST_INCLUDE_ROOT}/capsicum_helpers.h) > _WITH_CAPH_ENTER!= grep -c caph_enter ${HOST_INCLUDE_ROOT}/capsicum_helpers.h || true > diff --git a/tools/build/fcntl.h b/tools/build/fcntl.h > new file mode 100644 > index 000000000000..3f88a4bf73d3 > --- /dev/null > +++ b/tools/build/fcntl.h > @@ -0,0 +1,48 @@ > +/*- > + * Copyright (c) 2016 Jilles Tjoelker > + * All rights reserved. > + * > + * 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$ > + */ > + > +#ifndef _LEGACY_SYS_FCNTL_H_ > +#define _LEGACY_SYS_FCNTL_H_ > + > +#include_next > + > +struct spacectl_range { > + off_t r_offset; > + off_t r_len; > +}; > + > +#define SPACECTL_DEALLOC 1 > + > +#define SPACECTL_F_SUPPORTED 0 > + > +__BEGIN_DECLS > +int fspacectl(int, int, const struct spacectl_range *, int, > + struct spacectl_range *); > +__END_DECLS > + > +#endif /* !_LEGACY_SYS_STAT_H_ */ > diff --git a/tools/build/fspacectl.c b/tools/build/fspacectl.c > new file mode 100644 > index 000000000000..c17802c51e01 > --- /dev/null > +++ b/tools/build/fspacectl.c > @@ -0,0 +1,44 @@ > +/*- > + * Copyright (c) 2021 The FreeBSD Foundation > + * > + * This software was developed by Ka Ho Ng > + * 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 > + > +/* > + * This is currently a stub implementation of fspacectl(2). > + */ > +int > +fspacectl(int fd, int cmd, const struct spacectl_range *rqsr, int flags, > + struct spacectl_range *rmsr) > +{ > + errno = ENOSYS; > + return (-1); > +} > \ No newline at end of file > s/ENODEV/ENOSYS Ka Ho From owner-dev-commits-src-main@freebsd.org Tue Aug 24 11:24:12 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 241E765544D; Tue, 24 Aug 2021 11:24:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gv6FS0Bznz3lkl; Tue, 24 Aug 2021 11:24:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DEFF127746; Tue, 24 Aug 2021 11:24:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17OBOBIY059757; Tue, 24 Aug 2021 11:24:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OBOBlP059756; Tue, 24 Aug 2021 11:24:11 GMT (envelope-from git) Date: Tue, 24 Aug 2021 11:24:11 GMT Message-Id: <202108241124.17OBOBlP059756@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 38941f5993a1 - main - i386: retire bcopy MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 38941f5993a161cd4ce21a0c0b2360d3ee73cf84 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 11:24:12 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=38941f5993a161cd4ce21a0c0b2360d3ee73cf84 commit 38941f5993a161cd4ce21a0c0b2360d3ee73cf84 Author: Mateusz Guzik AuthorDate: 2021-08-23 19:18:49 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-24 11:24:07 +0000 i386: retire bcopy Unused since ba96f37758412151 ("Use __builtin for various mem* and b* (e.g. bzero) routines.") Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/i386/i386/support.s | 9 --------- 1 file changed, 9 deletions(-) diff --git a/sys/i386/i386/support.s b/sys/i386/i386/support.s index 4130affbba5c..c1ded3bb9357 100644 --- a/sys/i386/i386/support.s +++ b/sys/i386/i386/support.s @@ -127,17 +127,8 @@ END(fillw) /* * memmove(dst, src, cnt) (return dst) - * bcopy(src, dst, cnt) * ws@tools.de (Wolfgang Solfrank, TooLs GmbH) +49-228-985800 */ -ENTRY(bcopy) - movl 4(%esp),%eax - movl 8(%esp),%edx - movl %eax,8(%esp) - movl %edx,4(%esp) - jmp memmove -END(bcopy) - ENTRY(memmove) pushl %ebp movl %esp,%ebp From owner-dev-commits-src-main@freebsd.org Tue Aug 24 11:24:14 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 61F4A655884; Tue, 24 Aug 2021 11:24:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gv6FV28hgz3m34; Tue, 24 Aug 2021 11:24:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2899527A04; Tue, 24 Aug 2021 11:24:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17OBOEFj059806; Tue, 24 Aug 2021 11:24:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OBOElP059805; Tue, 24 Aug 2021 11:24:14 GMT (envelope-from git) Date: Tue, 24 Aug 2021 11:24:14 GMT Message-Id: <202108241124.17OBOElP059805@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 9a1d562085cb - main - mips: retire ovbcopy MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9a1d562085cb4623a95e3e7a649d81099ce67470 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 11:24:14 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=9a1d562085cb4623a95e3e7a649d81099ce67470 commit 9a1d562085cb4623a95e3e7a649d81099ce67470 Author: Mateusz Guzik AuthorDate: 2021-08-24 08:49:31 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-24 11:24:07 +0000 mips: retire ovbcopy ovbcopy is unused since 9f45b2da8fa08638 ("Define ovbcopy() as a macro which expands to the equivalent bcopy() call") bcopy is left in place because it is used by assembly primitives Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/mips/mips/bcopy.S | 1 - 1 file changed, 1 deletion(-) diff --git a/sys/mips/mips/bcopy.S b/sys/mips/mips/bcopy.S index 4205ca5e1680..ffd86f1de26d 100644 --- a/sys/mips/mips/bcopy.S +++ b/sys/mips/mips/bcopy.S @@ -74,7 +74,6 @@ XLEAF(memmove) move a1, v0 XLEAF(bcopy) -XLEAF(ovbcopy) /* * Make sure we can copy forwards. */ From owner-dev-commits-src-main@freebsd.org Tue Aug 24 11:24:13 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 361F36559EE; Tue, 24 Aug 2021 11:24:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gv6FT0lD6z3lkq; Tue, 24 Aug 2021 11:24:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F0E99277A2; Tue, 24 Aug 2021 11:24:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17OBOCGX059782; Tue, 24 Aug 2021 11:24:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OBOCcP059781; Tue, 24 Aug 2021 11:24:12 GMT (envelope-from git) Date: Tue, 24 Aug 2021 11:24:12 GMT Message-Id: <202108241124.17OBOCcP059781@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: d0bc029b4a1e - main - arm64: retire bcopy MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d0bc029b4a1ec6522375a1db7d5fc73e3b0461f3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 11:24:13 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=d0bc029b4a1ec6522375a1db7d5fc73e3b0461f3 commit d0bc029b4a1ec6522375a1db7d5fc73e3b0461f3 Author: Mateusz Guzik AuthorDate: 2021-08-23 19:21:48 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-24 11:24:07 +0000 arm64: retire bcopy Unused since ba96f37758412151 ("Use __builtin for various mem* and b* (e.g. bzero) routines.") Reviewed by: andrew Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D31651 --- sys/arm64/arm64/memmove.S | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/sys/arm64/arm64/memmove.S b/sys/arm64/arm64/memmove.S index 4b99dccc536e..22e7edb54636 100644 --- a/sys/arm64/arm64/memmove.S +++ b/sys/arm64/arm64/memmove.S @@ -84,12 +84,7 @@ __FBSDID("$FreeBSD$"); unrolled loop processes 64 bytes per iteration. */ -ENTRY(bcopy) - /* Switch the input pointers when called as bcopy */ - mov x3, x1 - mov x1, x0 - mov x0, x3 -EENTRY(memmove) +ENTRY(memmove) sub tmp1, dstin, src cmp count, 96 ccmp tmp1, count, 2, hi @@ -146,5 +141,4 @@ EENTRY(memmove) stp B_l, B_h, [dstin, 16] stp C_l, C_h, [dstin] 3: ret -EEND(memmove) -END(bcopy) +END(memmove) From owner-dev-commits-src-main@freebsd.org Tue Aug 24 11:24:16 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B47AB6551D8; Tue, 24 Aug 2021 11:24:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gv6FX4S7hz3lm7; Tue, 24 Aug 2021 11:24:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6DB912733E; Tue, 24 Aug 2021 11:24:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17OBOGOj059854; Tue, 24 Aug 2021 11:24:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OBOGxs059853; Tue, 24 Aug 2021 11:24:16 GMT (envelope-from git) Date: Tue, 24 Aug 2021 11:24:16 GMT Message-Id: <202108241124.17OBOGxs059853@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 36fc38301824 - main - Remove bcopy declaration MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 36fc38301824e2d6ca774200d8be972a6196f353 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 11:24:16 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=36fc38301824e2d6ca774200d8be972a6196f353 commit 36fc38301824e2d6ca774200d8be972a6196f353 Author: Mateusz Guzik AuthorDate: 2021-08-24 11:22:56 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-24 11:24:08 +0000 Remove bcopy declaration The kernel was migrated to memmove in ba96f37758412151 ("Use __builtin for various mem* and b* (e.g. bzero) routines."). Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/sys/systm.h | 1 - 1 file changed, 1 deletion(-) diff --git a/sys/sys/systm.h b/sys/sys/systm.h index 17d1e8933997..17c110a957c9 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -341,7 +341,6 @@ void hexdump(const void *ptr, int length, const char *hdr, int flags); #define HD_OMIT_CHARS (1 << 18) #define ovbcopy(f, t, l) bcopy((f), (t), (l)) -void bcopy(const void * _Nonnull from, void * _Nonnull to, size_t len); void explicit_bzero(void * _Nonnull, size_t); void *memset(void * _Nonnull buf, int c, size_t len); From owner-dev-commits-src-main@freebsd.org Tue Aug 24 11:24:15 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D002265546A; Tue, 24 Aug 2021 11:24:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gv6FW44XSz3lvY; Tue, 24 Aug 2021 11:24:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4B96E2733D; Tue, 24 Aug 2021 11:24:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17OBOFO7059830; Tue, 24 Aug 2021 11:24:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OBOFOd059829; Tue, 24 Aug 2021 11:24:15 GMT (envelope-from git) Date: Tue, 24 Aug 2021 11:24:15 GMT Message-Id: <202108241124.17OBOFOd059829@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 7ec4365671e3 - main - libkern: remove bcopy MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7ec4365671e395f99e32f954e2f83b735aca4ac7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 11:24:15 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=7ec4365671e395f99e32f954e2f83b735aca4ac7 commit 7ec4365671e395f99e32f954e2f83b735aca4ac7 Author: Mateusz Guzik AuthorDate: 2021-08-24 11:21:52 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-24 11:24:07 +0000 libkern: remove bcopy Unused since ba96f37758412151 ("Use __builtin for various mem* and b* (e.g. bzero) routines.") File name remains to reduce churn. Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/libkern/bcopy.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/sys/libkern/bcopy.c b/sys/libkern/bcopy.c index 8e34ad0daa53..833a9854f181 100644 --- a/sys/libkern/bcopy.c +++ b/sys/libkern/bcopy.c @@ -52,7 +52,6 @@ __FBSDID("$FreeBSD$"); #undef memcpy #undef memmove -#undef bcopy /* * sizeof(word) MUST BE A POWER OF TWO @@ -147,10 +146,3 @@ done: } __strong_reference(memcpy, memmove); - -void -(bcopy)(const void *src0, void *dst0, size_t length) -{ - - memcpy(dst0, src0, length); -} From owner-dev-commits-src-main@freebsd.org Tue Aug 24 12:57:37 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 86F616574A5; Tue, 24 Aug 2021 12:57:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gv8KF3NWpz4jTN; Tue, 24 Aug 2021 12:57:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5D01E8B7; Tue, 24 Aug 2021 12:57:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17OCvbGp079143; Tue, 24 Aug 2021 12:57:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OCvbon079142; Tue, 24 Aug 2021 12:57:37 GMT (envelope-from git) Date: Tue, 24 Aug 2021 12:57:37 GMT Message-Id: <202108241257.17OCvbon079142@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: e59eff9ad328 - main - pfctl: fix killing states by ID MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e59eff9ad3285838730acf48f6d066cec0e53114 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 12:57:37 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=e59eff9ad3285838730acf48f6d066cec0e53114 commit e59eff9ad3285838730acf48f6d066cec0e53114 Author: Kristof Provost AuthorDate: 2021-08-24 10:24:28 +0000 Commit: Kristof Provost CommitDate: 2021-08-24 10:54:13 +0000 pfctl: fix killing states by ID Since the conversion to the new DIOCKILLSTATESNV the kernel no longer exists the id and creatorid to be big-endian. As a result killing states by id (i.e. `pfctl -k id -k 12345`) no longer worked. Reported by: Özkan KIRIK MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") --- sbin/pfctl/pfctl.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index 6c689edf7c43..ad2cfd4e63bc 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -908,7 +908,6 @@ pfctl_id_kill_states(int dev, const char *iface, int opts) if ((sscanf(state_kill[1], "%jx/%x", &kill.cmp.id, &kill.cmp.creatorid)) == 2) - HTONL(kill.cmp.creatorid); else if ((sscanf(state_kill[1], "%jx", &kill.cmp.id)) == 1) { kill.cmp.creatorid = 0; } else { @@ -920,7 +919,6 @@ pfctl_id_kill_states(int dev, const char *iface, int opts) usage(); } - kill.cmp.id = htobe64(kill.cmp.id); if (pfctl_kill_states(dev, &kill, &killed)) err(1, "DIOCKILLSTATES"); From owner-dev-commits-src-main@freebsd.org Tue Aug 24 12:57:38 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B6ADE657458; Tue, 24 Aug 2021 12:57:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gv8KG4gq9z4jRG; Tue, 24 Aug 2021 12:57:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8012CBCB; Tue, 24 Aug 2021 12:57:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17OCvcrE079167; Tue, 24 Aug 2021 12:57:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OCvcQt079166; Tue, 24 Aug 2021 12:57:38 GMT (envelope-from git) Date: Tue, 24 Aug 2021 12:57:38 GMT Message-Id: <202108241257.17OCvcQt079166@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: bbf832f34479 - main - pf tests: test killing states by ID MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: bbf832f34479d19bff0fa8dc43b48ab5553cc85e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 12:57:38 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=bbf832f34479d19bff0fa8dc43b48ab5553cc85e commit bbf832f34479d19bff0fa8dc43b48ab5553cc85e Author: Kristof Provost AuthorDate: 2021-08-24 10:36:57 +0000 Commit: Kristof Provost CommitDate: 2021-08-24 10:54:13 +0000 pf tests: test killing states by ID MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") --- tests/sys/netpfil/pf/killstate.sh | 65 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/tests/sys/netpfil/pf/killstate.sh b/tests/sys/netpfil/pf/killstate.sh index e140ee4d144d..91fa9b42c8be 100644 --- a/tests/sys/netpfil/pf/killstate.sh +++ b/tests/sys/netpfil/pf/killstate.sh @@ -519,6 +519,70 @@ interface_cleanup() pft_cleanup } +atf_test_case "id" "cleanup" +id_head() +{ + atf_set descr 'Test killing states by id' + atf_set require.user root + atf_set require.progs scapy +} + +id_body() +{ + pft_init + + epair=$(vnet_mkepair) + ifconfig ${epair}a 192.0.2.1/24 up + + vnet_mkjail alcatraz ${epair}b + jexec alcatraz ifconfig ${epair}b 192.0.2.2/24 up + jexec alcatraz pfctl -e + + pft_set_rules alcatraz "block all" \ + "pass in proto tcp" \ + "pass in proto icmp" + + # Sanity check & establish state + # Note: use pft_ping so we always use the same ID, so pf considers all + # echo requests part of the same flow. + atf_check -s exit:0 -o ignore ${common_dir}/pft_ping.py \ + --sendif ${epair}a \ + --to 192.0.2.2 \ + --replyif ${epair}a + + # Change rules to now deny the ICMP traffic + pft_set_rules noflush alcatraz "block all" + + # Established state means we can still ping alcatraz + atf_check -s exit:0 -o ignore ${common_dir}/pft_ping.py \ + --sendif ${epair}a \ + --to 192.0.2.2 \ + --replyif ${epair}a + + # Get the state ID + id=$(jexec alcatraz pfctl -ss -vvv | grep -A 3 icmp | + grep -A 3 192.0.2.2 | awk '/id:/ { printf("%s/%s", $2, $4); }') + + # Kill the wrong ID + jexec alcatraz pfctl -k id -k 1 + atf_check -s exit:0 -o ignore ${common_dir}/pft_ping.py \ + --sendif ${epair}a \ + --to 192.0.2.2 \ + --replyif ${epair}a + + # Kill the correct ID + jexec alcatraz pfctl -k id -k ${id} + atf_check -s exit:1 -o ignore ${common_dir}/pft_ping.py \ + --sendif ${epair}a \ + --to 192.0.2.2 \ + --replyif ${epair}a +} + +id_cleanup() +{ + pft_cleanup +} + atf_init_test_cases() { atf_add_test_case "v4" @@ -528,4 +592,5 @@ atf_init_test_cases() atf_add_test_case "gateway" atf_add_test_case "match" atf_add_test_case "interface" + atf_add_test_case "id" } From owner-dev-commits-src-main@freebsd.org Tue Aug 24 13:21:40 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 344756579F0; Tue, 24 Aug 2021 13:21:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gv8s00zdwz4qqf; Tue, 24 Aug 2021 13:21:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0AE5A1061; Tue, 24 Aug 2021 13:21:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17ODLdoc015896; Tue, 24 Aug 2021 13:21:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ODLdTl015895; Tue, 24 Aug 2021 13:21:39 GMT (envelope-from git) Date: Tue, 24 Aug 2021 13:21:39 GMT Message-Id: <202108241321.17ODLdTl015895@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 9ce320820e6d - main - pfctl: build fix MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9ce320820e6d760df11a88de11fbae024c18d23c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 13:21:40 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=9ce320820e6d760df11a88de11fbae024c18d23c commit 9ce320820e6d760df11a88de11fbae024c18d23c Author: Kristof Provost AuthorDate: 2021-08-24 11:21:05 +0000 Commit: Kristof Provost CommitDate: 2021-08-24 11:21:05 +0000 pfctl: build fix Fix the build issue introduced in e59eff9ad328 (pfctl: fix killing states by ID) MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") --- sbin/pfctl/pfctl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index ad2cfd4e63bc..016075058b21 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -907,7 +907,8 @@ pfctl_id_kill_states(int dev, const char *iface, int opts) kill.kill_match = true; if ((sscanf(state_kill[1], "%jx/%x", - &kill.cmp.id, &kill.cmp.creatorid)) == 2) + &kill.cmp.id, &kill.cmp.creatorid)) == 2) { + } else if ((sscanf(state_kill[1], "%jx", &kill.cmp.id)) == 1) { kill.cmp.creatorid = 0; } else { From owner-dev-commits-src-main@freebsd.org Tue Aug 24 13:59:22 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 14BDC6584AC; Tue, 24 Aug 2021 13:59:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gv9hV06drz519p; Tue, 24 Aug 2021 13:59:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E07801987; Tue, 24 Aug 2021 13:59:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17ODxLWp060647; Tue, 24 Aug 2021 13:59:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ODxLsg060646; Tue, 24 Aug 2021 13:59:21 GMT (envelope-from git) Date: Tue, 24 Aug 2021 13:59:21 GMT Message-Id: <202108241359.17ODxLsg060646@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: 37296464defd - main - memcpy.3: remove BUGS section allowing overlapping strings MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 37296464defda0aa769c39ab554deb4875aef000 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 13:59:22 -0000 The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=37296464defda0aa769c39ab554deb4875aef000 commit 37296464defda0aa769c39ab554deb4875aef000 Author: Ed Maste AuthorDate: 2021-08-24 13:20:18 +0000 Commit: Ed Maste CommitDate: 2021-08-24 13:58:10 +0000 memcpy.3: remove BUGS section allowing overlapping strings The removed text claimed that memcpy is implemented using bcopy and thus strings may overlap. Use of bcopy is an implementation detail that is no longer true, even if the implementation (on some archs) does allow overlap. In any case behaviour is undefined per the C standard if memcpy is called with overlapping objects, and this man page already claimed that src and dst may not overlap. Reviewed by: kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31192 --- lib/libc/string/memcpy.3 | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/lib/libc/string/memcpy.3 b/lib/libc/string/memcpy.3 index c65e4145264a..66a91592d90e 100644 --- a/lib/libc/string/memcpy.3 +++ b/lib/libc/string/memcpy.3 @@ -86,19 +86,3 @@ The function conforms to .St -isoC . -.Sh BUGS -In this implementation -.Fn memcpy -and -.Fn mempcpy -are implemented using -.Xr bcopy 3 , -and therefore the strings may overlap. -On other systems, copying overlapping strings may produce surprises. -Programs intended to be portable should use -.Xr memmove 3 -when -.Fa src -and -.Fa dst -may overlap. From owner-dev-commits-src-main@freebsd.org Tue Aug 24 14:05:59 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 008BC658897; Tue, 24 Aug 2021 14:05:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gv9r66ZQmz531w; Tue, 24 Aug 2021 14:05:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C9C4E17FE; Tue, 24 Aug 2021 14:05:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17OE5wSg074498; Tue, 24 Aug 2021 14:05:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OE5wVI074497; Tue, 24 Aug 2021 14:05:58 GMT (envelope-from git) Date: Tue, 24 Aug 2021 14:05:58 GMT Message-Id: <202108241405.17OE5wVI074497@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jessica Clarke Subject: git: ab3a18095fae - main - Makefile.inc1: Make sure sub-makes see MK_CLANG_BOOTSTRAP=no when XCC is a path MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jrtc27 X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ab3a18095faebe306989f25288c44968f4144063 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 14:05:59 -0000 The branch main has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=ab3a18095faebe306989f25288c44968f4144063 commit ab3a18095faebe306989f25288c44968f4144063 Author: Jessica Clarke AuthorDate: 2021-08-24 13:55:31 +0000 Commit: Jessica Clarke CommitDate: 2021-08-24 14:04:25 +0000 Makefile.inc1: Make sure sub-makes see MK_CLANG_BOOTSTRAP=no when XCC is a path Currently we override MK_CLANG_BOOTSTRAP to no so we don't build a bootstrap compiler, but subdirectories don't see that and so the hack in bsd.sys.mk to prefer our includes over Clang's resource dir for external toolchains is not enabled unless you use -DWITHOUT_CLANG_BOOTSTRAP explicitly on top of XCC (which tools/build/make.py does not do), causing duplicate definition errors when building rtld-elf due to the use of -ffreestanding (Clang's stdint.h will use the system one when hosted, but its own when freestanding, and only has glibc's preprocessor guards, not FreeBSD's). This broke when dropping CLANG_BOOTSTRAP from BROKEN_OPTIONS. Fixes: 31ba4ce8898f ("Allow bootstrapping llvm-tblgen on macOS and Linux") MFC after: 1 week Reviewed by: imp, arichardson Differential Revision: https://reviews.freebsd.org/D31529 --- Makefile.inc1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile.inc1 b/Makefile.inc1 index 5bb2412e4042..604fef201c48 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -93,6 +93,9 @@ X${COMPILER}?= ${${COMPILER}} # a cross compiler. .if ${XCC:N${CCACHE_BIN}:M/*} MK_CLANG_BOOTSTRAP= no +# Make sure sub-makes see the option as disabled so the hack in bsd.sys.mk to +# work around incompatible headers in Clang's resource directory is enabled. +.MAKEOVERRIDES+= MK_CLANG_BOOTSTRAP .endif # Pull in compiler metadata from buildworld/toolchain if possible to avoid From owner-dev-commits-src-main@freebsd.org Tue Aug 24 14:06:00 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 35DEF65869C; Tue, 24 Aug 2021 14:06:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gv9r80wdbz52yy; Tue, 24 Aug 2021 14:06:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F329717FF; Tue, 24 Aug 2021 14:05:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17OE5xhT074522; Tue, 24 Aug 2021 14:05:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OE5xcf074521; Tue, 24 Aug 2021 14:05:59 GMT (envelope-from git) Date: Tue, 24 Aug 2021 14:05:59 GMT Message-Id: <202108241405.17OE5xcf074521@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jessica Clarke Subject: git: 1e4c802913af - main - Fix bootstrapping to actually build lldb-tblgen for later use MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jrtc27 X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1e4c802913af619ac15741bbd276e1141ca17dc9 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 14:06:00 -0000 The branch main has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=1e4c802913af619ac15741bbd276e1141ca17dc9 commit 1e4c802913af619ac15741bbd276e1141ca17dc9 Author: Jessica Clarke AuthorDate: 2021-08-24 13:59:04 +0000 Commit: Jessica Clarke CommitDate: 2021-08-24 14:04:25 +0000 Fix bootstrapping to actually build lldb-tblgen for later use Because MK_LLDB=no is in BSARGS, the bootstrap-tools recursive make does not add lldb-tblgen to _clang_tblgen, causing it to not be built. This means that the build currently always uses the host's lldb-tblgen (which, whilst currently it appears to work, could in future break if TableGen backends are added or altered) and, if it doesn't exist (either because the current FreeBSD system was built with it disabled, or you're building on macOS/Linux), fails. Linux and macOS cross-builds used to work simply because LLDB was previously in BROKEN_OPTIONS when building on non-FreeBSD. Instead, move MK_LLDB=no from BSARGS to XMAKE. This ensures that the lib/clang build in cross-tools continues to not build LLDB parts for the bootstrap toolchain (both to save time/space on FreeBSD, and because our vendored LLDB does not include the macOS and Linux host files so those would fail to build). The DIRDEPS target is updated to move MK_LLDB=no from the BSARGS block that mirrors Makefile.inc1 to the line that disables additional toolchain components. The DIRDEPS build likely suffers from the same issue currently, but having never used it and not being familiar with how it works I am leaving that as-is. If it does suffer from the same issue it should be easily reproducible by renaming /usr/bin/lldb-tblgen or moving it to a directory not in PATH. Fixes: 31ba4ce8898f ("Allow bootstrapping llvm-tblgen on macOS and Linux") MFC after: 1 week Reviewed by: dim, emaste, imp Differential Revision: https://reviews.freebsd.org/D31531 --- Makefile.inc1 | 2 +- targets/pseudo/bootstrap-tools/Makefile | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Makefile.inc1 b/Makefile.inc1 index 604fef201c48..b59c1913f8ce 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -727,7 +727,6 @@ BSARGS= DESTDIR= \ MK_CLANG_FORMAT=no \ MK_CLANG_FULL=no \ MK_HTML=no \ - MK_LLDB=no \ MK_MAN=no \ MK_PROFILE=no \ MK_RETPOLINE=no \ @@ -771,6 +770,7 @@ TMAKE= \ XMAKE= ${BMAKE} \ TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \ MK_CLANG_IS_CC=${MK_CLANG_BOOTSTRAP} \ + MK_LLDB=no \ MK_TESTS=no # kernel-tools stage diff --git a/targets/pseudo/bootstrap-tools/Makefile b/targets/pseudo/bootstrap-tools/Makefile index 3ac47053a388..d5545f082283 100644 --- a/targets/pseudo/bootstrap-tools/Makefile +++ b/targets/pseudo/bootstrap-tools/Makefile @@ -48,7 +48,6 @@ BSARGS= DESTDIR= \ MK_CLANG_FORMAT=no \ MK_CLANG_FULL=no \ MK_HTML=no \ - MK_LLDB=no \ MK_MAN=no \ MK_PROFILE=no \ MK_RETPOLINE=no \ @@ -59,7 +58,7 @@ BSARGS= DESTDIR= \ MK_MAN_UTILS=yes # We will handle building the toolchain and cross-compiler. -BSARGS+= MK_CROSS_COMPILER=no MK_CLANG=no +BSARGS+= MK_CROSS_COMPILER=no MK_CLANG=no MK_LLDB=no DISTRIB_ENV= INSTALL="sh ${SRCTOP}/tools/install.sh" NO_FSCHG=1 MK_TESTS=no legacy: .MAKE ${META_DEPS} From owner-dev-commits-src-main@freebsd.org Tue Aug 24 14:06:01 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 92D0D658455; Tue, 24 Aug 2021 14:06:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gv9r933srz533W; Tue, 24 Aug 2021 14:06:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3418E1739; Tue, 24 Aug 2021 14:06:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17OE61ue074546; Tue, 24 Aug 2021 14:06:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OE619s074545; Tue, 24 Aug 2021 14:06:01 GMT (envelope-from git) Date: Tue, 24 Aug 2021 14:06:01 GMT Message-Id: <202108241406.17OE619s074545@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jessica Clarke Subject: git: c8edd0542647 - main - clang: Support building with GCC and DEBUG_FILES disabled MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jrtc27 X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c8edd0542647f59ab07dd73e865edd34706397a5 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 14:06:01 -0000 The branch main has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=c8edd0542647f59ab07dd73e865edd34706397a5 commit c8edd0542647f59ab07dd73e865edd34706397a5 Author: Jessica Clarke AuthorDate: 2021-08-24 13:59:18 +0000 Commit: Jessica Clarke CommitDate: 2021-08-24 14:04:25 +0000 clang: Support building with GCC and DEBUG_FILES disabled If MK_DEBUG_FILES=no then the Clang link rule has clang as .TARGET, rather than clang.full, causing the implicit ${CFLAGS.${.TARGET:T}} to be CFLAGS.clang, and thus pull in flags intended for when your compiler is Clang, not when linking Clang itself. This doesn't matter if your compiler is in fact Clang, but it breaks using GCC as, for example, bsd.sys.mk adds -Qunused-arguments to CFLAGS.clang. This is seen when trying to build a bootstrap toolchain on Linux where GCC is the system compiler. Thus, introduce a new internal NO_TARGET_FLAGS variable that is set by Clang to disable the addition of these implicit flags. This is a bigger hammer than necessary, as flags for .o files would be safe, but that is not needed for Clang. Note that the same problem does not arise for LDFLAGS when building LLD with BFD, since our build produces a program called ld.lld, not plain lld (unlike upstream, where ld.lld is a symlink to lld so they can support multiple different flavours in one binary). Suggested by: sjg Fixes: 31ba4ce8898f ("Allow bootstrapping llvm-tblgen on macOS and Linux") MFC after: 1 week Reviewed by: dim, imp, emaste Differential Revision: https://reviews.freebsd.org/D31532 --- share/mk/bsd.sys.mk | 9 ++++++++- usr.bin/clang/clang/Makefile | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk index a964cf6e596c..80cc3080e552 100644 --- a/share/mk/bsd.sys.mk +++ b/share/mk/bsd.sys.mk @@ -273,7 +273,14 @@ LDFLAGS+= ${LDFLAGS.${LINKER_TYPE}} # Only allow .TARGET when not using PROGS as it has the same syntax # per PROG which is ambiguous with this syntax. This is only needed # for PROG_VARS vars. -.if !defined(_RECURSING_PROGS) +# +# Some directories (currently just clang) also need to disable this since +# CFLAGS.${COMPILER_TYPE}, CFLAGS.${.IMPSRC:T} and CFLAGS.${.TARGET:T} all live +# in the same namespace, meaning that, for example, GCC builds of clang pick up +# CFLAGS.clang via CFLAGS.${.TARGET:T} and thus try to pass Clang-specific +# flags. Ideally the different sources of CFLAGS would be namespaced to avoid +# collisions. +.if !defined(_RECURSING_PROGS) && !defined(NO_TARGET_FLAGS) .if ${MK_WARNS} != "no" CFLAGS+= ${CWARNFLAGS.${.TARGET:T}} .endif diff --git a/usr.bin/clang/clang/Makefile b/usr.bin/clang/clang/Makefile index ec42fe78cf90..31f092608583 100644 --- a/usr.bin/clang/clang/Makefile +++ b/usr.bin/clang/clang/Makefile @@ -34,4 +34,7 @@ MLINKS+= clang.1 cc.1 \ LIBADD+= z +# Ensure we don't add CFLAGS.clang when using GCC +NO_TARGET_FLAGS= + .include "../clang.prog.mk" From owner-dev-commits-src-main@freebsd.org Tue Aug 24 14:06:02 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8737D6581D4; Tue, 24 Aug 2021 14:06:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gv9rB2s2jz533Z; Tue, 24 Aug 2021 14:06:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4102F1C96; Tue, 24 Aug 2021 14:06:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17OE62li074574; Tue, 24 Aug 2021 14:06:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OE62Cq074573; Tue, 24 Aug 2021 14:06:02 GMT (envelope-from git) Date: Tue, 24 Aug 2021 14:06:02 GMT Message-Id: <202108241406.17OE62Cq074573@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jessica Clarke Subject: git: c1f7d8dd23db - main - clang: Build with -fno-strict-aliasing when using GCC MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jrtc27 X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c1f7d8dd23db693106fcd66e0b1766a3f3194670 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 14:06:02 -0000 The branch main has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=c1f7d8dd23db693106fcd66e0b1766a3f3194670 commit c1f7d8dd23db693106fcd66e0b1766a3f3194670 Author: Jessica Clarke AuthorDate: 2021-08-24 13:59:36 +0000 Commit: Jessica Clarke CommitDate: 2021-08-24 14:04:25 +0000 clang: Build with -fno-strict-aliasing when using GCC Somewhat ironically, there are strict aliasing violations in Clang, which can result in the following assertion failure: Assertion `*(NamedDecl **)&Data == ND && "PointerUnion mangles the NamedDecl pointer!"' failed. Upstream's clang/CMakeLists.txt specifically (not LLVM as a whole) passes -fno-strict-aliasing if the compiler is not Clang, and this fixes the above issue. This was seen when cross-building from Linux using a bootstrap compiler, but likely also affects worlds built with a new enough external GCC toolchain. MFC after: 1 week Reviewed by: dim Differential Revision: https://reviews.freebsd.org/D31533 --- lib/clang/clang.build.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/clang/clang.build.mk b/lib/clang/clang.build.mk index 0d3151178eb9..fb64b16935f2 100644 --- a/lib/clang/clang.build.mk +++ b/lib/clang/clang.build.mk @@ -13,4 +13,6 @@ CFLAGS+= -DCLANG_ENABLE_ARCMT CFLAGS+= -DCLANG_ENABLE_STATIC_ANALYZER .endif +CFLAGS.gcc+= -fno-strict-aliasing + .include "llvm.build.mk" From owner-dev-commits-src-main@freebsd.org Tue Aug 24 14:06:03 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A82626582C6; Tue, 24 Aug 2021 14:06:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gv9rC3vkhz52nq; Tue, 24 Aug 2021 14:06:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 64AD01D00; Tue, 24 Aug 2021 14:06:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17OE63ZF074601; Tue, 24 Aug 2021 14:06:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OE63aY074600; Tue, 24 Aug 2021 14:06:03 GMT (envelope-from git) Date: Tue, 24 Aug 2021 14:06:03 GMT Message-Id: <202108241406.17OE63aY074600@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jessica Clarke Subject: git: 83ec48b79275 - main - Revert "Mark LLDB/CLANG_BOOTSTRAP/LLD_BOOTSTRAP as broken on non-FreeBSD for now" MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jrtc27 X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 83ec48b79275b5211b06675dba04dab1f58c3a70 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 14:06:04 -0000 The branch main has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=83ec48b79275b5211b06675dba04dab1f58c3a70 commit 83ec48b79275b5211b06675dba04dab1f58c3a70 Author: Jessica Clarke AuthorDate: 2021-08-24 14:00:06 +0000 Commit: Jessica Clarke CommitDate: 2021-08-24 14:04:25 +0000 Revert "Mark LLDB/CLANG_BOOTSTRAP/LLD_BOOTSTRAP as broken on non-FreeBSD for now" The fixes for this have now been committed so we can re-enable these. This reverts commit d9f25575a29ff7c83f226349a10a37b9aaf75ad5. MFC after: 1 week --- share/mk/src.opts.mk | 7 ------- 1 file changed, 7 deletions(-) diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk index e4427cb637a1..bd360dd1ad29 100644 --- a/share/mk/src.opts.mk +++ b/share/mk/src.opts.mk @@ -360,13 +360,6 @@ __DEFAULT_YES_OPTIONS+=OPENMP __DEFAULT_NO_OPTIONS+=OPENMP .endif -.if ${.MAKE.OS} != "FreeBSD" -# Bootstrapping the toolchain and building LLDB currently results in build -# failures non-FreeBSD, so disable these options until the fixes that are -# currently under review have landed. -BROKEN_OPTIONS+=LLDB CLANG_BOOTSTRAP LLD_BOOTSTRAP -.endif - .include # From owner-dev-commits-src-main@freebsd.org Tue Aug 24 14:24:40 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8DD72658FA1; Tue, 24 Aug 2021 14:24:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvBFh3Ktyz57lr; Tue, 24 Aug 2021 14:24:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5A98C177E; Tue, 24 Aug 2021 14:24:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17OEOeWG000498; Tue, 24 Aug 2021 14:24:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OEOePe000497; Tue, 24 Aug 2021 14:24:40 GMT (envelope-from git) Date: Tue, 24 Aug 2021 14:24:40 GMT Message-Id: <202108241424.17OEOePe000497@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 80b1995bb5d6 - main - arm: export actlr as sysctl hw.cpu.quirks.actlr_value MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 80b1995bb5d6e4a962c9a53ddede2420c299d9e4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 14:24:40 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=80b1995bb5d6e4a962c9a53ddede2420c299d9e4 commit 80b1995bb5d6e4a962c9a53ddede2420c299d9e4 Author: Mateusz Guzik AuthorDate: 2021-08-24 14:20:13 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-24 14:21:39 +0000 arm: export actlr as sysctl hw.cpu.quirks.actlr_value Reviewed by: cognet Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/arm/arm/cpuinfo.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sys/arm/arm/cpuinfo.c b/sys/arm/arm/cpuinfo.c index a14fc578cd05..7a60fa335bc6 100644 --- a/sys/arm/arm/cpuinfo.c +++ b/sys/arm/arm/cpuinfo.c @@ -77,6 +77,19 @@ SYSCTL_INT(_hw_cpu_quirks, OID_AUTO, actlr_set, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &cpu_quirks_actlr_set, 0, "Bits to be set in ACTLR"); +static int +sysctl_hw_cpu_quirks_actrl_value(SYSCTL_HANDLER_ARGS) +{ + uint32_t reg; + + reg = cp15_actlr_get(); + return (SYSCTL_OUT(req, ®, sizeof(reg))); +} +SYSCTL_PROC(_hw_cpu_quirks, OID_AUTO, actlr_value, + CTLTYPE_UINT | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, + sysctl_hw_cpu_quirks_actrl_value, "IU", + "Value of ACTLR"); + /* Read and parse CPU id scheme */ void cpuinfo_init(void) From owner-dev-commits-src-main@freebsd.org Tue Aug 24 15:49:32 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8966165A6B2; Tue, 24 Aug 2021 15:49:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvD7c3GXqz3q9n; Tue, 24 Aug 2021 15:49:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5875531E1; Tue, 24 Aug 2021 15:49:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17OFnWcB007481; Tue, 24 Aug 2021 15:49:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OFnWXQ007480; Tue, 24 Aug 2021 15:49:32 GMT (envelope-from git) Date: Tue, 24 Aug 2021 15:49:32 GMT Message-Id: <202108241549.17OFnWXQ007480@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ka Ho Ng Subject: git: c12118f6cec0 - main - tmpfs: Fix styles MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c12118f6cec0ca5f720be6c06d6c59d551461e5a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 15:49:32 -0000 The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=c12118f6cec0ca5f720be6c06d6c59d551461e5a commit c12118f6cec0ca5f720be6c06d6c59d551461e5a Author: Ka Ho Ng AuthorDate: 2021-08-24 13:09:21 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-24 14:45:08 +0000 tmpfs: Fix styles A lot of return statements were in the wrong style before this commit. Sponsored by: The FreeBSD Foundation MFC after: 3 days --- sys/fs/tmpfs/tmpfs_subr.c | 6 +++--- sys/fs/tmpfs/tmpfs_vfsops.c | 4 ++-- sys/fs/tmpfs/tmpfs_vnops.c | 26 +++++++++++++------------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c index b7dae82a71b4..387bc741e3cf 100644 --- a/sys/fs/tmpfs/tmpfs_subr.c +++ b/sys/fs/tmpfs/tmpfs_subr.c @@ -714,7 +714,7 @@ tmpfs_alloc_dirent(struct tmpfs_mount *tmp, struct tmpfs_node *node, *de = nde; - return 0; + return (0); } /* @@ -1861,11 +1861,11 @@ tmpfs_chmod(struct vnode *vp, mode_t mode, struct ucred *cred, struct thread *p) /* Disallow this operation if the file system is mounted read-only. */ if (vp->v_mount->mnt_flag & MNT_RDONLY) - return EROFS; + return (EROFS); /* Immutable or append-only files cannot be modified, either. */ if (node->tn_flags & (IMMUTABLE | APPEND)) - return EPERM; + return (EPERM); /* * To modify the permissions on a file, must possess VADMIN diff --git a/sys/fs/tmpfs/tmpfs_vfsops.c b/sys/fs/tmpfs/tmpfs_vfsops.c index 7dffb9027946..b8ecedbb0348 100644 --- a/sys/fs/tmpfs/tmpfs_vfsops.c +++ b/sys/fs/tmpfs/tmpfs_vfsops.c @@ -479,7 +479,7 @@ tmpfs_mount(struct mount *mp) vfs_getnewfsid(mp); vfs_mountedfrom(mp, "tmpfs"); - return 0; + return (0); } /* ARGSUSED2 */ @@ -644,7 +644,7 @@ tmpfs_statfs(struct mount *mp, struct statfs *sbp) sbp->f_ffree = sbp->f_files - used; /* sbp->f_owner = tmp->tn_uid; */ - return 0; + return (0); } static int diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c index 5d0d80639046..325b8d2789bb 100644 --- a/sys/fs/tmpfs/tmpfs_vnops.c +++ b/sys/fs/tmpfs/tmpfs_vnops.c @@ -277,9 +277,9 @@ tmpfs_mknod(struct vop_mknod_args *v) if (vap->va_type != VBLK && vap->va_type != VCHR && vap->va_type != VFIFO) - return EINVAL; + return (EINVAL); - return tmpfs_alloc_file(dvp, vpp, vap, cnp, NULL); + return (tmpfs_alloc_file(dvp, vpp, vap, cnp, NULL)); } struct fileops tmpfs_fnops; @@ -517,7 +517,7 @@ tmpfs_getattr(struct vop_getattr_args *v) vap->va_bytes = node->tn_size; vap->va_filerev = 0; - return 0; + return (0); } int @@ -575,7 +575,7 @@ tmpfs_setattr(struct vop_setattr_args *v) MPASS(VOP_ISLOCKED(vp)); - return error; + return (error); } static int @@ -705,7 +705,7 @@ tmpfs_fsync(struct vop_fsync_args *v) tmpfs_check_mtime(vp); tmpfs_update(vp); - return 0; + return (0); } static int @@ -808,7 +808,7 @@ tmpfs_link(struct vop_link_args *v) error = 0; out: - return error; + return (0); } /* @@ -1264,7 +1264,7 @@ tmpfs_mkdir(struct vop_mkdir_args *v) MPASS(vap->va_type == VDIR); - return tmpfs_alloc_file(dvp, vpp, vap, cnp, NULL); + return (tmpfs_alloc_file(dvp, vpp, vap, cnp, NULL)); } static int @@ -1355,7 +1355,7 @@ tmpfs_rmdir(struct vop_rmdir_args *v) error = 0; out: - return error; + return (error); } static int @@ -1373,7 +1373,7 @@ tmpfs_symlink(struct vop_symlink_args *v) vap->va_type = VLNK; #endif - return tmpfs_alloc_file(dvp, vpp, vap, cnp, target); + return (tmpfs_alloc_file(dvp, vpp, vap, cnp, target)); } static int @@ -1396,7 +1396,7 @@ tmpfs_readdir(struct vop_readdir_args *va) /* This operation only makes sense on directory nodes. */ if (vp->v_type != VDIR) - return ENOTDIR; + return (ENOTDIR); maxcookies = 0; node = VP_TO_TMPFS_DIR(vp); @@ -1433,7 +1433,7 @@ tmpfs_readdir(struct vop_readdir_args *va) *eofflag = (error == 0 && uio->uio_offset == TMPFS_DIRCOOKIE_EOF); - return error; + return (error); } static int @@ -1580,7 +1580,7 @@ tmpfs_print(struct vop_print_args *v) printf("\n"); - return 0; + return (0); } int @@ -1634,7 +1634,7 @@ tmpfs_pathconf(struct vop_pathconf_args *v) error = vop_stdpathconf(v); } - return error; + return (error); } static int From owner-dev-commits-src-main@freebsd.org Tue Aug 24 15:49:33 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D957065A536; Tue, 24 Aug 2021 15:49:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvD7d5VGkz3qD4; Tue, 24 Aug 2021 15:49:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7BA8431E2; Tue, 24 Aug 2021 15:49:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17OFnXik007505; Tue, 24 Aug 2021 15:49:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OFnXA0007504; Tue, 24 Aug 2021 15:49:33 GMT (envelope-from git) Date: Tue, 24 Aug 2021 15:49:33 GMT Message-Id: <202108241549.17OFnXA0007504@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ka Ho Ng Subject: git: 5c1428d2c4a6 - main - uipc_shm: Handle offset on shm_size as if it is beyond shm_size MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5c1428d2c4a63ae373181579b3af35d7e12f2e7c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 15:49:34 -0000 The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=5c1428d2c4a63ae373181579b3af35d7e12f2e7c commit 5c1428d2c4a63ae373181579b3af35d7e12f2e7c Author: Ka Ho Ng AuthorDate: 2021-08-24 14:39:43 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-24 15:49:18 +0000 uipc_shm: Handle offset on shm_size as if it is beyond shm_size This avoids any unnecessary works in such case. Sponsored by: The FreeBSD Foundation Reviewed by: markj, kib Differential Revision: https://reviews.freebsd.org/D31655 --- sys/kern/uipc_shm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/kern/uipc_shm.c b/sys/kern/uipc_shm.c index 60815ef24c26..c632c7f150df 100644 --- a/sys/kern/uipc_shm.c +++ b/sys/kern/uipc_shm.c @@ -1915,8 +1915,8 @@ shm_deallocate(struct shmfd *shmfd, off_t *offset, off_t *length, int flags) pi = OFF_TO_IDX(off + PAGE_MASK); error = 0; - /* Handle the case when offset is beyond shm size */ - if ((off_t)len < 0) { + /* Handle the case when offset is on or beyond shm size. */ + if ((off_t)len <= 0) { *offset = shmfd->shm_size; *length = 0; return (0); From owner-dev-commits-src-main@freebsd.org Tue Aug 24 16:37:16 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 571F065ACDA; Tue, 24 Aug 2021 16:37:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvFBh243cz4YB1; Tue, 24 Aug 2021 16:37:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2FFA14088; Tue, 24 Aug 2021 16:37:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17OGbGFW074300; Tue, 24 Aug 2021 16:37:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OGbGVi074299; Tue, 24 Aug 2021 16:37:16 GMT (envelope-from git) Date: Tue, 24 Aug 2021 16:37:16 GMT Message-Id: <202108241637.17OGbGVi074299@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ka Ho Ng Subject: git: a48416f844e3 - main - tmpfs: Fix error being cleared after commit c12118f6cec0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a48416f844e3007b4e9f6df125e25cf3a1daad62 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 16:37:16 -0000 The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=a48416f844e3007b4e9f6df125e25cf3a1daad62 commit a48416f844e3007b4e9f6df125e25cf3a1daad62 Author: Ka Ho Ng AuthorDate: 2021-08-24 16:35:29 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-24 16:35:29 +0000 tmpfs: Fix error being cleared after commit c12118f6cec0 In tmpfs_link() error was erroneously cleared in commit c12118f6cec0. Sponsored by: The FreeBSD Foundation MFC after: 3 days MFC with: c12118f6cec0 --- sys/fs/tmpfs/tmpfs_vnops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c index 325b8d2789bb..326a5132990d 100644 --- a/sys/fs/tmpfs/tmpfs_vnops.c +++ b/sys/fs/tmpfs/tmpfs_vnops.c @@ -808,7 +808,7 @@ tmpfs_link(struct vop_link_args *v) error = 0; out: - return (0); + return (error); } /* From owner-dev-commits-src-main@freebsd.org Tue Aug 24 16:45:02 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4817965B3EC; Tue, 24 Aug 2021 16:45:02 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvFMf109Cz4ZZ8; Tue, 24 Aug 2021 16:45:02 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-lf1-x12a.google.com with SMTP id o10so46829461lfr.11; Tue, 24 Aug 2021 09:45:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=ja/3H8dl+/XQh34gBZZfcOranCJ+xED03YFPnFzo5Gs=; b=HMJgfJgAcx9GHRDXJPexI06ENHgHthalpvxuRkXcilg7Ca4PRfVXrr+dSlz54sTBYB DFT78nKLt47phYL2wn2wWvJYgCSO9ToGjfa+AcClwIYcYuyXVdPDyne2YGNe2iJS02Sa CIZHhbuAbE1B2w0GpVp0v0Mg9Bj4LaK6+qyMjSgE+s7N4kkQlNAY8hyhy5D3U0Zf4sjS 3s6+z/4siAYblE8rH4bxWX+R9HJgVhUsG+9Od/rDpW+jyoTNhYWAecEEq/YcGDwXOLjF GGw0IT+2esQc3SGiOd/RPKtYCzfOiQSkL2hoBiZ7MSYtfwYfwnPkqVFwY1BYEgaOiIqE eY2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=ja/3H8dl+/XQh34gBZZfcOranCJ+xED03YFPnFzo5Gs=; b=Szd0VeZ/d43otKzKfpdd1BYLgM7lwsHEco67rR7RNyTRWEJhcGmQGOcWG9mEUxSk72 djeaUDR2an9iVHEEqta7oz1tbuq6ZH+yAqXs/SNzWQJ70V1kHiyJKEW2yFToLUs7O2IS gFRg3L79WVydhVo+vVSfcJsb+BmF+tNUxemvONxOe2nMlUdtcglbjQ7BmeyPvl7op6Ur GBcIIf/sm6ypI/6IHLeSXN41eFIPlmD1UaLMmFFA7PtkogLAN7E78z/sa5/K9IDqnkFO h0/QR7EzPdtYcP5O773FO2pHzNV9MIwbMS8xa36MJVfvNWizkGhTkk3WKa/voGS3kG0j Jn9Q== X-Gm-Message-State: AOAM531Ti9YfEdA72ZGZ8lB4QDrK4w2ON4GETC5AS4KWcAM766OVJVLq xs7TdjtxiyDEXUSGa56gj0vsZkoeJ9GatxL17zTUQDHL X-Google-Smtp-Source: ABdhPJwqBfU6h0yyuEOneACd6D2NJ88RASFxKan/hefsKImgUSvTtGemrznqitY0UqWSNjdZAA4mQZ8nZn4STXcjG4I= X-Received: by 2002:a05:6512:541:: with SMTP id h1mr28854325lfl.118.1629823494757; Tue, 24 Aug 2021 09:44:54 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a2e:6f04:0:0:0:0:0 with HTTP; Tue, 24 Aug 2021 09:44:54 -0700 (PDT) In-Reply-To: <202108241637.17OGbGVi074299@gitrepo.freebsd.org> References: <202108241637.17OGbGVi074299@gitrepo.freebsd.org> From: Mateusz Guzik Date: Tue, 24 Aug 2021 18:44:54 +0200 Message-ID: Subject: Re: git: a48416f844e3 - main - tmpfs: Fix error being cleared after commit c12118f6cec0 To: Ka Ho Ng Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4GvFMf109Cz4ZZ8 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 16:45:02 -0000 On 8/24/21, Ka Ho Ng wrote: > The branch main has been updated by khng: > > URL: > https://cgit.FreeBSD.org/src/commit/?id=a48416f844e3007b4e9f6df125e25cf3a1daad62 > > commit a48416f844e3007b4e9f6df125e25cf3a1daad62 > Author: Ka Ho Ng > AuthorDate: 2021-08-24 16:35:29 +0000 > Commit: Ka Ho Ng > CommitDate: 2021-08-24 16:35:29 +0000 > > tmpfs: Fix error being cleared after commit c12118f6cec0 > > In tmpfs_link() error was erroneously cleared in commit c12118f6cec0. > > Sponsored by: The FreeBSD Foundation > MFC after: 3 days > MFC with: c12118f6cec0 > --- > sys/fs/tmpfs/tmpfs_vnops.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c > index 325b8d2789bb..326a5132990d 100644 > --- a/sys/fs/tmpfs/tmpfs_vnops.c > +++ b/sys/fs/tmpfs/tmpfs_vnops.c > @@ -808,7 +808,7 @@ tmpfs_link(struct vop_link_args *v) > error = 0; > > out: > - return (0); > + return (error); > } > You should use coccinelle for changs like this. > /* > -- Mateusz Guzik From owner-dev-commits-src-main@freebsd.org Tue Aug 24 18:27:54 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3357065D286; Tue, 24 Aug 2021 18:27:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvHfL0YRwz3MwH; Tue, 24 Aug 2021 18:27:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EF9C15AEB; Tue, 24 Aug 2021 18:27:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17OIRr0t022912; Tue, 24 Aug 2021 18:27:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OIRrOP022911; Tue, 24 Aug 2021 18:27:53 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:27:53 GMT Message-Id: <202108241827.17OIRrOP022911@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Tetlow Subject: git: 91a8bed5a49e - main - Fix remote code execution in ggatec(8). MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 91a8bed5a49eb2d1e4e096a4c68c108cebec8818 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:27:54 -0000 The branch main has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=91a8bed5a49eb2d1e4e096a4c68c108cebec8818 commit 91a8bed5a49eb2d1e4e096a4c68c108cebec8818 Author: Gordon Tetlow AuthorDate: 2021-08-24 17:40:49 +0000 Commit: Gordon Tetlow CommitDate: 2021-08-24 18:26:45 +0000 Fix remote code execution in ggatec(8). Approved by: so Security: SA-21:14.ggatec Security: CVE-2021-29630 --- sbin/ggate/ggatec/ggatec.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sbin/ggate/ggatec/ggatec.c b/sbin/ggate/ggatec/ggatec.c index 45a93c4512fe..0695dae0dca2 100644 --- a/sbin/ggate/ggatec/ggatec.c +++ b/sbin/ggate/ggatec/ggatec.c @@ -145,7 +145,21 @@ send_thread(void *arg __unused) case BIO_WRITE: hdr.gh_cmd = GGATE_CMD_WRITE; break; + default: + g_gate_log(LOG_NOTICE, "Unknown gctl_cmd: %i", ggio.gctl_cmd); + ggio.gctl_error = EOPNOTSUPP; + g_gate_ioctl(G_GATE_CMD_DONE, &ggio); + continue; + } + + /* Don't send requests for more data than we can handle the response for! */ + if (ggio.gctl_length > MAXPHYS) { + g_gate_log(LOG_ERR, "Request too big: %zd", ggio.gctl_length); + ggio.gctl_error = EOPNOTSUPP; + g_gate_ioctl(G_GATE_CMD_DONE, &ggio); + continue; } + hdr.gh_seq = ggio.gctl_seq; hdr.gh_offset = ggio.gctl_offset; hdr.gh_length = ggio.gctl_length; @@ -219,6 +233,12 @@ recv_thread(void *arg __unused) ggio.gctl_length = hdr.gh_length; ggio.gctl_error = hdr.gh_error; + /* Do not overflow our buffer if there is a bogus response. */ + if (ggio.gctl_length > (off_t) sizeof(buf)) { + g_gate_log(LOG_ERR, "Received too big response: %zd", ggio.gctl_length); + break; + } + if (ggio.gctl_error == 0 && ggio.gctl_cmd == GGATE_CMD_READ) { data = g_gate_recv(recvfd, ggio.gctl_data, ggio.gctl_length, MSG_WAITALL); From owner-dev-commits-src-main@freebsd.org Tue Aug 24 18:27:55 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3FB2965D482; Tue, 24 Aug 2021 18:27:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvHfM1Ngdz3Myk; Tue, 24 Aug 2021 18:27:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 178495AEC; Tue, 24 Aug 2021 18:27:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17OIRtRA022936; Tue, 24 Aug 2021 18:27:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OIRs3h022935; Tue, 24 Aug 2021 18:27:54 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:27:54 GMT Message-Id: <202108241827.17OIRs3h022935@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Tetlow Subject: git: 64ae2f785e06 - main - Fix libfetch out of bounds read. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 64ae2f785e0672286901c15045a24cbc533538d3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:27:55 -0000 The branch main has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=64ae2f785e0672286901c15045a24cbc533538d3 commit 64ae2f785e0672286901c15045a24cbc533538d3 Author: Gordon Tetlow AuthorDate: 2021-08-24 17:59:01 +0000 Commit: Gordon Tetlow CommitDate: 2021-08-24 18:26:45 +0000 Fix libfetch out of bounds read. Approved by: so Security: SA-21:15.libfetch Security: CVE-2021-36159 --- lib/libfetch/ftp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/libfetch/ftp.c b/lib/libfetch/ftp.c index 9a546f3fecad..dfde6edce734 100644 --- a/lib/libfetch/ftp.c +++ b/lib/libfetch/ftp.c @@ -704,8 +704,11 @@ ftp_transfer(conn_t *conn, const char *oper, const char *file, goto ouch; } l = (e == FTP_PASSIVE_MODE ? 6 : 21); - for (i = 0; *p && i < l; i++, p++) + for (i = 0; *p && i < l; i++, p++) { addr[i] = strtol(p, &p, 10); + if (*p == '\0' && i < l - 1) + break; + } if (i < l) { e = FTP_PROTOCOL_ERROR; goto ouch; From owner-dev-commits-src-main@freebsd.org Tue Aug 24 18:27:56 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 883BF65D030; Tue, 24 Aug 2021 18:27:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvHfN38l8z3N9F; Tue, 24 Aug 2021 18:27:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 36B7059BE; Tue, 24 Aug 2021 18:27:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17OIRu0P022960; Tue, 24 Aug 2021 18:27:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OIRuUx022959; Tue, 24 Aug 2021 18:27:56 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:27:56 GMT Message-Id: <202108241827.17OIRuUx022959@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Tetlow Subject: git: aef815e7873b - main - Fix multiple OpenSSL vulnerabilities. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: aef815e7873b006bd040ac1690425709635e32e7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:27:56 -0000 The branch main has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=aef815e7873b006bd040ac1690425709635e32e7 commit aef815e7873b006bd040ac1690425709635e32e7 Author: Gordon Tetlow AuthorDate: 2021-08-24 18:03:46 +0000 Commit: Gordon Tetlow CommitDate: 2021-08-24 18:26:45 +0000 Fix multiple OpenSSL vulnerabilities. Approved by: so Security: SA-21:16.openssl Security: CVE-2021-3711 Security: CVE-2021-3712 --- crypto/openssl/crypto/asn1/asn1_lib.c | 12 ++++- crypto/openssl/crypto/asn1/t_spki.c | 2 +- crypto/openssl/crypto/ec/ec_asn1.c | 5 +- crypto/openssl/crypto/sm2/sm2_crypt.c | 27 +++++------ crypto/openssl/crypto/sm2/sm2_pmeth.c | 2 +- crypto/openssl/crypto/x509v3/v3_akey.c | 38 +++++++++++++-- crypto/openssl/crypto/x509v3/v3_alt.c | 10 ++-- crypto/openssl/crypto/x509v3/v3_cpols.c | 9 ++-- crypto/openssl/crypto/x509v3/v3_ncons.c | 77 +++++++++++++++++++++---------- crypto/openssl/crypto/x509v3/v3_pci.c | 3 +- crypto/openssl/crypto/x509v3/v3_utl.c | 53 ++++++++++++++++----- crypto/openssl/include/crypto/sm2.h | 3 +- crypto/openssl/include/crypto/x509.h | 5 ++ crypto/openssl/include/openssl/opensslv.h | 2 +- 14 files changed, 177 insertions(+), 71 deletions(-) diff --git a/crypto/openssl/crypto/asn1/asn1_lib.c b/crypto/openssl/crypto/asn1/asn1_lib.c index 366afc5f6c6b..8e62f3307443 100644 --- a/crypto/openssl/crypto/asn1/asn1_lib.c +++ b/crypto/openssl/crypto/asn1/asn1_lib.c @@ -292,7 +292,12 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len_in) } if ((size_t)str->length <= len || str->data == NULL) { c = str->data; +#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION + /* No NUL terminator in fuzzing builds */ + str->data = OPENSSL_realloc(c, len); +#else str->data = OPENSSL_realloc(c, len + 1); +#endif if (str->data == NULL) { ASN1err(ASN1_F_ASN1_STRING_SET, ERR_R_MALLOC_FAILURE); str->data = c; @@ -302,8 +307,13 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len_in) str->length = len; if (data != NULL) { memcpy(str->data, data, len); - /* an allowance for strings :-) */ +#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION + /* + * Add a NUL terminator. This should not be necessary - but we add it as + * a safety precaution + */ str->data[len] = '\0'; +#endif } return 1; } diff --git a/crypto/openssl/crypto/asn1/t_spki.c b/crypto/openssl/crypto/asn1/t_spki.c index 51b56d0aa9f7..64ee77eeecba 100644 --- a/crypto/openssl/crypto/asn1/t_spki.c +++ b/crypto/openssl/crypto/asn1/t_spki.c @@ -38,7 +38,7 @@ int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki) } chal = spki->spkac->challenge; if (chal->length) - BIO_printf(out, " Challenge String: %s\n", chal->data); + BIO_printf(out, " Challenge String: %.*s\n", chal->length, chal->data); i = OBJ_obj2nid(spki->sig_algor.algorithm); BIO_printf(out, " Signature Algorithm: %s", (i == NID_undef) ? "UNKNOWN" : OBJ_nid2ln(i)); diff --git a/crypto/openssl/crypto/ec/ec_asn1.c b/crypto/openssl/crypto/ec/ec_asn1.c index 7b7c75ce8443..e497a259095d 100644 --- a/crypto/openssl/crypto/ec/ec_asn1.c +++ b/crypto/openssl/crypto/ec/ec_asn1.c @@ -761,7 +761,10 @@ EC_GROUP *EC_GROUP_new_from_ecparameters(const ECPARAMETERS *params) ret->seed_len = params->curve->seed->length; } - if (!params->order || !params->base || !params->base->data) { + if (params->order == NULL + || params->base == NULL + || params->base->data == NULL + || params->base->length == 0) { ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR); goto err; } diff --git a/crypto/openssl/crypto/sm2/sm2_crypt.c b/crypto/openssl/crypto/sm2/sm2_crypt.c index ef505f64412b..00055a4e510e 100644 --- a/crypto/openssl/crypto/sm2/sm2_crypt.c +++ b/crypto/openssl/crypto/sm2/sm2_crypt.c @@ -61,29 +61,20 @@ static size_t ec_field_size(const EC_GROUP *group) return field_size; } -int sm2_plaintext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len, - size_t *pt_size) +int sm2_plaintext_size(const unsigned char *ct, size_t ct_size, size_t *pt_size) { - const size_t field_size = ec_field_size(EC_KEY_get0_group(key)); - const int md_size = EVP_MD_size(digest); - size_t overhead; + struct SM2_Ciphertext_st *sm2_ctext = NULL; - if (md_size < 0) { - SM2err(SM2_F_SM2_PLAINTEXT_SIZE, SM2_R_INVALID_DIGEST); - return 0; - } - if (field_size == 0) { - SM2err(SM2_F_SM2_PLAINTEXT_SIZE, SM2_R_INVALID_FIELD); - return 0; - } + sm2_ctext = d2i_SM2_Ciphertext(NULL, &ct, ct_size); - overhead = 10 + 2 * field_size + (size_t)md_size; - if (msg_len <= overhead) { + if (sm2_ctext == NULL) { SM2err(SM2_F_SM2_PLAINTEXT_SIZE, SM2_R_INVALID_ENCODING); return 0; } - *pt_size = msg_len - overhead; + *pt_size = sm2_ctext->C2->length; + SM2_Ciphertext_free(sm2_ctext); + return 1; } @@ -303,6 +294,10 @@ int sm2_decrypt(const EC_KEY *key, C2 = sm2_ctext->C2->data; C3 = sm2_ctext->C3->data; msg_len = sm2_ctext->C2->length; + if (*ptext_len < (size_t)msg_len) { + SM2err(SM2_F_SM2_DECRYPT, SM2_R_BUFFER_TOO_SMALL); + goto done; + } ctx = BN_CTX_new(); if (ctx == NULL) { diff --git a/crypto/openssl/crypto/sm2/sm2_pmeth.c b/crypto/openssl/crypto/sm2/sm2_pmeth.c index b42a14c32f26..27025fbf3a2c 100644 --- a/crypto/openssl/crypto/sm2/sm2_pmeth.c +++ b/crypto/openssl/crypto/sm2/sm2_pmeth.c @@ -151,7 +151,7 @@ static int pkey_sm2_decrypt(EVP_PKEY_CTX *ctx, const EVP_MD *md = (dctx->md == NULL) ? EVP_sm3() : dctx->md; if (out == NULL) { - if (!sm2_plaintext_size(ec, md, inlen, outlen)) + if (!sm2_plaintext_size(in, inlen, outlen)) return -1; else return 1; diff --git a/crypto/openssl/crypto/x509v3/v3_akey.c b/crypto/openssl/crypto/x509v3/v3_akey.c index d9f770433cfb..f917142223b7 100644 --- a/crypto/openssl/crypto/x509v3/v3_akey.c +++ b/crypto/openssl/crypto/x509v3/v3_akey.c @@ -39,20 +39,48 @@ static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_KEYID(X509V3_EXT_METHOD *method, STACK_OF(CONF_VALUE) *extlist) { - char *tmp; + char *tmp = NULL; + STACK_OF(CONF_VALUE) *origextlist = extlist, *tmpextlist; + if (akeyid->keyid) { tmp = OPENSSL_buf2hexstr(akeyid->keyid->data, akeyid->keyid->length); - X509V3_add_value("keyid", tmp, &extlist); + if (tmp == NULL) { + X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, ERR_R_MALLOC_FAILURE); + return NULL; + } + if (!X509V3_add_value("keyid", tmp, &extlist)) { + OPENSSL_free(tmp); + X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, ERR_R_X509_LIB); + goto err; + } OPENSSL_free(tmp); } - if (akeyid->issuer) - extlist = i2v_GENERAL_NAMES(NULL, akeyid->issuer, extlist); + if (akeyid->issuer) { + tmpextlist = i2v_GENERAL_NAMES(NULL, akeyid->issuer, extlist); + if (tmpextlist == NULL) { + X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, ERR_R_X509_LIB); + goto err; + } + extlist = tmpextlist; + } if (akeyid->serial) { tmp = OPENSSL_buf2hexstr(akeyid->serial->data, akeyid->serial->length); - X509V3_add_value("serial", tmp, &extlist); + if (tmp == NULL) { + X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, ERR_R_MALLOC_FAILURE); + goto err; + } + if (!X509V3_add_value("serial", tmp, &extlist)) { + OPENSSL_free(tmp); + X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, ERR_R_X509_LIB); + goto err; + } OPENSSL_free(tmp); } return extlist; + err: + if (origextlist == NULL) + sk_CONF_VALUE_pop_free(extlist, X509V3_conf_free); + return NULL; } /*- diff --git a/crypto/openssl/crypto/x509v3/v3_alt.c b/crypto/openssl/crypto/x509v3/v3_alt.c index 4dce0041012e..6e5f9f8b0eac 100644 --- a/crypto/openssl/crypto/x509v3/v3_alt.c +++ b/crypto/openssl/crypto/x509v3/v3_alt.c @@ -9,6 +9,7 @@ #include #include "internal/cryptlib.h" +#include "crypto/x509.h" #include #include #include "ext_dat.h" @@ -99,17 +100,20 @@ STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method, break; case GEN_EMAIL: - if (!X509V3_add_value_uchar("email", gen->d.ia5->data, &ret)) + if (!x509v3_add_len_value_uchar("email", gen->d.ia5->data, + gen->d.ia5->length, &ret)) return NULL; break; case GEN_DNS: - if (!X509V3_add_value_uchar("DNS", gen->d.ia5->data, &ret)) + if (!x509v3_add_len_value_uchar("DNS", gen->d.ia5->data, + gen->d.ia5->length, &ret)) return NULL; break; case GEN_URI: - if (!X509V3_add_value_uchar("URI", gen->d.ia5->data, &ret)) + if (!x509v3_add_len_value_uchar("URI", gen->d.ia5->data, + gen->d.ia5->length, &ret)) return NULL; break; diff --git a/crypto/openssl/crypto/x509v3/v3_cpols.c b/crypto/openssl/crypto/x509v3/v3_cpols.c index 1d12c899125c..861e8455dd08 100644 --- a/crypto/openssl/crypto/x509v3/v3_cpols.c +++ b/crypto/openssl/crypto/x509v3/v3_cpols.c @@ -422,7 +422,8 @@ static void print_qualifiers(BIO *out, STACK_OF(POLICYQUALINFO) *quals, qualinfo = sk_POLICYQUALINFO_value(quals, i); switch (OBJ_obj2nid(qualinfo->pqualid)) { case NID_id_qt_cps: - BIO_printf(out, "%*sCPS: %s\n", indent, "", + BIO_printf(out, "%*sCPS: %.*s\n", indent, "", + qualinfo->d.cpsuri->length, qualinfo->d.cpsuri->data); break; @@ -447,7 +448,8 @@ static void print_notice(BIO *out, USERNOTICE *notice, int indent) if (notice->noticeref) { NOTICEREF *ref; ref = notice->noticeref; - BIO_printf(out, "%*sOrganization: %s\n", indent, "", + BIO_printf(out, "%*sOrganization: %.*s\n", indent, "", + ref->organization->length, ref->organization->data); BIO_printf(out, "%*sNumber%s: ", indent, "", sk_ASN1_INTEGER_num(ref->noticenos) > 1 ? "s" : ""); @@ -470,7 +472,8 @@ static void print_notice(BIO *out, USERNOTICE *notice, int indent) BIO_puts(out, "\n"); } if (notice->exptext) - BIO_printf(out, "%*sExplicit Text: %s\n", indent, "", + BIO_printf(out, "%*sExplicit Text: %.*s\n", indent, "", + notice->exptext->length, notice->exptext->data); } diff --git a/crypto/openssl/crypto/x509v3/v3_ncons.c b/crypto/openssl/crypto/x509v3/v3_ncons.c index 2a7b4f0992a8..cb701c4d844b 100644 --- a/crypto/openssl/crypto/x509v3/v3_ncons.c +++ b/crypto/openssl/crypto/x509v3/v3_ncons.c @@ -63,8 +63,31 @@ ASN1_SEQUENCE(NAME_CONSTRAINTS) = { IMPLEMENT_ASN1_ALLOC_FUNCTIONS(GENERAL_SUBTREE) IMPLEMENT_ASN1_ALLOC_FUNCTIONS(NAME_CONSTRAINTS) + +#define IA5_OFFSET_LEN(ia5base, offset) \ + ((ia5base)->length - ((unsigned char *)(offset) - (ia5base)->data)) + +/* Like memchr but for ASN1_IA5STRING. Additionally you can specify the + * starting point to search from + */ +# define ia5memchr(str, start, c) memchr(start, c, IA5_OFFSET_LEN(str, start)) + +/* Like memrrchr but for ASN1_IA5STRING */ +static char *ia5memrchr(ASN1_IA5STRING *str, int c) +{ + int i; + + for (i = str->length; i > 0 && str->data[i - 1] != c; i--); + + if (i == 0) + return NULL; + + return (char *)&str->data[i - 1]; +} + /* - * We cannot use strncasecmp here because that applies locale specific rules. + * We cannot use strncasecmp here because that applies locale specific rules. It + * also doesn't work with ASN1_STRINGs that may have embedded NUL characters. * For example in Turkish 'I' is not the uppercase character for 'i'. We need to * do a simple ASCII case comparison ignoring the locale (that is why we use * numeric constants below). @@ -89,20 +112,12 @@ static int ia5ncasecmp(const char *s1, const char *s2, size_t n) /* c1 > c2 */ return 1; - } else if (*s1 == 0) { - /* If we get here we know that *s2 == 0 too */ - return 0; } } return 0; } -static int ia5casecmp(const char *s1, const char *s2) -{ - return ia5ncasecmp(s1, s2, SIZE_MAX); -} - static void *v2i_NAME_CONSTRAINTS(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) { @@ -337,7 +352,7 @@ static int cn2dnsid(ASN1_STRING *cn, unsigned char **dnsid, size_t *idlen) --utf8_length; /* Reject *embedded* NULs */ - if ((size_t)utf8_length != strlen((char *)utf8_value)) { + if (memchr(utf8_value, 0, utf8_length) != NULL) { OPENSSL_free(utf8_value); return X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; } @@ -536,9 +551,14 @@ static int nc_dns(ASN1_IA5STRING *dns, ASN1_IA5STRING *base) { char *baseptr = (char *)base->data; char *dnsptr = (char *)dns->data; + /* Empty matches everything */ - if (!*baseptr) + if (base->length == 0) return X509_V_OK; + + if (dns->length < base->length) + return X509_V_ERR_PERMITTED_VIOLATION; + /* * Otherwise can add zero or more components on the left so compare RHS * and if dns is longer and expect '.' as preceding character. @@ -549,7 +569,7 @@ static int nc_dns(ASN1_IA5STRING *dns, ASN1_IA5STRING *base) return X509_V_ERR_PERMITTED_VIOLATION; } - if (ia5casecmp(baseptr, dnsptr)) + if (ia5ncasecmp(baseptr, dnsptr, base->length)) return X509_V_ERR_PERMITTED_VIOLATION; return X509_V_OK; @@ -560,16 +580,17 @@ static int nc_email(ASN1_IA5STRING *eml, ASN1_IA5STRING *base) { const char *baseptr = (char *)base->data; const char *emlptr = (char *)eml->data; + const char *baseat = ia5memrchr(base, '@'); + const char *emlat = ia5memrchr(eml, '@'); + size_t basehostlen, emlhostlen; - const char *baseat = strchr(baseptr, '@'); - const char *emlat = strchr(emlptr, '@'); if (!emlat) return X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; /* Special case: initial '.' is RHS match */ - if (!baseat && (*baseptr == '.')) { + if (!baseat && base->length > 0 && (*baseptr == '.')) { if (eml->length > base->length) { emlptr += eml->length - base->length; - if (ia5casecmp(baseptr, emlptr) == 0) + if (ia5ncasecmp(baseptr, emlptr, base->length) == 0) return X509_V_OK; } return X509_V_ERR_PERMITTED_VIOLATION; @@ -589,8 +610,10 @@ static int nc_email(ASN1_IA5STRING *eml, ASN1_IA5STRING *base) baseptr = baseat + 1; } emlptr = emlat + 1; + basehostlen = IA5_OFFSET_LEN(base, baseptr); + emlhostlen = IA5_OFFSET_LEN(eml, emlptr); /* Just have hostname left to match: case insensitive */ - if (ia5casecmp(baseptr, emlptr)) + if (basehostlen != emlhostlen || ia5ncasecmp(baseptr, emlptr, emlhostlen)) return X509_V_ERR_PERMITTED_VIOLATION; return X509_V_OK; @@ -601,10 +624,14 @@ static int nc_uri(ASN1_IA5STRING *uri, ASN1_IA5STRING *base) { const char *baseptr = (char *)base->data; const char *hostptr = (char *)uri->data; - const char *p = strchr(hostptr, ':'); + const char *p = ia5memchr(uri, (char *)uri->data, ':'); int hostlen; + /* Check for foo:// and skip past it */ - if (!p || (p[1] != '/') || (p[2] != '/')) + if (p == NULL + || IA5_OFFSET_LEN(uri, p) < 3 + || p[1] != '/' + || p[2] != '/') return X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; hostptr = p + 3; @@ -612,13 +639,13 @@ static int nc_uri(ASN1_IA5STRING *uri, ASN1_IA5STRING *base) /* Look for a port indicator as end of hostname first */ - p = strchr(hostptr, ':'); + p = ia5memchr(uri, hostptr, ':'); /* Otherwise look for trailing slash */ - if (!p) - p = strchr(hostptr, '/'); + if (p == NULL) + p = ia5memchr(uri, hostptr, '/'); - if (!p) - hostlen = strlen(hostptr); + if (p == NULL) + hostlen = IA5_OFFSET_LEN(uri, hostptr); else hostlen = p - hostptr; @@ -626,7 +653,7 @@ static int nc_uri(ASN1_IA5STRING *uri, ASN1_IA5STRING *base) return X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; /* Special case: initial '.' is RHS match */ - if (*baseptr == '.') { + if (base->length > 0 && *baseptr == '.') { if (hostlen > base->length) { p = hostptr + hostlen - base->length; if (ia5ncasecmp(p, baseptr, base->length) == 0) diff --git a/crypto/openssl/crypto/x509v3/v3_pci.c b/crypto/openssl/crypto/x509v3/v3_pci.c index 3d124fa6d95d..98b6ef25e280 100644 --- a/crypto/openssl/crypto/x509v3/v3_pci.c +++ b/crypto/openssl/crypto/x509v3/v3_pci.c @@ -77,7 +77,8 @@ static int i2r_pci(X509V3_EXT_METHOD *method, PROXY_CERT_INFO_EXTENSION *pci, i2a_ASN1_OBJECT(out, pci->proxyPolicy->policyLanguage); BIO_puts(out, "\n"); if (pci->proxyPolicy->policy && pci->proxyPolicy->policy->data) - BIO_printf(out, "%*sPolicy Text: %s\n", indent, "", + BIO_printf(out, "%*sPolicy Text: %.*s\n", indent, "", + pci->proxyPolicy->policy->length, pci->proxyPolicy->policy->data); return 1; } diff --git a/crypto/openssl/crypto/x509v3/v3_utl.c b/crypto/openssl/crypto/x509v3/v3_utl.c index 7281a7b917a8..706dd22ffaba 100644 --- a/crypto/openssl/crypto/x509v3/v3_utl.c +++ b/crypto/openssl/crypto/x509v3/v3_utl.c @@ -12,6 +12,7 @@ #include "e_os.h" #include "internal/cryptlib.h" #include +#include #include "crypto/ctype.h" #include #include @@ -34,17 +35,23 @@ static int ipv6_hex(unsigned char *out, const char *in, int inlen); /* Add a CONF_VALUE name value pair to stack */ -int X509V3_add_value(const char *name, const char *value, - STACK_OF(CONF_VALUE) **extlist) +static int x509v3_add_len_value(const char *name, const char *value, + size_t vallen, STACK_OF(CONF_VALUE) **extlist) { CONF_VALUE *vtmp = NULL; char *tname = NULL, *tvalue = NULL; int sk_allocated = (*extlist == NULL); - if (name && (tname = OPENSSL_strdup(name)) == NULL) - goto err; - if (value && (tvalue = OPENSSL_strdup(value)) == NULL) + if (name != NULL && (tname = OPENSSL_strdup(name)) == NULL) goto err; + if (value != NULL) { + /* We don't allow embeded NUL characters */ + if (memchr(value, 0, vallen) != NULL) + goto err; + tvalue = OPENSSL_strndup(value, vallen); + if (tvalue == NULL) + goto err; + } if ((vtmp = OPENSSL_malloc(sizeof(*vtmp))) == NULL) goto err; if (sk_allocated && (*extlist = sk_CONF_VALUE_new_null()) == NULL) @@ -67,10 +74,26 @@ int X509V3_add_value(const char *name, const char *value, return 0; } +int X509V3_add_value(const char *name, const char *value, + STACK_OF(CONF_VALUE) **extlist) +{ + return x509v3_add_len_value(name, value, + value != NULL ? strlen((const char *)value) : 0, + extlist); +} + int X509V3_add_value_uchar(const char *name, const unsigned char *value, STACK_OF(CONF_VALUE) **extlist) { - return X509V3_add_value(name, (const char *)value, extlist); + return x509v3_add_len_value(name, (const char *)value, + value != NULL ? strlen((const char *)value) : 0, + extlist); +} + +int x509v3_add_len_value_uchar(const char *name, const unsigned char *value, + size_t vallen, STACK_OF(CONF_VALUE) **extlist) +{ + return x509v3_add_len_value(name, (const char *)value, vallen, extlist); } /* Free function for STACK_OF(CONF_VALUE) */ @@ -502,18 +525,26 @@ static int append_ia5(STACK_OF(OPENSSL_STRING) **sk, const ASN1_IA5STRING *email /* First some sanity checks */ if (email->type != V_ASN1_IA5STRING) return 1; - if (!email->data || !email->length) + if (email->data == NULL || email->length == 0) + return 1; + if (memchr(email->data, 0, email->length) != NULL) return 1; if (*sk == NULL) *sk = sk_OPENSSL_STRING_new(sk_strcmp); if (*sk == NULL) return 0; + + emtmp = OPENSSL_strndup((char *)email->data, email->length); + if (emtmp == NULL) + return 0; + /* Don't add duplicates */ - if (sk_OPENSSL_STRING_find(*sk, (char *)email->data) != -1) + if (sk_OPENSSL_STRING_find(*sk, emtmp) != -1) { + OPENSSL_free(emtmp); return 1; - emtmp = OPENSSL_strdup((char *)email->data); - if (emtmp == NULL || !sk_OPENSSL_STRING_push(*sk, emtmp)) { - OPENSSL_free(emtmp); /* free on push failure */ + } + if (!sk_OPENSSL_STRING_push(*sk, emtmp)) { + OPENSSL_free(emtmp); /* free on push failure */ X509_email_free(*sk); *sk = NULL; return 0; diff --git a/crypto/openssl/include/crypto/sm2.h b/crypto/openssl/include/crypto/sm2.h index 76ee80baff19..50851a83cea2 100644 --- a/crypto/openssl/include/crypto/sm2.h +++ b/crypto/openssl/include/crypto/sm2.h @@ -60,8 +60,7 @@ int sm2_verify(const unsigned char *dgst, int dgstlen, int sm2_ciphertext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len, size_t *ct_size); -int sm2_plaintext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len, - size_t *pt_size); +int sm2_plaintext_size(const unsigned char *ct, size_t ct_size, size_t *pt_size); int sm2_encrypt(const EC_KEY *key, const EVP_MD *digest, diff --git a/crypto/openssl/include/crypto/x509.h b/crypto/openssl/include/crypto/x509.h index b53c2b03c39e..7ffb8abfe71b 100644 --- a/crypto/openssl/include/crypto/x509.h +++ b/crypto/openssl/include/crypto/x509.h @@ -8,6 +8,8 @@ */ #include "internal/refcount.h" +#include +#include /* Internal X509 structures and functions: not for application use */ @@ -284,3 +286,6 @@ int a2i_ipadd(unsigned char *ipout, const char *ipasc); int x509_set1_time(ASN1_TIME **ptm, const ASN1_TIME *tm); void x509_init_sig_info(X509 *x); + +int x509v3_add_len_value_uchar(const char *name, const unsigned char *value, + size_t vallen, STACK_OF(CONF_VALUE) **extlist); diff --git a/crypto/openssl/include/openssl/opensslv.h b/crypto/openssl/include/openssl/opensslv.h index ec4a1123f131..328d0971c414 100644 --- a/crypto/openssl/include/openssl/opensslv.h +++ b/crypto/openssl/include/openssl/opensslv.h @@ -40,7 +40,7 @@ extern "C" { * major minor fix final patch/beta) */ # define OPENSSL_VERSION_NUMBER 0x101010bfL -# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1k-freebsd 25 Mar 2021" +# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1k-freebsd 24 Aug 2021" /*- * The macros below are to be used for shared library (.so, .dll, ...) From owner-dev-commits-src-main@freebsd.org Tue Aug 24 18:32:15 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A156365E7AF; Tue, 24 Aug 2021 18:32:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvHlM3HXTz3Q3t; Tue, 24 Aug 2021 18:32:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5716D5B9F; Tue, 24 Aug 2021 18:32:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17OIWFT4037218; Tue, 24 Aug 2021 18:32:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OIWFjZ037217; Tue, 24 Aug 2021 18:32:15 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:32:15 GMT Message-Id: <202108241832.17OIWFjZ037217@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 71fbc6faed62 - main - bhyve: Fix vq_getchain() error handling bugs in various device models MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 71fbc6faed62e8eb5864f7c40839740f5e9f5558 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:32:15 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=71fbc6faed62e8eb5864f7c40839740f5e9f5558 commit 71fbc6faed62e8eb5864f7c40839740f5e9f5558 Author: Mark Johnston AuthorDate: 2021-08-24 18:10:08 +0000 Commit: Mark Johnston CommitDate: 2021-08-24 18:29:13 +0000 bhyve: Fix vq_getchain() error handling bugs in various device models Reviewed by: grehan, khng Approved by: so Security: CVE-2021-29631 Security: FreeBSD-SA-21:13.bhyve --- usr.sbin/bhyve/pci_virtio_9p.c | 3 ++- usr.sbin/bhyve/pci_virtio_console.c | 6 +++--- usr.sbin/bhyve/pci_virtio_rnd.c | 5 +++-- usr.sbin/bhyve/pci_virtio_scsi.c | 8 +++++--- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/usr.sbin/bhyve/pci_virtio_9p.c b/usr.sbin/bhyve/pci_virtio_9p.c index f96d53858225..70f3eba4bc34 100644 --- a/usr.sbin/bhyve/pci_virtio_9p.c +++ b/usr.sbin/bhyve/pci_virtio_9p.c @@ -198,12 +198,13 @@ pci_vt9p_notify(void *vsc, struct vqueue_info *vq) struct pci_vt9p_softc *sc; struct pci_vt9p_request *preq; struct vi_req req; - uint16_t n; + int n; sc = vsc; while (vq_has_descs(vq)) { n = vq_getchain(vq, iov, VT9P_MAX_IOV, &req); + assert(n >= 1 && n <= VT9P_MAX_IOV); preq = calloc(1, sizeof(struct pci_vt9p_request)); preq->vsr_sc = sc; preq->vsr_idx = req.idx; diff --git a/usr.sbin/bhyve/pci_virtio_console.c b/usr.sbin/bhyve/pci_virtio_console.c index 6832a3f92774..71c3375a57ac 100644 --- a/usr.sbin/bhyve/pci_virtio_console.c +++ b/usr.sbin/bhyve/pci_virtio_console.c @@ -442,6 +442,7 @@ pci_vtcon_sock_rx(int fd __unused, enum ev_type t __unused, void *arg) do { n = vq_getchain(vq, &iov, 1, &req); + assert(n == 1); len = readv(sock->vss_conn_fd, &iov, n); if (len == 0 || (len < 0 && errno == EWOULDBLOCK)) { @@ -582,7 +583,6 @@ pci_vtcon_control_send(struct pci_vtcon_softc *sc, return; n = vq_getchain(vq, &iov, 1, &req); - assert(n == 1); memcpy(iov.iov_base, ctrl, sizeof(struct pci_vtcon_control)); @@ -602,14 +602,14 @@ pci_vtcon_notify_tx(void *vsc, struct vqueue_info *vq) struct pci_vtcon_port *port; struct iovec iov[1]; struct vi_req req; - uint16_t n; + int n; sc = vsc; port = pci_vtcon_vq_to_port(sc, vq); while (vq_has_descs(vq)) { n = vq_getchain(vq, iov, 1, &req); - assert(n >= 1); + assert(n == 1); if (port != NULL) port->vsp_cb(port, port->vsp_arg, iov, 1); diff --git a/usr.sbin/bhyve/pci_virtio_rnd.c b/usr.sbin/bhyve/pci_virtio_rnd.c index 1d2d6144f949..7274d0b05912 100644 --- a/usr.sbin/bhyve/pci_virtio_rnd.c +++ b/usr.sbin/bhyve/pci_virtio_rnd.c @@ -114,7 +114,7 @@ pci_vtrnd_notify(void *vsc, struct vqueue_info *vq) struct iovec iov; struct pci_vtrnd_softc *sc; struct vi_req req; - int len; + int len, n; sc = vsc; @@ -124,7 +124,8 @@ pci_vtrnd_notify(void *vsc, struct vqueue_info *vq) } while (vq_has_descs(vq)) { - vq_getchain(vq, &iov, 1, &req); + n = vq_getchain(vq, &iov, 1, &req); + assert(n == 1); len = read(sc->vrsc_fd, iov.iov_base, iov.iov_len); diff --git a/usr.sbin/bhyve/pci_virtio_scsi.c b/usr.sbin/bhyve/pci_virtio_scsi.c index e8124b9b3441..37eba90fa2bc 100644 --- a/usr.sbin/bhyve/pci_virtio_scsi.c +++ b/usr.sbin/bhyve/pci_virtio_scsi.c @@ -559,15 +559,16 @@ pci_vtscsi_controlq_notify(void *vsc, struct vqueue_info *vq) struct pci_vtscsi_softc *sc; struct iovec iov[VTSCSI_MAXSEG]; struct vi_req req; - uint16_t n; void *buf = NULL; size_t bufsize; - int iolen; + int iolen, n; sc = vsc; while (vq_has_descs(vq)) { n = vq_getchain(vq, iov, VTSCSI_MAXSEG, &req); + assert(n >= 1 && n <= VTSCSI_MAXSEG); + bufsize = iov_to_buf(iov, n, &buf); iolen = pci_vtscsi_control_handle(sc, buf, bufsize); buf_to_iov(buf + bufsize - iolen, iolen, iov, n, @@ -597,13 +598,14 @@ pci_vtscsi_requestq_notify(void *vsc, struct vqueue_info *vq) struct pci_vtscsi_request *req; struct iovec iov[VTSCSI_MAXSEG]; struct vi_req vireq; - uint16_t n; + int n; sc = vsc; q = &sc->vss_queues[vq->vq_num - 2]; while (vq_has_descs(vq)) { n = vq_getchain(vq, iov, VTSCSI_MAXSEG, &vireq); + assert(n >= 1 && n <= VTSCSI_MAXSEG); req = calloc(1, sizeof(struct pci_vtscsi_request)); req->vsr_idx = vireq.idx; From owner-dev-commits-src-main@freebsd.org Tue Aug 24 22:25:31 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0E637667C5A; Tue, 24 Aug 2021 22:25:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvNwV6rZbz3spn; Tue, 24 Aug 2021 22:25:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C8C8510D4E; Tue, 24 Aug 2021 22:25:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17OMPU2k046559; Tue, 24 Aug 2021 22:25:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OMPUI5046558; Tue, 24 Aug 2021 22:25:30 GMT (envelope-from git) Date: Tue, 24 Aug 2021 22:25:30 GMT Message-Id: <202108242225.17OMPUI5046558@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 4f0f5bf99591 - main - iscsi: Validate DataSN values in Data-In PDUs in the initiator. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4f0f5bf99591ad9907822082270523ac919e3b8c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 22:25:31 -0000 The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=4f0f5bf99591ad9907822082270523ac919e3b8c commit 4f0f5bf99591ad9907822082270523ac919e3b8c Author: John Baldwin AuthorDate: 2021-08-24 21:58:34 +0000 Commit: John Baldwin CommitDate: 2021-08-24 21:58:34 +0000 iscsi: Validate DataSN values in Data-In PDUs in the initiator. As is done in the target, require that DataSN values are consecutive and in-order. If an out of order Data-In PDU is received, force a session reconnect. In addition, when a SCSI Response PDU is received, verify that the ExpDataSN field matches the count of Data-In PDUs received for this command. If not, force a session reconnect. Reviewed by: mav Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D31594 --- sys/dev/iscsi/iscsi.c | 21 ++++++++++++++++++++- sys/dev/iscsi/iscsi.h | 1 + 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/sys/dev/iscsi/iscsi.c b/sys/dev/iscsi/iscsi.c index 60b3e3766da7..eba365f7ad3e 100644 --- a/sys/dev/iscsi/iscsi.c +++ b/sys/dev/iscsi/iscsi.c @@ -892,6 +892,15 @@ iscsi_pdu_handle_scsi_response(struct icl_pdu *response) } ccb = io->io_ccb; + if (ntohl(bhssr->bhssr_expdatasn) != io->io_datasn) { + ISCSI_SESSION_WARN(is, + "ExpDataSN mismatch in SCSI Response (%u vs %u)", + ntohl(bhssr->bhssr_expdatasn), io->io_datasn); + icl_pdu_free(response); + iscsi_session_reconnect(is); + ISCSI_SESSION_UNLOCK(is); + return; + } /* * With iSER, after getting good response we can be sure @@ -1047,6 +1056,17 @@ iscsi_pdu_handle_data_in(struct icl_pdu *response) return; } + if (io->io_datasn != ntohl(bhsdi->bhsdi_datasn)) { + ISCSI_SESSION_WARN(is, "received Data-In PDU with " + "DataSN %u, while expected %u; dropping connection", + ntohl(bhsdi->bhsdi_datasn), io->io_datasn); + icl_pdu_free(response); + iscsi_session_reconnect(is); + ISCSI_SESSION_UNLOCK(is); + return; + } + io->io_datasn += response->ip_additional_pdus + 1; + data_segment_len = icl_pdu_data_segment_length(response); if (data_segment_len == 0) { /* @@ -1096,7 +1116,6 @@ iscsi_pdu_handle_data_in(struct icl_pdu *response) icl_pdu_get_data(response, 0, csio->data_ptr + oreceived, data_segment_len); /* - * XXX: Check DataSN. * XXX: Check F. */ if ((bhsdi->bhsdi_flags & BHSDI_FLAGS_S) == 0) { diff --git a/sys/dev/iscsi/iscsi.h b/sys/dev/iscsi/iscsi.h index fe1cc64f88db..871fc6fc90e9 100644 --- a/sys/dev/iscsi/iscsi.h +++ b/sys/dev/iscsi/iscsi.h @@ -44,6 +44,7 @@ struct iscsi_outstanding { TAILQ_ENTRY(iscsi_outstanding) io_next; union ccb *io_ccb; size_t io_received; + uint32_t io_datasn; uint32_t io_initiator_task_tag; uint32_t io_referenced_task_tag; void *io_icl_prv; From owner-dev-commits-src-main@freebsd.org Tue Aug 24 23:04:11 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 62F316692B7; Tue, 24 Aug 2021 23:04:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvPn728fFz4ZyM; Tue, 24 Aug 2021 23:04:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 32FEC118C4; Tue, 24 Aug 2021 23:04:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17ON4BdF000701; Tue, 24 Aug 2021 23:04:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ON4BeH000700; Tue, 24 Aug 2021 23:04:11 GMT (envelope-from git) Date: Tue, 24 Aug 2021 23:04:11 GMT Message-Id: <202108242304.17ON4BeH000700@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: 98a7606b85e0 - main - evdev: Multitouch code style changes. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 98a7606b85e05132f328a2498dccab78df31cb7e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 23:04:11 -0000 The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=98a7606b85e05132f328a2498dccab78df31cb7e commit 98a7606b85e05132f328a2498dccab78df31cb7e Author: Vladimir Kondratyev AuthorDate: 2021-08-24 22:43:41 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-08-24 22:43:41 +0000 evdev: Multitouch code style changes. 1. Move touch count reporting helpers to utils. They are not multitouch. 2. Use evdev_mt prefix for private multitouch support routines. 3. Use int instead of int32_t where fixed size is not required. 4. Export some internal functions. This change should be no-op. MFC after: 2 weeks --- sys/dev/evdev/cdev.c | 2 +- sys/dev/evdev/evdev.c | 19 +++--- sys/dev/evdev/evdev.h | 12 +++- sys/dev/evdev/evdev_mt.c | 152 +++++++++++++++++++----------------------- sys/dev/evdev/evdev_private.h | 12 ++-- sys/dev/evdev/evdev_utils.c | 41 ++++++++++++ 6 files changed, 134 insertions(+), 104 deletions(-) diff --git a/sys/dev/evdev/cdev.c b/sys/dev/evdev/cdev.c index 66d00ad16aee..d124e691a7c3 100644 --- a/sys/dev/evdev/cdev.c +++ b/sys/dev/evdev/cdev.c @@ -621,7 +621,7 @@ evdev_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag, MIN(len / sizeof(int32_t) - 1, MAXIMAL_MT_SLOT(evdev) + 1); for (int i = 0; i < nvalues; i++) ((int32_t *)data)[i + 1] = - evdev_get_mt_value(evdev, i, code); + evdev_mt_get_value(evdev, i, code); return (0); case EVIOCGKEY(0): diff --git a/sys/dev/evdev/evdev.c b/sys/dev/evdev/evdev.c index 597342a364af..8483faee8d6b 100644 --- a/sys/dev/evdev/evdev.c +++ b/sys/dev/evdev/evdev.c @@ -707,8 +707,8 @@ evdev_modify_event(struct evdev_dev *evdev, uint16_t type, uint16_t code, else if (!ABS_IS_MT(code)) old_value = evdev->ev_absinfo[code].value; else if (bit_test(evdev->ev_abs_flags, ABS_MT_SLOT)) - old_value = evdev_get_mt_value(evdev, - evdev_get_last_mt_slot(evdev), code); + old_value = evdev_mt_get_value(evdev, + evdev_mt_get_last_slot(evdev), code); else /* Pass MT protocol type A events as is */ break; @@ -788,7 +788,7 @@ evdev_sparse_event(struct evdev_dev *evdev, uint16_t type, uint16_t code, switch (code) { case ABS_MT_SLOT: /* Postpone ABS_MT_SLOT till next event */ - evdev_set_last_mt_slot(evdev, value); + evdev_mt_set_last_slot(evdev, value); return (EV_SKIP_EVENT); case ABS_MT_FIRST ... ABS_MT_LAST: @@ -796,11 +796,11 @@ evdev_sparse_event(struct evdev_dev *evdev, uint16_t type, uint16_t code, if (!bit_test(evdev->ev_abs_flags, ABS_MT_SLOT)) break; /* Don`t repeat MT protocol type B events */ - last_mt_slot = evdev_get_last_mt_slot(evdev); - if (evdev_get_mt_value(evdev, last_mt_slot, code) + last_mt_slot = evdev_mt_get_last_slot(evdev); + if (evdev_mt_get_value(evdev, last_mt_slot, code) == value) return (EV_SKIP_EVENT); - evdev_set_mt_value(evdev, last_mt_slot, code, value); + evdev_mt_set_value(evdev, last_mt_slot, code, value); if (last_mt_slot != CURRENT_MT_SLOT(evdev)) { CURRENT_MT_SLOT(evdev) = last_mt_slot; evdev->ev_report_opened = true; @@ -941,11 +941,8 @@ evdev_push_event(struct evdev_dev *evdev, uint16_t type, uint16_t code, evdev_modify_event(evdev, type, code, &value); if (type == EV_SYN && code == SYN_REPORT && - bit_test(evdev->ev_flags, EVDEV_FLAG_MT_AUTOREL)) - evdev_send_mt_autorel(evdev); - if (type == EV_SYN && code == SYN_REPORT && evdev->ev_report_opened && - bit_test(evdev->ev_flags, EVDEV_FLAG_MT_STCOMPAT)) - evdev_send_mt_compat(evdev); + bit_test(evdev->ev_abs_flags, ABS_MT_SLOT)) + evdev_mt_sync_frame(evdev); evdev_send_event(evdev, type, code, value); EVDEV_EXIT(evdev); diff --git a/sys/dev/evdev/evdev.h b/sys/dev/evdev/evdev.h index 30d6a106d8b3..fe21f8cea4c2 100644 --- a/sys/dev/evdev/evdev.h +++ b/sys/dev/evdev/evdev.h @@ -131,11 +131,15 @@ void evdev_set_flag(struct evdev_dev *, uint16_t); void *evdev_get_softc(struct evdev_dev *); /* Multitouch related functions: */ -int32_t evdev_get_mt_slot_by_tracking_id(struct evdev_dev *, int32_t); -void evdev_support_nfingers(struct evdev_dev *, int32_t); +int evdev_get_mt_slot_by_tracking_id(struct evdev_dev *, int32_t); void evdev_support_mt_compat(struct evdev_dev *); -void evdev_push_nfingers(struct evdev_dev *, int32_t); void evdev_push_mt_compat(struct evdev_dev *); +void evdev_mt_push_autorel(struct evdev_dev *); +static inline int +evdev_mt_id_to_slot(struct evdev_dev *evdev, int32_t id) +{ + return (evdev_get_mt_slot_by_tracking_id(evdev, id)); +} /* Utility functions: */ uint16_t evdev_hid2key(int); @@ -144,6 +148,8 @@ uint16_t evdev_scancode2key(int *, int); void evdev_push_mouse_btn(struct evdev_dev *, int); void evdev_push_leds(struct evdev_dev *, int); void evdev_push_repeats(struct evdev_dev *, keyboard_t *); +void evdev_support_nfingers(struct evdev_dev *, int); +void evdev_push_nfingers(struct evdev_dev *, int); /* Event reporting shortcuts: */ static __inline int diff --git a/sys/dev/evdev/evdev_mt.c b/sys/dev/evdev/evdev_mt.c index 1f9c9756db02..e8f892e235c0 100644 --- a/sys/dev/evdev/evdev_mt.c +++ b/sys/dev/evdev/evdev_mt.c @@ -42,14 +42,6 @@ #define debugf(fmt, args...) #endif -static uint16_t evdev_fngmap[] = { - BTN_TOOL_FINGER, - BTN_TOOL_DOUBLETAP, - BTN_TOOL_TRIPLETAP, - BTN_TOOL_QUADTAP, - BTN_TOOL_QUINTTAP, -}; - static uint16_t evdev_mtstmap[][2] = { { ABS_MT_POSITION_X, ABS_X }, { ABS_MT_POSITION_Y, ABS_Y }, @@ -58,23 +50,26 @@ static uint16_t evdev_mtstmap[][2] = { }; struct evdev_mt_slot { - uint64_t ev_report; - int32_t ev_mt_states[MT_CNT]; + uint64_t ev_report; + int32_t val[MT_CNT]; }; struct evdev_mt { - int32_t ev_mt_last_reported_slot; - struct evdev_mt_slot ev_mt_slots[]; + int last_reported_slot; + struct evdev_mt_slot slots[]; }; +static void evdev_mt_send_st_compat(struct evdev_dev *); +static void evdev_mt_send_autorel(struct evdev_dev *); + void evdev_mt_init(struct evdev_dev *evdev) { - int32_t slot, slots; + int slot, slots; slots = MAXIMAL_MT_SLOT(evdev) + 1; - evdev->ev_mt = malloc(offsetof(struct evdev_mt, ev_mt_slots) + + evdev->ev_mt = malloc(offsetof(struct evdev_mt, slots) + sizeof(struct evdev_mt_slot) * slots, M_EVDEV, M_WAITOK | M_ZERO); /* Initialize multitouch protocol type B states */ @@ -84,9 +79,9 @@ evdev_mt_init(struct evdev_dev *evdev) * report counter (0) as it brokes free slot detection in * evdev_get_mt_slot_by_tracking_id. So initialize it to -1 */ - evdev->ev_mt->ev_mt_slots[slot] = (struct evdev_mt_slot) { + evdev->ev_mt->slots[slot] = (struct evdev_mt_slot) { .ev_report = 0xFFFFFFFFFFFFFFFFULL, - .ev_mt_states[ABS_MT_INDEX(ABS_MT_TRACKING_ID)] = -1, + .val[ABS_MT_INDEX(ABS_MT_TRACKING_ID)] = -1, }; } @@ -97,49 +92,66 @@ evdev_mt_init(struct evdev_dev *evdev) void evdev_mt_free(struct evdev_dev *evdev) { - free(evdev->ev_mt, M_EVDEV); } -int32_t -evdev_get_last_mt_slot(struct evdev_dev *evdev) +void +evdev_mt_sync_frame(struct evdev_dev *evdev) { + if (bit_test(evdev->ev_flags, EVDEV_FLAG_MT_AUTOREL)) + evdev_mt_send_autorel(evdev); + if (evdev->ev_report_opened && + bit_test(evdev->ev_flags, EVDEV_FLAG_MT_STCOMPAT)) + evdev_mt_send_st_compat(evdev); +} - return (evdev->ev_mt->ev_mt_last_reported_slot); +int +evdev_mt_get_last_slot(struct evdev_dev *evdev) +{ + return (evdev->ev_mt->last_reported_slot); } void -evdev_set_last_mt_slot(struct evdev_dev *evdev, int32_t slot) +evdev_mt_set_last_slot(struct evdev_dev *evdev, int slot) { + struct evdev_mt *mt = evdev->ev_mt; + + MPASS(slot >= 0 && slot <= MAXIMAL_MT_SLOT(evdev)); - evdev->ev_mt->ev_mt_slots[slot].ev_report = evdev->ev_report_count; - evdev->ev_mt->ev_mt_last_reported_slot = slot; + mt->slots[slot].ev_report = evdev->ev_report_count; + mt->last_reported_slot = slot; } -inline int32_t -evdev_get_mt_value(struct evdev_dev *evdev, int32_t slot, int16_t code) +int32_t +evdev_mt_get_value(struct evdev_dev *evdev, int slot, int16_t code) { + struct evdev_mt *mt = evdev->ev_mt; + + MPASS(slot >= 0 && slot <= MAXIMAL_MT_SLOT(evdev)); - return (evdev->ev_mt-> - ev_mt_slots[slot].ev_mt_states[ABS_MT_INDEX(code)]); + return (mt->slots[slot].val[ABS_MT_INDEX(code)]); } -inline void -evdev_set_mt_value(struct evdev_dev *evdev, int32_t slot, int16_t code, +void +evdev_mt_set_value(struct evdev_dev *evdev, int slot, int16_t code, int32_t value) { + struct evdev_mt *mt = evdev->ev_mt; + + MPASS(slot >= 0 && slot <= MAXIMAL_MT_SLOT(evdev)); - evdev->ev_mt->ev_mt_slots[slot].ev_mt_states[ABS_MT_INDEX(code)] = - value; + mt->slots[slot].val[ABS_MT_INDEX(code)] = value; } -int32_t +int evdev_get_mt_slot_by_tracking_id(struct evdev_dev *evdev, int32_t tracking_id) { - int32_t tr_id, slot, free_slot = -1; + struct evdev_mt *mt = evdev->ev_mt; + int32_t tr_id; + int slot, free_slot = -1; for (slot = 0; slot <= MAXIMAL_MT_SLOT(evdev); slot++) { - tr_id = evdev_get_mt_value(evdev, slot, ABS_MT_TRACKING_ID); + tr_id = evdev_mt_get_value(evdev, slot, ABS_MT_TRACKING_ID); if (tr_id == tracking_id) return (slot); /* @@ -149,27 +161,17 @@ evdev_get_mt_slot_by_tracking_id(struct evdev_dev *evdev, int32_t tracking_id) * ABS_MT_TRACKING_ID change. */ if (free_slot == -1 && tr_id == -1 && - evdev->ev_mt->ev_mt_slots[slot].ev_report != - evdev->ev_report_count) + mt->slots[slot].ev_report != evdev->ev_report_count) free_slot = slot; } return (free_slot); } -void -evdev_support_nfingers(struct evdev_dev *evdev, int32_t nfingers) -{ - int32_t i; - - for (i = 0; i < MIN(nitems(evdev_fngmap), nfingers); i++) - evdev_support_key(evdev, evdev_fngmap[i]); -} - void evdev_support_mt_compat(struct evdev_dev *evdev) { - int32_t i; + int i; if (evdev->ev_absinfo == NULL) return; @@ -195,56 +197,32 @@ evdev_support_mt_compat(struct evdev_dev *evdev) static int32_t evdev_count_fingers(struct evdev_dev *evdev) { - int32_t nfingers = 0, i; + int nfingers = 0, i; for (i = 0; i <= MAXIMAL_MT_SLOT(evdev); i++) - if (evdev_get_mt_value(evdev, i, ABS_MT_TRACKING_ID) != -1) + if (evdev_mt_get_value(evdev, i, ABS_MT_TRACKING_ID) != -1) nfingers++; return (nfingers); } static void -evdev_send_nfingers(struct evdev_dev *evdev, int32_t nfingers) -{ - int32_t i; - - EVDEV_LOCK_ASSERT(evdev); - - if (nfingers > nitems(evdev_fngmap)) - nfingers = nitems(evdev_fngmap); - - for (i = 0; i < nitems(evdev_fngmap); i++) - evdev_send_event(evdev, EV_KEY, evdev_fngmap[i], - nfingers == i + 1); -} - -void -evdev_push_nfingers(struct evdev_dev *evdev, int32_t nfingers) +evdev_mt_send_st_compat(struct evdev_dev *evdev) { - - EVDEV_ENTER(evdev); - evdev_send_nfingers(evdev, nfingers); - EVDEV_EXIT(evdev); -} - -void -evdev_send_mt_compat(struct evdev_dev *evdev) -{ - int32_t nfingers, i; + int nfingers, i; EVDEV_LOCK_ASSERT(evdev); nfingers = evdev_count_fingers(evdev); evdev_send_event(evdev, EV_KEY, BTN_TOUCH, nfingers > 0); - if (evdev_get_mt_value(evdev, 0, ABS_MT_TRACKING_ID) != -1) + if (evdev_mt_get_value(evdev, 0, ABS_MT_TRACKING_ID) != -1) /* Echo 0-th MT-slot as ST-slot */ for (i = 0; i < nitems(evdev_mtstmap); i++) if (bit_test(evdev->ev_abs_flags, evdev_mtstmap[i][1])) evdev_send_event(evdev, EV_ABS, evdev_mtstmap[i][1], - evdev_get_mt_value(evdev, 0, + evdev_mt_get_value(evdev, 0, evdev_mtstmap[i][0])); /* Touchscreens should not report tool taps */ @@ -260,24 +238,32 @@ evdev_push_mt_compat(struct evdev_dev *evdev) { EVDEV_ENTER(evdev); - evdev_send_mt_compat(evdev); + evdev_mt_send_st_compat(evdev); EVDEV_EXIT(evdev); } -void -evdev_send_mt_autorel(struct evdev_dev *evdev) +static void +evdev_mt_send_autorel(struct evdev_dev *evdev) { - int32_t slot; + struct evdev_mt *mt = evdev->ev_mt; + int slot; EVDEV_LOCK_ASSERT(evdev); for (slot = 0; slot <= MAXIMAL_MT_SLOT(evdev); slot++) { - if (evdev->ev_mt->ev_mt_slots[slot].ev_report != - evdev->ev_report_count && - evdev_get_mt_value(evdev, slot, ABS_MT_TRACKING_ID) != -1){ + if (mt->slots[slot].ev_report != evdev->ev_report_count && + evdev_mt_get_value(evdev, slot, ABS_MT_TRACKING_ID) != -1){ evdev_send_event(evdev, EV_ABS, ABS_MT_SLOT, slot); evdev_send_event(evdev, EV_ABS, ABS_MT_TRACKING_ID, -1); } } } + +void +evdev_mt_push_autorel(struct evdev_dev *evdev) +{ + EVDEV_ENTER(evdev); + evdev_mt_send_autorel(evdev); + EVDEV_EXIT(evdev); +} diff --git a/sys/dev/evdev/evdev_private.h b/sys/dev/evdev/evdev_private.h index 463f93847295..fc079a324ba4 100644 --- a/sys/dev/evdev/evdev_private.h +++ b/sys/dev/evdev/evdev_private.h @@ -279,14 +279,14 @@ void evdev_revoke_client(struct evdev_client *); /* Multitouch related functions: */ void evdev_mt_init(struct evdev_dev *); void evdev_mt_free(struct evdev_dev *); -int32_t evdev_get_last_mt_slot(struct evdev_dev *); -void evdev_set_last_mt_slot(struct evdev_dev *, int32_t); -int32_t evdev_get_mt_value(struct evdev_dev *, int32_t, int16_t); -void evdev_set_mt_value(struct evdev_dev *, int32_t, int16_t, int32_t); -void evdev_send_mt_compat(struct evdev_dev *); -void evdev_send_mt_autorel(struct evdev_dev *); +void evdev_mt_sync_frame(struct evdev_dev *); +int evdev_mt_get_last_slot(struct evdev_dev *); +void evdev_mt_set_last_slot(struct evdev_dev *, int); +int32_t evdev_mt_get_value(struct evdev_dev *, int, int16_t); +void evdev_mt_set_value(struct evdev_dev *, int, int16_t, int32_t); /* Utility functions: */ void evdev_client_dumpqueue(struct evdev_client *); +void evdev_send_nfingers(struct evdev_dev *, int); #endif /* _DEV_EVDEV_EVDEV_PRIVATE_H */ diff --git a/sys/dev/evdev/evdev_utils.c b/sys/dev/evdev/evdev_utils.c index dcdd3a6d5126..9bb58d9b7ba1 100644 --- a/sys/dev/evdev/evdev_utils.c +++ b/sys/dev/evdev/evdev_utils.c @@ -38,6 +38,7 @@ #include #include +#include #include #define NONE KEY_RESERVED @@ -205,6 +206,14 @@ static uint16_t evdev_led_codes[] = { LED_SCROLLL, /* SLKED */ }; +static uint16_t evdev_nfinger_codes[] = { + BTN_TOOL_FINGER, + BTN_TOOL_DOUBLETAP, + BTN_TOOL_TRIPLETAP, + BTN_TOOL_QUADTAP, + BTN_TOOL_QUINTTAP, +}; + uint16_t evdev_hid2key(int scancode) { @@ -300,3 +309,35 @@ evdev_push_repeats(struct evdev_dev *evdev, keyboard_t *kbd) evdev_push_event(evdev, EV_REP, REP_DELAY, kbd->kb_delay1); evdev_push_event(evdev, EV_REP, REP_PERIOD, kbd->kb_delay2); } + +void +evdev_support_nfingers(struct evdev_dev *evdev, int nfingers) +{ + int i; + + for (i = 0; i < MIN(nitems(evdev_nfinger_codes), nfingers); i++) + evdev_support_key(evdev, evdev_nfinger_codes[i]); +} + +void +evdev_send_nfingers(struct evdev_dev *evdev, int nfingers) +{ + int i; + + EVDEV_LOCK_ASSERT(evdev); + + if (nfingers > nitems(evdev_nfinger_codes)) + nfingers = nitems(evdev_nfinger_codes); + + for (i = 0; i < nitems(evdev_nfinger_codes); i++) + evdev_send_event(evdev, EV_KEY, evdev_nfinger_codes[i], + nfingers == i + 1); +} + +void +evdev_push_nfingers(struct evdev_dev *evdev, int nfingers) +{ + EVDEV_ENTER(evdev); + evdev_send_nfingers(evdev, nfingers); + EVDEV_EXIT(evdev); +} From owner-dev-commits-src-main@freebsd.org Tue Aug 24 23:04:14 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F3FF1669150; Tue, 24 Aug 2021 23:04:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvPn95VkMz4Zkx; Tue, 24 Aug 2021 23:04:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 731CE11B0F; Tue, 24 Aug 2021 23:04:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17ON4D4S000749; Tue, 24 Aug 2021 23:04:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ON4DsM000748; Tue, 24 Aug 2021 23:04:13 GMT (envelope-from git) Date: Tue, 24 Aug 2021 23:04:13 GMT Message-Id: <202108242304.17ON4DsM000748@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: fbe17f9017e7 - main - evdev: Send first active rather than 0-th slot state as ST report MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fbe17f9017e785dd564ce7fc5553a9136d3a0b03 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 23:04:14 -0000 The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=fbe17f9017e785dd564ce7fc5553a9136d3a0b03 commit fbe17f9017e785dd564ce7fc5553a9136d3a0b03 Author: Vladimir Kondratyev AuthorDate: 2021-08-24 22:45:16 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-08-24 22:45:16 +0000 evdev: Send first active rather than 0-th slot state as ST report MFC after: 2 weeks --- sys/dev/evdev/evdev_mt.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sys/dev/evdev/evdev_mt.c b/sys/dev/evdev/evdev_mt.c index a28b034884ba..0ededf053f36 100644 --- a/sys/dev/evdev/evdev_mt.c +++ b/sys/dev/evdev/evdev_mt.c @@ -205,20 +205,21 @@ static void evdev_mt_send_st_compat(struct evdev_dev *evdev) { struct evdev_mt *mt = evdev->ev_mt; - int nfingers, i; + int nfingers, i, st_slot; EVDEV_LOCK_ASSERT(evdev); nfingers = bitcount(mt->touches); evdev_send_event(evdev, EV_KEY, BTN_TOUCH, nfingers > 0); - if ((mt->touches & 1U << 0) != 0) - /* Echo 0-th MT-slot as ST-slot */ + /* Send first active MT-slot state as single touch report */ + st_slot = ffs(mt->touches) - 1; + if (st_slot != -1) for (i = 0; i < nitems(evdev_mtstmap); i++) if (bit_test(evdev->ev_abs_flags, evdev_mtstmap[i][1])) evdev_send_event(evdev, EV_ABS, evdev_mtstmap[i][1], - evdev_mt_get_value(evdev, 0, + evdev_mt_get_value(evdev, st_slot, evdev_mtstmap[i][0])); /* Touchscreens should not report tool taps */ From owner-dev-commits-src-main@freebsd.org Tue Aug 24 23:04:12 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CDC36669068; Tue, 24 Aug 2021 23:04:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvPn83HKDz4ZhM; Tue, 24 Aug 2021 23:04:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4AC8911B0E; Tue, 24 Aug 2021 23:04:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17ON4CxP000725; Tue, 24 Aug 2021 23:04:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ON4CW0000724; Tue, 24 Aug 2021 23:04:12 GMT (envelope-from git) Date: Tue, 24 Aug 2021 23:04:12 GMT Message-Id: <202108242304.17ON4CW0000724@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: 2dc7188e532f - main - evdev: Use bitsets to track active touches and slots changed in current report MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2dc7188e532f0147b36a44ce5c033d9f59cbd9f4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 23:04:13 -0000 The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=2dc7188e532f0147b36a44ce5c033d9f59cbd9f4 commit 2dc7188e532f0147b36a44ce5c033d9f59cbd9f4 Author: Vladimir Kondratyev AuthorDate: 2021-08-24 22:44:36 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-08-24 22:44:36 +0000 evdev: Use bitsets to track active touches and slots changed in current report Obtained from: OpenBSD MFC after: 2 weeks --- sys/dev/evdev/evdev_mt.c | 94 ++++++++++++++++++++++-------------------------- 1 file changed, 43 insertions(+), 51 deletions(-) diff --git a/sys/dev/evdev/evdev_mt.c b/sys/dev/evdev/evdev_mt.c index e8f892e235c0..a28b034884ba 100644 --- a/sys/dev/evdev/evdev_mt.c +++ b/sys/dev/evdev/evdev_mt.c @@ -42,6 +42,13 @@ #define debugf(fmt, args...) #endif +typedef u_int slotset_t; + +_Static_assert(MAX_MT_SLOTS < sizeof(slotset_t) * 8, "MAX_MT_SLOTS too big"); + +#define FOREACHBIT(v, i) \ + for ((i) = ffs(v) - 1; (i) != -1; (i) = ffs((v) & (~1 << (i))) - 1) + static uint16_t evdev_mtstmap[][2] = { { ABS_MT_POSITION_X, ABS_X }, { ABS_MT_POSITION_Y, ABS_Y }, @@ -50,18 +57,27 @@ static uint16_t evdev_mtstmap[][2] = { }; struct evdev_mt_slot { - uint64_t ev_report; int32_t val[MT_CNT]; }; struct evdev_mt { int last_reported_slot; + /* the set of slots with active touches */ + slotset_t touches; + /* the set of slots with unsynchronized state */ + slotset_t frame; struct evdev_mt_slot slots[]; }; static void evdev_mt_send_st_compat(struct evdev_dev *); static void evdev_mt_send_autorel(struct evdev_dev *); +static inline int +ffc_slot(struct evdev_dev *evdev, slotset_t slots) +{ + return (ffs(~slots & (2U << MAXIMAL_MT_SLOT(evdev)) - 1) - 1); +} + void evdev_mt_init(struct evdev_dev *evdev) { @@ -73,17 +89,9 @@ evdev_mt_init(struct evdev_dev *evdev) sizeof(struct evdev_mt_slot) * slots, M_EVDEV, M_WAITOK | M_ZERO); /* Initialize multitouch protocol type B states */ - for (slot = 0; slot < slots; slot++) { - /* - * .ev_report should not be initialized to initial value of - * report counter (0) as it brokes free slot detection in - * evdev_get_mt_slot_by_tracking_id. So initialize it to -1 - */ - evdev->ev_mt->slots[slot] = (struct evdev_mt_slot) { - .ev_report = 0xFFFFFFFFFFFFFFFFULL, - .val[ABS_MT_INDEX(ABS_MT_TRACKING_ID)] = -1, - }; - } + for (slot = 0; slot < slots; slot++) + evdev->ev_mt->slots[slot].val[ABS_MT_INDEX(ABS_MT_TRACKING_ID)] + = -1; if (bit_test(evdev->ev_flags, EVDEV_FLAG_MT_STCOMPAT)) evdev_support_mt_compat(evdev); @@ -103,6 +111,7 @@ evdev_mt_sync_frame(struct evdev_dev *evdev) if (evdev->ev_report_opened && bit_test(evdev->ev_flags, EVDEV_FLAG_MT_STCOMPAT)) evdev_mt_send_st_compat(evdev); + evdev->ev_mt->frame = 0; } int @@ -118,7 +127,7 @@ evdev_mt_set_last_slot(struct evdev_dev *evdev, int slot) MPASS(slot >= 0 && slot <= MAXIMAL_MT_SLOT(evdev)); - mt->slots[slot].ev_report = evdev->ev_report_count; + mt->frame |= 1U << slot; mt->last_reported_slot = slot; } @@ -140,6 +149,12 @@ evdev_mt_set_value(struct evdev_dev *evdev, int slot, int16_t code, MPASS(slot >= 0 && slot <= MAXIMAL_MT_SLOT(evdev)); + if (code == ABS_MT_TRACKING_ID) { + if (value != -1) + mt->touches |= 1U << slot; + else + mt->touches &= ~(1U << slot); + } mt->slots[slot].val[ABS_MT_INDEX(code)] = value; } @@ -147,25 +162,17 @@ int evdev_get_mt_slot_by_tracking_id(struct evdev_dev *evdev, int32_t tracking_id) { struct evdev_mt *mt = evdev->ev_mt; - int32_t tr_id; - int slot, free_slot = -1; + int slot; - for (slot = 0; slot <= MAXIMAL_MT_SLOT(evdev); slot++) { - tr_id = evdev_mt_get_value(evdev, slot, ABS_MT_TRACKING_ID); - if (tr_id == tracking_id) + FOREACHBIT(mt->touches, slot) + if (evdev_mt_get_value(evdev, slot, ABS_MT_TRACKING_ID) == + tracking_id) return (slot); - /* - * Its possible that slot will be reassigned in a place of just - * released one within the same report. To avoid this compare - * report counter with slot`s report number updated with each - * ABS_MT_TRACKING_ID change. - */ - if (free_slot == -1 && tr_id == -1 && - mt->slots[slot].ev_report != evdev->ev_report_count) - free_slot = slot; - } - - return (free_slot); + /* + * Do not allow allocation of new slot in a place of just + * released one within the same report. + */ + return (ffc_slot(evdev, mt->touches | mt->frame)); } void @@ -194,29 +201,18 @@ evdev_support_mt_compat(struct evdev_dev *evdev) evdev->ev_absinfo[evdev_mtstmap[i][0]].resolution); } -static int32_t -evdev_count_fingers(struct evdev_dev *evdev) -{ - int nfingers = 0, i; - - for (i = 0; i <= MAXIMAL_MT_SLOT(evdev); i++) - if (evdev_mt_get_value(evdev, i, ABS_MT_TRACKING_ID) != -1) - nfingers++; - - return (nfingers); -} - static void evdev_mt_send_st_compat(struct evdev_dev *evdev) { + struct evdev_mt *mt = evdev->ev_mt; int nfingers, i; EVDEV_LOCK_ASSERT(evdev); - nfingers = evdev_count_fingers(evdev); + nfingers = bitcount(mt->touches); evdev_send_event(evdev, EV_KEY, BTN_TOUCH, nfingers > 0); - if (evdev_mt_get_value(evdev, 0, ABS_MT_TRACKING_ID) != -1) + if ((mt->touches & 1U << 0) != 0) /* Echo 0-th MT-slot as ST-slot */ for (i = 0; i < nitems(evdev_mtstmap); i++) if (bit_test(evdev->ev_abs_flags, evdev_mtstmap[i][1])) @@ -250,13 +246,9 @@ evdev_mt_send_autorel(struct evdev_dev *evdev) EVDEV_LOCK_ASSERT(evdev); - for (slot = 0; slot <= MAXIMAL_MT_SLOT(evdev); slot++) { - if (mt->slots[slot].ev_report != evdev->ev_report_count && - evdev_mt_get_value(evdev, slot, ABS_MT_TRACKING_ID) != -1){ - evdev_send_event(evdev, EV_ABS, ABS_MT_SLOT, slot); - evdev_send_event(evdev, EV_ABS, ABS_MT_TRACKING_ID, - -1); - } + FOREACHBIT(mt->touches & ~mt->frame, slot) { + evdev_send_event(evdev, EV_ABS, ABS_MT_SLOT, slot); + evdev_send_event(evdev, EV_ABS, ABS_MT_TRACKING_ID, -1); } } From owner-dev-commits-src-main@freebsd.org Tue Aug 24 23:04:16 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 09CF2669153; Tue, 24 Aug 2021 23:04:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvPnB6jltz4ZwR; Tue, 24 Aug 2021 23:04:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 889F511B10; Tue, 24 Aug 2021 23:04:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17ON4Ep7000773; Tue, 24 Aug 2021 23:04:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ON4EJ2000772; Tue, 24 Aug 2021 23:04:14 GMT (envelope-from git) Date: Tue, 24 Aug 2021 23:04:14 GMT Message-Id: <202108242304.17ON4EJ2000772@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: 314913ed7c6e - main - evdev: force no fuzz for autogenerated single touch compat events. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 314913ed7c6e6e1b7c80a1063620f478961419b7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 23:04:16 -0000 The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=314913ed7c6e6e1b7c80a1063620f478961419b7 commit 314913ed7c6e6e1b7c80a1063620f478961419b7 Author: Vladimir Kondratyev AuthorDate: 2021-08-24 22:45:50 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-08-24 22:45:50 +0000 evdev: force no fuzz for autogenerated single touch compat events. As fuzz has already been applied on multitouch event processing. This allows to remove existing workaround for double fuzz procesing. MFC after: 2 weeks --- sys/dev/evdev/evdev.c | 2 +- sys/dev/evdev/evdev_mt.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/evdev/evdev.c b/sys/dev/evdev/evdev.c index 8483faee8d6b..d6f6cc2e003f 100644 --- a/sys/dev/evdev/evdev.c +++ b/sys/dev/evdev/evdev.c @@ -876,6 +876,7 @@ evdev_send_event(struct evdev_dev *evdev, uint16_t type, uint16_t code, EVDEV_LOCK_ASSERT(evdev); + evdev_modify_event(evdev, type, code, &value); sparse = evdev_sparse_event(evdev, type, code, value); switch (sparse) { case EV_REPORT_MT_SLOT: @@ -939,7 +940,6 @@ evdev_push_event(struct evdev_dev *evdev, uint16_t type, uint16_t code, evdev_restore_after_kdb(evdev); } - evdev_modify_event(evdev, type, code, &value); if (type == EV_SYN && code == SYN_REPORT && bit_test(evdev->ev_abs_flags, ABS_MT_SLOT)) evdev_mt_sync_frame(evdev); diff --git a/sys/dev/evdev/evdev_mt.c b/sys/dev/evdev/evdev_mt.c index 0ededf053f36..0b5d2cb6bb85 100644 --- a/sys/dev/evdev/evdev_mt.c +++ b/sys/dev/evdev/evdev_mt.c @@ -196,7 +196,7 @@ evdev_support_mt_compat(struct evdev_dev *evdev) evdev_support_abs(evdev, evdev_mtstmap[i][1], evdev->ev_absinfo[evdev_mtstmap[i][0]].minimum, evdev->ev_absinfo[evdev_mtstmap[i][0]].maximum, - evdev->ev_absinfo[evdev_mtstmap[i][0]].fuzz, + 0, evdev->ev_absinfo[evdev_mtstmap[i][0]].flat, evdev->ev_absinfo[evdev_mtstmap[i][0]].resolution); } From owner-dev-commits-src-main@freebsd.org Tue Aug 24 23:04:17 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 651D966932B; Tue, 24 Aug 2021 23:04:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvPnD09kmz4Zsv; Tue, 24 Aug 2021 23:04:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9BA8F11B11; Tue, 24 Aug 2021 23:04:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17ON4FKL000797; Tue, 24 Aug 2021 23:04:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ON4FfL000796; Tue, 24 Aug 2021 23:04:15 GMT (envelope-from git) Date: Tue, 24 Aug 2021 23:04:15 GMT Message-Id: <202108242304.17ON4FfL000796@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: 127e54deb6d8 - main - evdev: Normalize width and pressure of single touch compat events MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 127e54deb6d8899e1dc1bc6251d512e19f21b0f1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 23:04:18 -0000 The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=127e54deb6d8899e1dc1bc6251d512e19f21b0f1 commit 127e54deb6d8899e1dc1bc6251d512e19f21b0f1 Author: Vladimir Kondratyev AuthorDate: 2021-08-24 22:46:49 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-08-24 22:46:49 +0000 evdev: Normalize width and pressure of single touch compat events to match Synaptics touchpad reporting range. MFC after: 2 weeks --- sys/dev/evdev/evdev_mt.c | 67 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 49 insertions(+), 18 deletions(-) diff --git a/sys/dev/evdev/evdev_mt.c b/sys/dev/evdev/evdev_mt.c index 0b5d2cb6bb85..a3600e837960 100644 --- a/sys/dev/evdev/evdev_mt.c +++ b/sys/dev/evdev/evdev_mt.c @@ -49,11 +49,15 @@ _Static_assert(MAX_MT_SLOTS < sizeof(slotset_t) * 8, "MAX_MT_SLOTS too big"); #define FOREACHBIT(v, i) \ for ((i) = ffs(v) - 1; (i) != -1; (i) = ffs((v) & (~1 << (i))) - 1) -static uint16_t evdev_mtstmap[][2] = { - { ABS_MT_POSITION_X, ABS_X }, - { ABS_MT_POSITION_Y, ABS_Y }, - { ABS_MT_PRESSURE, ABS_PRESSURE }, - { ABS_MT_TOUCH_MAJOR, ABS_TOOL_WIDTH }, +struct { + uint16_t mt; + uint16_t st; + int32_t max; +} static evdev_mtstmap[] = { + { ABS_MT_POSITION_X, ABS_X, 0 }, + { ABS_MT_POSITION_Y, ABS_Y, 0 }, + { ABS_MT_PRESSURE, ABS_PRESSURE, 255 }, + { ABS_MT_TOUCH_MAJOR, ABS_TOOL_WIDTH, 15 }, }; struct evdev_mt_slot { @@ -62,6 +66,7 @@ struct evdev_mt_slot { struct evdev_mt { int last_reported_slot; + u_int mtst_events; /* the set of slots with active touches */ slotset_t touches; /* the set of slots with unsynchronized state */ @@ -175,9 +180,20 @@ evdev_get_mt_slot_by_tracking_id(struct evdev_dev *evdev, int32_t tracking_id) return (ffc_slot(evdev, mt->touches | mt->frame)); } +static inline int32_t +evdev_mt_normalize(int32_t value, int32_t mtmin, int32_t mtmax, int32_t stmax) +{ + if (stmax != 0 && mtmax != mtmin) { + value = (value - mtmin) * stmax / (mtmax - mtmin); + value = MAX(MIN(value, stmax), 0); + } + return (value); +} + void evdev_support_mt_compat(struct evdev_dev *evdev) { + struct input_absinfo *ai; int i; if (evdev->ev_absinfo == NULL) @@ -191,14 +207,28 @@ evdev_support_mt_compat(struct evdev_dev *evdev) evdev_support_nfingers(evdev, MAXIMAL_MT_SLOT(evdev) + 1); /* Echo 0-th MT-slot as ST-slot */ - for (i = 0; i < nitems(evdev_mtstmap); i++) - if (bit_test(evdev->ev_abs_flags, evdev_mtstmap[i][0])) - evdev_support_abs(evdev, evdev_mtstmap[i][1], - evdev->ev_absinfo[evdev_mtstmap[i][0]].minimum, - evdev->ev_absinfo[evdev_mtstmap[i][0]].maximum, + for (i = 0; i < nitems(evdev_mtstmap); i++) { + if (!bit_test(evdev->ev_abs_flags, evdev_mtstmap[i].mt) || + bit_test(evdev->ev_abs_flags, evdev_mtstmap[i].st)) + continue; + ai = evdev->ev_absinfo + evdev_mtstmap[i].mt; + evdev->ev_mt->mtst_events |= 1U << i; + if (evdev_mtstmap[i].max != 0) + evdev_support_abs(evdev, evdev_mtstmap[i].st, 0, - evdev->ev_absinfo[evdev_mtstmap[i][0]].flat, - evdev->ev_absinfo[evdev_mtstmap[i][0]].resolution); + evdev_mtstmap[i].max, + 0, + evdev_mt_normalize( + ai->flat, 0, ai->maximum, evdev_mtstmap[i].max), + 0); + else + evdev_support_abs(evdev, evdev_mtstmap[i].st, + ai->minimum, + ai->maximum, + 0, + ai->flat, + ai->resolution); + } } static void @@ -215,12 +245,13 @@ evdev_mt_send_st_compat(struct evdev_dev *evdev) /* Send first active MT-slot state as single touch report */ st_slot = ffs(mt->touches) - 1; if (st_slot != -1) - for (i = 0; i < nitems(evdev_mtstmap); i++) - if (bit_test(evdev->ev_abs_flags, evdev_mtstmap[i][1])) - evdev_send_event(evdev, EV_ABS, - evdev_mtstmap[i][1], - evdev_mt_get_value(evdev, st_slot, - evdev_mtstmap[i][0])); + FOREACHBIT(mt->mtst_events, i) + evdev_send_event(evdev, EV_ABS, evdev_mtstmap[i].st, + evdev_mt_normalize(evdev_mt_get_value(evdev, + st_slot, evdev_mtstmap[i].mt), + evdev->ev_absinfo[evdev_mtstmap[i].mt].minimum, + evdev->ev_absinfo[evdev_mtstmap[i].mt].maximum, + evdev_mtstmap[i].max)); /* Touchscreens should not report tool taps */ if (!bit_test(evdev->ev_prop_flags, INPUT_PROP_DIRECT)) From owner-dev-commits-src-main@freebsd.org Tue Aug 24 23:04:19 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7EA0266915D; Tue, 24 Aug 2021 23:04:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvPnG2ymdz4ZqY; Tue, 24 Aug 2021 23:04:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0E573119D6; Tue, 24 Aug 2021 23:04:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17ON4HHH000852; Tue, 24 Aug 2021 23:04:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ON4Hhk000851; Tue, 24 Aug 2021 23:04:17 GMT (envelope-from git) Date: Tue, 24 Aug 2021 23:04:17 GMT Message-Id: <202108242304.17ON4Hhk000851@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: 66bd52f5e241 - main - evdev: Make MT tracking IDs monotonically increasing sequence. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 66bd52f5e241bd2548015f847f12cdff69176c40 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 23:04:19 -0000 The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=66bd52f5e241bd2548015f847f12cdff69176c40 commit 66bd52f5e241bd2548015f847f12cdff69176c40 Author: Vladimir Kondratyev AuthorDate: 2021-08-24 22:48:33 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-08-24 22:48:33 +0000 evdev: Make MT tracking IDs monotonically increasing sequence. MFC after: 2 weeks --- sys/dev/evdev/evdev.c | 16 ++++++++++++---- sys/dev/evdev/evdev.h | 1 + sys/dev/evdev/evdev_mt.c | 35 ++++++++++++++++++++++++++++++++++- sys/dev/evdev/evdev_private.h | 1 + sys/dev/evdev/uinput.c | 1 + 5 files changed, 49 insertions(+), 5 deletions(-) diff --git a/sys/dev/evdev/evdev.c b/sys/dev/evdev/evdev.c index d6f6cc2e003f..b5eed0e5f02f 100644 --- a/sys/dev/evdev/evdev.c +++ b/sys/dev/evdev/evdev.c @@ -701,15 +701,23 @@ evdev_modify_event(struct evdev_dev *evdev, uint16_t type, uint16_t code, break; case EV_ABS: - fuzz = evdev->ev_absinfo[code].fuzz; - if (fuzz == 0 || code == ABS_MT_SLOT) + if (code == ABS_MT_SLOT) break; else if (!ABS_IS_MT(code)) old_value = evdev->ev_absinfo[code].value; - else if (bit_test(evdev->ev_abs_flags, ABS_MT_SLOT)) + else if (!bit_test(evdev->ev_abs_flags, ABS_MT_SLOT)) + /* Pass MT protocol type A events as is */ + break; + else if (code == ABS_MT_TRACKING_ID) { + *value = evdev_mt_reassign_id(evdev, + evdev_mt_get_last_slot(evdev), *value); + break; + } else old_value = evdev_mt_get_value(evdev, evdev_mt_get_last_slot(evdev), code); - else /* Pass MT protocol type A events as is */ + + fuzz = evdev->ev_absinfo[code].fuzz; + if (fuzz == 0) break; abs_change = abs(*value - old_value); diff --git a/sys/dev/evdev/evdev.h b/sys/dev/evdev/evdev.h index 64bf75f04efd..e1c5aedb029c 100644 --- a/sys/dev/evdev/evdev.h +++ b/sys/dev/evdev/evdev.h @@ -90,6 +90,7 @@ extern int evdev_sysmouse_t_axis; * current MT protocol type B report */ #define EVDEV_FLAG_EXT_EPOCH 0x03 /* evdev_push_* is allways called with * input (global) epoch entered */ +#define EVDEV_FLAG_MT_KEEPID 0x04 /* Do not reassign tracking ID */ #define EVDEV_FLAG_MAX 0x1F #define EVDEV_FLAG_CNT (EVDEV_FLAG_MAX + 1) diff --git a/sys/dev/evdev/evdev_mt.c b/sys/dev/evdev/evdev_mt.c index 6f5cce4a008d..1a600fe3480d 100644 --- a/sys/dev/evdev/evdev_mt.c +++ b/sys/dev/evdev/evdev_mt.c @@ -62,6 +62,8 @@ struct { struct evdev_mt { int last_reported_slot; + uint16_t tracking_id; + int32_t tracking_ids[MAX_MT_SLOTS]; u_int mtst_events; /* the set of slots with active touches */ slotset_t touches; @@ -93,6 +95,9 @@ evdev_mt_init(struct evdev_dev *evdev) for (slot = 0; slot < slots; slot++) evdev->ev_mt->slots[slot].id = -1; + if (!bit_test(evdev->ev_flags, EVDEV_FLAG_MT_KEEPID)) + evdev_support_abs(evdev, + ABS_MT_TRACKING_ID, -1, UINT16_MAX, 0, 0, 0); if (bit_test(evdev->ev_flags, EVDEV_FLAG_MT_STCOMPAT)) evdev_support_mt_compat(evdev); } @@ -208,7 +213,7 @@ evdev_get_mt_slot_by_tracking_id(struct evdev_dev *evdev, int32_t tracking_id) int slot; FOREACHBIT(mt->touches, slot) - if (mt->slots[slot].id == tracking_id) + if (mt->tracking_ids[slot] == tracking_id) return (slot); /* * Do not allow allocation of new slot in a place of just @@ -217,6 +222,34 @@ evdev_get_mt_slot_by_tracking_id(struct evdev_dev *evdev, int32_t tracking_id) return (ffc_slot(evdev, mt->touches | mt->frame)); } +int32_t +evdev_mt_reassign_id(struct evdev_dev *evdev, int slot, int32_t id) +{ + struct evdev_mt *mt = evdev->ev_mt; + int32_t nid; + + if (id == -1 || bit_test(evdev->ev_flags, EVDEV_FLAG_MT_KEEPID)) { + mt->tracking_ids[slot] = id; + return (id); + } + + nid = evdev_mt_get_value(evdev, slot, ABS_MT_TRACKING_ID); + if (nid != -1) { + KASSERT(id == mt->tracking_ids[slot], + ("MT-slot tracking id has changed")); + return (nid); + } + + mt->tracking_ids[slot] = id; +again: + nid = mt->tracking_id++; + FOREACHBIT(mt->touches, slot) + if (evdev_mt_get_value(evdev, slot, ABS_MT_TRACKING_ID) == nid) + goto again; + + return (nid); +} + static inline int32_t evdev_mt_normalize(int32_t value, int32_t mtmin, int32_t mtmax, int32_t stmax) { diff --git a/sys/dev/evdev/evdev_private.h b/sys/dev/evdev/evdev_private.h index fc079a324ba4..3fb2d61d091a 100644 --- a/sys/dev/evdev/evdev_private.h +++ b/sys/dev/evdev/evdev_private.h @@ -284,6 +284,7 @@ int evdev_mt_get_last_slot(struct evdev_dev *); void evdev_mt_set_last_slot(struct evdev_dev *, int); int32_t evdev_mt_get_value(struct evdev_dev *, int, int16_t); void evdev_mt_set_value(struct evdev_dev *, int, int16_t, int32_t); +int32_t evdev_mt_reassign_id(struct evdev_dev *, int, int32_t); /* Utility functions: */ void evdev_client_dumpqueue(struct evdev_client *); diff --git a/sys/dev/evdev/uinput.c b/sys/dev/evdev/uinput.c index ceecee652ac3..e7854e89f645 100644 --- a/sys/dev/evdev/uinput.c +++ b/sys/dev/evdev/uinput.c @@ -495,6 +495,7 @@ uinput_ioctl_sub(struct uinput_cdev_state *state, u_long cmd, caddr_t data) evdev_set_methods(state->ucs_evdev, state, &uinput_ev_methods); evdev_set_flag(state->ucs_evdev, EVDEV_FLAG_SOFTREPEAT); + evdev_set_flag(state->ucs_evdev, EVDEV_FLAG_MT_KEEPID); ret = evdev_register(state->ucs_evdev); if (ret == 0) state->ucs_state = UINPUT_RUNNING; From owner-dev-commits-src-main@freebsd.org Tue Aug 24 23:04:23 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2DBA766925A; Tue, 24 Aug 2021 23:04:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvPnL51kdz4Zqt; Tue, 24 Aug 2021 23:04:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6945711B13; Tue, 24 Aug 2021 23:04:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17ON4LaG000924; Tue, 24 Aug 2021 23:04:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ON4L8c000923; Tue, 24 Aug 2021 23:04:21 GMT (envelope-from git) Date: Tue, 24 Aug 2021 23:04:21 GMT Message-Id: <202108242304.17ON4L8c000923@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: d056693d7bc6 - main - evdev: Add support for automatic MT protocol type A to type B conversion. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d056693d7bc6c1b5f2c1612e5b34807f173e21c7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 23:04:23 -0000 The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=d056693d7bc6c1b5f2c1612e5b34807f173e21c7 commit d056693d7bc6c1b5f2c1612e5b34807f173e21c7 Author: Vladimir Kondratyev AuthorDate: 2021-08-24 22:53:56 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-08-24 22:53:56 +0000 evdev: Add support for automatic MT protocol type A to type B conversion. MFC after: 2 weeks --- sys/dev/evdev/evdev.c | 5 +++-- sys/dev/evdev/evdev_mt.c | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/sys/dev/evdev/evdev.c b/sys/dev/evdev/evdev.c index 74335b6f40b1..2fd7c2e201ea 100644 --- a/sys/dev/evdev/evdev.c +++ b/sys/dev/evdev/evdev.c @@ -306,8 +306,9 @@ evdev_register_common(struct evdev_dev *evdev) } } - /* Initialize multitouch protocol type B states */ - if (bit_test(evdev->ev_abs_flags, ABS_MT_SLOT)) + /* Initialize multitouch protocol type B states or A to B converter */ + if (bit_test(evdev->ev_abs_flags, ABS_MT_SLOT) || + bit_test(evdev->ev_flags, EVDEV_FLAG_MT_TRACK)) evdev_mt_init(evdev); /* Estimate maximum report size */ diff --git a/sys/dev/evdev/evdev_mt.c b/sys/dev/evdev/evdev_mt.c index d5bf4affea1b..3030a60e098a 100644 --- a/sys/dev/evdev/evdev_mt.c +++ b/sys/dev/evdev/evdev_mt.c @@ -79,6 +79,7 @@ struct evdev_mt { int last_reported_slot; uint16_t tracking_id; int32_t tracking_ids[MAX_MT_SLOTS]; + bool type_a; u_int mtst_events; /* the set of slots with active touches */ slotset_t touches; @@ -108,6 +109,16 @@ evdev_mt_init(struct evdev_dev *evdev) struct evdev_mt *mt; size_t size = offsetof(struct evdev_mt, slots); int slot, slots; + bool type_a; + + type_a = !bit_test(evdev->ev_abs_flags, ABS_MT_SLOT); + if (type_a) { + /* Add events produced by MT type A to type B converter */ + evdev_support_abs(evdev, + ABS_MT_SLOT, 0, MAX_MT_SLOTS - 1, 0, 0, 0); + evdev_support_abs(evdev, + ABS_MT_TRACKING_ID, -1, MAX_MT_SLOTS - 1, 0, 0, 0); + } slots = MAXIMAL_MT_SLOT(evdev) + 1; size += sizeof(mt->slots[0]) * slots; @@ -118,6 +129,7 @@ evdev_mt_init(struct evdev_dev *evdev) mt = malloc(size, M_EVDEV, M_WAITOK | M_ZERO); evdev->ev_mt = mt; + mt->type_a = type_a; if (bit_test(evdev->ev_flags, EVDEV_FLAG_MT_TRACK)) { mt->match_slots = mt->slots + slots; @@ -186,13 +198,16 @@ evdev_mt_push_slot(struct evdev_dev *evdev, int slot, struct evdev_mt *mt = evdev->ev_mt; bool type_a = !bit_test(evdev->ev_abs_flags, ABS_MT_SLOT); - if (type_a && state == NULL) + if ((type_a || (mt != NULL && mt->type_a)) && state == NULL) return (EINVAL); if (!type_a && (slot < 0 || slot > MAXIMAL_MT_SLOT(evdev))) return (EINVAL); EVDEV_ENTER(evdev); - if (bit_test(evdev->ev_flags, EVDEV_FLAG_MT_TRACK)) { + if (bit_test(evdev->ev_flags, EVDEV_FLAG_MT_TRACK) && mt->type_a) { + mt->match_slots[mt->match_slot] = *state; + evdev_mt_record_event(evdev, EV_SYN, SYN_MT_REPORT, 1); + } else if (bit_test(evdev->ev_flags, EVDEV_FLAG_MT_TRACK)) { evdev_mt_record_event(evdev, EV_ABS, ABS_MT_SLOT, slot); if (state != NULL) mt->match_slots[mt->match_slot] = *state; @@ -394,14 +409,25 @@ evdev_mt_record_event(struct evdev_dev *evdev, uint16_t type, uint16_t code, EVDEV_LOCK_ASSERT(evdev); switch (type) { + case EV_SYN: + if (code == SYN_MT_REPORT) { + /* MT protocol type A support */ + KASSERT(mt->type_a, ("Not a MT type A protocol")); + mt->match_frame |= 1U << mt->match_slot; + mt->match_slot++; + return (true); + } + break; case EV_ABS: if (code == ABS_MT_SLOT) { /* MT protocol type B support */ + KASSERT(!mt->type_a, ("Not a MT type B protocol")); KASSERT(value >= 0, ("Negative slot number")); mt->match_slot = value; mt->match_frame |= 1U << mt->match_slot; return (true); } else if (code == ABS_MT_TRACKING_ID) { + KASSERT(!mt->type_a, ("Not a MT type B protocol")); if (value == -1) mt->match_frame &= ~(1U << mt->match_slot); return (true); @@ -496,6 +522,8 @@ evdev_get_mt_slot_by_tracking_id(struct evdev_dev *evdev, int32_t tracking_id) struct evdev_mt *mt = evdev->ev_mt; int slot; + KASSERT(!mt->type_a, ("Not a MT type B protocol")); + /* * Ignore tracking_id if slot assignment is performed by evdev. * Events are written sequentially to temporary matching buffer. From owner-dev-commits-src-main@freebsd.org Tue Aug 24 23:04:17 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B65DE669157; Tue, 24 Aug 2021 23:04:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvPnF069qz4Zt2; Tue, 24 Aug 2021 23:04:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D835F118C5; Tue, 24 Aug 2021 23:04:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17ON4Ga7000827; Tue, 24 Aug 2021 23:04:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ON4Gbn000826; Tue, 24 Aug 2021 23:04:16 GMT (envelope-from git) Date: Tue, 24 Aug 2021 23:04:16 GMT Message-Id: <202108242304.17ON4Gbn000826@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: 059360287e33 - main - evdev: Give short aliases to items of evdev_mt_slot array MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 059360287e3344f48f5a7839e2d6d54016b18b19 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 23:04:18 -0000 The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=059360287e3344f48f5a7839e2d6d54016b18b19 commit 059360287e3344f48f5a7839e2d6d54016b18b19 Author: Vladimir Kondratyev AuthorDate: 2021-08-24 22:47:34 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-08-24 22:47:34 +0000 evdev: Give short aliases to items of evdev_mt_slot array with using of unioned anonymous structure. Access to the same data by using different members of union generally works despite it is not supported by C specs. Also add helper function to report entire slot state. MFC after: 2 weeks --- sys/dev/evdev/evdev.h | 24 ++++++++++++++++++ sys/dev/evdev/evdev_mt.c | 63 +++++++++++++++++++++++++++++++++++++----------- 2 files changed, 73 insertions(+), 14 deletions(-) diff --git a/sys/dev/evdev/evdev.h b/sys/dev/evdev/evdev.h index fe21f8cea4c2..64bf75f04efd 100644 --- a/sys/dev/evdev/evdev.h +++ b/sys/dev/evdev/evdev.h @@ -102,6 +102,29 @@ struct evdev_methods evdev_keycode_t *ev_set_keycode; }; +union evdev_mt_slot { + int32_t val[MT_CNT]; + struct { + int32_t maj; /* ABS_MT_TOUCH_MAJOR */ + int32_t min; /* ABS_MT_TOUCH_MINOR */ + int32_t w_maj; /* ABS_MT_WIDTH_MAJOR */ + int32_t w_min; /* ABS_MT_WIDTH_MINOR */ + int32_t ori; /* ABS_MT_ORIENTATION */ + int32_t x; /* ABS_MT_POSITION_X */ + int32_t y; /* ABS_MT_POSITION_Y */ + int32_t type; /* ABS_MT_TOOL_TYPE */ + int32_t blob_id; /* ABS_MT_BLOB_ID */ + int32_t id; /* ABS_MT_TRACKING_ID */ + int32_t p; /* ABS_MT_PRESSURE */ + int32_t dist; /* ABS_MT_DISTANCE */ + int32_t tool_x; /* ABS_MT_TOOL_X */ + int32_t tool_y; /* ABS_MT_TOOL_Y */ + }; +}; +_Static_assert(offsetof(union evdev_mt_slot, tool_y) == + offsetof(union evdev_mt_slot, val[ABS_MT_INDEX(ABS_MT_TOOL_Y)]), + "evdev_mt_slot array members does not match their structure aliases"); + /* Input device interface: */ struct evdev_dev *evdev_alloc(void); void evdev_free(struct evdev_dev *); @@ -134,6 +157,7 @@ void *evdev_get_softc(struct evdev_dev *); int evdev_get_mt_slot_by_tracking_id(struct evdev_dev *, int32_t); void evdev_support_mt_compat(struct evdev_dev *); void evdev_push_mt_compat(struct evdev_dev *); +int evdev_mt_push_slot(struct evdev_dev *, int, union evdev_mt_slot *); void evdev_mt_push_autorel(struct evdev_dev *); static inline int evdev_mt_id_to_slot(struct evdev_dev *evdev, int32_t id) diff --git a/sys/dev/evdev/evdev_mt.c b/sys/dev/evdev/evdev_mt.c index a3600e837960..6f5cce4a008d 100644 --- a/sys/dev/evdev/evdev_mt.c +++ b/sys/dev/evdev/evdev_mt.c @@ -60,10 +60,6 @@ struct { { ABS_MT_TOUCH_MAJOR, ABS_TOOL_WIDTH, 15 }, }; -struct evdev_mt_slot { - int32_t val[MT_CNT]; -}; - struct evdev_mt { int last_reported_slot; u_int mtst_events; @@ -71,7 +67,7 @@ struct evdev_mt { slotset_t touches; /* the set of slots with unsynchronized state */ slotset_t frame; - struct evdev_mt_slot slots[]; + union evdev_mt_slot slots[]; }; static void evdev_mt_send_st_compat(struct evdev_dev *); @@ -91,12 +87,11 @@ evdev_mt_init(struct evdev_dev *evdev) slots = MAXIMAL_MT_SLOT(evdev) + 1; evdev->ev_mt = malloc(offsetof(struct evdev_mt, slots) + - sizeof(struct evdev_mt_slot) * slots, M_EVDEV, M_WAITOK | M_ZERO); + sizeof(union evdev_mt_slot) * slots, M_EVDEV, M_WAITOK | M_ZERO); /* Initialize multitouch protocol type B states */ for (slot = 0; slot < slots; slot++) - evdev->ev_mt->slots[slot].val[ABS_MT_INDEX(ABS_MT_TRACKING_ID)] - = -1; + evdev->ev_mt->slots[slot].id = -1; if (bit_test(evdev->ev_flags, EVDEV_FLAG_MT_STCOMPAT)) evdev_support_mt_compat(evdev); @@ -119,6 +114,49 @@ evdev_mt_sync_frame(struct evdev_dev *evdev) evdev->ev_mt->frame = 0; } +static void +evdev_mt_send_slot(struct evdev_dev *evdev, int slot, + union evdev_mt_slot *state) +{ + int i; + bool type_a = !bit_test(evdev->ev_abs_flags, ABS_MT_SLOT); + + EVDEV_LOCK_ASSERT(evdev); + MPASS(type_a || (slot >= 0 && slot <= MAXIMAL_MT_SLOT(evdev))); + MPASS(!type_a || state != NULL); + + if (!type_a) { + evdev_send_event(evdev, EV_ABS, ABS_MT_SLOT, slot); + if (state == NULL) { + evdev_send_event(evdev, EV_ABS, ABS_MT_TRACKING_ID, -1); + return; + } + } + bit_foreach_at(evdev->ev_abs_flags, ABS_MT_FIRST, ABS_MT_LAST + 1, i) + evdev_send_event(evdev, EV_ABS, i, + state->val[ABS_MT_INDEX(i)]); + if (type_a) + evdev_send_event(evdev, EV_SYN, SYN_MT_REPORT, 1); +} + +int +evdev_mt_push_slot(struct evdev_dev *evdev, int slot, + union evdev_mt_slot *state) +{ + bool type_a = !bit_test(evdev->ev_abs_flags, ABS_MT_SLOT); + + if (type_a && state == NULL) + return (EINVAL); + if (!type_a && (slot < 0 || slot > MAXIMAL_MT_SLOT(evdev))) + return (EINVAL); + + EVDEV_ENTER(evdev); + evdev_mt_send_slot(evdev, slot, state); + EVDEV_EXIT(evdev); + + return (0); +} + int evdev_mt_get_last_slot(struct evdev_dev *evdev) { @@ -170,8 +208,7 @@ evdev_get_mt_slot_by_tracking_id(struct evdev_dev *evdev, int32_t tracking_id) int slot; FOREACHBIT(mt->touches, slot) - if (evdev_mt_get_value(evdev, slot, ABS_MT_TRACKING_ID) == - tracking_id) + if (mt->slots[slot].id == tracking_id) return (slot); /* * Do not allow allocation of new slot in a place of just @@ -278,10 +315,8 @@ evdev_mt_send_autorel(struct evdev_dev *evdev) EVDEV_LOCK_ASSERT(evdev); - FOREACHBIT(mt->touches & ~mt->frame, slot) { - evdev_send_event(evdev, EV_ABS, ABS_MT_SLOT, slot); - evdev_send_event(evdev, EV_ABS, ABS_MT_TRACKING_ID, -1); - } + FOREACHBIT(mt->touches & ~mt->frame, slot) + evdev_mt_send_slot(evdev, slot, NULL); } void From owner-dev-commits-src-main@freebsd.org Tue Aug 24 23:04:28 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 13F3366916B; Tue, 24 Aug 2021 23:04:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvPnQ5Cyrz4b2b; Tue, 24 Aug 2021 23:04:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D2AFC117B4; Tue, 24 Aug 2021 23:04:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17ON4OGh001002; Tue, 24 Aug 2021 23:04:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ON4ODq001001; Tue, 24 Aug 2021 23:04:24 GMT (envelope-from git) Date: Tue, 24 Aug 2021 23:04:24 GMT Message-Id: <202108242304.17ON4ODq001001@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: 8d73071c47ff - main - wsp(4): Add evdev support. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8d73071c47ff1f911bdaec6356f37feb4e3b7cb5 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 23:04:28 -0000 The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=8d73071c47ff1f911bdaec6356f37feb4e3b7cb5 commit 8d73071c47ff1f911bdaec6356f37feb4e3b7cb5 Author: Vladimir Kondratyev AuthorDate: 2021-08-24 23:01:42 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-08-24 23:01:42 +0000 wsp(4): Add evdev support. Reviewed by: hselasky Tested by: Greg V, Constantin Furst MFC after: 2 weeks PR: 252236 Differential revision: https://reviews.freebsd.org/D31653 --- sys/dev/usb/input/wsp.c | 305 ++++++++++++++++++++++++++++++++++++++++--- sys/modules/usb/wsp/Makefile | 4 +- 2 files changed, 287 insertions(+), 22 deletions(-) diff --git a/sys/dev/usb/input/wsp.c b/sys/dev/usb/input/wsp.c index cc99c4678633..2c70b24d1f89 100644 --- a/sys/dev/usb/input/wsp.c +++ b/sys/dev/usb/input/wsp.c @@ -29,6 +29,8 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_evdev.h" + #include #include #include @@ -56,6 +58,11 @@ __FBSDID("$FreeBSD$"); #define USB_DEBUG_VAR wsp_debug #include +#ifdef EVDEV_SUPPORT +#include +#include +#endif + #include #define WSP_DRIVER_NAME "wsp" @@ -288,9 +295,14 @@ struct tp_finger { } __packed; /* trackpad finger data size, empirically at least ten fingers */ +#ifdef EVDEV_SUPPORT +#define MAX_FINGERS MAX_MT_SLOTS +#else #define MAX_FINGERS 16 +#endif #define SIZEOF_FINGER sizeof(struct tp_finger) #define SIZEOF_ALL_FINGERS (MAX_FINGERS * SIZEOF_FINGER) +#define MAX_FINGER_ORIENTATION 16384 #if (WSP_BUFFER_MAX < ((MAX_FINGERS * FSIZE_TYPE4) + FINGER_TYPE4)) #error "WSP_BUFFER_MAX is too small" @@ -313,50 +325,147 @@ enum { WSP_FLAG_MAX, }; +/* device-specific parameters */ +struct wsp_param { + int snratio; /* signal-to-noise ratio */ + int min; /* device minimum reading */ + int max; /* device maximum reading */ + int size; /* physical size, mm */ +}; + /* device-specific configuration */ struct wsp_dev_params { const struct wsp_tp* tp; + struct wsp_param p; /* finger pressure limits */ + struct wsp_param w; /* finger width limits */ + struct wsp_param x; /* horizontal limits */ + struct wsp_param y; /* vertical limits */ + struct wsp_param o; /* orientation limits */ }; +/* logical signal quality */ +#define SN_PRESSURE 45 /* pressure signal-to-noise ratio */ +#define SN_WIDTH 25 /* width signal-to-noise ratio */ +#define SN_COORD 250 /* coordinate signal-to-noise ratio */ +#define SN_ORIENT 10 /* orientation signal-to-noise ratio */ + static const struct wsp_dev_params wsp_dev_params[WSP_FLAG_MAX] = { [WSP_FLAG_WELLSPRING1] = { .tp = wsp_tp + TYPE1, + .p = { SN_PRESSURE, 0, 256, 0 }, + .w = { SN_WIDTH, 0, 2048, 0 }, + .x = { SN_COORD, -4824, 5342, 105 }, + .y = { SN_COORD, -172, 5820, 75 }, + .o = { SN_ORIENT, + -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 }, }, [WSP_FLAG_WELLSPRING2] = { .tp = wsp_tp + TYPE1, + .p = { SN_PRESSURE, 0, 256, 0 }, + .w = { SN_WIDTH, 0, 2048, 0 }, + .x = { SN_COORD, -4824, 4824, 105 }, + .y = { SN_COORD, -172, 4290, 75 }, + .o = { SN_ORIENT, + -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 }, }, [WSP_FLAG_WELLSPRING3] = { .tp = wsp_tp + TYPE2, + .p = { SN_PRESSURE, 0, 300, 0 }, + .w = { SN_WIDTH, 0, 2048, 0 }, + .x = { SN_COORD, -4460, 5166, 105 }, + .y = { SN_COORD, -75, 6700, 75 }, + .o = { SN_ORIENT, + -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 }, }, [WSP_FLAG_WELLSPRING4] = { .tp = wsp_tp + TYPE2, + .p = { SN_PRESSURE, 0, 300, 0 }, + .w = { SN_WIDTH, 0, 2048, 0 }, + .x = { SN_COORD, -4620, 5140, 105 }, + .y = { SN_COORD, -150, 6600, 75 }, + .o = { SN_ORIENT, + -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 }, }, [WSP_FLAG_WELLSPRING4A] = { .tp = wsp_tp + TYPE2, + .p = { SN_PRESSURE, 0, 300, 0 }, + .w = { SN_WIDTH, 0, 2048, 0 }, + .x = { SN_COORD, -4616, 5112, 105 }, + .y = { SN_COORD, -142, 5234, 75 }, + .o = { SN_ORIENT, + -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 }, }, [WSP_FLAG_WELLSPRING5] = { .tp = wsp_tp + TYPE2, + .p = { SN_PRESSURE, 0, 300, 0 }, + .w = { SN_WIDTH, 0, 2048, 0 }, + .x = { SN_COORD, -4415, 5050, 105 }, + .y = { SN_COORD, -55, 6680, 75 }, + .o = { SN_ORIENT, + -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 }, }, [WSP_FLAG_WELLSPRING6] = { .tp = wsp_tp + TYPE2, + .p = { SN_PRESSURE, 0, 300, 0 }, + .w = { SN_WIDTH, 0, 2048, 0 }, + .x = { SN_COORD, -4620, 5140, 105 }, + .y = { SN_COORD, -150, 6600, 75 }, + .o = { SN_ORIENT, + -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 }, }, [WSP_FLAG_WELLSPRING5A] = { .tp = wsp_tp + TYPE2, + .p = { SN_PRESSURE, 0, 300, 0 }, + .w = { SN_WIDTH, 0, 2048, 0 }, + .x = { SN_COORD, -4750, 5280, 105 }, + .y = { SN_COORD, -150, 6730, 75 }, + .o = { SN_ORIENT, + -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 }, }, [WSP_FLAG_WELLSPRING6A] = { .tp = wsp_tp + TYPE2, + .p = { SN_PRESSURE, 0, 300, 0 }, + .w = { SN_WIDTH, 0, 2048, 0 }, + .x = { SN_COORD, -4620, 5140, 105 }, + .y = { SN_COORD, -150, 6600, 75 }, + .o = { SN_ORIENT, + -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 }, }, [WSP_FLAG_WELLSPRING7] = { .tp = wsp_tp + TYPE2, + .p = { SN_PRESSURE, 0, 300, 0 }, + .w = { SN_WIDTH, 0, 2048, 0 }, + .x = { SN_COORD, -4750, 5280, 105 }, + .y = { SN_COORD, -150, 6730, 75 }, + .o = { SN_ORIENT, + -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 }, }, [WSP_FLAG_WELLSPRING7A] = { .tp = wsp_tp + TYPE2, + .p = { SN_PRESSURE, 0, 300, 0 }, + .w = { SN_WIDTH, 0, 2048, 0 }, + .x = { SN_COORD, -4750, 5280, 105 }, + .y = { SN_COORD, -150, 6730, 75 }, + .o = { SN_ORIENT, + -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 }, }, [WSP_FLAG_WELLSPRING8] = { .tp = wsp_tp + TYPE3, + .p = { SN_PRESSURE, 0, 300, 0 }, + .w = { SN_WIDTH, 0, 2048, 0 }, + .x = { SN_COORD, -4620, 5140, 105 }, + .y = { SN_COORD, -150, 6600, 75 }, + .o = { SN_ORIENT, + -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 }, }, [WSP_FLAG_WELLSPRING9] = { .tp = wsp_tp + TYPE4, + .p = { SN_PRESSURE, 0, 300, 0 }, + .w = { SN_WIDTH, 0, 2048, 0 }, + .x = { SN_COORD, -4828, 5345, 105 }, + .y = { SN_COORD, -203, 6803, 75 }, + .o = { SN_ORIENT, + -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 }, }, }; #define WSP_DEV(v,p,i) { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, i) } @@ -445,12 +554,17 @@ struct wsp_softc { const struct wsp_dev_params *sc_params; /* device configuration */ +#ifdef EVDEV_SUPPORT + struct evdev_dev *sc_evdev; +#endif mousehw_t sc_hw; mousemode_t sc_mode; u_int sc_pollrate; mousestatus_t sc_status; + int sc_fflags; u_int sc_state; -#define WSP_ENABLED 0x01 +#define WSP_ENABLED 0x01 +#define WSP_EVDEV_OPENED 0x02 struct tp_finger *index[MAX_FINGERS]; /* finger index data */ int16_t pos_x[MAX_FINGERS]; /* position array */ @@ -491,8 +605,8 @@ struct wsp_softc { /* * function prototypes */ -static usb_fifo_cmd_t wsp_start_read; -static usb_fifo_cmd_t wsp_stop_read; +static usb_fifo_cmd_t wsp_fifo_start_read; +static usb_fifo_cmd_t wsp_fifo_stop_read; static usb_fifo_open_t wsp_open; static usb_fifo_close_t wsp_close; static usb_fifo_ioctl_t wsp_ioctl; @@ -501,11 +615,20 @@ static struct usb_fifo_methods wsp_fifo_methods = { .f_open = &wsp_open, .f_close = &wsp_close, .f_ioctl = &wsp_ioctl, - .f_start_read = &wsp_start_read, - .f_stop_read = &wsp_stop_read, + .f_start_read = &wsp_fifo_start_read, + .f_stop_read = &wsp_fifo_stop_read, .basename[0] = WSP_DRIVER_NAME, }; +#ifdef EVDEV_SUPPORT +static evdev_open_t wsp_ev_open; +static evdev_close_t wsp_ev_close; +static const struct evdev_methods wsp_evdev_methods = { + .ev_open = &wsp_ev_open, + .ev_close = &wsp_ev_close, +}; +#endif + /* device initialization and shutdown */ static int wsp_enable(struct wsp_softc *sc); static void wsp_disable(struct wsp_softc *sc); @@ -714,6 +837,56 @@ wsp_attach(device_t dev) sc->sc_touch = WSP_UNTOUCH; sc->scr_mode = WSP_SCR_NONE; +#ifdef EVDEV_SUPPORT + sc->sc_evdev = evdev_alloc(); + evdev_set_name(sc->sc_evdev, device_get_desc(dev)); + evdev_set_phys(sc->sc_evdev, device_get_nameunit(dev)); + evdev_set_id(sc->sc_evdev, BUS_USB, uaa->info.idVendor, + uaa->info.idProduct, 0); + evdev_set_serial(sc->sc_evdev, usb_get_serial(uaa->device)); + evdev_set_methods(sc->sc_evdev, sc, &wsp_evdev_methods); + evdev_support_prop(sc->sc_evdev, INPUT_PROP_POINTER); + evdev_support_event(sc->sc_evdev, EV_SYN); + evdev_support_event(sc->sc_evdev, EV_ABS); + evdev_support_event(sc->sc_evdev, EV_KEY); + +#define WSP_SUPPORT_ABS(evdev, code, param) \ + evdev_support_abs((evdev), (code), (param).min, (param).max, \ + ((param).max - (param).min) / (param).snratio, 0, \ + (param).size != 0 ? ((param).max - (param).min) / (param).size : 0); + + /* finger position */ + WSP_SUPPORT_ABS(sc->sc_evdev, ABS_MT_POSITION_X, sc->sc_params->x); + WSP_SUPPORT_ABS(sc->sc_evdev, ABS_MT_POSITION_Y, sc->sc_params->y); + /* finger pressure */ + WSP_SUPPORT_ABS(sc->sc_evdev, ABS_MT_PRESSURE, sc->sc_params->p); + /* finger touch area */ + WSP_SUPPORT_ABS(sc->sc_evdev, ABS_MT_TOUCH_MAJOR, sc->sc_params->w); + WSP_SUPPORT_ABS(sc->sc_evdev, ABS_MT_TOUCH_MINOR, sc->sc_params->w); + /* finger approach area */ + WSP_SUPPORT_ABS(sc->sc_evdev, ABS_MT_WIDTH_MAJOR, sc->sc_params->w); + WSP_SUPPORT_ABS(sc->sc_evdev, ABS_MT_WIDTH_MINOR, sc->sc_params->w); + /* finger orientation */ + WSP_SUPPORT_ABS(sc->sc_evdev, ABS_MT_ORIENTATION, sc->sc_params->o); + /* button properties */ + evdev_support_key(sc->sc_evdev, BTN_LEFT); + if ((sc->sc_params->tp->caps & HAS_INTEGRATED_BUTTON) != 0) + evdev_support_prop(sc->sc_evdev, INPUT_PROP_BUTTONPAD); + /* Enable automatic touch assignment for type B MT protocol */ + evdev_support_abs(sc->sc_evdev, ABS_MT_SLOT, + 0, MAX_FINGERS - 1, 0, 0, 0); + evdev_support_abs(sc->sc_evdev, ABS_MT_TRACKING_ID, + -1, MAX_FINGERS - 1, 0, 0, 0); + evdev_set_flag(sc->sc_evdev, EVDEV_FLAG_MT_TRACK); + evdev_set_flag(sc->sc_evdev, EVDEV_FLAG_MT_AUTOREL); + /* Synaptics compatibility events */ + evdev_set_flag(sc->sc_evdev, EVDEV_FLAG_MT_STCOMPAT); + + err = evdev_register(sc->sc_evdev); + if (err) + goto detach; +#endif + return (0); detach: @@ -735,6 +908,10 @@ wsp_detach(device_t dev) usb_fifo_detach(&sc->sc_fifo); +#ifdef EVDEV_SUPPORT + evdev_free(sc->sc_evdev); +#endif + usbd_transfer_unsetup(sc->sc_xfer, WSP_N_TRANSFER); mtx_destroy(&sc->sc_mutex); @@ -761,6 +938,9 @@ wsp_intr_callback(struct usb_xfer *xfer, usb_error_t error) int rdz = 0; int len; int i; +#ifdef EVDEV_SUPPORT + int slot = 0; +#endif wsp_runing_rangecheck(&tun); @@ -829,8 +1009,31 @@ wsp_intr_callback(struct usb_xfer *xfer, usb_error_t error) sc->pos_x[i] = f->abs_x; sc->pos_y[i] = -f->abs_y; sc->index[i] = f; +#ifdef EVDEV_SUPPORT + if (evdev_rcpt_mask & EVDEV_RCPT_HW_MOUSE && f->touch_major != 0) { + union evdev_mt_slot slot_data = { + .id = slot, + .x = f->abs_x, + .y = params->y.min + params->y.max - f->abs_y, + .p = f->pressure, + .maj = f->touch_major << 1, + .min = f->touch_minor << 1, + .w_maj = f->tool_major << 1, + .w_min = f->tool_minor << 1, + .ori = params->o.max - f->orientation, + }; + evdev_mt_push_slot(sc->sc_evdev, slot, &slot_data); + slot++; + } +#endif } +#ifdef EVDEV_SUPPORT + if (evdev_rcpt_mask & EVDEV_RCPT_HW_MOUSE) { + evdev_push_key(sc->sc_evdev, BTN_LEFT, ibt); + evdev_sync(sc->sc_evdev); + } +#endif sc->sc_status.flags &= ~MOUSE_POSCHANGED; sc->sc_status.flags &= ~MOUSE_STDBUTTONSCHANGED; sc->sc_status.obutton = sc->sc_status.button; @@ -1135,9 +1338,8 @@ wsp_reset_buf(struct wsp_softc *sc) } static void -wsp_start_read(struct usb_fifo *fifo) +wsp_start_read(struct wsp_softc *sc) { - struct wsp_softc *sc = usb_fifo_softc(fifo); int rate; /* Check if we should override the default polling interval */ @@ -1158,49 +1360,109 @@ wsp_start_read(struct usb_fifo *fifo) } static void -wsp_stop_read(struct usb_fifo *fifo) +wsp_stop_read(struct wsp_softc *sc) { - struct wsp_softc *sc = usb_fifo_softc(fifo); - usbd_transfer_stop(sc->sc_xfer[WSP_INTR_DT]); } static int wsp_open(struct usb_fifo *fifo, int fflags) { - DPRINTFN(WSP_LLEVEL_INFO, "\n"); + struct wsp_softc *sc = usb_fifo_softc(fifo); + int rc = 0; - if (fflags & FREAD) { - struct wsp_softc *sc = usb_fifo_softc(fifo); - int rc; + DPRINTFN(WSP_LLEVEL_INFO, "\n"); - if (sc->sc_state & WSP_ENABLED) - return (EBUSY); + if (sc->sc_fflags & fflags) + return (EBUSY); + if (fflags & FREAD) { if (usb_fifo_alloc_buffer(fifo, WSP_FIFO_BUF_SIZE, WSP_FIFO_QUEUE_MAXLEN)) { return (ENOMEM); } - rc = wsp_enable(sc); +#ifdef EVDEV_SUPPORT + if ((sc->sc_state & WSP_EVDEV_OPENED) == 0) +#endif + rc = wsp_enable(sc); if (rc != 0) { usb_fifo_free_buffer(fifo); return (rc); } } + sc->sc_fflags |= fflags & (FREAD | FWRITE); return (0); } static void wsp_close(struct usb_fifo *fifo, int fflags) { - if (fflags & FREAD) { - struct wsp_softc *sc = usb_fifo_softc(fifo); + struct wsp_softc *sc = usb_fifo_softc(fifo); - wsp_disable(sc); + if (fflags & FREAD) { +#ifdef EVDEV_SUPPORT + if ((sc->sc_state & WSP_EVDEV_OPENED) == 0) +#endif + wsp_disable(sc); usb_fifo_free_buffer(fifo); } + + sc->sc_fflags &= ~(fflags & (FREAD | FWRITE)); +} + +static void +wsp_fifo_start_read(struct usb_fifo *fifo) +{ + struct wsp_softc *sc = usb_fifo_softc(fifo); + + wsp_start_read(sc); +} + +static void +wsp_fifo_stop_read(struct usb_fifo *fifo) +{ + struct wsp_softc *sc = usb_fifo_softc(fifo); + +#ifdef EVDEV_SUPPORT + if ((sc->sc_state & WSP_EVDEV_OPENED) == 0) +#endif + wsp_stop_read(sc); } +#ifdef EVDEV_SUPPORT +static int +wsp_ev_open(struct evdev_dev *evdev) +{ + struct wsp_softc *sc = evdev_get_softc(evdev); + int rc = 0; + + mtx_lock(&sc->sc_mutex); + if (sc->sc_fflags == 0) + rc = wsp_enable(sc); + if (rc == 0) { + wsp_start_read(sc); + sc->sc_state |= WSP_EVDEV_OPENED; + } + mtx_unlock(&sc->sc_mutex); + + return (rc); +} + +static int +wsp_ev_close(struct evdev_dev *evdev) +{ + struct wsp_softc *sc = evdev_get_softc(evdev); + + mtx_lock(&sc->sc_mutex); + sc->sc_state &= ~WSP_EVDEV_OPENED; + if (sc->sc_fflags == 0) + wsp_stop_read(sc); + mtx_unlock(&sc->sc_mutex); + + return (0); +} +#endif + int wsp_ioctl(struct usb_fifo *fifo, u_long cmd, void *addr, int fflags) { @@ -1312,5 +1574,8 @@ static devclass_t wsp_devclass; DRIVER_MODULE(wsp, uhub, wsp_driver, wsp_devclass, NULL, 0); MODULE_DEPEND(wsp, usb, 1, 1, 1); MODULE_DEPEND(wsp, hid, 1, 1, 1); +#ifdef EVDEV_SUPPORT +MODULE_DEPEND(wsp, evdev, 1, 1, 1); +#endif MODULE_VERSION(wsp, 1); USB_PNP_HOST_INFO(wsp_devs); diff --git a/sys/modules/usb/wsp/Makefile b/sys/modules/usb/wsp/Makefile index a5215c0150f5..73a289a09544 100644 --- a/sys/modules/usb/wsp/Makefile +++ b/sys/modules/usb/wsp/Makefile @@ -30,7 +30,7 @@ S= ${SRCTOP}/sys .PATH: $S/dev/usb/input KMOD= wsp -SRCS= opt_bus.h opt_usb.h device_if.h bus_if.h usb_if.h vnode_if.h usbdevs.h \ - wsp.c +SRCS= opt_bus.h opt_evdev.h opt_usb.h device_if.h bus_if.h usb_if.h \ + vnode_if.h usbdevs.h wsp.c .include From owner-dev-commits-src-main@freebsd.org Tue Aug 24 23:04:25 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4F764669162; Tue, 24 Aug 2021 23:04:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvPnN6CfTz4Znn; Tue, 24 Aug 2021 23:04:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B750D118C6; Tue, 24 Aug 2021 23:04:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17ON4Nl0000978; Tue, 24 Aug 2021 23:04:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ON4N9I000977; Tue, 24 Aug 2021 23:04:23 GMT (envelope-from git) Date: Tue, 24 Aug 2021 23:04:23 GMT Message-Id: <202108242304.17ON4N9I000977@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: 250ab004074d - main - wsp(4): Compact parameter structure. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 250ab004074df27372b9afb18003c1e39d79aff5 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 23:04:25 -0000 The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=250ab004074df27372b9afb18003c1e39d79aff5 commit 250ab004074df27372b9afb18003c1e39d79aff5 Author: Vladimir Kondratyev AuthorDate: 2021-08-24 22:59:48 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-08-24 22:59:48 +0000 wsp(4): Compact parameter structure. MFC after: 2 weeks --- sys/dev/usb/input/wsp.c | 295 ++++++++++++++++-------------------------------- 1 file changed, 96 insertions(+), 199 deletions(-) diff --git a/sys/dev/usb/input/wsp.c b/sys/dev/usb/input/wsp.c index 0c449726d916..cc99c4678633 100644 --- a/sys/dev/usb/input/wsp.c +++ b/sys/dev/usb/input/wsp.c @@ -169,7 +169,8 @@ enum tp_type { TYPE1, /* plain trackpad */ TYPE2, /* button integrated in trackpad */ TYPE3, /* additional header fields since June 2013 */ - TYPE4 /* additional header field for pressure data */ + TYPE4, /* additional header field for pressure data */ + TYPE_CNT }; /* trackpad finger data offsets, le16-aligned */ @@ -192,6 +193,67 @@ enum tp_type { #define FSIZE_TYPE3 (14 * 2) #define FSIZE_TYPE4 (15 * 2) +struct wsp_tp { + uint8_t caps; /* device capability bitmask */ + uint8_t button; /* offset to button data */ + uint8_t offset; /* offset to trackpad finger data */ + uint8_t fsize; /* bytes in single finger block */ + uint8_t delta; /* offset from header to finger struct */ + uint8_t iface_index; + uint8_t um_size; /* usb control message length */ + uint8_t um_req_idx; /* usb control message index */ + uint8_t um_switch_idx; /* usb control message mode switch index */ + uint8_t um_switch_on; /* usb control message mode switch on */ + uint8_t um_switch_off; /* usb control message mode switch off */ +} const static wsp_tp[TYPE_CNT] = { + [TYPE1] = { + .caps = 0, + .button = 0, + .offset = FINGER_TYPE1, + .fsize = FSIZE_TYPE1, + .delta = 0, + .iface_index = 0, + .um_size = 8, + .um_req_idx = 0x00, + .um_switch_idx = 0, + .um_switch_on = 0x01, + .um_switch_off = 0x08, + }, + [TYPE2] = { + .caps = HAS_INTEGRATED_BUTTON, + .button = BUTTON_TYPE2, + .offset = FINGER_TYPE2, + .fsize = FSIZE_TYPE2, + .delta = 0, + .iface_index = 0, + .um_size = 8, + .um_req_idx = 0x00, + .um_switch_idx = 0, + .um_switch_on = 0x01, + .um_switch_off = 0x08, + }, + [TYPE3] = { + .caps = HAS_INTEGRATED_BUTTON, + .button = BUTTON_TYPE3, + .offset = FINGER_TYPE3, + .fsize = FSIZE_TYPE3, + .delta = 0, + }, + [TYPE4] = { + .caps = HAS_INTEGRATED_BUTTON, + .button = BUTTON_TYPE4, + .offset = FINGER_TYPE4, + .fsize = FSIZE_TYPE4, + .delta = 2, + .iface_index = 2, + .um_size = 2, + .um_req_idx = 0x02, + .um_switch_idx = 1, + .um_switch_on = 0x01, + .um_switch_off = 0x00, + }, +}; + /* trackpad finger header - little endian */ struct tp_header { uint8_t flag; @@ -253,215 +315,48 @@ enum { /* device-specific configuration */ struct wsp_dev_params { - uint8_t caps; /* device capability bitmask */ - uint8_t tp_type; /* type of trackpad interface */ - uint8_t tp_button; /* offset to button data */ - uint8_t tp_offset; /* offset to trackpad finger data */ - uint8_t tp_fsize; /* bytes in single finger block */ - uint8_t tp_delta; /* offset from header to finger struct */ - uint8_t iface_index; - uint8_t um_size; /* usb control message length */ - uint8_t um_req_val; /* usb control message value */ - uint8_t um_req_idx; /* usb control message index */ - uint8_t um_switch_idx; /* usb control message mode switch index */ - uint8_t um_switch_on; /* usb control message mode switch on */ - uint8_t um_switch_off; /* usb control message mode switch off */ + const struct wsp_tp* tp; }; static const struct wsp_dev_params wsp_dev_params[WSP_FLAG_MAX] = { [WSP_FLAG_WELLSPRING1] = { - .caps = 0, - .tp_type = TYPE1, - .tp_button = 0, - .tp_offset = FINGER_TYPE1, - .tp_fsize = FSIZE_TYPE1, - .tp_delta = 0, - .iface_index = 0, - .um_size = 8, - .um_req_val = 0x03, - .um_req_idx = 0x00, - .um_switch_idx = 0, - .um_switch_on = 0x01, - .um_switch_off = 0x08, + .tp = wsp_tp + TYPE1, }, [WSP_FLAG_WELLSPRING2] = { - .caps = 0, - .tp_type = TYPE1, - .tp_button = 0, - .tp_offset = FINGER_TYPE1, - .tp_fsize = FSIZE_TYPE1, - .tp_delta = 0, - .iface_index = 0, - .um_size = 8, - .um_req_val = 0x03, - .um_req_idx = 0x00, - .um_switch_idx = 0, - .um_switch_on = 0x01, - .um_switch_off = 0x08, + .tp = wsp_tp + TYPE1, }, [WSP_FLAG_WELLSPRING3] = { - .caps = HAS_INTEGRATED_BUTTON, - .tp_type = TYPE2, - .tp_button = BUTTON_TYPE2, - .tp_offset = FINGER_TYPE2, - .tp_fsize = FSIZE_TYPE2, - .tp_delta = 0, - .iface_index = 0, - .um_size = 8, - .um_req_val = 0x03, - .um_req_idx = 0x00, - .um_switch_idx = 0, - .um_switch_on = 0x01, - .um_switch_off = 0x08, + .tp = wsp_tp + TYPE2, }, [WSP_FLAG_WELLSPRING4] = { - .caps = HAS_INTEGRATED_BUTTON, - .tp_type = TYPE2, - .tp_button = BUTTON_TYPE2, - .tp_offset = FINGER_TYPE2, - .tp_fsize = FSIZE_TYPE2, - .tp_delta = 0, - .iface_index = 0, - .um_size = 8, - .um_req_val = 0x03, - .um_req_idx = 0x00, - .um_switch_idx = 0, - .um_switch_on = 0x01, - .um_switch_off = 0x08, + .tp = wsp_tp + TYPE2, }, [WSP_FLAG_WELLSPRING4A] = { - .caps = HAS_INTEGRATED_BUTTON, - .tp_type = TYPE2, - .tp_button = BUTTON_TYPE2, - .tp_offset = FINGER_TYPE2, - .tp_fsize = FSIZE_TYPE2, - .tp_delta = 0, - .iface_index = 0, - .um_size = 8, - .um_req_val = 0x03, - .um_req_idx = 0x00, - .um_switch_idx = 0, - .um_switch_on = 0x01, - .um_switch_off = 0x08, + .tp = wsp_tp + TYPE2, }, [WSP_FLAG_WELLSPRING5] = { - .caps = HAS_INTEGRATED_BUTTON, - .tp_type = TYPE2, - .tp_button = BUTTON_TYPE2, - .tp_offset = FINGER_TYPE2, - .tp_fsize = FSIZE_TYPE2, - .tp_delta = 0, - .iface_index = 0, - .um_size = 8, - .um_req_val = 0x03, - .um_req_idx = 0x00, - .um_switch_idx = 0, - .um_switch_on = 0x01, - .um_switch_off = 0x08, + .tp = wsp_tp + TYPE2, }, [WSP_FLAG_WELLSPRING6] = { - .caps = HAS_INTEGRATED_BUTTON, - .tp_type = TYPE2, - .tp_button = BUTTON_TYPE2, - .tp_offset = FINGER_TYPE2, - .tp_fsize = FSIZE_TYPE2, - .tp_delta = 0, - .iface_index = 0, - .um_size = 8, - .um_req_val = 0x03, - .um_req_idx = 0x00, - .um_switch_idx = 0, - .um_switch_on = 0x01, - .um_switch_off = 0x08, + .tp = wsp_tp + TYPE2, }, [WSP_FLAG_WELLSPRING5A] = { - .caps = HAS_INTEGRATED_BUTTON, - .tp_type = TYPE2, - .tp_button = BUTTON_TYPE2, - .tp_offset = FINGER_TYPE2, - .tp_fsize = FSIZE_TYPE2, - .tp_delta = 0, - .iface_index = 0, - .um_size = 8, - .um_req_val = 0x03, - .um_req_idx = 0x00, - .um_switch_idx = 0, - .um_switch_on = 0x01, - .um_switch_off = 0x08, + .tp = wsp_tp + TYPE2, }, [WSP_FLAG_WELLSPRING6A] = { - .caps = HAS_INTEGRATED_BUTTON, - .tp_type = TYPE2, - .tp_button = BUTTON_TYPE2, - .tp_offset = FINGER_TYPE2, - .tp_fsize = FSIZE_TYPE2, - .tp_delta = 0, - .um_size = 8, - .um_req_val = 0x03, - .um_req_idx = 0x00, - .um_switch_idx = 0, - .um_switch_on = 0x01, - .um_switch_off = 0x08, + .tp = wsp_tp + TYPE2, }, [WSP_FLAG_WELLSPRING7] = { - .caps = HAS_INTEGRATED_BUTTON, - .tp_type = TYPE2, - .tp_button = BUTTON_TYPE2, - .tp_offset = FINGER_TYPE2, - .tp_fsize = FSIZE_TYPE2, - .tp_delta = 0, - .iface_index = 0, - .um_size = 8, - .um_req_val = 0x03, - .um_req_idx = 0x00, - .um_switch_idx = 0, - .um_switch_on = 0x01, - .um_switch_off = 0x08, + .tp = wsp_tp + TYPE2, }, [WSP_FLAG_WELLSPRING7A] = { - .caps = HAS_INTEGRATED_BUTTON, - .tp_type = TYPE2, - .tp_button = BUTTON_TYPE2, - .tp_offset = FINGER_TYPE2, - .tp_fsize = FSIZE_TYPE2, - .tp_delta = 0, - .iface_index = 0, - .um_size = 8, - .um_req_val = 0x03, - .um_req_idx = 0x00, - .um_switch_idx = 0, - .um_switch_on = 0x01, - .um_switch_off = 0x08, + .tp = wsp_tp + TYPE2, }, [WSP_FLAG_WELLSPRING8] = { - .caps = HAS_INTEGRATED_BUTTON, - .tp_type = TYPE3, - .tp_button = BUTTON_TYPE3, - .tp_offset = FINGER_TYPE3, - .tp_fsize = FSIZE_TYPE3, - .tp_delta = 0, - .iface_index = 0, - .um_size = 8, - .um_req_val = 0x03, - .um_req_idx = 0x00, - .um_switch_idx = 0, - .um_switch_on = 0x01, - .um_switch_off = 0x08, + .tp = wsp_tp + TYPE3, }, [WSP_FLAG_WELLSPRING9] = { - .caps = HAS_INTEGRATED_BUTTON, - .tp_type = TYPE4, - .tp_button = BUTTON_TYPE4, - .tp_offset = FINGER_TYPE4, - .tp_fsize = FSIZE_TYPE4, - .tp_delta = 2, - .iface_index = 2, - .um_size = 2, - .um_req_val = 0x03, - .um_req_idx = 0x02, - .um_switch_idx = 1, - .um_switch_on = 0x01, - .um_switch_off = 0x00, + .tp = wsp_tp + TYPE4, }, }; #define WSP_DEV(v,p,i) { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, i) } @@ -647,12 +542,12 @@ wsp_set_device_mode(struct wsp_softc *sc, uint8_t on) usb_error_t err; /* Type 3 does not require a mode switch */ - if (params->tp_type == TYPE3) + if (params->tp == wsp_tp + TYPE3) return 0; err = usbd_req_get_report(sc->sc_usb_device, NULL, - mode_bytes, params->um_size, params->iface_index, - params->um_req_val, params->um_req_idx); + mode_bytes, params->tp->um_size, params->tp->iface_index, + UHID_FEATURE_REPORT, params->tp->um_req_idx); if (err != USB_ERR_NORMAL_COMPLETION) { DPRINTF("Failed to read device mode (%d)\n", err); @@ -667,12 +562,12 @@ wsp_set_device_mode(struct wsp_softc *sc, uint8_t on) */ pause("WHW", hz / 4); - mode_bytes[params->um_switch_idx] = - on ? params->um_switch_on : params->um_switch_off; + mode_bytes[params->tp->um_switch_idx] = + on ? params->tp->um_switch_on : params->tp->um_switch_off; return (usbd_req_set_report(sc->sc_usb_device, NULL, - mode_bytes, params->um_size, params->iface_index, - params->um_req_val, params->um_req_idx)); + mode_bytes, params->tp->um_size, params->tp->iface_index, + UHID_FEATURE_REPORT, params->tp->um_req_idx)); } static int @@ -881,8 +776,8 @@ wsp_intr_callback(struct usb_xfer *xfer, usb_error_t error) pc = usbd_xfer_get_frame(xfer, 0); usbd_copy_out(pc, 0, sc->tp_data, len); - if ((len < params->tp_offset + params->tp_fsize) || - ((len - params->tp_offset) % params->tp_fsize) != 0) { + if ((len < params->tp->offset + params->tp->fsize) || + ((len - params->tp->offset) % params->tp->fsize) != 0) { DPRINTFN(WSP_LLEVEL_INFO, "Invalid length: %d, %x, %x\n", len, sc->tp_data[0], sc->tp_data[1]); goto tr_setup; @@ -895,10 +790,12 @@ wsp_intr_callback(struct usb_xfer *xfer, usb_error_t error) h = (struct tp_header *)(sc->tp_data); - if (params->tp_type >= TYPE2) { - ibt = sc->tp_data[params->tp_button]; - ntouch = sc->tp_data[params->tp_button - 1]; - } + if (params->tp != wsp_tp + TYPE1) { + ibt = sc->tp_data[params->tp->button]; + ntouch = sc->tp_data[params->tp->button - 1]; + } else + ntouch = (len - params->tp->offset) / params->tp->fsize; + /* range check */ if (ntouch < 0) ntouch = 0; @@ -906,7 +803,7 @@ wsp_intr_callback(struct usb_xfer *xfer, usb_error_t error) ntouch = MAX_FINGERS; for (i = 0; i != ntouch; i++) { - f = (struct tp_finger *)(sc->tp_data + params->tp_offset + params->tp_delta + i * params->tp_fsize); + f = (struct tp_finger *)(sc->tp_data + params->tp->offset + params->tp->delta + i * params->tp->fsize); /* swap endianness, if any */ if (le16toh(0x1234) != 0x1234) { f->origin = le16toh((uint16_t)f->origin); @@ -940,9 +837,9 @@ wsp_intr_callback(struct usb_xfer *xfer, usb_error_t error) sc->sc_status.button = 0; if (ibt != 0) { - if ((params->caps & HAS_INTEGRATED_BUTTON) && ntouch == 2) + if ((params->tp->caps & HAS_INTEGRATED_BUTTON) && ntouch == 2) sc->sc_status.button |= MOUSE_BUTTON3DOWN; - else if ((params->caps & HAS_INTEGRATED_BUTTON) && ntouch == 3) + else if ((params->tp->caps & HAS_INTEGRATED_BUTTON) && ntouch == 3) sc->sc_status.button |= MOUSE_BUTTON2DOWN; else sc->sc_status.button |= MOUSE_BUTTON1DOWN; @@ -989,7 +886,7 @@ wsp_intr_callback(struct usb_xfer *xfer, usb_error_t error) */ switch (sc->ntaps) { case 1: - if (!(params->caps & HAS_INTEGRATED_BUTTON) || tun.enable_single_tap_clicks) { + if (!(params->tp->caps & HAS_INTEGRATED_BUTTON) || tun.enable_single_tap_clicks) { wsp_add_to_queue(sc, 0, 0, 0, MOUSE_BUTTON1DOWN); DPRINTFN(WSP_LLEVEL_INFO, "LEFT CLICK!\n"); } From owner-dev-commits-src-main@freebsd.org Tue Aug 24 23:04:22 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 27DF966907A; Tue, 24 Aug 2021 23:04:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvPnK3xdyz4Zt8; Tue, 24 Aug 2021 23:04:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4267E11A88; Tue, 24 Aug 2021 23:04:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17ON4KaB000900; Tue, 24 Aug 2021 23:04:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ON4KlT000899; Tue, 24 Aug 2021 23:04:20 GMT (envelope-from git) Date: Tue, 24 Aug 2021 23:04:20 GMT Message-Id: <202108242304.17ON4KlT000899@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: f76051c7dabe - main - evdev: Add implicit mode for touch tracking. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f76051c7dabe952b75127a8031d87d78b603be20 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 23:04:22 -0000 The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=f76051c7dabe952b75127a8031d87d78b603be20 commit f76051c7dabe952b75127a8031d87d78b603be20 Author: Vladimir Kondratyev AuthorDate: 2021-08-24 22:52:37 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-08-24 22:52:37 +0000 evdev: Add implicit mode for touch tracking. In implicit mode assignment of slot number and tracking id is performed automatically on each synchronization requested by device driver. This is done with creation of intermediate buffer for multitouch events. This buffer holds untracked events until synchronization is requested by device driver. It is needed as touch assigment requires knowledges of all touch positions pushed in current and previous reports. MFC after: 2 weeks --- sys/dev/evdev/evdev.c | 7 +++- sys/dev/evdev/evdev.h | 1 + sys/dev/evdev/evdev_mt.c | 97 ++++++++++++++++++++++++++++++++++++++++--- sys/dev/evdev/evdev_private.h | 1 + 4 files changed, 99 insertions(+), 7 deletions(-) diff --git a/sys/dev/evdev/evdev.c b/sys/dev/evdev/evdev.c index b5eed0e5f02f..74335b6f40b1 100644 --- a/sys/dev/evdev/evdev.c +++ b/sys/dev/evdev/evdev.c @@ -951,8 +951,13 @@ evdev_push_event(struct evdev_dev *evdev, uint16_t type, uint16_t code, if (type == EV_SYN && code == SYN_REPORT && bit_test(evdev->ev_abs_flags, ABS_MT_SLOT)) evdev_mt_sync_frame(evdev); - evdev_send_event(evdev, type, code, value); + else + if (bit_test(evdev->ev_flags, EVDEV_FLAG_MT_TRACK) && + evdev_mt_record_event(evdev, type, code, value)) + goto exit; + evdev_send_event(evdev, type, code, value); +exit: EVDEV_EXIT(evdev); return (0); diff --git a/sys/dev/evdev/evdev.h b/sys/dev/evdev/evdev.h index 4cf885612c3e..dde9bba9b1e2 100644 --- a/sys/dev/evdev/evdev.h +++ b/sys/dev/evdev/evdev.h @@ -162,6 +162,7 @@ void evdev_push_mt_compat(struct evdev_dev *); int evdev_mt_push_slot(struct evdev_dev *, int, union evdev_mt_slot *); int evdev_mt_push_frame(struct evdev_dev *, union evdev_mt_slot *, int); void evdev_mt_match_frame(struct evdev_dev *, union evdev_mt_slot *, int); +union evdev_mt_slot *evdev_mt_get_match_slots(struct evdev_dev *); void evdev_mt_push_autorel(struct evdev_dev *); static inline int evdev_mt_id_to_slot(struct evdev_dev *evdev, int32_t id) diff --git a/sys/dev/evdev/evdev_mt.c b/sys/dev/evdev/evdev_mt.c index f61943604a3a..d5bf4affea1b 100644 --- a/sys/dev/evdev/evdev_mt.c +++ b/sys/dev/evdev/evdev_mt.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2016 Vladimir Kondratyev + * Copyright (c) 2016, 2020 Vladimir Kondratyev * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -84,12 +84,17 @@ struct evdev_mt { slotset_t touches; /* the set of slots with unsynchronized state */ slotset_t frame; + /* the set of slots to match with active touches */ + slotset_t match_frame; + int match_slot; + union evdev_mt_slot *match_slots; int *matrix; union evdev_mt_slot slots[]; }; static void evdev_mt_send_st_compat(struct evdev_dev *); static void evdev_mt_send_autorel(struct evdev_dev *); +static void evdev_mt_replay_events(struct evdev_dev *); static inline int ffc_slot(struct evdev_dev *evdev, slotset_t slots) @@ -107,6 +112,7 @@ evdev_mt_init(struct evdev_dev *evdev) slots = MAXIMAL_MT_SLOT(evdev) + 1; size += sizeof(mt->slots[0]) * slots; if (bit_test(evdev->ev_flags, EVDEV_FLAG_MT_TRACK)) { + size += sizeof(mt->match_slots[0]) * slots; size += sizeof(mt->matrix[0]) * (slots + 6) * slots; } @@ -114,14 +120,13 @@ evdev_mt_init(struct evdev_dev *evdev) evdev->ev_mt = mt; if (bit_test(evdev->ev_flags, EVDEV_FLAG_MT_TRACK)) { - evdev_support_abs(evdev, - ABS_MT_TRACKING_ID, -1, slots - 1, 0, 0, 0); - mt->matrix = (int *)(mt->slots + slots); + mt->match_slots = mt->slots + slots; + mt->matrix = (int *)(mt->match_slots + slots); } /* Initialize multitouch protocol type B states */ for (slot = 0; slot < slots; slot++) - evdev->ev_mt->slots[slot].id = -1; + mt->slots[slot].id = -1; if (!bit_test(evdev->ev_flags, EVDEV_FLAG_MT_KEEPID)) evdev_support_abs(evdev, @@ -139,6 +144,8 @@ evdev_mt_free(struct evdev_dev *evdev) void evdev_mt_sync_frame(struct evdev_dev *evdev) { + if (bit_test(evdev->ev_flags, EVDEV_FLAG_MT_TRACK)) + evdev_mt_replay_events(evdev); if (bit_test(evdev->ev_flags, EVDEV_FLAG_MT_AUTOREL)) evdev_mt_send_autorel(evdev); if (evdev->ev_report_opened && @@ -176,6 +183,7 @@ int evdev_mt_push_slot(struct evdev_dev *evdev, int slot, union evdev_mt_slot *state) { + struct evdev_mt *mt = evdev->ev_mt; bool type_a = !bit_test(evdev->ev_abs_flags, ABS_MT_SLOT); if (type_a && state == NULL) @@ -184,7 +192,15 @@ evdev_mt_push_slot(struct evdev_dev *evdev, int slot, return (EINVAL); EVDEV_ENTER(evdev); - evdev_mt_send_slot(evdev, slot, state); + if (bit_test(evdev->ev_flags, EVDEV_FLAG_MT_TRACK)) { + evdev_mt_record_event(evdev, EV_ABS, ABS_MT_SLOT, slot); + if (state != NULL) + mt->match_slots[mt->match_slot] = *state; + else + evdev_mt_record_event(evdev, EV_ABS, + ABS_MT_TRACKING_ID, -1); + } else + evdev_mt_send_slot(evdev, slot, state); EVDEV_EXIT(evdev); return (0); @@ -369,6 +385,67 @@ evdev_mt_push_frame(struct evdev_dev *evdev, union evdev_mt_slot *pt, int size) return (0); } +bool +evdev_mt_record_event(struct evdev_dev *evdev, uint16_t type, uint16_t code, + int32_t value) +{ + struct evdev_mt *mt = evdev->ev_mt; + + EVDEV_LOCK_ASSERT(evdev); + + switch (type) { + case EV_ABS: + if (code == ABS_MT_SLOT) { + /* MT protocol type B support */ + KASSERT(value >= 0, ("Negative slot number")); + mt->match_slot = value; + mt->match_frame |= 1U << mt->match_slot; + return (true); + } else if (code == ABS_MT_TRACKING_ID) { + if (value == -1) + mt->match_frame &= ~(1U << mt->match_slot); + return (true); + } else if (ABS_IS_MT(code)) { + KASSERT(mt->match_slot >= 0, ("Negative slot")); + KASSERT(mt->match_slot <= MAXIMAL_MT_SLOT(evdev), + ("Slot number too big")); + mt->match_slots[mt->match_slot]. + val[ABS_MT_INDEX(code)] = value; + return (true); + } + break; + default: + break; + } + + return (false); +} + +static void +evdev_mt_replay_events(struct evdev_dev *evdev) +{ + struct evdev_mt *mt = evdev->ev_mt; + int slot, size = 0; + + EVDEV_LOCK_ASSERT(evdev); + + FOREACHBIT(mt->match_frame, slot) { + if (slot != size) + mt->match_slots[size] = mt->match_slots[slot]; + size++; + } + evdev_mt_match_frame(evdev, mt->match_slots, size); + evdev_mt_send_frame(evdev, mt->match_slots, size); + mt->match_slot = 0; + mt->match_frame = 0; +} + +union evdev_mt_slot * +evdev_mt_get_match_slots(struct evdev_dev *evdev) +{ + return (evdev->ev_mt->match_slots); +} + int evdev_mt_get_last_slot(struct evdev_dev *evdev) { @@ -419,6 +496,13 @@ evdev_get_mt_slot_by_tracking_id(struct evdev_dev *evdev, int32_t tracking_id) struct evdev_mt *mt = evdev->ev_mt; int slot; + /* + * Ignore tracking_id if slot assignment is performed by evdev. + * Events are written sequentially to temporary matching buffer. + */ + if (bit_test(evdev->ev_flags, EVDEV_FLAG_MT_TRACK)) + return (ffc_slot(evdev, mt->match_frame)); + FOREACHBIT(mt->touches, slot) if (mt->tracking_ids[slot] == tracking_id) return (slot); @@ -554,6 +638,7 @@ evdev_mt_send_autorel(struct evdev_dev *evdev) int slot; EVDEV_LOCK_ASSERT(evdev); + KASSERT(mt->match_frame == 0, ("Unmatched events exist")); FOREACHBIT(mt->touches & ~mt->frame, slot) evdev_mt_send_slot(evdev, slot, NULL); diff --git a/sys/dev/evdev/evdev_private.h b/sys/dev/evdev/evdev_private.h index 3fb2d61d091a..48cd82ae0639 100644 --- a/sys/dev/evdev/evdev_private.h +++ b/sys/dev/evdev/evdev_private.h @@ -285,6 +285,7 @@ void evdev_mt_set_last_slot(struct evdev_dev *, int); int32_t evdev_mt_get_value(struct evdev_dev *, int, int16_t); void evdev_mt_set_value(struct evdev_dev *, int, int16_t, int32_t); int32_t evdev_mt_reassign_id(struct evdev_dev *, int, int32_t); +bool evdev_mt_record_event(struct evdev_dev *, uint16_t, uint16_t, int32_t); /* Utility functions: */ void evdev_client_dumpqueue(struct evdev_client *); From owner-dev-commits-src-main@freebsd.org Tue Aug 24 23:04:20 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 544E566938B; Tue, 24 Aug 2021 23:04:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvPnH6dycz4ZnT; Tue, 24 Aug 2021 23:04:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2216211B12; Tue, 24 Aug 2021 23:04:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17ON4Jav000876; Tue, 24 Aug 2021 23:04:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ON4J7x000875; Tue, 24 Aug 2021 23:04:19 GMT (envelope-from git) Date: Tue, 24 Aug 2021 23:04:19 GMT Message-Id: <202108242304.17ON4J7x000875@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: 4c0a134e32a7 - main - evdev: Import support for touch-tracking. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4c0a134e32a7f4dec556fea15c8de22f69864492 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 23:04:20 -0000 The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=4c0a134e32a7f4dec556fea15c8de22f69864492 commit 4c0a134e32a7f4dec556fea15c8de22f69864492 Author: Vladimir Kondratyev AuthorDate: 2021-08-24 22:50:53 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-08-24 22:50:53 +0000 evdev: Import support for touch-tracking. Touch tracking is a process of assignment of unique trackingID to each initiated contact on the surface. Keeping the trackingIDs persistent across multitouch reports requires solving of so called Euclidian Bipartite Matching problem. This commit imports EBM-solver implementation based on Dinitz-Kronrod algorithm to find minimum cost matching between contacts listed in two consecutive reports. Obtained from: OpenBSD MFC after: 2 weeks --- sys/dev/evdev/evdev.h | 3 + sys/dev/evdev/evdev_mt.c | 211 ++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 212 insertions(+), 2 deletions(-) diff --git a/sys/dev/evdev/evdev.h b/sys/dev/evdev/evdev.h index e1c5aedb029c..4cf885612c3e 100644 --- a/sys/dev/evdev/evdev.h +++ b/sys/dev/evdev/evdev.h @@ -91,6 +91,7 @@ extern int evdev_sysmouse_t_axis; #define EVDEV_FLAG_EXT_EPOCH 0x03 /* evdev_push_* is allways called with * input (global) epoch entered */ #define EVDEV_FLAG_MT_KEEPID 0x04 /* Do not reassign tracking ID */ +#define EVDEV_FLAG_MT_TRACK 0x05 /* Assign touch to slot by evdev */ #define EVDEV_FLAG_MAX 0x1F #define EVDEV_FLAG_CNT (EVDEV_FLAG_MAX + 1) @@ -159,6 +160,8 @@ int evdev_get_mt_slot_by_tracking_id(struct evdev_dev *, int32_t); void evdev_support_mt_compat(struct evdev_dev *); void evdev_push_mt_compat(struct evdev_dev *); int evdev_mt_push_slot(struct evdev_dev *, int, union evdev_mt_slot *); +int evdev_mt_push_frame(struct evdev_dev *, union evdev_mt_slot *, int); +void evdev_mt_match_frame(struct evdev_dev *, union evdev_mt_slot *, int); void evdev_mt_push_autorel(struct evdev_dev *); static inline int evdev_mt_id_to_slot(struct evdev_dev *evdev, int32_t id) diff --git a/sys/dev/evdev/evdev_mt.c b/sys/dev/evdev/evdev_mt.c index 1a600fe3480d..f61943604a3a 100644 --- a/sys/dev/evdev/evdev_mt.c +++ b/sys/dev/evdev/evdev_mt.c @@ -25,6 +25,21 @@ * * $FreeBSD$ */ +/*- + * Copyright (c) 2015, 2016 Ulf Brosziewski + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ #include #include @@ -69,6 +84,7 @@ struct evdev_mt { slotset_t touches; /* the set of slots with unsynchronized state */ slotset_t frame; + int *matrix; union evdev_mt_slot slots[]; }; @@ -84,12 +100,24 @@ ffc_slot(struct evdev_dev *evdev, slotset_t slots) void evdev_mt_init(struct evdev_dev *evdev) { + struct evdev_mt *mt; + size_t size = offsetof(struct evdev_mt, slots); int slot, slots; slots = MAXIMAL_MT_SLOT(evdev) + 1; + size += sizeof(mt->slots[0]) * slots; + if (bit_test(evdev->ev_flags, EVDEV_FLAG_MT_TRACK)) { + size += sizeof(mt->matrix[0]) * (slots + 6) * slots; + } + + mt = malloc(size, M_EVDEV, M_WAITOK | M_ZERO); + evdev->ev_mt = mt; - evdev->ev_mt = malloc(offsetof(struct evdev_mt, slots) + - sizeof(union evdev_mt_slot) * slots, M_EVDEV, M_WAITOK | M_ZERO); + if (bit_test(evdev->ev_flags, EVDEV_FLAG_MT_TRACK)) { + evdev_support_abs(evdev, + ABS_MT_TRACKING_ID, -1, slots - 1, 0, 0, 0); + mt->matrix = (int *)(mt->slots + slots); + } /* Initialize multitouch protocol type B states */ for (slot = 0; slot < slots; slot++) @@ -162,6 +190,185 @@ evdev_mt_push_slot(struct evdev_dev *evdev, int slot, return (0); } +/* + * Find a minimum-weight matching for an m-by-n matrix. + * + * m must be greater than or equal to n. The size of the buffer must be + * at least 3m + 3n. + * + * On return, the first m elements of the buffer contain the row-to- + * column mappings, i.e., buffer[i] is the column index for row i, or -1 + * if there is no assignment for that row (which may happen if n < m). + * + * Wrong results because of overflows will not occur with input values + * in the range of 0 to INT_MAX / 2 inclusive. + * + * The function applies the Dinic-Kronrod algorithm. It is not modern or + * popular, but it seems to be a good choice for small matrices at least. + * The original form of the algorithm is modified as follows: There is no + * initial search for row minima, the initial assignments are in a + * "virtual" column with the index -1 and zero values. This permits inputs + * with n < m, and it simplifies the reassignments. + */ +static void +evdev_mt_matching(int *matrix, int m, int n, int *buffer) +{ + int i, j, k, d, e, row, col, delta; + int *p; + int *r2c = buffer; /* row-to-column assignments */ + int *red = r2c + m; /* reduced values of the assignments */ + int *mc = red + m; /* row-wise minimal elements of cs */ + int *cs = mc + m; /* the column set */ + int *c2r = cs + n; /* column-to-row assignments in cs */ + int *cd = c2r + n; /* column deltas (reduction) */ + + for (p = r2c; p < red; *p++ = -1) {} + for (; p < mc; *p++ = 0) {} + for (col = 0; col < n; col++) { + delta = INT_MAX; + for (i = 0, p = matrix + col; i < m; i++, p += n) { + d = *p - red[i]; + if (d < delta || (d == delta && r2c[i] < 0)) { + delta = d; + row = i; + } + } + cd[col] = delta; + if (r2c[row] < 0) { + r2c[row] = col; + continue; + } + for (p = mc; p < cs; *p++ = col) {} + for (k = 0; (j = r2c[row]) >= 0;) { + cs[k++] = j; + c2r[j] = row; + mc[row] -= n; + delta = INT_MAX; + for (i = 0, p = matrix; i < m; i++, p += n) + if (mc[i] >= 0) { + d = p[mc[i]] - cd[mc[i]]; + e = p[j] - cd[j]; + if (e < d) { + d = e; + mc[i] = j; + } + d -= red[i]; + if (d < delta || (d == delta + && r2c[i] < 0)) { + delta = d; + row = i; + } + } + cd[col] += delta; + for (i = 0; i < k; i++) { + cd[cs[i]] += delta; + red[c2r[cs[i]]] -= delta; + } + } + for (j = mc[row]; (r2c[row] = j) != col;) { + row = c2r[j]; + j = mc[row] + n; + } + } +} + +/* + * Assign tracking IDs to the points in the pt array. The tracking ID + * assignment pairs the points with points of the previous frame in + * such a way that the sum of the squared distances is minimal. Using + * squares instead of simple distances favours assignments with more uniform + * distances, and it is faster. + * Set tracking id to -1 for unassigned (new) points. + */ +void +evdev_mt_match_frame(struct evdev_dev *evdev, union evdev_mt_slot *pt, + int size) +{ + struct evdev_mt *mt = evdev->ev_mt; + int i, j, m, n, dx, dy, slot, num_touches; + int *p, *r2c, *c2r; + + EVDEV_LOCK_ASSERT(evdev); + MPASS(mt->matrix != NULL); + MPASS(size >= 0 && size <= MAXIMAL_MT_SLOT(evdev) + 1); + + if (size == 0) + return; + + p = mt->matrix; + num_touches = bitcount(mt->touches); + if (num_touches >= size) { + FOREACHBIT(mt->touches, slot) + for (i = 0; i < size; i++) { + dx = pt[i].x - mt->slots[slot].x; + dy = pt[i].y - mt->slots[slot].y; + *p++ = dx * dx + dy * dy; + } + m = num_touches; + n = size; + } else { + for (i = 0; i < size; i++) + FOREACHBIT(mt->touches, slot) { + dx = pt[i].x - mt->slots[slot].x; + dy = pt[i].y - mt->slots[slot].y; + *p++ = dx * dx + dy * dy; + } + m = size; + n = num_touches; + } + evdev_mt_matching(mt->matrix, m, n, p); + + r2c = p; + c2r = p + m; + for (i = 0; i < m; i++) + if ((j = r2c[i]) >= 0) + c2r[j] = i; + + p = (n == size ? c2r : r2c); + for (i = 0; i < size; i++) + if (*p++ < 0) + pt[i].id = -1; + + p = (n == size ? r2c : c2r); + FOREACHBIT(mt->touches, slot) + if ((i = *p++) >= 0) + pt[i].id = mt->tracking_ids[slot]; +} + +static void +evdev_mt_send_frame(struct evdev_dev *evdev, union evdev_mt_slot *pt, int size) +{ + struct evdev_mt *mt = evdev->ev_mt; + union evdev_mt_slot *slot; + + EVDEV_LOCK_ASSERT(evdev); + MPASS(size >= 0 && size <= MAXIMAL_MT_SLOT(evdev) + 1); + + /* + * While MT-matching assign tracking IDs of new contacts to be equal + * to a slot number to make things simpler. + */ + for (slot = pt; slot < pt + size; slot++) { + if (slot->id < 0) + slot->id = ffc_slot(evdev, mt->touches | mt->frame); + if (slot->id >= 0) + evdev_mt_send_slot(evdev, slot->id, slot); + } +} + +int +evdev_mt_push_frame(struct evdev_dev *evdev, union evdev_mt_slot *pt, int size) +{ + if (size < 0 || size > MAXIMAL_MT_SLOT(evdev) + 1) + return (EINVAL); + + EVDEV_ENTER(evdev); + evdev_mt_send_frame(evdev, pt, size); + EVDEV_EXIT(evdev); + + return (0); +} + int evdev_mt_get_last_slot(struct evdev_dev *evdev) { From owner-dev-commits-src-main@freebsd.org Tue Aug 24 23:04:24 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A1677669481; Tue, 24 Aug 2021 23:04:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvPnN2Vc1z4Zx1; Tue, 24 Aug 2021 23:04:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 94A6711819; Tue, 24 Aug 2021 23:04:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17ON4Mhf000954; Tue, 24 Aug 2021 23:04:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ON4Mtq000953; Tue, 24 Aug 2021 23:04:22 GMT (envelope-from git) Date: Tue, 24 Aug 2021 23:04:22 GMT Message-Id: <202108242304.17ON4Mtq000953@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: 9fa1201d60dc - main - atp(4), wsp(4): Return correct priority from probe() method; MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9fa1201d60dc7004f11d950f0fbd277bdcdcaf2d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 23:04:24 -0000 The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=9fa1201d60dc7004f11d950f0fbd277bdcdcaf2d commit 9fa1201d60dc7004f11d950f0fbd277bdcdcaf2d Author: Vladimir Kondratyev AuthorDate: 2021-08-24 22:59:17 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-08-24 22:59:17 +0000 atp(4), wsp(4): Return correct priority from probe() method; MFC after: 2 weeks --- sys/dev/usb/input/atp.c | 4 ++-- sys/dev/usb/input/wsp.c | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/sys/dev/usb/input/atp.c b/sys/dev/usb/input/atp.c index 3515c08a1a6d..585afbaf1a1b 100644 --- a/sys/dev/usb/input/atp.c +++ b/sys/dev/usb/input/atp.c @@ -2175,11 +2175,11 @@ atp_probe(device_t self) if ((usbd_lookup_id_by_uaa(fg_devs, sizeof(fg_devs), uaa)) == 0) return ((uaa->info.bInterfaceProtocol == UIPROTO_MOUSE) ? - 0 : ENXIO); + BUS_PROBE_DEFAULT : ENXIO); if ((usbd_lookup_id_by_uaa(wsp_devs, sizeof(wsp_devs), uaa)) == 0) if (uaa->info.bIfaceIndex == WELLSPRING_INTERFACE_INDEX) - return (0); + return (BUS_PROBE_DEFAULT); return (ENXIO); } diff --git a/sys/dev/usb/input/wsp.c b/sys/dev/usb/input/wsp.c index c44c4aceb308..0c449726d916 100644 --- a/sys/dev/usb/input/wsp.c +++ b/sys/dev/usb/input/wsp.c @@ -720,7 +720,10 @@ wsp_probe(device_t self) /* check if we are attaching to the first match */ if (uaa->info.bIfaceIndex != i) return (ENXIO); - return (usbd_lookup_id_by_uaa(wsp_devs, sizeof(wsp_devs), uaa)); + if (usbd_lookup_id_by_uaa(wsp_devs, sizeof(wsp_devs), uaa) != 0) + return (ENXIO); + + return (BUS_PROBE_DEFAULT); } static int From owner-dev-commits-src-main@freebsd.org Wed Aug 25 02:02:16 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5509266C1E9; Wed, 25 Aug 2021 02:02:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvTkc1yvqz4TVh; Wed, 25 Aug 2021 02:02:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2C3781402D; Wed, 25 Aug 2021 02:02:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17P22GAG039641; Wed, 25 Aug 2021 02:02:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17P22G7w039640; Wed, 25 Aug 2021 02:02:16 GMT (envelope-from git) Date: Wed, 25 Aug 2021 02:02:16 GMT Message-Id: <202108250202.17P22G7w039640@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Eric van Gyzen Subject: git: 3b29c8b4bdb0 - main - ddb: do not assume that ffs is mounted with softdep MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vangyzen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3b29c8b4bdb0e396d7bb5d0760f11d7fa4208c84 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 02:02:16 -0000 The branch main has been updated by vangyzen: URL: https://cgit.FreeBSD.org/src/commit/?id=3b29c8b4bdb0e396d7bb5d0760f11d7fa4208c84 commit 3b29c8b4bdb0e396d7bb5d0760f11d7fa4208c84 Author: Keith Owens AuthorDate: 2021-08-25 01:59:31 +0000 Commit: Eric van Gyzen CommitDate: 2021-08-25 02:00:19 +0000 ddb: do not assume that ffs is mounted with softdep Avoid a panic when debugging with "show ffs" in ddb. Reviewed By: kib, markj, mckusick MFC after: 1 week Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D31622 --- sys/ufs/ffs/ffs_softdep.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index e518cc5c5deb..6f1de407135e 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -15009,9 +15009,15 @@ db_print_ffs(struct ufsmount *ump) { db_printf("mp %p (%s) devvp %p\n", ump->um_mountp, ump->um_mountp->mnt_stat.f_mntonname, ump->um_devvp); - db_printf(" fs %p su_wl %d su_deps %d su_req %d\n", - ump->um_fs, ump->softdep_on_worklist, - ump->softdep_deps, ump->softdep_req); + db_printf(" fs %p ", ump->um_fs); + + if (ump->um_softdep != NULL) { + db_printf("su_wl %d su_deps %d su_req %d\n", + ump->softdep_on_worklist, ump->softdep_deps, + ump->softdep_req); + } else { + db_printf("su disabled\n"); + } } static void From owner-dev-commits-src-main@freebsd.org Wed Aug 25 08:04:28 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AC580670710; Wed, 25 Aug 2021 08:04:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvdmX3pP1z3hW8; Wed, 25 Aug 2021 08:04:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6A74919082; Wed, 25 Aug 2021 08:04:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17P84SDU025165; Wed, 25 Aug 2021 08:04:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17P84SCM025164; Wed, 25 Aug 2021 08:04:28 GMT (envelope-from git) Date: Wed, 25 Aug 2021 08:04:28 GMT Message-Id: <202108250804.17P84SCM025164@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 2e5ff01d0a1f - main - if_vlan: add the ALTQ support to if_vlan. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2e5ff01d0a1fabc757252f9c28ad5cddc98a652d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 08:04:28 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=2e5ff01d0a1fabc757252f9c28ad5cddc98a652d commit 2e5ff01d0a1fabc757252f9c28ad5cddc98a652d Author: Luiz Otavio O Souza AuthorDate: 2021-08-21 09:41:03 +0000 Commit: Kristof Provost CommitDate: 2021-08-25 06:56:45 +0000 if_vlan: add the ALTQ support to if_vlan. Inspired by the iflib implementation, allow ALTQ to be used with if_vlan interfaces. Reviewed by: donner Obtained from: pfsense MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D31647 --- sys/net/if_vlan.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c index 39978afe7ce1..10a254d22440 100644 --- a/sys/net/if_vlan.c +++ b/sys/net/if_vlan.c @@ -305,6 +305,10 @@ static int vlan_setflag(struct ifnet *ifp, int flag, int status, static int vlan_setflags(struct ifnet *ifp, int status); static int vlan_setmulti(struct ifnet *ifp); static int vlan_transmit(struct ifnet *ifp, struct mbuf *m); +#ifdef ALTQ +static void vlan_altq_start(struct ifnet *ifp); +static int vlan_altq_transmit(struct ifnet *ifp, struct mbuf *m); +#endif static int vlan_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, struct route *ro); static void vlan_unconfig(struct ifnet *ifp); @@ -1097,7 +1101,15 @@ vlan_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params) ifp->if_dunit = unit; ifp->if_init = vlan_init; +#ifdef ALTQ + ifp->if_start = vlan_altq_start; + ifp->if_transmit = vlan_altq_transmit; + IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen); + ifp->if_snd.ifq_drv_maxlen = 0; + IFQ_SET_READY(&ifp->if_snd); +#else ifp->if_transmit = vlan_transmit; +#endif ifp->if_qflush = vlan_qflush; ifp->if_ioctl = vlan_ioctl; #if defined(KERN_TLS) || defined(RATELIMIT) @@ -1150,6 +1162,9 @@ vlan_clone_destroy(struct if_clone *ifc, struct ifnet *ifp) if (ifp->if_vlantrunk) return (EBUSY); +#ifdef ALTQ + IFQ_PURGE(&ifp->if_snd); +#endif ether_ifdetach(ifp); /* first, remove it from system-wide lists */ vlan_unconfig(ifp); /* now it can be unconfigured and freed */ /* @@ -1271,6 +1286,38 @@ vlan_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, return p->if_output(ifp, m, dst, ro); } +#ifdef ALTQ +static void +vlan_altq_start(if_t ifp) +{ + struct ifaltq *ifq = &ifp->if_snd; + struct mbuf *m; + + IFQ_LOCK(ifq); + IFQ_DEQUEUE_NOLOCK(ifq, m); + while (m != NULL) { + vlan_transmit(ifp, m); + IFQ_DEQUEUE_NOLOCK(ifq, m); + } + IFQ_UNLOCK(ifq); +} + +static int +vlan_altq_transmit(if_t ifp, struct mbuf *m) +{ + int err; + + if (ALTQ_IS_ENABLED(&ifp->if_snd)) { + IFQ_ENQUEUE(&ifp->if_snd, m, err); + if (err == 0) + vlan_altq_start(ifp); + } else + err = vlan_transmit(ifp, m); + + return (err); +} +#endif /* ALTQ */ + /* * The ifp->if_qflush entry point for vlan(4) is a no-op. */ From owner-dev-commits-src-main@freebsd.org Wed Aug 25 08:04:29 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C7B5E670903; Wed, 25 Aug 2021 08:04:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvdmY4nLsz3hFX; Wed, 25 Aug 2021 08:04:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8769F18F58; Wed, 25 Aug 2021 08:04:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17P84To5025189; Wed, 25 Aug 2021 08:04:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17P84TPn025188; Wed, 25 Aug 2021 08:04:29 GMT (envelope-from git) Date: Wed, 25 Aug 2021 08:04:29 GMT Message-Id: <202108250804.17P84TPn025188@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: e62175df4ec2 - main - pf tests: test ALTQ CBQ on top of if_vlan MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e62175df4ec2c8fe2aa2e372f683ddb933768e62 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 08:04:30 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=e62175df4ec2c8fe2aa2e372f683ddb933768e62 commit e62175df4ec2c8fe2aa2e372f683ddb933768e62 Author: Kristof Provost AuthorDate: 2021-08-23 14:58:50 +0000 Commit: Kristof Provost CommitDate: 2021-08-25 06:57:10 +0000 pf tests: test ALTQ CBQ on top of if_vlan The main purpose of this test is to verify that we can use ALTQ on top of if_vlan, but while we're here we also exercise the CBQ code. There's already a basis test for HFSC, so it makes sense to test another algorithm while we test if_vlan. Reviewed by: donner MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D31649 --- tests/sys/common/vnet.subr | 7 ++++++ tests/sys/netpfil/pf/altq.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/tests/sys/common/vnet.subr b/tests/sys/common/vnet.subr index f9a9e9c428fd..590e8dea992e 100644 --- a/tests/sys/common/vnet.subr +++ b/tests/sys/common/vnet.subr @@ -24,6 +24,13 @@ vnet_mkbridge() echo ${ifname} } +vnet_mkvlan() +{ + ifname=$(ifconfig vlan create) + echo ${ifname} >> created_interfaces.lst + echo ${ifname} +} + vnet_mkloopback() { ifname=$(ifconfig lo create) diff --git a/tests/sys/netpfil/pf/altq.sh b/tests/sys/netpfil/pf/altq.sh index 294c01e9f8bd..53cf10e47565 100644 --- a/tests/sys/netpfil/pf/altq.sh +++ b/tests/sys/netpfil/pf/altq.sh @@ -86,9 +86,69 @@ match_cleanup() altq_cleanup } +atf_test_case "cbq_vlan" "cleanup" +cbq_vlan_head() +{ + atf_set descr 'CBQ over VLAN test' + atf_set require.user root +} + +cbq_vlan_body() +{ + altq_init + is_altq_supported cbq + + epair=$(vnet_mkepair) + vnet_mkjail altq_cbq_vlan ${epair}b + + vlan=$(vnet_mkvlan) + ifconfig ${vlan} vlan 42 vlandev ${epair}a + ifconfig ${vlan} 192.0.2.1/24 up + ifconfig ${epair}a up + + vlanj=$(jexec altq_cbq_vlan ifconfig vlan create) + echo ${vlanj} >> created_interfaces.lst + + jexec altq_cbq_vlan ifconfig ${epair}b up + jexec altq_cbq_vlan ifconfig ${vlanj} vlan 42 vlandev ${epair}b + jexec altq_cbq_vlan ifconfig ${vlanj} 192.0.2.2/24 up + + # Sanity check + atf_check -s exit:0 -o ignore ping -i .1 -c 3 -s 1200 192.0.2.2 + + jexec altq_cbq_vlan pfctl -e + pft_set_rules altq_cbq_vlan \ + "altq on ${vlanj} bandwidth 14000b cbq queue { default }" \ + "queue default bandwidth 14000b cbq(default) { slow } " \ + "queue slow bandwidth 6000b cbq(borrow)" \ + "match proto icmp queue slow" \ + "match proto tcp queue default" \ + "pass" + + # single ping succeeds just fine + atf_check -s exit:0 -o ignore ping -c 1 192.0.2.2 + + # "Saturate the link" + ping -i .01 -c 50 -s 1200 192.0.2.2 + + # We should now be hitting the limits and get these packet dropped. + rcv=$(ping -i .1 -c 5 -s 1200 192.0.2.2 | tr "," "\n" | awk '/packets received/ { print $1; }') + echo "Received $rcv packets" + if [ ${rcv} -gt 1 ] + then + atf_fail "Received ${rcv} packets in a saturated link" + fi +} + +cbq_vlan_cleanup() +{ + altq_cleanup +} + atf_init_test_cases() { atf_add_test_case "hfsc" atf_add_test_case "match" + atf_add_test_case "cbq_vlan" } From owner-dev-commits-src-main@freebsd.org Wed Aug 25 15:14:19 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3F469675C4A; Wed, 25 Aug 2021 15:14:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvqJW0SMbz3QmQ; Wed, 25 Aug 2021 15:14:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E78C71EC90; Wed, 25 Aug 2021 15:14:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17PFEIVi097540; Wed, 25 Aug 2021 15:14:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17PFEIST097539; Wed, 25 Aug 2021 15:14:18 GMT (envelope-from git) Date: Wed, 25 Aug 2021 15:14:18 GMT Message-Id: <202108251514.17PFEIST097539@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michael Tuexen Subject: git: dc6ab77d66f8 - main - tcp: make network epoch expectations of LRO explicit MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: dc6ab77d66f892566de926274e6a58a637975510 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 15:14:19 -0000 The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=dc6ab77d66f892566de926274e6a58a637975510 commit dc6ab77d66f892566de926274e6a58a637975510 Author: Michael Tuexen AuthorDate: 2021-08-25 15:09:25 +0000 Commit: Michael Tuexen CommitDate: 2021-08-25 15:12:36 +0000 tcp: make network epoch expectations of LRO explicit Reviewed by: gallatin, hselasky MFC after: 3 days Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D31648 --- sys/netinet/tcp_lro.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sys/netinet/tcp_lro.c b/sys/netinet/tcp_lro.c index cb548d457bb3..cb9681559777 100644 --- a/sys/netinet/tcp_lro.c +++ b/sys/netinet/tcp_lro.c @@ -598,6 +598,7 @@ tcp_lro_flush_inactive(struct lro_ctrl *lc, const struct timeval *timeout) uint64_t now, tov; struct bintime bt; + NET_EPOCH_ASSERT(); if (LIST_EMPTY(&lc->lro_active)) return; @@ -1177,8 +1178,6 @@ tcp_lro_lookup(struct ifnet *ifp, struct lro_parser *pa) { struct inpcb *inp; - NET_EPOCH_ASSERT(); - switch (pa->data.lro_type) { #ifdef INET6 case LRO_TYPE_IPV6_TCP: @@ -1368,7 +1367,10 @@ tcp_lro_flush(struct lro_ctrl *lc, struct lro_entry *le) /* Only optimise if there are multiple packets waiting. */ #ifdef TCPHPTS int error; +#endif + NET_EPOCH_ASSERT(); +#ifdef TCPHPTS CURVNET_SET(lc->ifp->if_vnet); error = tcp_lro_flush_tcphpts(lc, le); CURVNET_RESTORE(); @@ -1479,6 +1481,7 @@ tcp_lro_flush_all(struct lro_ctrl *lc) uint64_t nseq; unsigned x; + NET_EPOCH_ASSERT(); /* check if no mbufs to flush */ if (lc->lro_mbuf_count == 0) goto done; @@ -1919,6 +1922,7 @@ tcp_lro_rx(struct lro_ctrl *lc, struct mbuf *m, uint32_t csum) void tcp_lro_queue_mbuf(struct lro_ctrl *lc, struct mbuf *mb) { + NET_EPOCH_ASSERT(); /* sanity checks */ if (__predict_false(lc->ifp == NULL || lc->lro_mbuf_data == NULL || lc->lro_mbuf_max == 0)) { From owner-dev-commits-src-main@freebsd.org Wed Aug 25 16:04:27 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 513EB67702E; Wed, 25 Aug 2021 16:04:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvrQM1PzNz3vRC; Wed, 25 Aug 2021 16:04:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1535F1F5C8; Wed, 25 Aug 2021 16:04:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17PG4QV4064335; Wed, 25 Aug 2021 16:04:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17PG4QpD064334; Wed, 25 Aug 2021 16:04:26 GMT (envelope-from git) Date: Wed, 25 Aug 2021 16:04:26 GMT Message-Id: <202108251604.17PG4QpD064334@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ka Ho Ng Subject: git: 9e202d036dd6 - main - fspacectl(2): Changes on rmsr.r_offset's minimum value returned MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9e202d036dd6f38ce0f578aa2086ebc358315bab Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 16:04:27 -0000 The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=9e202d036dd6f38ce0f578aa2086ebc358315bab commit 9e202d036dd6f38ce0f578aa2086ebc358315bab Author: Ka Ho Ng AuthorDate: 2021-08-25 16:02:27 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-25 16:03:37 +0000 fspacectl(2): Changes on rmsr.r_offset's minimum value returned rmsr.r_offset now is set to rqsr.r_offset plus the number of bytes zeroed before hitting the end-of-file. After this change rmsr.r_offset no longer contains the EOF when the requested operation range is completely beyond the end-of-file. Instead in such case rmsr.r_offset is equal to rqsr.r_offset. Callers can obtain the number of bytes zeroed by subtracting rqsr.r_offset from rmsr.r_offset. Sponsored by: The FreeBSD Foundation Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D31677 --- lib/libc/sys/fspacectl.2 | 9 ++++----- share/man/man9/VOP_DEALLOCATE.9 | 9 +++------ share/man/man9/vn_deallocate.9 | 7 ++----- sys/kern/uipc_shm.c | 1 - sys/kern/vfs_default.c | 5 ++--- 5 files changed, 11 insertions(+), 20 deletions(-) diff --git a/lib/libc/sys/fspacectl.2 b/lib/libc/sys/fspacectl.2 index 0e369785b883..430f3de950df 100644 --- a/lib/libc/sys/fspacectl.2 +++ b/lib/libc/sys/fspacectl.2 @@ -27,7 +27,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd August 18, 2021 +.Dd August 25, 2021 .Dt FSPACECTL 2 .Os .Sh NAME @@ -73,10 +73,9 @@ operation range, .Fa "rmsr->r_len" is updated to be the value 0, and .Fa "rmsr->r_offset" -is updated to be the smallest of -.Fa "rqsr->r_offset" + -.Fa "rqsr->r_len" ; -and the end-of-file offset. +is updated to be +.Fa "rqsr->r_offset" +plus the number of bytes zeroed before the end-of-file. The file descriptor's file offset is not used or modified by the system call. Both .Fa rqsr diff --git a/share/man/man9/VOP_DEALLOCATE.9 b/share/man/man9/VOP_DEALLOCATE.9 index 2ec915c6fef3..d20fe1590314 100644 --- a/share/man/man9/VOP_DEALLOCATE.9 +++ b/share/man/man9/VOP_DEALLOCATE.9 @@ -27,7 +27,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd August 11, 2021 +.Dd August 25, 2021 .Dt VOP_DEALLOCATE 9 .Os .Sh NAME @@ -74,14 +74,11 @@ and are updated to reflect the portion of the range that still needs to be zeroed/deallocated on return. Partial result is considered a successful operation. -For a successful completion without an unprocessed portion of the range, +For a non-partial successful completion, .Fa *len is updated to be the value 0, and .Fa *offset -is updated to be the smallest of -.Fa *offset + -.Fa *len -passed to the call and the end-of-file offset. +is incremented by the number of bytes zeroed before the end-of-file. .Sh LOCKS The vnode should be locked on entry and will still be locked on exit. .Sh RETURN VALUES diff --git a/share/man/man9/vn_deallocate.9 b/share/man/man9/vn_deallocate.9 index 08f4e92ec597..ce1515ddaaa1 100644 --- a/share/man/man9/vn_deallocate.9 +++ b/share/man/man9/vn_deallocate.9 @@ -27,7 +27,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd August 11, 2021 +.Dd August 25, 2021 .Dt VN_DEALLOCATE 9 .Os .Sh NAME @@ -99,10 +99,7 @@ For a successful completion, .Fa *length is updated to be the value 0, and .Fa *offset -is updated to be the smallest of -.Fa *offset + -.Fa *length -passed to the call and the end-of-file offset. +is incremented by the number of bytes zeroed before the end-of-file. .Sh RETURN VALUES Upon successful completion, the value 0 is returned; otherwise the appropriate error is returned. diff --git a/sys/kern/uipc_shm.c b/sys/kern/uipc_shm.c index c632c7f150df..c672c0477b95 100644 --- a/sys/kern/uipc_shm.c +++ b/sys/kern/uipc_shm.c @@ -1917,7 +1917,6 @@ shm_deallocate(struct shmfd *shmfd, off_t *offset, off_t *length, int flags) /* Handle the case when offset is on or beyond shm size. */ if ((off_t)len <= 0) { - *offset = shmfd->shm_size; *length = 0; return (0); } diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index d5df9cd8bf7b..9fd43004b8fd 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -1156,6 +1156,7 @@ vop_stddeallocate(struct vop_deallocate_args *ap) /* * No more data region to be filled */ + offset += len; len = 0; error = 0; break; @@ -1185,10 +1186,8 @@ vop_stddeallocate(struct vop_deallocate_args *ap) break; } /* Handle the case when offset is beyond EOF */ - if (len < 0) { - offset += len; + if (len < 0) len = 0; - } out: *ap->a_offset = offset; *ap->a_len = len; From owner-dev-commits-src-main@freebsd.org Wed Aug 25 16:04:28 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BB3D0676D59; Wed, 25 Aug 2021 16:04:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvrQN38FWz3vZ4; Wed, 25 Aug 2021 16:04:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2B6ED1F69F; Wed, 25 Aug 2021 16:04:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17PG4Sbv064359; Wed, 25 Aug 2021 16:04:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17PG4Sev064358; Wed, 25 Aug 2021 16:04:28 GMT (envelope-from git) Date: Wed, 25 Aug 2021 16:04:28 GMT Message-Id: <202108251604.17PG4Sev064358@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ka Ho Ng Subject: git: 76321d2d432e - main - param: Bump __FreeBSD_version to 1400032 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 76321d2d432ed270d93b282e54e59b708c0cf3b4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 16:04:28 -0000 The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=76321d2d432ed270d93b282e54e59b708c0cf3b4 commit 76321d2d432ed270d93b282e54e59b708c0cf3b4 Author: Ka Ho Ng AuthorDate: 2021-08-25 16:02:43 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-25 16:03:55 +0000 param: Bump __FreeBSD_version to 1400032 Commit 9e202d036dd6 introduces incompatible changes to fspacectl(2), vn_deallocate(9) and VOP_DEALLOCATE(9)'s rmsr.r_offset/*offset return value. Sponsored by: The FreeBSD Foundation --- sys/sys/param.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/sys/param.h b/sys/sys/param.h index 82787b4552af..04baa3cf3690 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -76,7 +76,7 @@ * cannot include sys/param.h and should only be updated here. */ #undef __FreeBSD_version -#define __FreeBSD_version 1400031 +#define __FreeBSD_version 1400032 /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From owner-dev-commits-src-main@freebsd.org Wed Aug 25 16:22:20 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CB8AE677498; Wed, 25 Aug 2021 16:22:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gvrq051FKz4VYD; Wed, 25 Aug 2021 16:22:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 863271F6E4; Wed, 25 Aug 2021 16:22:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17PGMKfg090817; Wed, 25 Aug 2021 16:22:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17PGMKDc090816; Wed, 25 Aug 2021 16:22:20 GMT (envelope-from git) Date: Wed, 25 Aug 2021 16:22:20 GMT Message-Id: <202108251622.17PGMKDc090816@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Piotr Pawel Stefaniak Subject: git: 9f7a81b133c7 - main - diff3: document and test -T MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pstef X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9f7a81b133c715f649136dcd0ad004e4180c56c9 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 16:22:20 -0000 The branch main has been updated by pstef: URL: https://cgit.FreeBSD.org/src/commit/?id=9f7a81b133c715f649136dcd0ad004e4180c56c9 commit 9f7a81b133c715f649136dcd0ad004e4180c56c9 Author: Piotr Pawel Stefaniak AuthorDate: 2021-08-23 19:33:27 +0000 Commit: Piotr Pawel Stefaniak CommitDate: 2021-08-25 16:20:59 +0000 diff3: document and test -T Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D31650 --- usr.bin/diff3/diff3.1 | 11 +++++++++-- usr.bin/diff3/tests/1t.out | 14 ++++++++++++++ usr.bin/diff3/tests/Makefile | 1 + usr.bin/diff3/tests/diff3_test.sh | 3 +++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/usr.bin/diff3/diff3.1 b/usr.bin/diff3/diff3.1 index 22e04b6af5e8..2cf1e57cb74e 100644 --- a/usr.bin/diff3/diff3.1 +++ b/usr.bin/diff3/diff3.1 @@ -30,7 +30,7 @@ .\" @(#)diff3.1 8.2 (Berkeley) 4/18/94 .\" $FreeBSD$ .\" -.Dd May 25, 2017 +.Dd August 23, 2021 .Dt DIFF3 1 .Os .Sh NAME @@ -38,7 +38,7 @@ .Nd 3-way differential file comparison .Sh SYNOPSIS .Nm diff3 -.Op Fl 3aEeiXx +.Op Fl 3aEeiTXx .Op Fl Fl diff-program Ar program .Op Fl Fl strip-trailing-cr .Op Fl L | Fl Fl label Ar label1 @@ -115,6 +115,13 @@ Defines labels to print instead of file names .Ar file2 and .Ar file3 . +.It Fl T, Fl Fl initial-tab +In the normal listing, +use a tab instead of two spaces +at the beginning of each line. +In modes that produce an +.Xr ed 1 +script, this option changes nothing. .It Fl x, Fl Fl overlap-only Produces an output script suitable for .Xr ed 1 diff --git a/usr.bin/diff3/tests/1t.out b/usr.bin/diff3/tests/1t.out new file mode 100644 index 000000000000..fc54ce50286f --- /dev/null +++ b/usr.bin/diff3/tests/1t.out @@ -0,0 +1,14 @@ +==== +1:2,3c + which multiple lines + and a few typ0s to fix +2:2,3c + which multiple lines + and a few typos to fix +3:2c + and a few typ0s to fix +====2 +1:4a +3:3a +2:5c + New line diff --git a/usr.bin/diff3/tests/Makefile b/usr.bin/diff3/tests/Makefile index 2ec7fbaab564..b8bea154944b 100644 --- a/usr.bin/diff3/tests/Makefile +++ b/usr.bin/diff3/tests/Makefile @@ -10,6 +10,7 @@ ${PACKAGE}FILES+= \ 2.txt \ 3.txt \ 1.out \ + 1t.out \ 2.out \ 3.out \ 4.out \ diff --git a/usr.bin/diff3/tests/diff3_test.sh b/usr.bin/diff3/tests/diff3_test.sh index f4b5adf95700..64031b023187 100755 --- a/usr.bin/diff3/tests/diff3_test.sh +++ b/usr.bin/diff3/tests/diff3_test.sh @@ -11,6 +11,9 @@ diff3_body() atf_check -o file:$(atf_get_srcdir)/1.out \ diff3 --strip-trailing-cr $(atf_get_srcdir)/1cr.txt $(atf_get_srcdir)/2.txt $(atf_get_srcdir)/3.txt + atf_check -o file:$(atf_get_srcdir)/1t.out \ + diff3 -T $(atf_get_srcdir)/1.txt $(atf_get_srcdir)/2.txt $(atf_get_srcdir)/3.txt + atf_check -o file:$(atf_get_srcdir)/2.out \ diff3 -e $(atf_get_srcdir)/1.txt $(atf_get_srcdir)/2.txt $(atf_get_srcdir)/3.txt From owner-dev-commits-src-main@freebsd.org Wed Aug 25 19:27:02 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EF2D0659DAD; Wed, 25 Aug 2021 19:27:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gvww66KRwz3Pbd; Wed, 25 Aug 2021 19:27:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C138921876; Wed, 25 Aug 2021 19:27:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17PJR2P9031298; Wed, 25 Aug 2021 19:27:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17PJR21A031297; Wed, 25 Aug 2021 19:27:02 GMT (envelope-from git) Date: Wed, 25 Aug 2021 19:27:02 GMT Message-Id: <202108251927.17PJR21A031297@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 6032b6ba9596 - main - amd64 UEFI loader: enable automatic disable of staging area copying MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6032b6ba9596927aba15a8004ade521a593a7d58 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 19:27:03 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=6032b6ba9596927aba15a8004ade521a593a7d58 commit 6032b6ba9596927aba15a8004ade521a593a7d58 Author: Konstantin Belousov AuthorDate: 2021-08-10 01:38:55 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-25 19:26:52 +0000 amd64 UEFI loader: enable automatic disable of staging area copying Discussed with: emaste Sponsored by: The FreeBSD Foundation MFC after: 1 month --- stand/efi/loader/copy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stand/efi/loader/copy.c b/stand/efi/loader/copy.c index b8ed4c8e027e..ba5da28aee92 100644 --- a/stand/efi/loader/copy.c +++ b/stand/efi/loader/copy.c @@ -215,7 +215,7 @@ efi_copy_free(void) } #ifdef __amd64__ -int copy_staging = COPY_STAGING_ENABLE; +int copy_staging = COPY_STAGING_AUTO; static int command_copy_staging(int argc, char *argv[]) From owner-dev-commits-src-main@freebsd.org Wed Aug 25 20:29:55 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 97AA565AC83; Wed, 25 Aug 2021 20:29:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvyJg3ppPz3vBf; Wed, 25 Aug 2021 20:29:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6B0ED22D5F; Wed, 25 Aug 2021 20:29:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17PKTtXR011162; Wed, 25 Aug 2021 20:29:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17PKTtR1011161; Wed, 25 Aug 2021 20:29:55 GMT (envelope-from git) Date: Wed, 25 Aug 2021 20:29:55 GMT Message-Id: <202108252029.17PKTtR1011161@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 1d874ba4f8ba - main - fsetown: Fix process lookup bugs MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1d874ba4f8ba58296cd9df611f5346dad8e91664 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 20:29:55 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=1d874ba4f8ba58296cd9df611f5346dad8e91664 commit 1d874ba4f8ba58296cd9df611f5346dad8e91664 Author: Mark Johnston AuthorDate: 2021-08-25 20:18:10 +0000 Commit: Mark Johnston CommitDate: 2021-08-25 20:18:10 +0000 fsetown: Fix process lookup bugs - pget()/pfind() will acquire the PID hash bucket locks, which are sleepable sx locks, but this means that the sigio mutex cannot be held while calling these functions. Instead, use pget() to hold the process, after which we lock the sigio and proc locks, respectively. - funsetownlst() assumes that processes cannot be registered for SIGIO once they have P_WEXIT set. However, pfind() will happily return exiting processes, breaking the invariant. Add an explicit check for P_WEXIT in fsetown() to fix this. [1] Fixes: f52979098d3c ("Fix a pair of races in SIGIO registration") Reported by: syzkaller [1] Reviewed by: kib MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31661 --- sys/kern/kern_descrip.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index c7269e4b33a9..e6a6a36801e4 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1031,18 +1031,16 @@ funsetown_locked(struct sigio *sigio) if (sigio == NULL) return (NULL); - *(sigio->sio_myref) = NULL; + *sigio->sio_myref = NULL; if (sigio->sio_pgid < 0) { pg = sigio->sio_pgrp; PGRP_LOCK(pg); - SLIST_REMOVE(&sigio->sio_pgrp->pg_sigiolst, sigio, - sigio, sio_pgsigio); + SLIST_REMOVE(&pg->pg_sigiolst, sigio, sigio, sio_pgsigio); PGRP_UNLOCK(pg); } else { p = sigio->sio_proc; PROC_LOCK(p); - SLIST_REMOVE(&sigio->sio_proc->p_sigiolst, sigio, - sigio, sio_pgsigio); + SLIST_REMOVE(&p->p_sigiolst, sigio, sigio, sio_pgsigio); PROC_UNLOCK(p); } return (sigio); @@ -1156,18 +1154,25 @@ fsetown(pid_t pgid, struct sigio **sigiop) } ret = 0; + osigio = NULL; sigio = malloc(sizeof(struct sigio), M_SIGIO, M_WAITOK); sigio->sio_pgid = pgid; sigio->sio_ucred = crhold(curthread->td_ucred); sigio->sio_myref = sigiop; - sx_slock(&proctree_lock); - SIGIO_LOCK(); - osigio = funsetown_locked(*sigiop); if (pgid > 0) { - proc = pfind(pgid); - if (proc == NULL) { + ret = pget(pgid, PGET_NOTWEXIT | PGET_NOTID | PGET_HOLD, &proc); + SIGIO_LOCK(); + if (ret != 0) + goto fail; + + osigio = funsetown_locked(*sigiop); + + PROC_LOCK(proc); + _PRELE(proc); + if ((proc->p_flag & P_WEXIT) != 0) { + PROC_UNLOCK(proc); ret = ESRCH; goto fail; } @@ -1190,12 +1195,17 @@ fsetown(pid_t pgid, struct sigio **sigiop) SLIST_INSERT_HEAD(&proc->p_sigiolst, sigio, sio_pgsigio); PROC_UNLOCK(proc); } else /* if (pgid < 0) */ { + sx_slock(&proctree_lock); + SIGIO_LOCK(); pgrp = pgfind(-pgid); if (pgrp == NULL) { + sx_sunlock(&proctree_lock); ret = ESRCH; goto fail; } + osigio = funsetown_locked(*sigiop); + /* * Policy - Don't allow a process to FSETOWN a process * in another session. @@ -1205,16 +1215,17 @@ fsetown(pid_t pgid, struct sigio **sigiop) * group for maximum safety. */ if (pgrp->pg_session != curthread->td_proc->p_session) { + sx_sunlock(&proctree_lock); PGRP_UNLOCK(pgrp); ret = EPERM; goto fail; } - SLIST_INSERT_HEAD(&pgrp->pg_sigiolst, sigio, sio_pgsigio); sigio->sio_pgrp = pgrp; + SLIST_INSERT_HEAD(&pgrp->pg_sigiolst, sigio, sio_pgsigio); PGRP_UNLOCK(pgrp); + sx_sunlock(&proctree_lock); } - sx_sunlock(&proctree_lock); *sigiop = sigio; SIGIO_UNLOCK(); if (osigio != NULL) @@ -1223,7 +1234,6 @@ fsetown(pid_t pgid, struct sigio **sigiop) fail: SIGIO_UNLOCK(); - sx_sunlock(&proctree_lock); sigiofree(sigio); if (osigio != NULL) sigiofree(osigio); From owner-dev-commits-src-main@freebsd.org Wed Aug 25 20:29:56 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D73F865A861; Wed, 25 Aug 2021 20:29:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvyJh5RC4z3v48; Wed, 25 Aug 2021 20:29:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 96A2A22D60; Wed, 25 Aug 2021 20:29:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17PKTuxl011186; Wed, 25 Aug 2021 20:29:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17PKTuQH011185; Wed, 25 Aug 2021 20:29:56 GMT (envelope-from git) Date: Wed, 25 Aug 2021 20:29:56 GMT Message-Id: <202108252029.17PKTuQH011185@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: a507a40f3b58 - main - fsetown: Simplify error handling MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a507a40f3b587bde7ab391f8f1400a25f33e65c1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 20:29:57 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=a507a40f3b587bde7ab391f8f1400a25f33e65c1 commit a507a40f3b587bde7ab391f8f1400a25f33e65c1 Author: Mark Johnston AuthorDate: 2021-08-25 20:20:07 +0000 Commit: Mark Johnston CommitDate: 2021-08-25 20:20:07 +0000 fsetown: Simplify error handling No functional change intended. Suggested by: kib Reviewed by: kib MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31671 --- sys/kern/kern_descrip.c | 106 ++++++++++++++++++++---------------------------- 1 file changed, 45 insertions(+), 61 deletions(-) diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index e6a6a36801e4..f78e999ab3b5 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1153,88 +1153,72 @@ fsetown(pid_t pgid, struct sigio **sigiop) return (0); } - ret = 0; - osigio = NULL; - sigio = malloc(sizeof(struct sigio), M_SIGIO, M_WAITOK); sigio->sio_pgid = pgid; sigio->sio_ucred = crhold(curthread->td_ucred); sigio->sio_myref = sigiop; + osigio = NULL; + ret = 0; if (pgid > 0) { ret = pget(pgid, PGET_NOTWEXIT | PGET_NOTID | PGET_HOLD, &proc); SIGIO_LOCK(); - if (ret != 0) - goto fail; - - osigio = funsetown_locked(*sigiop); - - PROC_LOCK(proc); - _PRELE(proc); - if ((proc->p_flag & P_WEXIT) != 0) { - PROC_UNLOCK(proc); - ret = ESRCH; - goto fail; - } - - /* - * Policy - Don't allow a process to FSETOWN a process - * in another session. - * - * Remove this test to allow maximum flexibility or - * restrict FSETOWN to the current process or process - * group for maximum safety. - */ - if (proc->p_session != curthread->td_proc->p_session) { + if (ret == 0) { + osigio = funsetown_locked(*sigiop); + + PROC_LOCK(proc); + _PRELE(proc); + if ((proc->p_flag & P_WEXIT) != 0) { + ret = ESRCH; + } else if (proc->p_session != + curthread->td_proc->p_session) { + /* + * Policy - Don't allow a process to FSETOWN a + * process in another session. + * + * Remove this test to allow maximum flexibility + * or restrict FSETOWN to the current process or + * process group for maximum safety. + */ + ret = EPERM; + } else { + sigio->sio_proc = proc; + SLIST_INSERT_HEAD(&proc->p_sigiolst, sigio, + sio_pgsigio); + } PROC_UNLOCK(proc); - ret = EPERM; - goto fail; } - - sigio->sio_proc = proc; - SLIST_INSERT_HEAD(&proc->p_sigiolst, sigio, sio_pgsigio); - PROC_UNLOCK(proc); } else /* if (pgid < 0) */ { sx_slock(&proctree_lock); SIGIO_LOCK(); pgrp = pgfind(-pgid); if (pgrp == NULL) { - sx_sunlock(&proctree_lock); ret = ESRCH; - goto fail; - } - - osigio = funsetown_locked(*sigiop); - - /* - * Policy - Don't allow a process to FSETOWN a process - * in another session. - * - * Remove this test to allow maximum flexibility or - * restrict FSETOWN to the current process or process - * group for maximum safety. - */ - if (pgrp->pg_session != curthread->td_proc->p_session) { - sx_sunlock(&proctree_lock); + } else { + osigio = funsetown_locked(*sigiop); + + if (pgrp->pg_session != curthread->td_proc->p_session) { + /* + * Policy - Don't allow a process to FSETOWN a + * process in another session. + * + * Remove this test to allow maximum flexibility + * or restrict FSETOWN to the current process or + * process group for maximum safety. + */ + ret = EPERM; + } else { + sigio->sio_pgrp = pgrp; + SLIST_INSERT_HEAD(&pgrp->pg_sigiolst, sigio, + sio_pgsigio); + } PGRP_UNLOCK(pgrp); - ret = EPERM; - goto fail; } - - sigio->sio_pgrp = pgrp; - SLIST_INSERT_HEAD(&pgrp->pg_sigiolst, sigio, sio_pgsigio); - PGRP_UNLOCK(pgrp); sx_sunlock(&proctree_lock); } - *sigiop = sigio; - SIGIO_UNLOCK(); - if (osigio != NULL) - sigiofree(osigio); - return (0); - -fail: + if (ret == 0) + *sigiop = sigio; SIGIO_UNLOCK(); - sigiofree(sigio); if (osigio != NULL) sigiofree(osigio); return (ret); From owner-dev-commits-src-main@freebsd.org Wed Aug 25 21:35:12 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DF5D465BB54; Wed, 25 Aug 2021 21:35:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gvzm062kXz4lnj; Wed, 25 Aug 2021 21:35:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B7BF8239C2; Wed, 25 Aug 2021 21:35:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17PLZCZC004035; Wed, 25 Aug 2021 21:35:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17PLZCsW004034; Wed, 25 Aug 2021 21:35:12 GMT (envelope-from git) Date: Wed, 25 Aug 2021 21:35:12 GMT Message-Id: <202108252135.17PLZCsW004034@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ka Ho Ng Subject: git: 399be91098ad - main - tmpfs: Move partial page invalidation to a separate helper MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 399be91098adb23aa27ca1228b81a3ad67e8bba2 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 21:35:12 -0000 The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=399be91098adb23aa27ca1228b81a3ad67e8bba2 commit 399be91098adb23aa27ca1228b81a3ad67e8bba2 Author: Ka Ho Ng AuthorDate: 2021-08-25 21:30:53 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-25 21:34:54 +0000 tmpfs: Move partial page invalidation to a separate helper The partial page invalidation code is factored out to be a separate helper from tmpfs_reg_resize(). Sponsored by: The FreeBSD Foundation Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31683 --- sys/fs/tmpfs/tmpfs_subr.c | 96 +++++++++++++++++++++++++++-------------------- 1 file changed, 56 insertions(+), 40 deletions(-) diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c index 387bc741e3cf..e746a7455860 100644 --- a/sys/fs/tmpfs/tmpfs_subr.c +++ b/sys/fs/tmpfs/tmpfs_subr.c @@ -361,6 +361,57 @@ tmpfs_pages_check_avail(struct tmpfs_mount *tmp, size_t req_pages) return (1); } +static int +tmpfs_partial_page_invalidate(vm_object_t object, vm_pindex_t idx, int base, + int end, boolean_t ignerr) +{ + vm_page_t m; + int rv, error; + + VM_OBJECT_ASSERT_WLOCKED(object); + KASSERT(base >= 0, ("%s: base %d", __func__, base)); + KASSERT(end - base <= PAGE_SIZE, ("%s: base %d end %d", __func__, base, + end)); + error = 0; + +retry: + m = vm_page_grab(object, idx, VM_ALLOC_NOCREAT); + if (m != NULL) { + MPASS(vm_page_all_valid(m)); + } else if (vm_pager_has_page(object, idx, NULL, NULL)) { + m = vm_page_alloc(object, idx, VM_ALLOC_NORMAL | + VM_ALLOC_WAITFAIL); + if (m == NULL) + goto retry; + vm_object_pip_add(object, 1); + VM_OBJECT_WUNLOCK(object); + rv = vm_pager_get_pages(object, &m, 1, NULL, NULL); + VM_OBJECT_WLOCK(object); + vm_object_pip_wakeup(object); + if (rv == VM_PAGER_OK) { + /* + * Since the page was not resident, and therefore not + * recently accessed, immediately enqueue it for + * asynchronous laundering. The current operation is + * not regarded as an access. + */ + vm_page_launder(m); + } else { + vm_page_free(m); + m = NULL; + if (!ignerr) + error = EIO; + } + } + if (m != NULL) { + pmap_zero_page_area(m, base, end - base); + vm_page_set_dirty(m); + vm_page_xunbusy(m); + } + + return (error); +} + void tmpfs_ref_node(struct tmpfs_node *node) { @@ -1662,10 +1713,9 @@ tmpfs_reg_resize(struct vnode *vp, off_t newsize, boolean_t ignerr) struct tmpfs_mount *tmp; struct tmpfs_node *node; vm_object_t uobj; - vm_page_t m; vm_pindex_t idx, newpages, oldpages; off_t oldsize; - int base, rv; + int base, error; MPASS(vp->v_type == VREG); MPASS(newsize >= 0); @@ -1702,45 +1752,11 @@ tmpfs_reg_resize(struct vnode *vp, off_t newsize, boolean_t ignerr) base = newsize & PAGE_MASK; if (base != 0) { idx = OFF_TO_IDX(newsize); -retry: - m = vm_page_grab(uobj, idx, VM_ALLOC_NOCREAT); - if (m != NULL) { - MPASS(vm_page_all_valid(m)); - } else if (vm_pager_has_page(uobj, idx, NULL, NULL)) { - m = vm_page_alloc(uobj, idx, VM_ALLOC_NORMAL | - VM_ALLOC_WAITFAIL); - if (m == NULL) - goto retry; - vm_object_pip_add(uobj, 1); + error = tmpfs_partial_page_invalidate(uobj, idx, base, + PAGE_SIZE, ignerr); + if (error != 0) { VM_OBJECT_WUNLOCK(uobj); - rv = vm_pager_get_pages(uobj, &m, 1, NULL, - NULL); - VM_OBJECT_WLOCK(uobj); - vm_object_pip_wakeup(uobj); - if (rv == VM_PAGER_OK) { - /* - * Since the page was not resident, - * and therefore not recently - * accessed, immediately enqueue it - * for asynchronous laundering. The - * current operation is not regarded - * as an access. - */ - vm_page_launder(m); - } else { - vm_page_free(m); - if (ignerr) - m = NULL; - else { - VM_OBJECT_WUNLOCK(uobj); - return (EIO); - } - } - } - if (m != NULL) { - pmap_zero_page_area(m, base, PAGE_SIZE - base); - vm_page_set_dirty(m); - vm_page_xunbusy(m); + return (error); } } From owner-dev-commits-src-main@freebsd.org Wed Aug 25 21:35:14 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 261F465B833; Wed, 25 Aug 2021 21:35:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gvzm20Q0Xz4lqp; Wed, 25 Aug 2021 21:35:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DC51D23DE0; Wed, 25 Aug 2021 21:35:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17PLZDMn004059; Wed, 25 Aug 2021 21:35:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17PLZDQR004058; Wed, 25 Aug 2021 21:35:13 GMT (envelope-from git) Date: Wed, 25 Aug 2021 21:35:13 GMT Message-Id: <202108252135.17PLZDQR004058@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ka Ho Ng Subject: git: 8d7cd10ba633 - main - tmpfs: Implement VOP_DEALLOCATE MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8d7cd10ba633309a2fa8c0d6475f85e0266e3d94 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 21:35:14 -0000 The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=8d7cd10ba633309a2fa8c0d6475f85e0266e3d94 commit 8d7cd10ba633309a2fa8c0d6475f85e0266e3d94 Author: Ka Ho Ng AuthorDate: 2021-08-25 21:34:35 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-25 21:34:54 +0000 tmpfs: Implement VOP_DEALLOCATE Implementing VOP_DEALLOCATE to allow hole-punching in the same manner as POSIX shared memory's fspacectl(SPACECTL_DEALLOC) support. Sponsored by: The FreeBSD Foundation Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D31684 --- sys/fs/tmpfs/tmpfs.h | 1 + sys/fs/tmpfs/tmpfs_subr.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++ sys/fs/tmpfs/tmpfs_vnops.c | 7 ++++ 3 files changed, 93 insertions(+) diff --git a/sys/fs/tmpfs/tmpfs.h b/sys/fs/tmpfs/tmpfs.h index 99368d67aaaa..bfa12b0382bc 100644 --- a/sys/fs/tmpfs/tmpfs.h +++ b/sys/fs/tmpfs/tmpfs.h @@ -459,6 +459,7 @@ int tmpfs_dir_getdents(struct tmpfs_mount *, struct tmpfs_node *, int tmpfs_dir_whiteout_add(struct vnode *, struct componentname *); void tmpfs_dir_whiteout_remove(struct vnode *, struct componentname *); int tmpfs_reg_resize(struct vnode *, off_t, boolean_t); +int tmpfs_reg_punch_hole(struct vnode *vp, off_t *, off_t *); int tmpfs_chflags(struct vnode *, u_long, struct ucred *, struct thread *); int tmpfs_chmod(struct vnode *, mode_t, struct ucred *, struct thread *); int tmpfs_chown(struct vnode *, uid_t, gid_t, struct ucred *, diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c index e746a7455860..1b7521cf0b0d 100644 --- a/sys/fs/tmpfs/tmpfs_subr.c +++ b/sys/fs/tmpfs/tmpfs_subr.c @@ -1775,6 +1775,91 @@ tmpfs_reg_resize(struct vnode *vp, off_t newsize, boolean_t ignerr) return (0); } +/* + * Punch hole in the aobj associated with the regular file pointed to by 'vp'. + * Requests completely beyond the end-of-file are converted to no-op. + * + * Returns 0 on success or error code from tmpfs_partial_page_invalidate() on + * failure. + */ +int +tmpfs_reg_punch_hole(struct vnode *vp, off_t *offset, off_t *length) +{ + struct tmpfs_mount *tmp; + struct tmpfs_node *node; + vm_object_t object; + vm_pindex_t pistart, pi, piend; + int startofs, endofs, end; + off_t off, len; + int error; + + KASSERT(*length <= OFF_MAX - *offset, ("%s: offset + length overflows", + __func__)); + node = VP_TO_TMPFS_NODE(vp); + KASSERT(node->tn_type == VREG, ("%s: node is not regular file", + __func__)); + object = node->tn_reg.tn_aobj; + tmp = VFS_TO_TMPFS(vp->v_mount); + off = *offset; + len = omin(node->tn_size - off, *length); + startofs = off & PAGE_MASK; + endofs = (off + len) & PAGE_MASK; + pistart = OFF_TO_IDX(off); + piend = OFF_TO_IDX(off + len); + pi = OFF_TO_IDX((vm_ooffset_t)off + PAGE_MASK); + error = 0; + + /* Handle the case when offset is on or beyond file size. */ + if (len <= 0) { + *length = 0; + return (0); + } + + VM_OBJECT_WLOCK(object); + + /* + * If there is a partial page at the beginning of the hole-punching + * request, fill the partial page with zeroes. + */ + if (startofs != 0) { + end = pistart != piend ? PAGE_SIZE : endofs; + error = tmpfs_partial_page_invalidate(object, pistart, startofs, + end, FALSE); + if (error != 0) + goto out; + off += end - startofs; + len -= end - startofs; + } + + /* + * Toss away the full pages in the affected area. + */ + if (pi < piend) { + vm_object_page_remove(object, pi, piend, 0); + off += IDX_TO_OFF(piend - pi); + len -= IDX_TO_OFF(piend - pi); + } + + /* + * If there is a partial page at the end of the hole-punching request, + * fill the partial page with zeroes. + */ + if (endofs != 0 && pistart != piend) { + error = tmpfs_partial_page_invalidate(object, piend, 0, endofs, + FALSE); + if (error != 0) + goto out; + off += endofs; + len -= endofs; + } + +out: + VM_OBJECT_WUNLOCK(object); + *offset = off; + *length = len; + return (error); +} + void tmpfs_check_mtime(struct vnode *vp) { diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c index 326a5132990d..d8c74cecdfe4 100644 --- a/sys/fs/tmpfs/tmpfs_vnops.c +++ b/sys/fs/tmpfs/tmpfs_vnops.c @@ -695,6 +695,12 @@ out: return (error); } +static int +tmpfs_deallocate(struct vop_deallocate_args *v) +{ + return (tmpfs_reg_punch_hole(v->a_vp, v->a_offset, v->a_len)); +} + static int tmpfs_fsync(struct vop_fsync_args *v) { @@ -1840,6 +1846,7 @@ struct vop_vector tmpfs_vnodeop_entries = { .vop_read = tmpfs_read, .vop_read_pgcache = tmpfs_read_pgcache, .vop_write = tmpfs_write, + .vop_deallocate = tmpfs_deallocate, .vop_fsync = tmpfs_fsync, .vop_remove = tmpfs_remove, .vop_link = tmpfs_link, From owner-dev-commits-src-main@freebsd.org Thu Aug 26 03:00:20 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 808B965FBC6; Thu, 26 Aug 2021 03:00:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gw6z830dvz3rsp; Thu, 26 Aug 2021 03:00:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4FD3A29A; Thu, 26 Aug 2021 03:00:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17Q30KjZ038113; Thu, 26 Aug 2021 03:00:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17Q30KUm038110; Thu, 26 Aug 2021 03:00:20 GMT (envelope-from git) Date: Thu, 26 Aug 2021 03:00:20 GMT Message-Id: <202108260300.17Q30KUm038110@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kyle Evans Subject: git: 3daa8e165c66 - main - pxeboot: improve and simplify rx handling MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3daa8e165c661c1b45e759f4997f447384c15446 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 03:00:20 -0000 The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=3daa8e165c661c1b45e759f4997f447384c15446 commit 3daa8e165c661c1b45e759f4997f447384c15446 Author: Kyle Evans AuthorDate: 2021-08-12 02:49:17 +0000 Commit: Kyle Evans CommitDate: 2021-08-26 02:59:08 +0000 pxeboot: improve and simplify rx handling This pushes the bulk of the rx servicing into a single loop that's only slightly convoluted, and it addresses a problem with rx handling in the process. If we hit a tx interrupt while we're processing, we'd previously drop the frame on the floor completely and ultimately timeout, increasing boot time on particularly busy hosts as we keep having to backoff and resend. After this patch, we don't seem to hit timeouts at all on zoo anymore though loading a 27M kernel is still relatively slow (~1m20s). Reviewed by: tsoome Triage by: Ash Gokhale Sponsored By: National Bureau of Economic Research Sponsored by: Klara, Inc. MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31512 --- stand/i386/libi386/pxe.c | 154 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 106 insertions(+), 48 deletions(-) diff --git a/stand/i386/libi386/pxe.c b/stand/i386/libi386/pxe.c index 217692b515f0..e80a1961e191 100644 --- a/stand/i386/libi386/pxe.c +++ b/stand/i386/libi386/pxe.c @@ -30,6 +30,8 @@ __FBSDID("$FreeBSD$"); #include +#include +#include #include #include #include @@ -432,91 +434,144 @@ pxe_netif_init(struct iodesc *desc, void *machdep_hint) } static int -pxe_netif_receive(void **pkt) +pxe_netif_receive_isr(t_PXENV_UNDI_ISR *isr, void **pkt, ssize_t *retsize) { - t_PXENV_UNDI_ISR *isr; + static bool data_pending; char *buf, *ptr, *frame; size_t size, rsize; - isr = bio_alloc(sizeof(*isr)); - if (isr == NULL) - return (-1); + buf = NULL; + size = rsize = 0; + + /* + * We can save ourselves the next two pxe calls because we already know + * we weren't done grabbing everything. + */ + if (data_pending) { + data_pending = false; + goto nextbuf; + } + /* + * We explicitly don't check for OURS/NOT_OURS as a result of START; + * it's been reported that some cards are known to mishandle these. + */ bzero(isr, sizeof(*isr)); isr->FuncFlag = PXENV_UNDI_ISR_IN_START; pxe_call(PXENV_UNDI_ISR, isr); + /* We could translate Status... */ if (isr->Status != 0) { - bio_free(isr, sizeof(*isr)); - return (-1); + return (ENXIO); } bzero(isr, sizeof(*isr)); isr->FuncFlag = PXENV_UNDI_ISR_IN_PROCESS; pxe_call(PXENV_UNDI_ISR, isr); if (isr->Status != 0) { - bio_free(isr, sizeof(*isr)); - return (-1); + return (ENXIO); } - - while (isr->FuncFlag == PXENV_UNDI_ISR_OUT_TRANSMIT) { + if (isr->FuncFlag == PXENV_UNDI_ISR_OUT_BUSY) { /* - * Wait till transmit is done. + * Let the caller decide if we need to be restarted. It will + * currently blindly restart us, but it could check timeout in + * the future. */ - bzero(isr, sizeof(*isr)); - isr->FuncFlag = PXENV_UNDI_ISR_IN_GET_NEXT; - pxe_call(PXENV_UNDI_ISR, isr); - if (isr->Status != 0 || - isr->FuncFlag == PXENV_UNDI_ISR_OUT_DONE) { - bio_free(isr, sizeof(*isr)); - return (-1); - } + return (ERESTART); } - while (isr->FuncFlag != PXENV_UNDI_ISR_OUT_RECEIVE) { - if (isr->Status != 0 || - isr->FuncFlag == PXENV_UNDI_ISR_OUT_DONE) { - bio_free(isr, sizeof(*isr)); - return (-1); + /* + * By design, we'll hardly ever hit this terminal condition unless we + * pick up nothing but tx interrupts here. More frequently, we will + * process rx buffers until we hit the terminal condition in the middle. + */ + while (isr->FuncFlag != PXENV_UNDI_ISR_OUT_DONE) { + /* + * This might have given us PXENV_UNDI_ISR_OUT_TRANSMIT, in + * which case we can just disregard and move on to the next + * buffer/frame. + */ + if (isr->FuncFlag != PXENV_UNDI_ISR_OUT_RECEIVE) + goto nextbuf; + + if (buf == NULL) { + /* + * Grab size from the first Frame that we picked up, + * allocate an rx buf to hold. Careful here, as we may + * see a fragmented frame that's spread out across + * multiple GET_NEXT calls. + */ + size = isr->FrameLength; + buf = malloc(size + ETHER_ALIGN); + if (buf == NULL) + return (ENOMEM); + + ptr = buf + ETHER_ALIGN; } - bzero(isr, sizeof(*isr)); - isr->FuncFlag = PXENV_UNDI_ISR_IN_GET_NEXT; - pxe_call(PXENV_UNDI_ISR, isr); - } - - size = isr->FrameLength; - buf = malloc(size + ETHER_ALIGN); - if (buf == NULL) { - bio_free(isr, sizeof(*isr)); - return (-1); - } - ptr = buf + ETHER_ALIGN; - rsize = 0; - while (rsize < size) { frame = (char *)((uintptr_t)isr->Frame.segment << 4); frame += isr->Frame.offset; bcopy(PTOV(frame), ptr, isr->BufferLength); ptr += isr->BufferLength; rsize += isr->BufferLength; + /* + * Stop here before we risk catching the start of another frame. + * It would be nice to continue reading until we actually get a + * PXENV_UNDI_ISR_OUT_DONE, but our network stack in libsa isn't + * suitable for reading more than one packet at a time. + */ + if (rsize >= size) { + data_pending = true; + break; + } + +nextbuf: bzero(isr, sizeof(*isr)); isr->FuncFlag = PXENV_UNDI_ISR_IN_GET_NEXT; pxe_call(PXENV_UNDI_ISR, isr); if (isr->Status != 0) { - bio_free(isr, sizeof(*isr)); free(buf); - return (-1); + return (ENXIO); } + } - /* Did we got another update? */ - if (isr->FuncFlag == PXENV_UNDI_ISR_OUT_RECEIVE) - continue; - break; + /* + * We may have never picked up a frame at all (all tx), in which case + * the caller should restart us. + */ + if (rsize == 0) { + return (ERESTART); } *pkt = buf; + *retsize = rsize; + return (0); +} + +static int +pxe_netif_receive(void **pkt, ssize_t *size) +{ + t_PXENV_UNDI_ISR *isr; + int ret; + + isr = bio_alloc(sizeof(*isr)); + if (isr == NULL) + return (ENOMEM); + + /* + * This completely ignores the timeout specified in pxe_netif_get(), but + * we shouldn't be running long enough here for that to make a + * difference. + */ + for (;;) { + /* We'll only really re-enter for PXENV_UNDI_ISR_OUT_BUSY. */ + ret = pxe_netif_receive_isr(isr, pkt, size); + if (ret != ERESTART) + break; + } + bio_free(isr, sizeof(*isr)); - return (rsize); + return (ret); } static ssize_t @@ -525,16 +580,19 @@ pxe_netif_get(struct iodesc *desc, void **pkt, time_t timeout) time_t t; void *ptr; int ret = -1; + ssize_t size; t = getsecs(); + size = 0; while ((getsecs() - t) < timeout) { - ret = pxe_netif_receive(&ptr); + ret = pxe_netif_receive(&ptr, &size); if (ret != -1) { *pkt = ptr; break; } } - return (ret); + + return (ret == 0 ? size : -1); } static ssize_t From owner-dev-commits-src-main@freebsd.org Thu Aug 26 09:16:16 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 36511665D0D; Thu, 26 Aug 2021 09:16:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GwHJw0r7sz3n3Y; Thu, 26 Aug 2021 09:16:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 04D145523; Thu, 26 Aug 2021 09:16:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17Q9GFIU051311; Thu, 26 Aug 2021 09:16:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17Q9GF2w051310; Thu, 26 Aug 2021 09:16:15 GMT (envelope-from git) Date: Thu, 26 Aug 2021 09:16:15 GMT Message-Id: <202108260916.17Q9GF2w051310@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wojciech Macek Subject: git: 3706af423ff2 - main - Add support for Lewisburg GPIO through P2SB MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wma X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3706af423ff257540dfe88bcb91fb0ab54e60946 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 09:16:16 -0000 The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=3706af423ff257540dfe88bcb91fb0ab54e60946 commit 3706af423ff257540dfe88bcb91fb0ab54e60946 Author: Arnaud Ysmal AuthorDate: 2021-06-29 13:54:07 +0000 Commit: Wojciech Macek CommitDate: 2021-08-26 09:00:39 +0000 Add support for Lewisburg GPIO through P2SB Obtained from: Semihalf Sponsored by: Stormshield Differential revision: https://reviews.freebsd.org/D31269 --- sys/conf/files.amd64 | 3 + sys/dev/p2sb/lewisburg_gpio.c | 269 ++++++++++++++++++++++++++++++ sys/dev/p2sb/lewisburg_gpiocm.c | 351 ++++++++++++++++++++++++++++++++++++++++ sys/dev/p2sb/lewisburg_gpiocm.h | 12 ++ sys/dev/p2sb/p2sb.c | 215 ++++++++++++++++++++++++ sys/dev/p2sb/p2sb.h | 11 ++ sys/modules/Makefile | 3 + sys/modules/p2sb/Makefile | 7 + 8 files changed, 871 insertions(+) diff --git a/sys/conf/files.amd64 b/sys/conf/files.amd64 index d58cf7927206..1bcfaa05d0ba 100644 --- a/sys/conf/files.amd64 +++ b/sys/conf/files.amd64 @@ -363,6 +363,9 @@ dev/viawd/viawd.c optional viawd dev/vmd/vmd.c optional vmd dev/vmd/vmd_bus.c optional vmd_bus dev/wbwd/wbwd.c optional wbwd +dev/p2sb/p2sb.c optional p2sb pci +dev/p2sb/lewisburg_gpiocm.c optional lbggpiocm p2sb +dev/p2sb/lewisburg_gpio.c optional lbggpio lbggpiocm isa/syscons_isa.c optional sc isa/vga_isa.c optional vga kern/imgact_aout.c optional compat_aout diff --git a/sys/dev/p2sb/lewisburg_gpio.c b/sys/dev/p2sb/lewisburg_gpio.c new file mode 100644 index 000000000000..d0b08520eb87 --- /dev/null +++ b/sys/dev/p2sb/lewisburg_gpio.c @@ -0,0 +1,269 @@ +/*- + * Copyright (c) 2018 Stormshield + * All rights reserved. + * + * 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 /* defines used in kernel.h */ +#include +#include +#include +#include /* types used in module initialization */ +#include /* cdevsw struct */ +#include /* uio struct */ +#include +#include /* structs, prototypes for pci bus stuff and DEVMETHOD macros! */ +#include + +#include +#include +#include + +#include + +#include "gpio_if.h" + +#include "lewisburg_gpiocm.h" + +#define P2SB_GROUP_GPIO_MAX_PINS 24 +struct lbggpio_softc +{ + device_t sc_busdev; + int groupid; + int pins_off; + int npins; + char grpname; + struct gpio_pin gpio_setup[P2SB_GROUP_GPIO_MAX_PINS]; +}; + +static device_t +lbggpio_get_bus(device_t dev) +{ + struct lbggpio_softc *sc; + + sc = device_get_softc(dev); + + return (sc->sc_busdev); +} + +static int +lbggpio_pin_max(device_t dev, int *maxpin) +{ + struct lbggpio_softc *sc; + + if (maxpin == NULL) + return (EINVAL); + + sc = device_get_softc(dev); + + *maxpin = sc->npins - 1; + + return (0); +} + +static int +lbggpio_pin_getname(device_t dev, uint32_t pin, char *name) +{ + struct lbggpio_softc *sc = device_get_softc(dev); + + if (name == NULL) + return (EINVAL); + + if (pin >= sc->npins) + return (EINVAL); + + strlcpy(name, sc->gpio_setup[pin].gp_name, GPIOMAXNAME); + + return (0); +} + +static int +lbggpio_pin_getflags(device_t dev, uint32_t pin, uint32_t *flags) +{ + struct lbggpio_softc *sc = device_get_softc(dev); + + if (flags == NULL) + return (EINVAL); + + if (pin >= sc->npins) + return (EINVAL); + + *flags = sc->gpio_setup[pin].gp_flags; + + return (0); +} + +static int +lbggpio_pin_getcaps(device_t dev, uint32_t pin, uint32_t *caps) +{ + struct lbggpio_softc *sc = device_get_softc(dev); + + if (caps == NULL) + return (EINVAL); + + if (pin >= sc->npins) + return (EINVAL); + + *caps = sc->gpio_setup[pin].gp_caps; + + return (0); +} + +static int +lbggpio_pin_setflags(device_t dev, uint32_t pin, uint32_t flags) +{ + struct lbggpio_softc *sc = device_get_softc(dev); + + if (pin >= sc->npins) + return (EINVAL); + + /* Check for unwanted flags. */ + if ((flags & sc->gpio_setup[pin].gp_caps) != flags) + return (EINVAL); + + lbggpiocm_pin_setflags(device_get_parent(dev), dev, pin, flags); + sc->gpio_setup[pin].gp_flags = flags; + + return (0); +} + +static int +lbggpio_pin_get(device_t dev, uint32_t pin, uint32_t *value) +{ + struct lbggpio_softc *sc = device_get_softc(dev); + + if (value == NULL) + return (EINVAL); + + if (pin >= sc->npins) + return (EINVAL); + + return (lbggpiocm_pin_get(device_get_parent(dev), dev, pin, value)); +} + +static int +lbggpio_pin_set(device_t dev, uint32_t pin, uint32_t value) +{ + struct lbggpio_softc *sc = device_get_softc(dev); + + if (pin >= sc->npins) + return (EINVAL); + + return (lbggpiocm_pin_set(device_get_parent(dev), dev, pin, value)); +} + +static int +lbggpio_pin_toggle(device_t dev, uint32_t pin) +{ + struct lbggpio_softc *sc = device_get_softc(dev); + + if (pin >= sc->npins) + return (EINVAL); + + return (lbggpiocm_pin_toggle(device_get_parent(dev), dev, pin)); +} + +static int +lbggpio_probe(device_t dev) +{ + struct lbggpio_softc *sc = device_get_softc(dev); + /* X is a placeholder for the actual one letter group name. */ + static char desc[] = "LewisBurg GPIO Group X"; + + sc->npins = lbggpiocm_get_group_npins(device_get_parent(dev), dev); + sc->grpname = lbggpiocm_get_group_name(device_get_parent(dev), dev); + if (sc->npins <= 0) + return (ENXIO); + + desc[sizeof(desc)-2] = sc->grpname; + device_set_desc_copy(dev, desc); + return (BUS_PROBE_DEFAULT); +} + +static int +lbggpio_attach(device_t dev) +{ + uint32_t i; + struct lbggpio_softc *sc; + + sc = device_get_softc(dev); + /* GPIO config */ + for (i = 0; i < sc->npins; ++i) { + sc->gpio_setup[i].gp_pin = i; + snprintf(sc->gpio_setup[i].gp_name, + sizeof(sc->gpio_setup[i].gp_name), + "GPIO %c%u", sc->grpname, i); + sc->gpio_setup[i].gp_caps = GPIO_PIN_INPUT | GPIO_PIN_OUTPUT; + } + + /* support gpio */ + sc->sc_busdev = gpiobus_attach_bus(dev); + if (sc->sc_busdev == NULL) + return (ENXIO); + + return (0); +} + +static int +lbggpio_detach(device_t dev) +{ + struct lbggpio_softc *sc; + + sc = device_get_softc(dev); + + if (sc->sc_busdev) + gpiobus_detach_bus(dev); + + return (0); +} + +static device_method_t lbggpio_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, lbggpio_probe), + DEVMETHOD(device_attach, lbggpio_attach), + DEVMETHOD(device_detach, lbggpio_detach), + + /* GPIO protocol */ + DEVMETHOD(gpio_get_bus, lbggpio_get_bus), + DEVMETHOD(gpio_pin_max, lbggpio_pin_max), + DEVMETHOD(gpio_pin_getcaps, lbggpio_pin_getcaps), + DEVMETHOD(gpio_pin_getflags, lbggpio_pin_getflags), + DEVMETHOD(gpio_pin_setflags, lbggpio_pin_setflags), + DEVMETHOD(gpio_pin_getname, lbggpio_pin_getname), + DEVMETHOD(gpio_pin_set, lbggpio_pin_set), + DEVMETHOD(gpio_pin_get, lbggpio_pin_get), + DEVMETHOD(gpio_pin_toggle, lbggpio_pin_toggle), + + DEVMETHOD_END +}; + +static driver_t lbggpio_driver = { + "gpio", + lbggpio_methods, + sizeof(struct lbggpio_softc) +}; + +static devclass_t lbggpio_devclass; + +DRIVER_MODULE(lbggpio, lbggpiocm, lbggpio_driver, lbggpio_devclass, NULL, NULL); +MODULE_DEPEND(lbggpio, gpiobus, 1, 1, 1); diff --git a/sys/dev/p2sb/lewisburg_gpiocm.c b/sys/dev/p2sb/lewisburg_gpiocm.c new file mode 100644 index 000000000000..4a046a50aed4 --- /dev/null +++ b/sys/dev/p2sb/lewisburg_gpiocm.c @@ -0,0 +1,351 @@ +/*- + * Copyright (c) 2018 Stormshield + * All rights reserved. + * + * 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 +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "gpio_if.h" + +#include "lewisburg_gpiocm.h" +#include "p2sb.h" + +#define PADBAR 0x00c + +#define PADCFG0_GPIORXDIS (1<<9) +#define PADCFG0_GPIOTXDIS (1<<8) +#define PADCFG0_GPIORXSTATE (1<<1) +#define PADCFG0_GPIOTXSTATE (1<<0) + +#define MAX_PAD_PER_GROUP 24 + +#define LBGGPIOCM_READ(sc, reg) p2sb_port_read_4(sc->p2sb, sc->port, reg) +#define LBGGPIOCM_WRITE(sc, reg, val) \ + p2sb_port_write_4(sc->p2sb, sc->port, reg, val) +#define LBGGPIOCM_LOCK(sc) p2sb_lock(sc->p2sb) +#define LBGGPIOCM_UNLOCK(sc) p2sb_unlock(sc->p2sb) + +struct lbggroup { + int groupid; + int npins; + int pins_off; + device_t dev; + char grpname; +}; + +struct lbgcommunity { + uint8_t npins; + const char *name; + uint32_t pad_off; + struct lbggroup groups[3]; + int ngroups; + const char *grpnames; +}; +#define LBG_COMMUNITY(n, np, g) \ +{ \ + .name = n, \ + .npins = np, \ + .grpnames = g, \ +} + +static struct lbgcommunity lbg_communities[] = { + LBG_COMMUNITY("LewisBurg GPIO Community 0", 72, "ABF"), + LBG_COMMUNITY("LewisBurg GPIO Community 1", 61, "CDE"), + LBG_COMMUNITY("LewisBurg GPIO Community 2", 0, ""), + LBG_COMMUNITY("LewisBurg GPIO Community 3", 12, "I"), + LBG_COMMUNITY("LewisBurg GPIO Community 4", 36, "JK"), + LBG_COMMUNITY("LewisBurg GPIO Community 5", 66, "GHL"), +}; + +struct lbggpiocm_softc +{ + int port; + device_t p2sb; + struct lbgcommunity *community; +}; + +static struct lbggroup *lbggpiocm_get_group(struct lbggpiocm_softc *sc, + device_t child); + +static __inline struct lbggroup * +lbggpiocm_get_group(struct lbggpiocm_softc *sc, device_t child) +{ + int i; + + for (i = 0; i < sc->community->ngroups; ++i) + if (sc->community->groups[i].dev == child) + return (&sc->community->groups[i]); + return (NULL); +} + + +static __inline uint32_t +lbggpiocm_getpad(struct lbggpiocm_softc *sc, uint32_t pin) +{ + + if (pin >= sc->community->npins) + return (0); + + return (sc->community->pad_off + 2 * 4 * pin); +} + +int +lbggpiocm_get_group_npins(device_t dev, device_t child) +{ + struct lbggpiocm_softc *sc = device_get_softc(dev); + struct lbggroup *group; + + group = lbggpiocm_get_group(sc, child); + if (group != NULL) + return (group->npins); + return (-1); +} + +char +lbggpiocm_get_group_name(device_t dev, device_t child) +{ + struct lbggpiocm_softc *sc = device_get_softc(dev); + struct lbggroup *group; + + group = lbggpiocm_get_group(sc, child); + if (group != NULL) + return (group->grpname); + return ('\0'); +} + +static int +lbggpiocm_pin2cpin(struct lbggpiocm_softc *sc, device_t child, uint32_t pin) +{ + struct lbggroup *group; + + group = lbggpiocm_get_group(sc, child); + if (group != NULL) + return (pin + group->pins_off); + return (-1); +} + +int +lbggpiocm_pin_setflags(device_t dev, device_t child, uint32_t pin, uint32_t flags) +{ + struct lbggpiocm_softc *sc = device_get_softc(dev); + uint32_t padreg, padval; + int rpin; + + if ((flags & (GPIO_PIN_INPUT | GPIO_PIN_OUTPUT)) == + (GPIO_PIN_INPUT | GPIO_PIN_OUTPUT)) + return (EINVAL); + + if ((flags & (GPIO_PIN_INPUT | GPIO_PIN_OUTPUT)) == 0) + return (EINVAL); + + rpin = lbggpiocm_pin2cpin(sc, child, pin); + if (rpin < 0) + return (EINVAL); + + padreg = lbggpiocm_getpad(sc, rpin); + + LBGGPIOCM_LOCK(sc); + padval = LBGGPIOCM_READ(sc, padreg); + + if (flags & GPIO_PIN_INPUT) { + padval &= ~PADCFG0_GPIORXDIS; + padval |= PADCFG0_GPIOTXDIS; + } else if (flags & GPIO_PIN_OUTPUT) { + padval &= ~PADCFG0_GPIOTXDIS; + padval |= PADCFG0_GPIORXDIS; + } + + LBGGPIOCM_WRITE(sc, padreg, padval); + LBGGPIOCM_UNLOCK(sc); + + return (0); +} + +int +lbggpiocm_pin_get(device_t dev, device_t child, uint32_t pin, uint32_t *value) +{ + struct lbggpiocm_softc *sc = device_get_softc(dev); + uint32_t padreg, val; + int rpin; + + if (value == NULL) + return (EINVAL); + + rpin = lbggpiocm_pin2cpin(sc, child, pin); + if (rpin < 0) + return (EINVAL); + + padreg = lbggpiocm_getpad(sc, rpin); + + LBGGPIOCM_LOCK(sc); + val = LBGGPIOCM_READ(sc, padreg); + LBGGPIOCM_UNLOCK(sc); + + if (!(val & PADCFG0_GPIOTXDIS)) + *value = !!(val & PADCFG0_GPIOTXSTATE); + else + *value = !!(val & PADCFG0_GPIORXSTATE); + + return (0); +} + +int +lbggpiocm_pin_set(device_t dev, device_t child, uint32_t pin, uint32_t value) +{ + struct lbggpiocm_softc *sc = device_get_softc(dev); + uint32_t padreg, padcfg; + int rpin; + + rpin = lbggpiocm_pin2cpin(sc, child, pin); + if (rpin < 0) + return (EINVAL); + + padreg = lbggpiocm_getpad(sc, rpin); + + LBGGPIOCM_LOCK(sc); + + padcfg = LBGGPIOCM_READ(sc, padreg); + if (value) + padcfg |= PADCFG0_GPIOTXSTATE; + else + padcfg &= ~PADCFG0_GPIOTXSTATE; + LBGGPIOCM_WRITE(sc, padreg, padcfg); + + LBGGPIOCM_UNLOCK(sc); + + return (0); +} + +int +lbggpiocm_pin_toggle(device_t dev, device_t child, uint32_t pin) +{ + struct lbggpiocm_softc *sc = device_get_softc(dev); + uint32_t padreg, padcfg; + int rpin; + + rpin = lbggpiocm_pin2cpin(sc, child, pin); + if (rpin < 0) + return (EINVAL); + + padreg = lbggpiocm_getpad(sc, rpin); + + LBGGPIOCM_LOCK(sc); + padcfg = LBGGPIOCM_READ(sc, padreg); + padcfg ^= PADCFG0_GPIOTXSTATE; + LBGGPIOCM_WRITE(sc, padreg, padcfg); + + LBGGPIOCM_UNLOCK(sc); + + return (0); +} + +static int +lbggpiocm_probe(device_t dev) +{ + struct lbggpiocm_softc *sc = device_get_softc(dev); + int unit; + + sc->p2sb = device_get_parent(dev); + unit = device_get_unit(dev); + KASSERT(unit < nitems(lbg_communities), ("Wrong number of devices or communities")); + sc->port = p2sb_get_port(sc->p2sb, unit); + sc->community = &lbg_communities[unit]; + if (sc->port < 0) + return (ENXIO); + + device_set_desc(dev, sc->community->name); + return (BUS_PROBE_DEFAULT); +} + +static int +lbggpiocm_attach(device_t dev) +{ + uint32_t npins; + struct lbggpiocm_softc *sc; + struct lbggroup *group; + int i; + + sc = device_get_softc(dev); + if (sc->community->npins == 0) + return (ENXIO); + + LBGGPIOCM_LOCK(sc); + sc->community->pad_off = LBGGPIOCM_READ(sc, PADBAR); + LBGGPIOCM_UNLOCK(sc); + + npins = sc->community->npins; + for (i = 0; i < nitems(sc->community->groups) && npins > 0; ++i) { + group = &sc->community->groups[i]; + + group->groupid = i; + group->grpname = sc->community->grpnames[i]; + group->pins_off = i * MAX_PAD_PER_GROUP; + group->npins = npins < MAX_PAD_PER_GROUP ? npins : + MAX_PAD_PER_GROUP; + npins -= group->npins; + group->dev = device_add_child(dev, "gpio", -1); + } + sc->community->ngroups = i; + return (bus_generic_attach(dev)); +} + +static int +lbggpiocm_detach(device_t dev) +{ + int error; + + error = device_delete_children(dev); + if (error) + return (error); + + return (bus_generic_detach(dev)); +} + +static device_method_t lbggpiocm_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, lbggpiocm_probe), + DEVMETHOD(device_attach, lbggpiocm_attach), + DEVMETHOD(device_detach, lbggpiocm_detach), + + DEVMETHOD_END +}; + +static driver_t lbggpiocm_driver = { + "lbggpiocm", + lbggpiocm_methods, + sizeof(struct lbggpiocm_softc) +}; +static devclass_t lbggpiocm_devclass; +DRIVER_MODULE(lbggpiocm, p2sb, lbggpiocm_driver, lbggpiocm_devclass, NULL, NULL); diff --git a/sys/dev/p2sb/lewisburg_gpiocm.h b/sys/dev/p2sb/lewisburg_gpiocm.h new file mode 100644 index 000000000000..7fcbf919949b --- /dev/null +++ b/sys/dev/p2sb/lewisburg_gpiocm.h @@ -0,0 +1,12 @@ +#ifndef __LEWISBURG_GPIOCM_H__ +#define __LEWISBURG_GPIOCM_H__ + +int lbggpiocm_get_group_npins(device_t dev, device_t child); +char lbggpiocm_get_group_name(device_t dev, device_t child); + +int lbggpiocm_pin_setflags(device_t, device_t, uint32_t, uint32_t); +int lbggpiocm_pin_get(device_t, device_t, uint32_t, uint32_t *); +int lbggpiocm_pin_set(device_t, device_t, uint32_t, uint32_t); +int lbggpiocm_pin_toggle(device_t, device_t, uint32_t); + +#endif /* __LEWISBURG_GPIOCM_H__ */ diff --git a/sys/dev/p2sb/p2sb.c b/sys/dev/p2sb/p2sb.c new file mode 100644 index 000000000000..80836cbb2f59 --- /dev/null +++ b/sys/dev/p2sb/p2sb.c @@ -0,0 +1,215 @@ +/*- + * Copyright (c) 2018 Stormshield + * All rights reserved. + * + * 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. + */ + +/* + * Implementation of Primary to Sideband bridge (P2SB), the documentation is available here : + * https://www.intel.com/content/dam/www/public/us/en/documents/datasheets/c620-series-chipset-datasheet.pdf + * section 36.9 P2SB Bridge. + * This device exposes a 16MB memory block, this block is composed of 256 64KB blocks called ports. + * The indexes of this array (target port ID) can be found on the Table 36-10 of the documentation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include "p2sb.h" + +#define PCI_PRODUCT_LEWISBURG_P2SB 0xa1a08086 + +#define P2SB_PORT2ADDRESS_SHIFT 16 +#define P2SB_PORT_ADDRESS(port) ((uint32_t)port << P2SB_PORT2ADDRESS_SHIFT) + +static const uint8_t lbg_communities[] = { + 0xAF, 0xAE, 0xAD, 0xAC, 0xAB, 0x11 +}; + +/* The softc holds our per-instance data. */ +struct p2sb_softc { + device_t dev; + int rid; + struct resource *res; + struct intel_community *communities; + int ncommunities; + struct mtx mutex; +}; + +int +p2sb_get_port(device_t dev, int unit) +{ + + if (unit >= nitems(lbg_communities)) + return (EINVAL); + return (lbg_communities[unit]); +} + +uint32_t +p2sb_port_read_4(device_t dev, uint8_t port, uint32_t reg) +{ + struct p2sb_softc *sc; + + KASSERT(reg < (1<res, P2SB_PORT_ADDRESS(port) + reg)); +} + +void +p2sb_port_write_4(device_t dev, uint8_t port, uint32_t reg, uint32_t val) +{ + struct p2sb_softc *sc; + + KASSERT(reg < (1<res, P2SB_PORT_ADDRESS(port) + reg, val); +} + +void +p2sb_lock(device_t dev) +{ + struct p2sb_softc *sc; + + sc = device_get_softc(dev); + mtx_lock_spin(&sc->mutex); +} + +void +p2sb_unlock(device_t dev) +{ + struct p2sb_softc *sc; + + sc = device_get_softc(dev); + mtx_unlock_spin(&sc->mutex); +} + + +static int +p2sb_probe(device_t dev) +{ + + if (pci_get_devid(dev) == PCI_PRODUCT_LEWISBURG_P2SB) { + device_set_desc(dev, "Lewisburg P2SB"); + return (BUS_PROBE_DEFAULT); + } + return (ENXIO); +} + +/* Attach function is only called if the probe is successful. */ + +static int +p2sb_attach(device_t dev) +{ + struct p2sb_softc *sc; + int i; + + sc = device_get_softc(dev); + sc->dev = dev; + sc->rid = PCIR_BAR(0); + sc->res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->rid, RF_ACTIVE); + if (sc->res == NULL) { + device_printf(dev, "Could not allocate memory.\n"); + return (ENXIO); + } + mtx_init(&sc->mutex, device_get_nameunit(dev), NULL, MTX_SPIN); + for (i = 0; i < nitems(lbg_communities); ++i) + device_add_child(dev, "lbggpiocm", i); + + return (bus_generic_attach(dev)); +} + +/* Detach device. */ + +static int +p2sb_detach(device_t dev) +{ + struct p2sb_softc *sc; + + /* Teardown the state in our softc created in our attach routine. */ + device_delete_children(dev); + sc = device_get_softc(dev); + mtx_destroy(&sc->mutex); + if (sc->res != NULL) + bus_release_resource(dev, SYS_RES_MEMORY, sc->rid, sc->res); + return (0); +} + +/* Called during system shutdown after sync. */ + +static int +p2sb_shutdown(device_t dev) +{ + + return (0); +} + +/* + * Device suspend routine. + */ +static int +p2sb_suspend(device_t dev) +{ + + return (0); +} + +/* + * Device resume routine. + */ +static int +p2sb_resume(device_t dev) +{ + + return (0); +} + +static device_method_t p2sb_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, p2sb_probe), + DEVMETHOD(device_attach, p2sb_attach), + DEVMETHOD(device_detach, p2sb_detach), + DEVMETHOD(device_shutdown, p2sb_shutdown), + DEVMETHOD(device_suspend, p2sb_suspend), + DEVMETHOD(device_resume, p2sb_resume), + + DEVMETHOD_END +}; + +static devclass_t p2sb_devclass; + +DEFINE_CLASS_0(p2sb, p2sb_driver, p2sb_methods, sizeof(struct p2sb_softc)); +DRIVER_MODULE(p2sb, pci, p2sb_driver, p2sb_devclass, 0, 0); diff --git a/sys/dev/p2sb/p2sb.h b/sys/dev/p2sb/p2sb.h new file mode 100644 index 000000000000..7c060a02fcf9 --- /dev/null +++ b/sys/dev/p2sb/p2sb.h @@ -0,0 +1,11 @@ +#ifndef __P2SB_H__ +#define __P2SB_H__ + +void p2sb_lock(device_t dev); +void p2sb_unlock(device_t dev); + +uint32_t p2sb_port_read_4(device_t dev, uint8_t port, uint32_t reg); +void p2sb_port_write_4(device_t dev, uint8_t port, uint32_t reg, uint32_t val); +int p2sb_get_port(device_t dev, int unit); + +#endif /* __P2SB_H__ */ diff --git a/sys/modules/Makefile b/sys/modules/Makefile index 7ef3c5a477ce..585e2bdc80ca 100644 --- a/sys/modules/Makefile +++ b/sys/modules/Makefile @@ -358,6 +358,7 @@ SUBDIR= \ stge \ ${_sume} \ ${_superio} \ + ${_p2sb} \ ${_sym} \ ${_syscons} \ sysvipc \ @@ -662,6 +663,7 @@ _safe= safe _speaker= speaker _splash= splash _sppp= sppp +_p2sb= p2sb _wbwd= wbwd _aac= aac @@ -755,6 +757,7 @@ _sfxge= sfxge _sgx= sgx _sgx_linux= sgx_linux _smartpqi= smartpqi +_p2sb= p2sb .if ${MK_BHYVE} != "no" || defined(ALL_MODULES) .if ${KERN_OPTS:MSMP} diff --git a/sys/modules/p2sb/Makefile b/sys/modules/p2sb/Makefile new file mode 100644 index 000000000000..8f4d604f73d5 --- /dev/null +++ b/sys/modules/p2sb/Makefile @@ -0,0 +1,7 @@ +.PATH: ${.CURDIR}/../../dev/p2sb + +KMOD= p2sb +SRCS= p2sb.c lewisburg_gpio.c lewisburg_gpiocm.c +SRCS+= device_if.h bus_if.h pci_if.h gpio_if.h + +.include From owner-dev-commits-src-main@freebsd.org Thu Aug 26 09:24:19 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A2CDC665C43; Thu, 26 Aug 2021 09:24:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GwHVC42Nqz3pd4; Thu, 26 Aug 2021 09:24:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6FB0056B2; Thu, 26 Aug 2021 09:24:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17Q9OJMP064596; Thu, 26 Aug 2021 09:24:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17Q9OJiB064595; Thu, 26 Aug 2021 09:24:19 GMT (envelope-from git) Date: Thu, 26 Aug 2021 09:24:19 GMT Message-Id: <202108260924.17Q9OJiB064595@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: eb680a63de1d - main - if_bridge: add ALTQ support MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: eb680a63de1dbf5c974f483975dcb2c60ec6fa08 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 09:24:19 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=eb680a63de1dbf5c974f483975dcb2c60ec6fa08 commit eb680a63de1dbf5c974f483975dcb2c60ec6fa08 Author: Luiz Otavio O Souza AuthorDate: 2021-08-25 09:07:44 +0000 Commit: Kristof Provost CommitDate: 2021-08-26 09:23:44 +0000 if_bridge: add ALTQ support Similar to the recent addition of ALTQ support to if_vlan. Reviewed by: donner Obtained from: pfsense MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D31675 --- sys/net/if_bridge.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c index adf1c9155ee1..703a76086c55 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -298,6 +298,10 @@ static void bridge_init(void *); static void bridge_dummynet(struct mbuf *, struct ifnet *); static void bridge_stop(struct ifnet *, int); static int bridge_transmit(struct ifnet *, struct mbuf *); +#ifdef ALTQ +static void bridge_altq_start(if_t); +static int bridge_altq_transmit(if_t, struct mbuf *); +#endif static void bridge_qflush(struct ifnet *); static struct mbuf *bridge_input(struct ifnet *, struct mbuf *); static int bridge_output(struct ifnet *, struct mbuf *, struct sockaddr *, @@ -726,7 +730,15 @@ bridge_clone_create(struct if_clone *ifc, int unit, caddr_t params) if_initname(ifp, bridge_name, unit); ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = bridge_ioctl; +#ifdef ALTQ + ifp->if_start = bridge_altq_start; + ifp->if_transmit = bridge_altq_transmit; + IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen); + ifp->if_snd.ifq_drv_maxlen = 0; + IFQ_SET_READY(&ifp->if_snd); +#else ifp->if_transmit = bridge_transmit; +#endif ifp->if_qflush = bridge_qflush; ifp->if_init = bridge_init; ifp->if_type = IFT_BRIDGE; @@ -798,6 +810,9 @@ bridge_clone_destroy(struct ifnet *ifp) BRIDGE_LIST_UNLOCK(); bstp_detach(&sc->sc_stp); +#ifdef ALTQ + IFQ_PURGE(&ifp->if_snd); +#endif NET_EPOCH_EXIT(et); ether_ifdetach(ifp); @@ -2219,6 +2234,38 @@ bridge_transmit(struct ifnet *ifp, struct mbuf *m) return (error); } +#ifdef ALTQ +static void +bridge_altq_start(if_t ifp) +{ + struct ifaltq *ifq = &ifp->if_snd; + struct mbuf *m; + + IFQ_LOCK(ifq); + IFQ_DEQUEUE_NOLOCK(ifq, m); + while (m != NULL) { + bridge_transmit(ifp, m); + IFQ_DEQUEUE_NOLOCK(ifq, m); + } + IFQ_UNLOCK(ifq); +} + +static int +bridge_altq_transmit(if_t ifp, struct mbuf *m) +{ + int err; + + if (ALTQ_IS_ENABLED(&ifp->if_snd)) { + IFQ_ENQUEUE(&ifp->if_snd, m, err); + if (err == 0) + bridge_altq_start(ifp); + } else + err = bridge_transmit(ifp, m); + + return (err); +} +#endif /* ALTQ */ + /* * The ifp->if_qflush entry point for if_bridge(4) is no-op. */ From owner-dev-commits-src-main@freebsd.org Thu Aug 26 09:24:18 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8D562665EB7; Thu, 26 Aug 2021 09:24:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GwHVB3GjZz3pXn; Thu, 26 Aug 2021 09:24:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4E5D45450; Thu, 26 Aug 2021 09:24:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17Q9OIf2064572; Thu, 26 Aug 2021 09:24:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17Q9OIZu064571; Thu, 26 Aug 2021 09:24:18 GMT (envelope-from git) Date: Thu, 26 Aug 2021 09:24:18 GMT Message-Id: <202108260924.17Q9OIZu064571@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: cd46399b9ccf - main - pf tests: ALTQ priority test MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: cd46399b9ccf04f6ec00a532e52c8b1edb007af7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 09:24:18 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=cd46399b9ccf04f6ec00a532e52c8b1edb007af7 commit cd46399b9ccf04f6ec00a532e52c8b1edb007af7 Author: Kristof Provost AuthorDate: 2021-08-26 08:25:57 +0000 Commit: Kristof Provost CommitDate: 2021-08-26 09:23:39 +0000 pf tests: ALTQ priority test Test that ALTQ can prioritise one type of traffic over another. Do this by establishing a slow link and saturating it with ICMP echos. When prioritised TCP connections reliably go through. When not prioritised TCP connections reliably fail. MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") --- tests/sys/netpfil/pf/altq.sh | 94 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 93 insertions(+), 1 deletion(-) diff --git a/tests/sys/netpfil/pf/altq.sh b/tests/sys/netpfil/pf/altq.sh index 53cf10e47565..ebb28f34c22e 100644 --- a/tests/sys/netpfil/pf/altq.sh +++ b/tests/sys/netpfil/pf/altq.sh @@ -145,10 +145,102 @@ cbq_vlan_cleanup() altq_cleanup } +atf_test_case "prioritise" "cleanup" +prioritise_head() +{ + atf_set descr "Test prioritising one type of traffic over the other" + atf_set require.user root +} + +prioritise_body() +{ + altq_init + is_altq_supported cbq + + epair=$(vnet_mkepair) + vnet_mkjail altq_prioritise ${epair}b + + ifconfig ${epair}a 192.0.2.1/24 up + jexec altq_prioritise ifconfig ${epair}b 192.0.2.2/24 up + + jexec altq_prioritise /usr/sbin/inetd -p inetd-altq.pid \ + $(atf_get_srcdir)/../pf/echo_inetd.conf + + # Sanity check + atf_check -s exit:0 -o ignore ping -i .1 -c 3 -s 1200 192.0.2.2 + + jexec altq_prioritise pfctl -e + pft_set_rules altq_prioritise \ + "altq on ${epair}b bandwidth 6000b cbq queue { default, slow }" \ + "queue default priority 7 cbq(default)" \ + "queue slow priority 1 cbq" \ + "match proto icmp queue slow" \ + "match proto tcp queue default" \ + "pass" + + # single ping succeeds just fine + atf_check -s exit:0 -o ignore ping -c 1 192.0.2.2 + + # Unsaturated TCP succeeds + reply=$(echo "foo" | nc -w 5 -N 192.0.2.2 7) + if [ "$reply" != "foo" ]; + then + atf_fail "Unsaturated echo failed" + fi + + # "Saturate the link" + ping -i .01 -c 50 -s 1200 192.0.2.2 + + # We should now be hitting the limits and get these packet dropped. + rcv=$(ping -i .1 -c 5 -s 1200 192.0.2.2 | tr "," "\n" | awk '/packets received/ { print $1; }') + echo "Received $rcv packets" + if [ ${rcv} -gt 1 ] + then + atf_fail "Received ${rcv} packets in a saturated link" + fi + + # TCP should still pass + for i in `seq 1 10` + do + reply=$(echo "foo_${i}" | nc -w 5 -N 192.0.2.2 7) + if [ "$reply" != "foo_${i}" ]; + then + atf_fail "Prioritised echo failed ${i}" + fi + + done + + # Now reverse priority + pft_set_rules altq_prioritise \ + "altq on ${epair}b bandwidth 6000b cbq queue { default, slow }" \ + "queue default priority 7 cbq(default)" \ + "queue slow priority 1 cbq" \ + "match proto tcp queue slow" \ + "match proto icmp queue default" \ + "pass" + + atf_check -s exit:0 -o ignore ping -c 1 192.0.2.2 + ping -i .01 -c 50 -s 1200 192.0.2.2 + for i in `seq 1 10` + do + reply=$(echo "foo_${i}" | nc -w 5 -N 192.0.2.2 7) + if [ "$reply" == "foo_${i}" ]; + then + atf_fail "Unexpected echo success" + fi + + done +} + +prioritise_cleanup() +{ + altq_cleanup +} + atf_init_test_cases() { atf_add_test_case "hfsc" atf_add_test_case "match" atf_add_test_case "cbq_vlan" + atf_add_test_case "prioritise" } - From owner-dev-commits-src-main@freebsd.org Thu Aug 26 09:24:20 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B6137665E5E; Thu, 26 Aug 2021 09:24:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GwHVD4fzkz3pZt; Thu, 26 Aug 2021 09:24:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 870E95830; Thu, 26 Aug 2021 09:24:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17Q9OK1g064625; Thu, 26 Aug 2021 09:24:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17Q9OKq2064624; Thu, 26 Aug 2021 09:24:20 GMT (envelope-from git) Date: Thu, 26 Aug 2021 09:24:20 GMT Message-Id: <202108260924.17Q9OKq2064624@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 062463698eea - main - pf tests: Test ALTQ on top of if_bridge MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 062463698eeafc7f75ce22541a244238f37ef2e2 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 09:24:20 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=062463698eeafc7f75ce22541a244238f37ef2e2 commit 062463698eeafc7f75ce22541a244238f37ef2e2 Author: Kristof Provost AuthorDate: 2021-08-25 09:08:38 +0000 Commit: Kristof Provost CommitDate: 2021-08-26 09:23:45 +0000 pf tests: Test ALTQ on top of if_bridge Reviewed by: donner MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D31676 --- tests/sys/netpfil/pf/altq.sh | 49 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/tests/sys/netpfil/pf/altq.sh b/tests/sys/netpfil/pf/altq.sh index ebb28f34c22e..2b5b1828595f 100644 --- a/tests/sys/netpfil/pf/altq.sh +++ b/tests/sys/netpfil/pf/altq.sh @@ -145,6 +145,54 @@ cbq_vlan_cleanup() altq_cleanup } +atf_test_case "codel_bridge" "cleanup" +codel_bridge_head() +{ + atf_set descr 'codel over if_bridge test' + atf_set require.user root +} + +codel_bridge_body() +{ + altq_init + is_altq_supported codel + + epair=$(vnet_mkepair) + ifconfig ${epair}a 192.0.2.1/24 up + + vnet_mkjail altq_codel_bridge ${epair}b + + bridge=$(jexec altq_codel_bridge ifconfig bridge create) + jexec altq_codel_bridge ifconfig ${bridge} addm ${epair}b + jexec altq_codel_bridge ifconfig ${epair}b up + jexec altq_codel_bridge ifconfig ${bridge} 192.0.2.2/24 up + + # Sanity check + atf_check -s exit:0 -o ignore ping -i .1 -c 3 -s 1200 192.0.2.2 + + jexec altq_codel_bridge pfctl -e + pft_set_rules altq_codel_bridge \ + "altq on ${bridge} bandwidth 1000b codelq queue { slow }" \ + "match queue slow" \ + "pass" + + # "Saturate the link" + ping -i .1 -c 5 -s 1200 192.0.2.2 + + # We should now be hitting the limits and get these packet dropped. + rcv=$(ping -i .1 -c 5 -s 1200 192.0.2.2 | tr "," "\n" | awk '/packets received/ { print $1; }') + echo "Received $rcv packets" + if [ ${rcv} -gt 1 ] + then + atf_fail "Received ${rcv} packets in a saturated link" + fi +} + +codel_bridge_cleanup() +{ + altq_cleanup +} + atf_test_case "prioritise" "cleanup" prioritise_head() { @@ -242,5 +290,6 @@ atf_init_test_cases() atf_add_test_case "hfsc" atf_add_test_case "match" atf_add_test_case "cbq_vlan" + atf_add_test_case "codel_bridge" atf_add_test_case "prioritise" } From owner-dev-commits-src-main@freebsd.org Thu Aug 26 10:05:03 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 67CDD6668B1; Thu, 26 Aug 2021 10:05:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GwJPC29Ksz4XRX; Thu, 26 Aug 2021 10:05:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 328E06277; Thu, 26 Aug 2021 10:05:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17QA53rF018815; Thu, 26 Aug 2021 10:05:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QA53dv018814; Thu, 26 Aug 2021 10:05:03 GMT (envelope-from git) Date: Thu, 26 Aug 2021 10:05:03 GMT Message-Id: <202108261005.17QA53dv018814@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wojciech Macek Subject: git: 9da8235cc843 - main - ichwd: add Lewisburg Super SKUs, Cannon and Comet Lake support MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wma X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9da8235cc843364bd2df7a4d6fcd8c1be7ca67c0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 10:05:03 -0000 The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=9da8235cc843364bd2df7a4d6fcd8c1be7ca67c0 commit 9da8235cc843364bd2df7a4d6fcd8c1be7ca67c0 Author: PaweÅ‚ Anikiel AuthorDate: 2021-07-30 08:57:28 +0000 Commit: Wojciech Macek CommitDate: 2021-08-26 10:04:28 +0000 ichwd: add Lewisburg Super SKUs, Cannon and Comet Lake support Cannon and Comet Lake PCHs have their PMC hidden, so when reading the ACPI Base Address fails, we assume a default value. Obtained from: Semihalf Sponsored by: Stormshield --- sys/dev/ichwd/ichwd.c | 27 ++++++++++++++++++++------- sys/dev/ichwd/ichwd.h | 14 ++++++++++++++ 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/sys/dev/ichwd/ichwd.c b/sys/dev/ichwd/ichwd.c index 587f99f9e7ee..5aab4af0a1f7 100644 --- a/sys/dev/ichwd/ichwd.c +++ b/sys/dev/ichwd/ichwd.c @@ -296,6 +296,9 @@ static struct ichwd_device ichwd_devices[] = { static struct ichwd_device ichwd_smb_devices[] = { { DEVICEID_LEWISBURG_SMB, "Lewisburg watchdog timer", 10, 4 }, + { DEVICEID_LEWISBURG_SMB_SSKU, "Lewisburg watchdog timer", 10, 4 }, + { DEVICEID_CANNON_SMB, "Cannon Lake watchdog timer", 10, 4, PMC_HIDDEN}, + { DEVICEID_COMET_SMB, "Comet Lake watchdog timer", 10, 4, PMC_HIDDEN}, { DEVICEID_SRPTLP_SMB, "Sunrise Point-LP watchdog timer", 10, 4 }, { DEVICEID_C3000, "Intel Atom C3000 watchdog timer", 10, 4 }, { 0, NULL, 0, 0 }, @@ -788,13 +791,23 @@ ichwd_smb_attach(device_t dev) isab = device_get_parent(device_get_parent(dev)); pmdev = pci_find_dbsf(pci_get_domain(isab), pci_get_bus(isab), 31, 2); if (pmdev == NULL) { - device_printf(dev, "unable to find Power Management device\n"); - return (ENXIO); - } - acpi_base = pci_read_config(pmdev, ICH_PMBASE, 4) & 0xffffff00; - if (acpi_base == 0) { - device_printf(dev, "ACPI base address is not set\n"); - return (ENXIO); + if (id_p->quirks & PMC_HIDDEN) { + /* + * Since the PMC is hidden, we take the default value for the + * given device, which happens to be the same for the ones we + * support. + */ + acpi_base = ACPI_DEFAULT_CANNON; + } else { + device_printf(dev, "unable to find Power Management device\n"); + return (ENXIO); + } + } else { + acpi_base = pci_read_config(pmdev, ICH_PMBASE, 4) & 0xffffff00; + if (acpi_base == 0) { + device_printf(dev, "ACPI base address is not set\n"); + return (ENXIO); + } } /* Allocate SMI control I/O register space. */ diff --git a/sys/dev/ichwd/ichwd.h b/sys/dev/ichwd/ichwd.h index f78485249871..4a15d5201a4b 100644 --- a/sys/dev/ichwd/ichwd.h +++ b/sys/dev/ichwd/ichwd.h @@ -38,6 +38,7 @@ struct ichwd_device { char *desc; unsigned int ich_version; unsigned int tco_version; + uint32_t quirks; }; struct ichwd_softc { @@ -277,6 +278,9 @@ struct ichwd_softc { #define DEVICEID_WCPT_LP7 0x9cc7 #define DEVICEID_WCPT_LP9 0x9cc9 #define DEVICEID_LEWISBURG_SMB 0xa1a3 +#define DEVICEID_LEWISBURG_SMB_SSKU 0xa223 +#define DEVICEID_CANNON_SMB 0xa323 +#define DEVICEID_COMET_SMB 0x06a3 #define DEVICEID_SRPTLP_SMB 0x9d23 /* ICH LPC Interface Bridge Registers (ICH5 and older) */ @@ -386,6 +390,9 @@ struct ichwd_softc { #define TCO_INTRD_SEL_INTR 0x0001 #define TCO_INTRD_SEL_SMI 0x0002 +/* default ACPI Base values */ +#define ACPI_DEFAULT_CANNON 0x1800 + /* * Masks for the TCO timer value field in TCO_RLD. * If the datasheets are to be believed, the minimum value actually varies @@ -408,4 +415,11 @@ struct ichwd_softc { */ #define ICHWD_TCO_V3_TICK 1000000000 +/* + * Quirks + */ + +/* On Cannon Lake and Commet Lake PHCs, the PMC is hidden */ +#define PMC_HIDDEN (1 << 0) + #endif From owner-dev-commits-src-main@freebsd.org Thu Aug 26 10:56:33 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 51D7F66749E; Thu, 26 Aug 2021 10:56:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GwKXd1bHfz4mdY; Thu, 26 Aug 2021 10:56:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 10D4E6D8F; Thu, 26 Aug 2021 10:56:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17QAuWck085362; Thu, 26 Aug 2021 10:56:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QAuWPS085361; Thu, 26 Aug 2021 10:56:32 GMT (envelope-from git) Date: Thu, 26 Aug 2021 10:56:32 GMT Message-Id: <202108261056.17QAuWPS085361@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Andrey V. Elsukov" Subject: git: da3a09d8941d - main - ipfw_nat64: fix direct output mode MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ae X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: da3a09d8941dc29f20447e263b3a6d60370c6203 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 10:56:33 -0000 The branch main has been updated by ae: URL: https://cgit.FreeBSD.org/src/commit/?id=da3a09d8941dc29f20447e263b3a6d60370c6203 commit da3a09d8941dc29f20447e263b3a6d60370c6203 Author: Andrey V. Elsukov AuthorDate: 2021-08-26 10:48:23 +0000 Commit: Andrey V. Elsukov CommitDate: 2021-08-26 10:48:23 +0000 ipfw_nat64: fix direct output mode In nat64_find_route[46] handle NHF_GATEWAY flag and use destination address from next hop to do link layer address lookup. PR: 255928 Reviewed by: melifaro Obtained from: Yandex LLC MFC after: 1 week Sponsored by: Yandex LLC Differential Revision: https://reviews.freebsd.org/D31680 --- sys/netpfil/ipfw/nat64/nat64_translate.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/sys/netpfil/ipfw/nat64/nat64_translate.c b/sys/netpfil/ipfw/nat64/nat64_translate.c index 29666a7d3a9a..aa6f47656d9d 100644 --- a/sys/netpfil/ipfw/nat64/nat64_translate.c +++ b/sys/netpfil/ipfw/nat64/nat64_translate.c @@ -622,27 +622,22 @@ static struct nhop_object * nat64_find_route6(struct sockaddr_in6 *dst, struct mbuf *m) { struct nhop_object *nh; + NET_EPOCH_ASSERT(); - nh = fib6_lookup(M_GETFIB(m), &dst->sin6_addr, 0, 0, 0); + nh = fib6_lookup(M_GETFIB(m), &dst->sin6_addr, 0, NHR_NONE, 0); if (nh == NULL) - return NULL; + return (NULL); if (nh->nh_flags & (NHF_BLACKHOLE | NHF_REJECT)) - return NULL; - /* - * XXX: we need to use destination address with embedded scope - * zone id, because LLTABLE uses such form of addresses for lookup. - */ + return (NULL); + dst->sin6_family = AF_INET6; dst->sin6_len = sizeof(*dst); - dst->sin6_addr = ifatoia6(nh->nh_ifa)->ia_addr.sin6_addr; - if (IN6_IS_SCOPE_LINKLOCAL(&dst->sin6_addr)) - dst->sin6_addr.s6_addr16[1] = - htons(nh->nh_ifp->if_index & 0xffff); + if (nh->nh_flags & NHF_GATEWAY) + dst->sin6_addr = nh->gw6_sa.sin6_addr; dst->sin6_port = 0; dst->sin6_scope_id = 0; dst->sin6_flowinfo = 0; - - return nh; + return (nh); } #define NAT64_ICMP6_PLEN 64 @@ -776,17 +771,18 @@ nat64_find_route4(struct sockaddr_in *dst, struct mbuf *m) struct nhop_object *nh; NET_EPOCH_ASSERT(); - nh = fib4_lookup(M_GETFIB(m), dst->sin_addr, 0, 0, 0); + nh = fib4_lookup(M_GETFIB(m), dst->sin_addr, 0, NHR_NONE, 0); if (nh == NULL) - return NULL; + return (NULL); if (nh->nh_flags & (NHF_BLACKHOLE | NHF_BROADCAST | NHF_REJECT)) - return NULL; + return (NULL); dst->sin_family = AF_INET; dst->sin_len = sizeof(*dst); - dst->sin_addr = IA_SIN(nh->nh_ifa)->sin_addr; + if (nh->nh_flags & NHF_GATEWAY) + dst->sin_addr = nh->gw4_sa.sin_addr; dst->sin_port = 0; - return nh; + return (nh); } #define NAT64_ICMP_PLEN 64 From owner-dev-commits-src-main@freebsd.org Thu Aug 26 11:38:39 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E6E75667BD9; Thu, 26 Aug 2021 11:38:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GwLTC5yC6z3Dfh; Thu, 26 Aug 2021 11:38:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B485D7346; Thu, 26 Aug 2021 11:38:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17QBcd2I039941; Thu, 26 Aug 2021 11:38:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QBcdXr039940; Thu, 26 Aug 2021 11:38:39 GMT (envelope-from git) Date: Thu, 26 Aug 2021 11:38:39 GMT Message-Id: <202108261138.17QBcdXr039940@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 7b2561b46be6 - main - vfs: stop open-coding vfs_getvfs in kern_unmount MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7b2561b46be609deedeaacb7ccb35b5bc70d77ad Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 11:38:40 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=7b2561b46be609deedeaacb7ccb35b5bc70d77ad commit 7b2561b46be609deedeaacb7ccb35b5bc70d77ad Author: Mateusz Guzik AuthorDate: 2021-08-26 08:29:47 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-26 11:38:31 +0000 vfs: stop open-coding vfs_getvfs in kern_unmount Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/kern/vfs_mount.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 6804f6eb68bf..2d955fc4889f 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -1589,7 +1589,8 @@ kern_unmount(struct thread *td, const char *path, int flags) struct nameidata nd; struct mount *mp; char *pathbuf; - int error, id0, id1; + fsid_t fsid; + int error; AUDIT_ARG_VALUE(flags); if (jailed(td->td_ucred) || usermount == 0) { @@ -1607,20 +1608,12 @@ kern_unmount(struct thread *td, const char *path, int flags) if (flags & MNT_BYFSID) { AUDIT_ARG_TEXT(pathbuf); /* Decode the filesystem ID. */ - if (sscanf(pathbuf, "FSID:%d:%d", &id0, &id1) != 2) { + if (sscanf(pathbuf, "FSID:%d:%d", &fsid.val[0], &fsid.val[1]) != 2) { free(pathbuf, M_TEMP); return (EINVAL); } - mtx_lock(&mountlist_mtx); - TAILQ_FOREACH_REVERSE(mp, &mountlist, mntlist, mnt_list) { - if (mp->mnt_stat.f_fsid.val[0] == id0 && - mp->mnt_stat.f_fsid.val[1] == id1) { - vfs_ref(mp); - break; - } - } - mtx_unlock(&mountlist_mtx); + mp = vfs_getvfs(&fsid); } else { /* * Try to find global path for path argument. From owner-dev-commits-src-main@freebsd.org Thu Aug 26 12:02:50 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9E21D668D25; Thu, 26 Aug 2021 12:02:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GwM1646Pkz3MZJ; Thu, 26 Aug 2021 12:02:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6AFFA7C16; Thu, 26 Aug 2021 12:02:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17QC2oEp080407; Thu, 26 Aug 2021 12:02:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QC2oHH080406; Thu, 26 Aug 2021 12:02:50 GMT (envelope-from git) Date: Thu, 26 Aug 2021 12:02:50 GMT Message-Id: <202108261202.17QC2oHH080406@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 0d28d014c855 - main - vfs: refactor kern_unmount MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0d28d014c8552520879d3c4f75b3e89dd116eaa5 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 12:02:50 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=0d28d014c8552520879d3c4f75b3e89dd116eaa5 commit 0d28d014c8552520879d3c4f75b3e89dd116eaa5 Author: Mateusz Guzik AuthorDate: 2021-08-26 11:49:41 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-26 11:58:28 +0000 vfs: refactor kern_unmount Split unmounting by path and id in preparation for other changes. Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/kern/vfs_mount.c | 52 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 2d955fc4889f..40581d9e6e79 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -1588,7 +1588,7 @@ kern_unmount(struct thread *td, const char *path, int flags) { struct nameidata nd; struct mount *mp; - char *pathbuf; + char *fsidbuf, *pathbuf; fsid_t fsid; int error; @@ -1599,22 +1599,34 @@ kern_unmount(struct thread *td, const char *path, int flags) return (error); } - pathbuf = malloc(MNAMELEN, M_TEMP, M_WAITOK); - error = copyinstr(path, pathbuf, MNAMELEN, NULL); - if (error) { - free(pathbuf, M_TEMP); - return (error); - } if (flags & MNT_BYFSID) { - AUDIT_ARG_TEXT(pathbuf); + fsidbuf = malloc(MNAMELEN, M_TEMP, M_WAITOK); + error = copyinstr(path, fsidbuf, MNAMELEN, NULL); + if (error) { + free(fsidbuf, M_TEMP); + return (error); + } + + AUDIT_ARG_TEXT(fsidbuf); /* Decode the filesystem ID. */ - if (sscanf(pathbuf, "FSID:%d:%d", &fsid.val[0], &fsid.val[1]) != 2) { - free(pathbuf, M_TEMP); + if (sscanf(fsidbuf, "FSID:%d:%d", &fsid.val[0], &fsid.val[1]) != 2) { + free(fsidbuf, M_TEMP); return (EINVAL); } mp = vfs_getvfs(&fsid); + free(fsidbuf, M_TEMP); + if (mp == NULL) { + return (ENOENT); + } } else { + pathbuf = malloc(MNAMELEN, M_TEMP, M_WAITOK); + error = copyinstr(path, pathbuf, MNAMELEN, NULL); + if (error) { + free(pathbuf, M_TEMP); + return (error); + } + /* * Try to find global path for path argument. */ @@ -1635,16 +1647,16 @@ kern_unmount(struct thread *td, const char *path, int flags) } } mtx_unlock(&mountlist_mtx); - } - free(pathbuf, M_TEMP); - if (mp == NULL) { - /* - * Previously we returned ENOENT for a nonexistent path and - * EINVAL for a non-mountpoint. We cannot tell these apart - * now, so in the !MNT_BYFSID case return the more likely - * EINVAL for compatibility. - */ - return ((flags & MNT_BYFSID) ? ENOENT : EINVAL); + free(pathbuf, M_TEMP); + if (mp == NULL) { + /* + * Previously we returned ENOENT for a nonexistent path and + * EINVAL for a non-mountpoint. We cannot tell these apart + * now, so in the !MNT_BYFSID case return the more likely + * EINVAL for compatibility. + */ + return (EINVAL); + } } /* From owner-dev-commits-src-main@freebsd.org Thu Aug 26 15:16:31 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1E31666BB0B; Thu, 26 Aug 2021 15:16:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GwRJb0C1wz3Lfx; Thu, 26 Aug 2021 15:16:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E35E61214E; Thu, 26 Aug 2021 15:16:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17QFGUxZ035445; Thu, 26 Aug 2021 15:16:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QFGULJ035444; Thu, 26 Aug 2021 15:16:30 GMT (envelope-from git) Date: Thu, 26 Aug 2021 15:16:30 GMT Message-Id: <202108261516.17QFGULJ035444@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: 58d868c88d21 - main - sound(4): Fix some common typos in comments MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 58d868c88d21b46d3d6d40a2920e7ba8996723b8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 15:16:31 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=58d868c88d21b46d3d6d40a2920e7ba8996723b8 commit 58d868c88d21b46d3d6d40a2920e7ba8996723b8 Author: Gordon Bergling AuthorDate: 2021-08-26 15:15:55 +0000 Commit: Gordon Bergling CommitDate: 2021-08-26 15:15:55 +0000 sound(4): Fix some common typos in comments - s/doens't/doesn't/ - s/apropriate/appropriate/ - s/intepretation/interpretation/ MFC after: 5 days --- sys/dev/sound/midi/sequencer.c | 4 ++-- sys/dev/sound/pcm/feeder_chain.c | 2 +- sys/dev/sound/pcm/feeder_matrix.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/dev/sound/midi/sequencer.c b/sys/dev/sound/midi/sequencer.c index ed8ba6dde699..6c80b3ec261c 100644 --- a/sys/dev/sound/midi/sequencer.c +++ b/sys/dev/sound/midi/sequencer.c @@ -894,7 +894,7 @@ mseq_read(struct cdev *i_dev, struct uio *uio, int ioflag) /* * I think the semantics are to return as soon * as possible. - * Second thought, it doens't seem like midimoutain + * Second thought, it doesn't seem like midimoutain * expects that at all. * TODO: Look up in some sort of spec */ @@ -1441,7 +1441,7 @@ mseq_poll(struct cdev *i_dev, int events, struct thread *td) ret = 0; - /* Look up the apropriate queue and select it. */ + /* Look up the appropriate queue and select it. */ if ((events & (POLLOUT | POLLWRNORM)) != 0) { /* Start playing. */ scp->playing = 1; diff --git a/sys/dev/sound/pcm/feeder_chain.c b/sys/dev/sound/pcm/feeder_chain.c index 73922ab55396..b2d48abd71d1 100644 --- a/sys/dev/sound/pcm/feeder_chain.c +++ b/sys/dev/sound/pcm/feeder_chain.c @@ -652,7 +652,7 @@ feeder_chain(struct pcm_channel *c) } /* - * The 'hardware' possibly have different intepretation of channel + * The 'hardware' possibly have different interpretation of channel * matrixing, so get it first ..... */ hwmatrix = CHANNEL_GETMATRIX(c->methods, c->devinfo, hwfmt); diff --git a/sys/dev/sound/pcm/feeder_matrix.c b/sys/dev/sound/pcm/feeder_matrix.c index 7d965860f886..c6a65113574a 100644 --- a/sys/dev/sound/pcm/feeder_matrix.c +++ b/sys/dev/sound/pcm/feeder_matrix.c @@ -699,7 +699,7 @@ feeder_matrix_compare(struct pcmchan_matrix *m_in, struct pcmchan_matrix *m_out) } /* - * XXX 4front intepretation of "surround" is ambigous and sort of + * XXX 4front interpretation of "surround" is ambigous and sort of * conflicting with "rear"/"back". Map it to "side". Well.. * who cares? */ From owner-dev-commits-src-main@freebsd.org Thu Aug 26 16:09:48 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7DB5266C61A; Thu, 26 Aug 2021 16:09:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GwSV42tfBz3tv3; Thu, 26 Aug 2021 16:09:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4BCA312F73; Thu, 26 Aug 2021 16:09:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17QG9mgu005367; Thu, 26 Aug 2021 16:09:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QG9mZ6005366; Thu, 26 Aug 2021 16:09:48 GMT (envelope-from git) Date: Thu, 26 Aug 2021 16:09:48 GMT Message-Id: <202108261609.17QG9mZ6005366@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 7aa47cace149 - main - amd64: remove lfence after swapgs on syscall entry MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7aa47cace14948a7b8277a4b24a0ca9e0308990a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 16:09:48 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=7aa47cace14948a7b8277a4b24a0ca9e0308990a commit 7aa47cace14948a7b8277a4b24a0ca9e0308990a Author: Konstantin Belousov AuthorDate: 2021-08-25 19:28:57 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-26 16:09:21 +0000 amd64: remove lfence after swapgs on syscall entry According to the description of SBSS issue at https://software.intel.com/content/www/us/en/develop/articles/software-security-guidance/technical-documentation/speculative-behavior-swapgs-and-segment-registers.html lfence after swapgs is needed only for the case when swapgs could be speculatively executed. Since syscall entry, unlike exception and interrupt entries, executes swapgs unconditionally, there is no opportunity for speculation. Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D31682 --- sys/amd64/amd64/exception.S | 2 -- 1 file changed, 2 deletions(-) diff --git a/sys/amd64/amd64/exception.S b/sys/amd64/amd64/exception.S index d1e49faa40e7..6471f9a3041c 100644 --- a/sys/amd64/amd64/exception.S +++ b/sys/amd64/amd64/exception.S @@ -524,7 +524,6 @@ prot_addrf: SUPERALIGN_TEXT IDTVEC(fast_syscall_pti) swapgs - lfence cmpq $~0,PCPU(UCR3) je fast_syscall_common movq %rax,PCPU(SCRATCH_RAX) @@ -535,7 +534,6 @@ IDTVEC(fast_syscall_pti) SUPERALIGN_TEXT IDTVEC(fast_syscall) swapgs - lfence fast_syscall_common: movq %rsp,PCPU(SCRATCH_RSP) movq PCPU(RSP0),%rsp From owner-dev-commits-src-main@freebsd.org Thu Aug 26 17:32:22 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 32E8C66D8C2; Thu, 26 Aug 2021 17:32:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GwVKL0vYLz4nKn; Thu, 26 Aug 2021 17:32:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 07ECC14321; Thu, 26 Aug 2021 17:32:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17QHWLsd023798; Thu, 26 Aug 2021 17:32:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QHWLXT023797; Thu, 26 Aug 2021 17:32:21 GMT (envelope-from git) Date: Thu, 26 Aug 2021 17:32:21 GMT Message-Id: <202108261732.17QHWLXT023797@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michael Tuexen Subject: git: 26d79d40a74f - main - Hyper-V: hn: Enter network epoch when required MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 26d79d40a74fc804c76acd88a1f8f10f9827a2b3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 17:32:22 -0000 The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=26d79d40a74fc804c76acd88a1f8f10f9827a2b3 commit 26d79d40a74fc804c76acd88a1f8f10f9827a2b3 Author: Michael Tuexen AuthorDate: 2021-08-26 17:27:04 +0000 Commit: Michael Tuexen CommitDate: 2021-08-26 17:32:00 +0000 Hyper-V: hn: Enter network epoch when required PR: 254695 --- sys/dev/hyperv/netvsc/if_hn.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys/dev/hyperv/netvsc/if_hn.c b/sys/dev/hyperv/netvsc/if_hn.c index cd0b5a5fa8b9..0ec398bed670 100644 --- a/sys/dev/hyperv/netvsc/if_hn.c +++ b/sys/dev/hyperv/netvsc/if_hn.c @@ -83,6 +83,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -2883,7 +2884,11 @@ static void hn_chan_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr) { #if defined(INET) || defined(INET6) + struct epoch_tracker et; + + NET_EPOCH_ENTER(et); tcp_lro_flush_all(&rxr->hn_lro); + NET_EPOCH_EXIT(et); #endif /* @@ -7459,6 +7464,7 @@ static void hn_nvs_handle_rxbuf(struct hn_rx_ring *rxr, struct vmbus_channel *chan, const struct vmbus_chanpkt_hdr *pkthdr) { + struct epoch_tracker et; const struct vmbus_chanpkt_rxbuf *pkt; const struct hn_nvs_hdr *nvs_hdr; int count, i, hlen; @@ -7496,6 +7502,7 @@ hn_nvs_handle_rxbuf(struct hn_rx_ring *rxr, struct vmbus_channel *chan, return; } + NET_EPOCH_ENTER(et); /* Each range represents 1 RNDIS pkt that contains 1 Ethernet frame */ for (i = 0; i < count; ++i) { int ofs, len; @@ -7511,6 +7518,7 @@ hn_nvs_handle_rxbuf(struct hn_rx_ring *rxr, struct vmbus_channel *chan, rxr->rsc.is_last = (i == (count - 1)); hn_rndis_rxpkt(rxr, rxr->hn_rxbuf + ofs, len); } + NET_EPOCH_EXIT(et); /* * Ack the consumed RXBUF associated w/ this channel packet, From owner-dev-commits-src-main@freebsd.org Thu Aug 26 17:36:58 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B516D66DC83; Thu, 26 Aug 2021 17:36:58 +0000 (UTC) (envelope-from tuexen@freebsd.org) Received: from drew.franken.de (mail-n.franken.de [193.175.24.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.franken.de", Issuer "Sectigo RSA Domain Validation Secure Server CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GwVQf2gvpz4qCX; Thu, 26 Aug 2021 17:36:58 +0000 (UTC) (envelope-from tuexen@freebsd.org) Received: from smtpclient.apple (ip1f100e9c.dynamic.kabel-deutschland.de [31.16.14.156]) (Authenticated sender: macmic) by mail-n.franken.de (Postfix) with ESMTPSA id F34BA721E282D; Thu, 26 Aug 2021 19:36:49 +0200 (CEST) From: tuexen@freebsd.org Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: Re: git: 26d79d40a74f - main - Hyper-V: hn: Enter network epoch when required Date: Thu, 26 Aug 2021 19:36:49 +0200 References: <202108261732.17QHWLXT023797@gitrepo.freebsd.org> To: "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" In-Reply-To: <202108261732.17QHWLXT023797@gitrepo.freebsd.org> Message-Id: <62898771-43CF-42E3-81DF-E3467F5BD7C4@freebsd.org> X-Mailer: Apple Mail (2.3654.120.0.1.13) X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=disabled version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on mail-n.franken.de X-Rspamd-Queue-Id: 4GwVQf2gvpz4qCX X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [0.00 / 15.00]; local_wl_from(0.00)[freebsd.org]; ASN(0.00)[asn:680, ipnet:193.174.0.0/15, country:DE] X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 17:36:58 -0000 > On 26. Aug 2021, at 19:32, Michael Tuexen wrote: >=20 > The branch main has been updated by tuexen: >=20 > URL: = https://cgit.FreeBSD.org/src/commit/?id=3D26d79d40a74fc804c76acd88a1f8f10f= 9827a2b3 >=20 > commit 26d79d40a74fc804c76acd88a1f8f10f9827a2b3 > Author: Michael Tuexen > AuthorDate: 2021-08-26 17:27:04 +0000 > Commit: Michael Tuexen > CommitDate: 2021-08-26 17:32:00 +0000 >=20 > Hyper-V: hn: Enter network epoch when required >=20 > PR: 254695 Missing: Reviewed by: hselasky, gallatin Tested by: gbe MFC after: 1 week Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D31679 > --- > sys/dev/hyperv/netvsc/if_hn.c | 8 ++++++++ > 1 file changed, 8 insertions(+) >=20 > diff --git a/sys/dev/hyperv/netvsc/if_hn.c = b/sys/dev/hyperv/netvsc/if_hn.c > index cd0b5a5fa8b9..0ec398bed670 100644 > --- a/sys/dev/hyperv/netvsc/if_hn.c > +++ b/sys/dev/hyperv/netvsc/if_hn.c > @@ -83,6 +83,7 @@ __FBSDID("$FreeBSD$"); > #include > #include > #include > +#include >=20 > #include > #include > @@ -2883,7 +2884,11 @@ static void > hn_chan_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr) > { > #if defined(INET) || defined(INET6) > + struct epoch_tracker et; > + > + NET_EPOCH_ENTER(et); > tcp_lro_flush_all(&rxr->hn_lro); > + NET_EPOCH_EXIT(et); > #endif >=20 > /* > @@ -7459,6 +7464,7 @@ static void > hn_nvs_handle_rxbuf(struct hn_rx_ring *rxr, struct vmbus_channel = *chan, > const struct vmbus_chanpkt_hdr *pkthdr) > { > + struct epoch_tracker et; > const struct vmbus_chanpkt_rxbuf *pkt; > const struct hn_nvs_hdr *nvs_hdr; > int count, i, hlen; > @@ -7496,6 +7502,7 @@ hn_nvs_handle_rxbuf(struct hn_rx_ring *rxr, = struct vmbus_channel *chan, > return; > } >=20 > + NET_EPOCH_ENTER(et); > /* Each range represents 1 RNDIS pkt that contains 1 Ethernet = frame */ > for (i =3D 0; i < count; ++i) { > int ofs, len; > @@ -7511,6 +7518,7 @@ hn_nvs_handle_rxbuf(struct hn_rx_ring *rxr, = struct vmbus_channel *chan, > rxr->rsc.is_last =3D (i =3D=3D (count - 1)); > hn_rndis_rxpkt(rxr, rxr->hn_rxbuf + ofs, len); > } > + NET_EPOCH_EXIT(et); >=20 > /* > * Ack the consumed RXBUF associated w/ this channel packet, From owner-dev-commits-src-main@freebsd.org Thu Aug 26 18:15:12 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3311566E8E1; Thu, 26 Aug 2021 18:15:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GwWGm0m5Jz3Hdp; Thu, 26 Aug 2021 18:15:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 02B8314B4C; Thu, 26 Aug 2021 18:15:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17QIFBgv078442; Thu, 26 Aug 2021 18:15:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QIFBTf078441; Thu, 26 Aug 2021 18:15:11 GMT (envelope-from git) Date: Thu, 26 Aug 2021 18:15:11 GMT Message-Id: <202108261815.17QIFBTf078441@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 620cf65c2bc4 - main - netinet: prevent NULL pointer dereference in in_aifaddr_ioctl() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 620cf65c2bc4035a07e1152da419a4e60d36ff9b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 18:15:12 -0000 The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=620cf65c2bc4035a07e1152da419a4e60d36ff9b commit 620cf65c2bc4035a07e1152da419a4e60d36ff9b Author: Artem Khramov AuthorDate: 2021-08-24 14:26:35 +0000 Commit: Warner Losh CommitDate: 2021-08-26 18:08:03 +0000 netinet: prevent NULL pointer dereference in in_aifaddr_ioctl() It appears that maliciously crafted ifaliasreq can lead to NULL pointer dereference in in_aifaddr_ioctl(). In order to replicate that, one needs to 1. Ensure that carp(4) is not loaded 2. Issue SIOCAIFADDR call setting ifra_vhid field of the request to a negative value. A repro code would look like this. int main() { struct ifaliasreq req; struct sockaddr_in sin, mask; int fd, error; bzero(&sin, sizeof(struct sockaddr_in)); bzero(&mask, sizeof(struct sockaddr_in)); sin.sin_len = sizeof(struct sockaddr_in); sin.sin_family = AF_INET; sin.sin_addr.s_addr = inet_addr("192.168.88.2"); mask.sin_len = sizeof(struct sockaddr_in); mask.sin_family = AF_INET; mask.sin_addr.s_addr = inet_addr("255.255.255.0"); fd = socket(AF_INET, SOCK_DGRAM, 0); if (fd < 0) return (-1); memset(&req, 0, sizeof(struct ifaliasreq)); strlcpy(req.ifra_name, "lo0", sizeof(req.ifra_name)); memcpy(&req.ifra_addr, &sin, sin.sin_len); memcpy(&req.ifra_mask, &mask, mask.sin_len); req.ifra_vhid = -1; return ioctl(fd, SIOCAIFADDR, (char *)&req); } To fix, discard both positive and negative vhid values in in_aifaddr_ioctl, if carp(4) is not loaded. This prevents NULL pointer dereference and kernel panic. Reviewed by: imp@ Pull Request: https://github.com/freebsd/freebsd-src/pull/530 --- sys/netinet/in.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/netinet/in.c b/sys/netinet/in.c index d1dd2b31b6ef..f9b46b414007 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -376,7 +376,7 @@ in_aifaddr_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp, struct thread *td) (dstaddr->sin_len != sizeof(struct sockaddr_in) || dstaddr->sin_addr.s_addr == INADDR_ANY)) return (EDESTADDRREQ); - if (vhid > 0 && carp_attach_p == NULL) + if (vhid != 0 && carp_attach_p == NULL) return (EPROTONOSUPPORT); /* From owner-dev-commits-src-main@freebsd.org Thu Aug 26 18:52:55 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 18F7266EC7B; Thu, 26 Aug 2021 18:52:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GwX6H0DBxz3hJN; Thu, 26 Aug 2021 18:52:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E4EB5154A5; Thu, 26 Aug 2021 18:52:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17QIqswP031010; Thu, 26 Aug 2021 18:52:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QIqsuh031009; Thu, 26 Aug 2021 18:52:54 GMT (envelope-from git) Date: Thu, 26 Aug 2021 18:52:54 GMT Message-Id: <202108261852.17QIqsuh031009@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: f1e2cc1c667a - main - vfs: drop dedicated sysinit for mountlist_mtx MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f1e2cc1c667a4fd5f3f6097a1e7a4d13bb4d887e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 18:52:55 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=f1e2cc1c667a4fd5f3f6097a1e7a4d13bb4d887e commit f1e2cc1c667a4fd5f3f6097a1e7a4d13bb4d887e Author: Mateusz Guzik AuthorDate: 2021-08-26 12:53:10 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-26 18:52:03 +0000 vfs: drop dedicated sysinit for mountlist_mtx Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/kern/vfs_mount.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 40581d9e6e79..73fd8321c9da 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -122,7 +122,6 @@ struct mntlist mountlist = TAILQ_HEAD_INITIALIZER(mountlist); /* For any iteration/modification of mountlist */ struct mtx_padalign __exclusive_cache_line mountlist_mtx; -MTX_SYSINIT(mountlist, &mountlist_mtx, "mountlist", MTX_DEF); EVENTHANDLER_LIST_DEFINE(vfs_mounted); EVENTHANDLER_LIST_DEFINE(vfs_unmounted); @@ -188,6 +187,7 @@ vfs_mount_init(void *dummy __unused) deferred_unmount_retry_delay_hz = hz; mount_zone = uma_zcreate("Mountpoints", sizeof(struct mount), NULL, NULL, mount_init, mount_fini, UMA_ALIGN_CACHE, UMA_ZONE_NOFREE); + mtx_init(&mountlist_mtx, "mountlist", NULL, MTX_DEF); } SYSINIT(vfs_mount, SI_SUB_VFS, SI_ORDER_ANY, vfs_mount_init, NULL); From owner-dev-commits-src-main@freebsd.org Thu Aug 26 18:53:46 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A27F066F2AF; Thu, 26 Aug 2021 18:53:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GwX7G1Vhtz3hx3; Thu, 26 Aug 2021 18:53:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 11A8815446; Thu, 26 Aug 2021 18:53:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17QIrjiQ031203; Thu, 26 Aug 2021 18:53:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QIrjEs031202; Thu, 26 Aug 2021 18:53:45 GMT (envelope-from git) Date: Thu, 26 Aug 2021 18:53:45 GMT Message-Id: <202108261853.17QIrjEs031202@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dimitry Andric Subject: git: f643997a1761 - main - Cleanup compiler warning flags in lib/libefivar/Makefile MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f643997a1761689ef9108d69b86d42881ea0ab1c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 18:53:46 -0000 The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=f643997a1761689ef9108d69b86d42881ea0ab1c commit f643997a1761689ef9108d69b86d42881ea0ab1c Author: Dimitry Andric AuthorDate: 2021-08-26 18:53:18 +0000 Commit: Dimitry Andric CommitDate: 2021-08-26 18:53:26 +0000 Cleanup compiler warning flags in lib/libefivar/Makefile There is no need to set -Wno-unused-parameter twice, and instead of appending to CFLAGS, append to CWARNFLAGS instead. While here, add -Wno-unused-but-set-variable for the sake of clang 13.0.0. MFC after: 3 days --- lib/libefivar/Makefile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/libefivar/Makefile b/lib/libefivar/Makefile index 3c6b17333407..c1503f4e5b62 100644 --- a/lib/libefivar/Makefile +++ b/lib/libefivar/Makefile @@ -43,8 +43,7 @@ MAN= efivar.3 CFLAGS+= -I${EFIBOOT}/include CFLAGS+= -I${.CURDIR} -I${EDK2INC} - -CFLAGS.efivar-dp-format.c=-Wno-unused-parameter +CFLAGS+= -fno-strict-aliasing MLINKS+=efivar.3 efi_set_variables_supported.3 \ efivar.3 efi_del_variable.3 \ @@ -65,4 +64,9 @@ WARNS?= 9 .include -CFLAGS+= -fno-strict-aliasing -Wno-cast-align -Wno-unused-parameter +CWARNFLAGS+= -Wno-cast-align +CWARNFLAGS+= -Wno-unused-parameter + +.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 130000 +CWARNFLAGS+= -Wno-unused-but-set-variable +.endif From owner-dev-commits-src-main@freebsd.org Thu Aug 26 20:10:07 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 21B5B67065F; Thu, 26 Aug 2021 20:10:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GwYqM0LPfz4YN5; Thu, 26 Aug 2021 20:10:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E3DD4162E9; Thu, 26 Aug 2021 20:10:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17QKA6XI028307; Thu, 26 Aug 2021 20:10:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QKA6b1028304; Thu, 26 Aug 2021 20:10:06 GMT (envelope-from git) Date: Thu, 26 Aug 2021 20:10:06 GMT Message-Id: <202108262010.17QKA6b1028304@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dimitry Andric Subject: git: d396c67f26b0 - main - googletest: Silence warnings about deprecated implicit copy constructors MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d396c67f26b079c2808002c07212d9df9818a11b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 20:10:07 -0000 The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=d396c67f26b079c2808002c07212d9df9818a11b commit d396c67f26b079c2808002c07212d9df9818a11b Author: Dimitry Andric AuthorDate: 2021-08-26 20:06:49 +0000 Commit: Dimitry Andric CommitDate: 2021-08-26 20:06:53 +0000 googletest: Silence warnings about deprecated implicit copy constructors Our copy of googletest is rather stale, and causes a number of -Werror warnings about implicit copy constructor definitions being deprecated, because several classes have user-declared copy assignment operators. Silence the warnings until we either upgrade or remove googletest. MFC after: 3 days --- lib/googletest/Makefile.inc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/googletest/Makefile.inc b/lib/googletest/Makefile.inc index 36f7228c079b..b77322df4ee2 100644 --- a/lib/googletest/Makefile.inc +++ b/lib/googletest/Makefile.inc @@ -10,3 +10,6 @@ CXXFLAGS+= ${GTESTS_FLAGS} # Silence warnings about usage of deprecated std::auto_ptr CXXWARNFLAGS+= -Wno-deprecated-declarations + +# Silence warnings about usage of deprecated implicit copy constructors +CXXWARNFLAGS+= -Wno-deprecated-copy From owner-dev-commits-src-main@freebsd.org Fri Aug 27 00:39:33 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8168D673F55; Fri, 27 Aug 2021 00:39:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GwgpF2C25z4YqV; Fri, 27 Aug 2021 00:39:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1819619B9C; Fri, 27 Aug 2021 00:39:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17R0dXQa084645; Fri, 27 Aug 2021 00:39:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17R0dWZj084644; Fri, 27 Aug 2021 00:39:32 GMT (envelope-from git) Date: Fri, 27 Aug 2021 00:39:32 GMT Message-Id: <202108270039.17R0dWZj084644@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alexander Motin Subject: git: 15cb3b5404bd - main - pcib(4): Write window registers after resource adjustment MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 15cb3b5404bd3181c0fbdc056f5a5299876f8f39 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 00:39:33 -0000 The branch main has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=15cb3b5404bd3181c0fbdc056f5a5299876f8f39 commit 15cb3b5404bd3181c0fbdc056f5a5299876f8f39 Author: Alexander Motin AuthorDate: 2021-08-27 00:21:56 +0000 Commit: Alexander Motin CommitDate: 2021-08-27 00:39:27 +0000 pcib(4): Write window registers after resource adjustment When adjusting resources we should write updated window base/limit into the registers. Without this newly added address range won't be routed through the bridge properly. Use MIN()/MAX() against current window base/limit to not shrink it on the other side if the window is shared by several resources. Align passed resource start/end to the set window granularity to keep it properly aligned. Currently this is mostly called by other bridges having the same window alignment, but it may be change one day. Reviewed by: jrtc27, jhb MFC after: 1 week Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D31693 --- sys/dev/pci/pci_pci.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sys/dev/pci/pci_pci.c b/sys/dev/pci/pci_pci.c index 83106eaa455b..33e277ed01ae 100644 --- a/sys/dev/pci/pci_pci.c +++ b/sys/dev/pci/pci_pci.c @@ -2345,6 +2345,7 @@ pcib_adjust_resource(device_t bus, device_t child, int type, struct resource *r, { struct pcib_softc *sc; struct pcib_window *w; + rman_res_t wmask; int error; sc = device_get_softc(bus); @@ -2375,9 +2376,18 @@ pcib_adjust_resource(device_t bus, device_t child, int type, struct resource *r, * then we need to expand the window. */ if (start < w->base || end > w->limit) { - error = pcib_expand_window(sc, w, type, start, end); + wmask = ((rman_res_t)1 << w->step) - 1; + error = pcib_expand_window(sc, w, type, + MIN(start & ~wmask, w->base), + MAX(end | wmask, w->limit)); if (error != 0) return (error); + if (bootverbose) + device_printf(sc->dev, + "grew %s window to %#jx-%#jx\n", + w->name, (uintmax_t)w->base, + (uintmax_t)w->limit); + pcib_write_windows(sc, w->mask); } } From owner-dev-commits-src-main@freebsd.org Fri Aug 27 01:01:07 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0ECCC674597; Fri, 27 Aug 2021 01:01:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GwhH66zd3z4g4L; Fri, 27 Aug 2021 01:01:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D856C1A304; Fri, 27 Aug 2021 01:01:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17R1163P019997; Fri, 27 Aug 2021 01:01:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17R1164o019996; Fri, 27 Aug 2021 01:01:06 GMT (envelope-from git) Date: Fri, 27 Aug 2021 01:01:06 GMT Message-Id: <202108270101.17R1164o019996@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Colin Percival Subject: git: c5af0ac1a732 - main - Add support for recording EC2 AMI Ids in SSM MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: cperciva X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c5af0ac1a732491aab789dda0da368ff48497871 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 01:01:07 -0000 The branch main has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=c5af0ac1a732491aab789dda0da368ff48497871 commit c5af0ac1a732491aab789dda0da368ff48497871 Author: Colin Percival AuthorDate: 2021-08-27 00:54:53 +0000 Commit: Colin Percival CommitDate: 2021-08-27 01:01:02 +0000 Add support for recording EC2 AMI Ids in SSM If SSMPREFIX is specified, AMI Ids will be recorded in the SSM Parameter Store under the name ${SSMPREFIX}/${ARCH}/${FLAVOUR}/${ROOTFS}/${REVISION}/${BRANCH} where ARCH is "amd64" or "arm64", FLAVOUR is "base" (but may have other options in the future), ROOTFS is "ufs" (but may have other options in the future), and REVISION and BRANCH have their normal meanings. FreeBSD will be using the public prefix "/aws/service/freebsd", resulting in SSM Parameter names which look like /aws/service/freebsd/amd64/base/ufs/14.0/CURRENT Relnotes: yes Sponsored by: https://patreon.com/cperciva MFC after: 2 weeks --- release/Makefile.ec2 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/release/Makefile.ec2 b/release/Makefile.ec2 index 171de4ee2fa0..5683cb6634b6 100644 --- a/release/Makefile.ec2 +++ b/release/Makefile.ec2 @@ -18,6 +18,9 @@ PUBLICSNAP= --publicsnap EC2SNSREL= ${REVISION}-${BRANCH} EC2SNSVERS= ${GITBRANCH}@${GITREV} .endif +.if defined(SSMPREFIX) && !empty(SSMPREFIX) +SSMOPTS= --ssm-name ${SSMPREFIX}/${TARGET_ARCH:S/aarch64/arm64/}/base/ufs/${REVISION}/${BRANCH} +.endif .if ${TARGET_ARCH} != "amd64" EC2ARCH= --${TARGET_ARCH:S/aarch64/arm64/} .endif @@ -62,7 +65,7 @@ ec2ami: cw-ec2 ${CW_EC2_PORTINSTALL} @false .endif /usr/local/bin/bsdec2-image-upload ${PUBLISH} ${PUBLICSNAP} \ - ${EC2ARCH} --sriov --ena \ + ${EC2ARCH} ${SSMOPTS} --sriov --ena \ ${.OBJDIR}/ec2.raw \ "${TYPE} ${REVISION}-${BRANCH}-${TARGET}${AMINAMESUFFIX}" \ "${TYPE}/${TARGET} ${GITBRANCH}@${GITREV}" \ From owner-dev-commits-src-main@freebsd.org Fri Aug 27 01:19:45 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 93155674EBF; Fri, 27 Aug 2021 01:19:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gwhhd3dQpz4kpd; Fri, 27 Aug 2021 01:19:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 654811A59C; Fri, 27 Aug 2021 01:19:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17R1JjxM038607; Fri, 27 Aug 2021 01:19:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17R1JjV3038606; Fri, 27 Aug 2021 01:19:45 GMT (envelope-from git) Date: Fri, 27 Aug 2021 01:19:45 GMT Message-Id: <202108270119.17R1JjV3038606@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: bb958dcf3d8a - main - nfsd: Add support for the NFSv4.2 Deallocate operation MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: bb958dcf3d8af3a033dacbf8133681c9b0c73b2f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 01:19:45 -0000 The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=bb958dcf3d8af3a033dacbf8133681c9b0c73b2f commit bb958dcf3d8af3a033dacbf8133681c9b0c73b2f Author: Rick Macklem AuthorDate: 2021-08-27 01:14:11 +0000 Commit: Rick Macklem CommitDate: 2021-08-27 01:14:11 +0000 nfsd: Add support for the NFSv4.2 Deallocate operation The recently added VOP_DEALLOCATE(9) VOP call allows implementation of the Deallocate NFSv4.2 operation. Since the Deallocate operation is a single succeed/fail operation, the call to VOP_DEALLOCATE(9) loops so long as progress is being made. It calls maybe_yield() between loop iterations to allow other processes to preempt it. Where RFC 7862 underspecifies behaviour, the code is written to be Linux NFSv4.2 server compatible. Reviewed by: khng Differential Revision: https://reviews.freebsd.org/D31624 --- sys/fs/nfs/nfs_var.h | 4 + sys/fs/nfsserver/nfs_nfsdport.c | 201 ++++++++++++++++++++++++++++++++++++++ sys/fs/nfsserver/nfs_nfsdserv.c | 105 ++++++++++++++++++++ sys/fs/nfsserver/nfs_nfsdsocket.c | 2 +- 4 files changed, 311 insertions(+), 1 deletion(-) diff --git a/sys/fs/nfs/nfs_var.h b/sys/fs/nfs/nfs_var.h index b4c21c6f7029..5ddae345f906 100644 --- a/sys/fs/nfs/nfs_var.h +++ b/sys/fs/nfs/nfs_var.h @@ -282,6 +282,8 @@ int nfsrvd_teststateid(struct nfsrv_descript *, int, vnode_t, struct nfsexstuff *); int nfsrvd_allocate(struct nfsrv_descript *, int, vnode_t, struct nfsexstuff *); +int nfsrvd_deallocate(struct nfsrv_descript *, int, + vnode_t, struct nfsexstuff *); int nfsrvd_copy_file_range(struct nfsrv_descript *, int, vnode_t, vnode_t, struct nfsexstuff *, struct nfsexstuff *); int nfsrvd_seek(struct nfsrv_descript *, int, @@ -752,6 +754,8 @@ int nfsrv_setacl(struct vnode *, NFSACL_T *, struct ucred *, NFSPROC_T *); int nfsvno_seek(struct nfsrv_descript *, struct vnode *, u_long, off_t *, int, bool *, struct ucred *, NFSPROC_T *); int nfsvno_allocate(struct vnode *, off_t, off_t, struct ucred *, NFSPROC_T *); +int nfsvno_deallocate(struct vnode *, off_t, off_t, struct ucred *, + NFSPROC_T *); int nfsvno_getxattr(struct vnode *, char *, uint32_t, struct ucred *, uint64_t, int, struct thread *, struct mbuf **, struct mbuf **, int *); int nfsvno_setxattr(struct vnode *, char *, int, struct mbuf *, char *, diff --git a/sys/fs/nfsserver/nfs_nfsdport.c b/sys/fs/nfsserver/nfs_nfsdport.c index efe9aac7a136..d93c547c5530 100644 --- a/sys/fs/nfsserver/nfs_nfsdport.c +++ b/sys/fs/nfsserver/nfs_nfsdport.c @@ -132,6 +132,8 @@ static int nfsrv_writedsrpc(fhandle_t *, off_t, int, struct ucred *, char *, int *); static int nfsrv_allocatedsrpc(fhandle_t *, off_t, off_t, struct ucred *, NFSPROC_T *, struct vnode *, struct nfsmount **, int, int *); +static int nfsrv_deallocatedsrpc(fhandle_t *, off_t, off_t, struct ucred *, + NFSPROC_T *, struct vnode *, struct nfsmount **, int, int *); static int nfsrv_setacldsrpc(fhandle_t *, struct ucred *, NFSPROC_T *, struct vnode *, struct nfsmount **, int, struct acl *, int *); static int nfsrv_setattrdsrpc(fhandle_t *, struct ucred *, NFSPROC_T *, @@ -4898,6 +4900,9 @@ tryagain: } else if (ioproc == NFSPROC_ALLOCATE) error = nfsrv_allocatedsrpc(fh, off, *offp, cred, p, vp, &nmp[0], mirrorcnt, &failpos); + else if (ioproc == NFSPROC_DEALLOCATE) + error = nfsrv_deallocatedsrpc(fh, off, *offp, cred, p, + vp, &nmp[0], mirrorcnt, &failpos); else { error = nfsrv_getattrdsrpc(&fh[mirrorcnt - 1], cred, p, vp, nmp[mirrorcnt - 1], nap); @@ -5679,6 +5684,166 @@ nfsrv_allocatedsrpc(fhandle_t *fhp, off_t off, off_t len, struct ucred *cred, return (error); } +/* + * Do a deallocate RPC on a DS data file, using this structure for the + * arguments, so that this function can be executed by a separate kernel + * process. + */ +struct nfsrvdeallocatedsdorpc { + int done; + int inprog; + struct task tsk; + fhandle_t fh; + off_t off; + off_t len; + struct nfsmount *nmp; + struct ucred *cred; + NFSPROC_T *p; + int err; +}; + +static int +nfsrv_deallocatedsdorpc(struct nfsmount *nmp, fhandle_t *fhp, off_t off, + off_t len, struct nfsvattr *nap, struct ucred *cred, NFSPROC_T *p) +{ + uint32_t *tl; + struct nfsrv_descript *nd; + nfsattrbit_t attrbits; + nfsv4stateid_t st; + int error; + + nd = malloc(sizeof(*nd), M_TEMP, M_WAITOK | M_ZERO); + nfscl_reqstart(nd, NFSPROC_DEALLOCATE, nmp, (u_int8_t *)fhp, + sizeof(fhandle_t), NULL, NULL, 0, 0); + + /* + * Use a stateid where other is an alternating 01010 pattern and + * seqid is 0xffffffff. This value is not defined as special by + * the RFC and is used by the FreeBSD NFS server to indicate an + * MDS->DS proxy operation. + */ + st.other[0] = 0x55555555; + st.other[1] = 0x55555555; + st.other[2] = 0x55555555; + st.seqid = 0xffffffff; + nfsm_stateidtom(nd, &st, NFSSTATEID_PUTSTATEID); + NFSM_BUILD(tl, uint32_t *, 2 * NFSX_HYPER + NFSX_UNSIGNED); + txdr_hyper(off, tl); tl += 2; + txdr_hyper(len, tl); tl += 2; + NFSD_DEBUG(4, "nfsrv_deallocatedsdorpc: len=%jd\n", (intmax_t)len); + + *tl = txdr_unsigned(NFSV4OP_GETATTR); + NFSGETATTR_ATTRBIT(&attrbits); + nfsrv_putattrbit(nd, &attrbits); + error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p, + cred, NFS_PROG, NFS_VER4, NULL, 1, NULL, NULL); + if (error != 0) { + free(nd, M_TEMP); + return (error); + } + NFSD_DEBUG(4, "nfsrv_deallocatedsdorpc: aft allocaterpc=%d\n", + nd->nd_repstat); + if (nd->nd_repstat == 0) { + NFSM_DISSECT(tl, uint32_t *, 2 * NFSX_UNSIGNED); + error = nfsv4_loadattr(nd, NULL, nap, NULL, NULL, 0, NULL, NULL, + NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL); + } else + error = nd->nd_repstat; + NFSD_DEBUG(4, "nfsrv_deallocatedsdorpc: aft loadattr=%d\n", error); +nfsmout: + m_freem(nd->nd_mrep); + free(nd, M_TEMP); + NFSD_DEBUG(4, "nfsrv_deallocatedsdorpc error=%d\n", error); + return (error); +} + +/* + * Start up the thread that will execute nfsrv_deallocatedsdorpc(). + */ +static void +start_deallocatedsdorpc(void *arg, int pending) +{ + struct nfsrvdeallocatedsdorpc *drpc; + + drpc = (struct nfsrvdeallocatedsdorpc *)arg; + drpc->err = nfsrv_deallocatedsdorpc(drpc->nmp, &drpc->fh, drpc->off, + drpc->len, NULL, drpc->cred, drpc->p); + drpc->done = 1; + NFSD_DEBUG(4, "start_deallocatedsdorpc: err=%d\n", drpc->err); +} + +static int +nfsrv_deallocatedsrpc(fhandle_t *fhp, off_t off, off_t len, struct ucred *cred, + NFSPROC_T *p, struct vnode *vp, struct nfsmount **nmpp, int mirrorcnt, + int *failposp) +{ + struct nfsrvdeallocatedsdorpc *drpc, *tdrpc = NULL; + struct nfsvattr na; + int error, i, ret, timo; + + NFSD_DEBUG(4, "in nfsrv_deallocatedsrpc\n"); + drpc = NULL; + if (mirrorcnt > 1) + tdrpc = drpc = malloc(sizeof(*drpc) * (mirrorcnt - 1), M_TEMP, + M_WAITOK); + + /* + * Do the deallocate RPC for every DS, using a separate kernel process + * for every DS except the last one. + */ + error = 0; + for (i = 0; i < mirrorcnt - 1; i++, tdrpc++) { + tdrpc->done = 0; + NFSBCOPY(fhp, &tdrpc->fh, sizeof(*fhp)); + tdrpc->off = off; + tdrpc->len = len; + tdrpc->nmp = *nmpp; + tdrpc->cred = cred; + tdrpc->p = p; + tdrpc->inprog = 0; + tdrpc->err = 0; + ret = EIO; + if (nfs_pnfsiothreads != 0) { + ret = nfs_pnfsio(start_deallocatedsdorpc, tdrpc); + NFSD_DEBUG(4, "nfsrv_deallocatedsrpc: nfs_pnfsio=%d\n", + ret); + } + if (ret != 0) { + ret = nfsrv_deallocatedsdorpc(*nmpp, fhp, off, len, + NULL, cred, p); + if (nfsds_failerr(ret) && *failposp == -1) + *failposp = i; + else if (error == 0 && ret != 0) + error = ret; + } + nmpp++; + fhp++; + } + ret = nfsrv_deallocatedsdorpc(*nmpp, fhp, off, len, &na, cred, p); + if (nfsds_failerr(ret) && *failposp == -1 && mirrorcnt > 1) + *failposp = mirrorcnt - 1; + else if (error == 0 && ret != 0) + error = ret; + if (error == 0) + error = nfsrv_setextattr(vp, &na, p); + NFSD_DEBUG(4, "nfsrv_deallocatedsrpc: aft setextat=%d\n", error); + tdrpc = drpc; + timo = hz / 50; /* Wait for 20msec. */ + if (timo < 1) + timo = 1; + for (i = 0; i < mirrorcnt - 1; i++, tdrpc++) { + /* Wait for RPCs on separate threads to complete. */ + while (tdrpc->inprog != 0 && tdrpc->done == 0) + tsleep(&tdrpc->tsk, PVFS, "srvalds", timo); + if (nfsds_failerr(tdrpc->err) && *failposp == -1) + *failposp = i; + else if (error == 0 && tdrpc->err != 0) + error = tdrpc->err; + } + free(drpc, M_TEMP); + return (error); +} + static int nfsrv_setattrdsdorpc(fhandle_t *fhp, struct ucred *cred, NFSPROC_T *p, struct vnode *vp, struct nfsmount *nmp, struct nfsvattr *nap, @@ -6425,6 +6590,42 @@ nfsvno_allocate(struct vnode *vp, off_t off, off_t len, struct ucred *cred, return (error); } +/* + * Deallocate vnode op call. + */ +int +nfsvno_deallocate(struct vnode *vp, off_t off, off_t len, struct ucred *cred, + NFSPROC_T *p) +{ + int error; + off_t olen; + + ASSERT_VOP_ELOCKED(vp, "nfsvno_deallocate vp"); + /* + * Attempt to deallocate on a DS file. A return of ENOENT implies + * there is no DS file to deallocate on. + */ + error = nfsrv_proxyds(vp, off, 0, cred, p, NFSPROC_DEALLOCATE, NULL, + NULL, NULL, NULL, NULL, &len, 0, NULL); + if (error != ENOENT) + return (error); + + /* + * Do the actual VOP_DEALLOCATE(), looping so long as + * progress is being made, to achieve completion. + */ + do { + olen = len; + error = VOP_DEALLOCATE(vp, &off, &len, 0, IO_SYNC, cred); + if (error == 0 && len > 0 && olen > len) + maybe_yield(); + } while (error == 0 && len > 0 && olen > len); + if (error == 0 && len > 0) + error = NFSERR_IO; + NFSEXITCODE(error); + return (error); +} + /* * Get Extended Atribute vnode op into an mbuf list. */ diff --git a/sys/fs/nfsserver/nfs_nfsdserv.c b/sys/fs/nfsserver/nfs_nfsdserv.c index 12181d04f1fa..2d4635c75204 100644 --- a/sys/fs/nfsserver/nfs_nfsdserv.c +++ b/sys/fs/nfsserver/nfs_nfsdserv.c @@ -5389,6 +5389,111 @@ nfsmout: return (error); } +/* + * nfs deallocate service + */ +int +nfsrvd_deallocate(struct nfsrv_descript *nd, __unused int isdgram, + vnode_t vp, struct nfsexstuff *exp) +{ + uint32_t *tl; + struct nfsvattr forat; + int error = 0, forat_ret = 1, gotproxystateid; + off_t off, len; + struct nfsstate st, *stp = &st; + struct nfslock lo, *lop = &lo; + nfsv4stateid_t stateid; + nfsquad_t clientid; + nfsattrbit_t attrbits; + + gotproxystateid = 0; + NFSM_DISSECT(tl, uint32_t *, NFSX_STATEID + 2 * NFSX_HYPER); + stp->ls_flags = (NFSLCK_CHECK | NFSLCK_WRITEACCESS); + lop->lo_flags = NFSLCK_WRITE; + stp->ls_ownerlen = 0; + stp->ls_op = NULL; + stp->ls_uid = nd->nd_cred->cr_uid; + stp->ls_stateid.seqid = fxdr_unsigned(u_int32_t, *tl++); + clientid.lval[0] = stp->ls_stateid.other[0] = *tl++; + clientid.lval[1] = stp->ls_stateid.other[1] = *tl++; + if ((nd->nd_flag & ND_IMPLIEDCLID) != 0) { + if ((nd->nd_flag & ND_NFSV41) != 0) + clientid.qval = nd->nd_clientid.qval; + else if (nd->nd_clientid.qval != clientid.qval) + printf("EEK2 multiple clids\n"); + } else { + if ((nd->nd_flag & ND_NFSV41) != 0) + printf("EEK! no clientid from session\n"); + nd->nd_flag |= ND_IMPLIEDCLID; + nd->nd_clientid.qval = clientid.qval; + } + stp->ls_stateid.other[2] = *tl++; + /* + * Don't allow this to be done for a DS. + */ + if ((nd->nd_flag & ND_DSSERVER) != 0) + nd->nd_repstat = NFSERR_NOTSUPP; + /* However, allow the proxy stateid. */ + if (stp->ls_stateid.seqid == 0xffffffff && + stp->ls_stateid.other[0] == 0x55555555 && + stp->ls_stateid.other[1] == 0x55555555 && + stp->ls_stateid.other[2] == 0x55555555) + gotproxystateid = 1; + off = fxdr_hyper(tl); tl += 2; + lop->lo_first = off; + len = fxdr_hyper(tl); + if (len < 0) + len = OFF_MAX; + NFSD_DEBUG(4, "dealloc: off=%jd len=%jd\n", (intmax_t)off, + (intmax_t)len); + lop->lo_end = lop->lo_first + len; + /* + * Sanity check the offset and length. + * off and len are off_t (signed int64_t) whereas + * lo_first and lo_end are uint64_t and, as such, + * if off >= 0 && len > 0, lo_end cannot overflow + * unless off_t is changed to something other than + * int64_t. Check lo_end < lo_first in case that + * is someday the case. + * The error to return is not specified by RFC 7862 so I + * made this compatible with the Linux knfsd. + */ + if (nd->nd_repstat == 0) { + if (off < 0 || lop->lo_end > NFSRV_MAXFILESIZE) + nd->nd_repstat = NFSERR_FBIG; + else if (len == 0 || lop->lo_end < lop->lo_first) + nd->nd_repstat = NFSERR_INVAL; + } + + if (nd->nd_repstat == 0 && vnode_vtype(vp) != VREG) + nd->nd_repstat = NFSERR_WRONGTYPE; + NFSZERO_ATTRBIT(&attrbits); + NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_OWNER); + forat_ret = nfsvno_getattr(vp, &forat, nd, curthread, 1, &attrbits); + if (nd->nd_repstat == 0) + nd->nd_repstat = forat_ret; + if (nd->nd_repstat == 0 && (forat.na_uid != nd->nd_cred->cr_uid || + NFSVNO_EXSTRICTACCESS(exp))) + nd->nd_repstat = nfsvno_accchk(vp, VWRITE, nd->nd_cred, exp, + curthread, NFSACCCHK_ALLOWOWNER, NFSACCCHK_VPISLOCKED, + NULL); + if (nd->nd_repstat == 0 && gotproxystateid == 0) + nd->nd_repstat = nfsrv_lockctrl(vp, &stp, &lop, NULL, clientid, + &stateid, exp, nd, curthread); + + if (nd->nd_repstat == 0) + nd->nd_repstat = nfsvno_deallocate(vp, off, len, nd->nd_cred, + curthread); + vput(vp); + NFSD_DEBUG(4, "eo deallocate=%d\n", nd->nd_repstat); + NFSEXITCODE2(0, nd); + return (0); +nfsmout: + vput(vp); + NFSEXITCODE2(error, nd); + return (error); +} + /* * nfs copy service */ diff --git a/sys/fs/nfsserver/nfs_nfsdsocket.c b/sys/fs/nfsserver/nfs_nfsdsocket.c index 85771974be2f..fdd46b6290e9 100644 --- a/sys/fs/nfsserver/nfs_nfsdsocket.c +++ b/sys/fs/nfsserver/nfs_nfsdsocket.c @@ -198,7 +198,7 @@ int (*nfsrv4_ops0[NFSV42_NOPS])(struct nfsrv_descript *, nfsrvd_allocate, (int (*)(struct nfsrv_descript *, int, vnode_t , struct nfsexstuff *))0, nfsrvd_notsupp, - nfsrvd_notsupp, + nfsrvd_deallocate, nfsrvd_ioadvise, nfsrvd_layouterror, nfsrvd_layoutstats, From owner-dev-commits-src-main@freebsd.org Fri Aug 27 08:15:14 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F24C965A45E; Fri, 27 Aug 2021 08:15:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gwsw269HWz4fPY; Fri, 27 Aug 2021 08:15:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BAE3A1FD3F; Fri, 27 Aug 2021 08:15:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17R8FExj098861; Fri, 27 Aug 2021 08:15:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17R8FEGc098860; Fri, 27 Aug 2021 08:15:14 GMT (envelope-from git) Date: Fri, 27 Aug 2021 08:15:14 GMT Message-Id: <202108270815.17R8FEGc098860@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hiroki Sato Subject: git: 9823a0c0acf4 - main - inet6(4): add a missing IPPROTO_ETHERIP entry MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hrs X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9823a0c0acf4fc277a71336ea737e1de7c65742f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 08:15:15 -0000 The branch main has been updated by hrs: URL: https://cgit.FreeBSD.org/src/commit/?id=9823a0c0acf4fc277a71336ea737e1de7c65742f commit 9823a0c0acf4fc277a71336ea737e1de7c65742f Author: Hiroki Sato AuthorDate: 2021-08-27 08:14:35 +0000 Commit: Hiroki Sato CommitDate: 2021-08-27 08:14:35 +0000 inet6(4): add a missing IPPROTO_ETHERIP entry bridge(4) + gif(4) did not work when the outer protocol was IPv6. Submitted by: Masahiro Kozuka PR: 256820 MFC after: 3 days --- sys/netinet6/in6_proto.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sys/netinet6/in6_proto.c b/sys/netinet6/in6_proto.c index 56ef41a27e88..909564b8c7e5 100644 --- a/sys/netinet6/in6_proto.c +++ b/sys/netinet6/in6_proto.c @@ -293,6 +293,15 @@ struct protosw inet6sw[] = { .pr_ctloutput = rip6_ctloutput, .pr_usrreqs = &rip6_usrreqs }, +{ + .pr_type = SOCK_RAW, + .pr_domain = &inet6domain, + .pr_protocol = IPPROTO_ETHERIP, + .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR, + .pr_input = encap6_input, + .pr_ctloutput = rip6_ctloutput, + .pr_usrreqs = &rip6_usrreqs +}, { .pr_type = SOCK_RAW, .pr_domain = &inet6domain, From owner-dev-commits-src-main@freebsd.org Fri Aug 27 08:52:43 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3BE8865ACC9; Fri, 27 Aug 2021 08:52:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GwtlG5YkJz4rJd; Fri, 27 Aug 2021 08:52:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A855820885; Fri, 27 Aug 2021 08:52:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17R8qgLu051055; Fri, 27 Aug 2021 08:52:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17R8qgYJ051054; Fri, 27 Aug 2021 08:52:42 GMT (envelope-from git) Date: Fri, 27 Aug 2021 08:52:42 GMT Message-Id: <202108270852.17R8qgYJ051054@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Popov Subject: git: 19f7f91133af - main - libc/posix1e: Add acl_from_mode_np() function. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arrowd X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 19f7f91133af6b699a87ed7656987ba017a75b6a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 08:52:43 -0000 The branch main has been updated by arrowd (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=19f7f91133af6b699a87ed7656987ba017a75b6a commit 19f7f91133af6b699a87ed7656987ba017a75b6a Author: Gleb Popov AuthorDate: 2021-01-19 15:25:07 +0000 Commit: Gleb Popov CommitDate: 2021-08-27 08:49:19 +0000 libc/posix1e: Add acl_from_mode_np() function. Reviewed by: kib, debdrup, gbe Approved by: kib Differential Revision: https://reviews.freebsd.org/D28255 --- lib/libc/posix1e/Makefile.inc | 2 + lib/libc/posix1e/Symbol.map | 4 ++ lib/libc/posix1e/acl_from_mode_np.3 | 95 +++++++++++++++++++++++++++++ lib/libc/posix1e/acl_from_mode_np.c | 115 ++++++++++++++++++++++++++++++++++++ sys/sys/acl.h | 3 +- 5 files changed, 218 insertions(+), 1 deletion(-) diff --git a/lib/libc/posix1e/Makefile.inc b/lib/libc/posix1e/Makefile.inc index fadc952f7acc..865a5e120b0f 100644 --- a/lib/libc/posix1e/Makefile.inc +++ b/lib/libc/posix1e/Makefile.inc @@ -18,6 +18,7 @@ SRCS+= acl_branding.c \ acl_entry.c \ acl_flag.c \ acl_free.c \ + acl_from_mode_np.c \ acl_from_text.c \ acl_from_text_nfs4.c \ acl_get.c \ @@ -54,6 +55,7 @@ MAN+= acl.3 \ acl_delete_perm.3 \ acl_dup.3 \ acl_free.3 \ + acl_from_mode_np.3 \ acl_from_text.3 \ acl_get.3 \ acl_get_brand_np.3 \ diff --git a/lib/libc/posix1e/Symbol.map b/lib/libc/posix1e/Symbol.map index 346c8ca7e290..6cc05daee818 100644 --- a/lib/libc/posix1e/Symbol.map +++ b/lib/libc/posix1e/Symbol.map @@ -84,3 +84,7 @@ FBSD_1.1 { acl_strip_np; acl_to_text_np; }; + +FBSD_1.7 { + acl_from_mode_np; +}; diff --git a/lib/libc/posix1e/acl_from_mode_np.3 b/lib/libc/posix1e/acl_from_mode_np.3 new file mode 100644 index 000000000000..6ba80de5567b --- /dev/null +++ b/lib/libc/posix1e/acl_from_mode_np.3 @@ -0,0 +1,95 @@ +.\"- +.\" Copyright (c) 2021 Gleb Popov +.\" All rights reserved. +.\" +.\" 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. +.\" +.Dd January 20, 2021 +.Dt ACL_FROM_MODE_NP 3 +.Os +.Sh NAME +.Nm acl_from_mode_np +.Nd create an ACL from status information +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In sys/acl.h +.Ft acl_t +.Fn acl_from_mode_np "const mode_t mode" +.Sh DESCRIPTION +The +.Fn acl_from_mode_np +function is a non-portable call that converts the permissions set referred to by +.Va mode +into the corresponding minimal ACL structure, appropriate for applying to +files or manipulating. +.Pp +This function causes memory to be allocated. +The caller should free any +free-able memory, when the new ACL is no longer required, by calling +.Xr acl_free 3 +with the +.Va (void *)acl_t +as an argument. +.Sh RETURN VALUES +Upon successful completion, the function returns a pointer to the +internal representation of the ACL in working storage. +Otherwise, a value +of +.Va (acl_t)NULL +is returned, and +.Va errno +is set to indicate the error. +.Sh ERRORS +If any of the following conditions occur, the +.Fn acl_from_mode_np +function returns a value of +.Va (acl_t)NULL +and set +.Va errno +to the corresponding value: +.Bl -tag -width Er +.It Bq Er ENOMEM +The ACL working storage requires more memory than is allowed by the +hardware or system-imposed memory management constraints. +.El +.Sh SEE ALSO +.Xr acl 3 , +.Xr acl_free 3 , +.Xr acl_from_text 3 , +.Xr posix1e 3 +.Sh STANDARDS +POSIX.1e is described in IEEE POSIX.1e draft 17. +Discussion +of the draft continues on the cross-platform POSIX.1e implementation +mailing list. +To join this list, see the +.Fx +POSIX.1e implementation +page for more information. +.Sh HISTORY +POSIX.1e support was introduced in +.Fx 4.0 , +and development continues. +.Sh AUTHORS +.An Gleb Popov diff --git a/lib/libc/posix1e/acl_from_mode_np.c b/lib/libc/posix1e/acl_from_mode_np.c new file mode 100644 index 000000000000..d78109469720 --- /dev/null +++ b/lib/libc/posix1e/acl_from_mode_np.c @@ -0,0 +1,115 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 Robert N M Watson, Gleb Popov + * All rights reserved. + * + * 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. + */ +/* + * acl_from_mode_np: Create an ACL from a mode_t. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +/* + * return an ACL corresponding to the permissions + * contained in mode_t + */ +acl_t +acl_from_mode_np(const mode_t mode) +{ + acl_t acl; + acl_entry_t entry; + acl_permset_t perms; + + /* create the ACL */ + acl = acl_init(3); + /* here and below, the only possible reason to fail is ENOMEM, so + * no need to set errno again + */ + if (acl == NULL) + return (NULL); + + /* First entry: ACL_USER_OBJ */ + if (acl_create_entry(&acl, &entry) == -1) + return (NULL); + /* TODO: need to handle error there and below? */ + acl_set_tag_type(entry, ACL_USER_OBJ); + + acl_get_permset(entry, &perms); + acl_clear_perms(perms); + + /* calculate user mode */ + if (mode & S_IRUSR) + acl_add_perm(perms, ACL_READ); + if (mode & S_IWUSR) + acl_add_perm(perms, ACL_WRITE); + if (mode & S_IXUSR) + acl_add_perm(perms, ACL_EXECUTE); + + acl_set_permset(entry, perms); + + /* Second entry: ACL_GROUP_OBJ */ + if (acl_create_entry(&acl, &entry) == -1) + return (NULL); + acl_set_tag_type(entry, ACL_GROUP_OBJ); + + acl_get_permset(entry, &perms); + acl_clear_perms(perms); + + /* calculate group mode */ + if (mode & S_IRGRP) + acl_add_perm(perms, ACL_READ); + if (mode & S_IWGRP) + acl_add_perm(perms, ACL_WRITE); + if (mode & S_IXGRP) + acl_add_perm(perms, ACL_EXECUTE); + + acl_set_permset(entry, perms); + + /* Third entry: ACL_OTHER */ + if (acl_create_entry(&acl, &entry) == -1) + return (NULL); + acl_set_tag_type(entry, ACL_OTHER); + + acl_get_permset(entry, &perms); + acl_clear_perms(perms); + + /* calculate other mode */ + if (mode & S_IROTH) + acl_add_perm(perms, ACL_READ); + if (mode & S_IWOTH) + acl_add_perm(perms, ACL_WRITE); + if (mode & S_IXOTH) + acl_add_perm(perms, ACL_EXECUTE); + + acl_set_permset(entry, perms); + + return (acl); +} diff --git a/sys/sys/acl.h b/sys/sys/acl.h index 196447a6d9cb..71bb0f2ac058 100644 --- a/sys/sys/acl.h +++ b/sys/sys/acl.h @@ -30,7 +30,7 @@ * * $FreeBSD$ */ -/* +/* * Developed by the TrustedBSD Project. * Support for POSIX.1e and NFSv4 access control lists. */ @@ -379,6 +379,7 @@ int acl_delete_flag_np(acl_flagset_t _flagset_d, acl_flag_t _flag); int acl_delete_perm(acl_permset_t _permset_d, acl_perm_t _perm); acl_t acl_dup(acl_t _acl); int acl_free(void *_obj_p); +acl_t acl_from_mode_np(const mode_t mode); acl_t acl_from_text(const char *_buf_p); int acl_get_brand_np(acl_t _acl, int *_brand_p); int acl_get_entry(acl_t _acl, int _entry_id, acl_entry_t *_entry_p); From owner-dev-commits-src-main@freebsd.org Fri Aug 27 08:52:44 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2B9DA65AF7D; Fri, 27 Aug 2021 08:52:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GwtlJ0Gfwz4rDK; Fri, 27 Aug 2021 08:52:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D8555206C4; Fri, 27 Aug 2021 08:52:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17R8qh16051079; Fri, 27 Aug 2021 08:52:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17R8qhsE051078; Fri, 27 Aug 2021 08:52:43 GMT (envelope-from git) Date: Fri, 27 Aug 2021 08:52:43 GMT Message-Id: <202108270852.17R8qhsE051078@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Popov Subject: git: 937f807a3675 - main - libc/posix1e: Add acl_cmp_np() function. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arrowd X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 937f807a3675d0970be68437c2eb5ce4c82fd68f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 08:52:44 -0000 The branch main has been updated by arrowd (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=937f807a3675d0970be68437c2eb5ce4c82fd68f commit 937f807a3675d0970be68437c2eb5ce4c82fd68f Author: Gleb Popov AuthorDate: 2021-01-19 15:26:19 +0000 Commit: Gleb Popov CommitDate: 2021-08-27 08:52:08 +0000 libc/posix1e: Add acl_cmp_np() function. Reviewed by: kib, debdrup, gbe Approved by: kib Differential Revision: https://reviews.freebsd.org/D28255 --- lib/libc/posix1e/Makefile.inc | 2 + lib/libc/posix1e/Symbol.map | 1 + lib/libc/posix1e/acl_cmp_np.3 | 83 ++++++++++++++++++++++++++++++++++++++++++ lib/libc/posix1e/acl_cmp_np.c | 55 ++++++++++++++++++++++++++++ lib/libc/posix1e/acl_support.c | 2 - sys/sys/acl.h | 1 + 6 files changed, 142 insertions(+), 2 deletions(-) diff --git a/lib/libc/posix1e/Makefile.inc b/lib/libc/posix1e/Makefile.inc index 865a5e120b0f..de3fa17ab3c9 100644 --- a/lib/libc/posix1e/Makefile.inc +++ b/lib/libc/posix1e/Makefile.inc @@ -11,6 +11,7 @@ subr_acl_nfs4.c: ${SRCTOP}/sys/kern/subr_acl_nfs4.c CONFS+= posix1e/mac.conf SRCS+= acl_branding.c \ acl_calc_mask.c \ + acl_cmp_np.c \ acl_compat.c \ acl_copy.c \ acl_delete.c \ @@ -47,6 +48,7 @@ MAN+= acl.3 \ acl_calc_mask.3 \ acl_clear_flags_np.3 \ acl_clear_perms.3 \ + acl_cmp_np.3 \ acl_copy_entry.3 \ acl_create_entry.3 \ acl_delete.3 \ diff --git a/lib/libc/posix1e/Symbol.map b/lib/libc/posix1e/Symbol.map index 6cc05daee818..a83d69e9a887 100644 --- a/lib/libc/posix1e/Symbol.map +++ b/lib/libc/posix1e/Symbol.map @@ -86,5 +86,6 @@ FBSD_1.1 { }; FBSD_1.7 { + acl_cmp_np; acl_from_mode_np; }; diff --git a/lib/libc/posix1e/acl_cmp_np.3 b/lib/libc/posix1e/acl_cmp_np.3 new file mode 100644 index 000000000000..a8dca4959d2e --- /dev/null +++ b/lib/libc/posix1e/acl_cmp_np.3 @@ -0,0 +1,83 @@ +.\"- +.\" Copyright (c) 2021 Gleb Popov +.\" All rights reserved. +.\" +.\" 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. +.\" +.Dd January 20, 2021 +.Dt ACL_CMP_NP 3 +.Os +.Sh NAME +.Nm acl_cmp +.Nd compare between two ACLs +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In sys/acl.h +.Ft int +.Fn acl_cmp_np "acl_t acl1" "acl_t acl2" +.Sh DESCRIPTION +The +.Fn acl_cmp_np +function is a non-portable call that checks if ACLs pointed to by +.Va acl1 +and +.Va acl2 +are equivalent. +The two ACLs are considered equal when they contain the same +entries with matching tag types, qualifiers and permissions. +.Sh RETURN VALUES +Upon successful completion, this function returns 0 if the given ACLs are +equivalent and 1 if they differ. +Otherwise, the value -1 is returned, and +.Va errno +indicates the error. +.Sh ERRORS +If any of the following conditions occur, the +.Fn acl_cmp_np +function shall return a value of +.Va -1 +and set +.Va errno +to the corresponding value: +.Bl -tag -width Er +.It Bq Er EINVAL +Either first or second argument does not point to a valid ACL. +.Sh SEE ALSO +.Xr acl 3 , +.Xr posix1e 3 +.Sh STANDARDS +POSIX.1e is described in IEEE POSIX.1e draft 17. +Discussion +of the draft continues on the cross-platform POSIX.1e implementation +mailing list. +To join this list, see the +.Fx +POSIX.1e implementation +page for more information. +.Sh HISTORY +POSIX.1e support was introduced in +.Fx 4.0 , +and development continues. +.Sh AUTHORS +.An Gleb Popov diff --git a/lib/libc/posix1e/acl_cmp_np.c b/lib/libc/posix1e/acl_cmp_np.c new file mode 100644 index 000000000000..43fe9dcb3f7e --- /dev/null +++ b/lib/libc/posix1e/acl_cmp_np.c @@ -0,0 +1,55 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 Gleb Popov + * All rights reserved. + * + * 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. + */ +/* + * acl_cmp_np: Compare two ACL's. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include + +#include "acl_support.h" + +/* + * returns 0 if acl_t's are identical, 1 otherwise + */ +int +acl_cmp_np(acl_t acl1, acl_t acl2) +{ + if (acl1 == NULL || acl2 == NULL) { + errno = EINVAL; + return (-1); + } + + if (_acl_brand(acl1) != _acl_brand(acl2)) + return (1); + + return (_acl_differs(acl1, acl2)); +} diff --git a/lib/libc/posix1e/acl_support.c b/lib/libc/posix1e/acl_support.c index bb09d119f988..342d2853ddda 100644 --- a/lib/libc/posix1e/acl_support.c +++ b/lib/libc/posix1e/acl_support.c @@ -62,8 +62,6 @@ _acl_differs(const acl_t a, const acl_t b) struct acl_entry *entrya, *entryb; assert(_acl_brand(a) == _acl_brand(b)); - assert(_acl_brand(a) != ACL_BRAND_UNKNOWN); - assert(_acl_brand(b) != ACL_BRAND_UNKNOWN); if (a->ats_acl.acl_cnt != b->ats_acl.acl_cnt) return (1); diff --git a/sys/sys/acl.h b/sys/sys/acl.h index 71bb0f2ac058..bbf0987a75e4 100644 --- a/sys/sys/acl.h +++ b/sys/sys/acl.h @@ -363,6 +363,7 @@ int acl_add_perm(acl_permset_t _permset_d, acl_perm_t _perm); int acl_calc_mask(acl_t *_acl_p); int acl_clear_flags_np(acl_flagset_t _flagset_d); int acl_clear_perms(acl_permset_t _permset_d); +int acl_cmp_np(acl_t _acl1, acl_t _acl2); int acl_copy_entry(acl_entry_t _dest_d, acl_entry_t _src_d); ssize_t acl_copy_ext(void *_buf_p, acl_t _acl, ssize_t _size); acl_t acl_copy_int(const void *_buf_p); From owner-dev-commits-src-main@freebsd.org Fri Aug 27 08:52:45 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5099965B3A4; Fri, 27 Aug 2021 08:52:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GwtlK1L0fz4rB5; Fri, 27 Aug 2021 08:52:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0824420901; Fri, 27 Aug 2021 08:52:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17R8qiIQ051103; Fri, 27 Aug 2021 08:52:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17R8qipP051102; Fri, 27 Aug 2021 08:52:44 GMT (envelope-from git) Date: Fri, 27 Aug 2021 08:52:44 GMT Message-Id: <202108270852.17R8qipP051102@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Popov Subject: git: d81d5b2f2c9c - main - libc/posix1e: Add acl_equiv_mode_np() function. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arrowd X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d81d5b2f2c9cda96ad960aac3313b89b2769323e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 08:52:45 -0000 The branch main has been updated by arrowd (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=d81d5b2f2c9cda96ad960aac3313b89b2769323e commit d81d5b2f2c9cda96ad960aac3313b89b2769323e Author: Gleb Popov AuthorDate: 2021-01-19 18:05:57 +0000 Commit: Gleb Popov CommitDate: 2021-08-27 08:52:15 +0000 libc/posix1e: Add acl_equiv_mode_np() function. Reviewed by: kib, debdrup, gbe Approved by: kib Differential Revision: https://reviews.freebsd.org/D28255 --- lib/libc/posix1e/Makefile.inc | 2 + lib/libc/posix1e/Symbol.map | 1 + lib/libc/posix1e/acl_equiv_mode_np.3 | 95 ++++++++++++++++++++++++++++++++ lib/libc/posix1e/acl_equiv_mode_np.c | 101 +++++++++++++++++++++++++++++++++++ sys/sys/acl.h | 1 + 5 files changed, 200 insertions(+) diff --git a/lib/libc/posix1e/Makefile.inc b/lib/libc/posix1e/Makefile.inc index de3fa17ab3c9..181e43026a6d 100644 --- a/lib/libc/posix1e/Makefile.inc +++ b/lib/libc/posix1e/Makefile.inc @@ -17,6 +17,7 @@ SRCS+= acl_branding.c \ acl_delete.c \ acl_delete_entry.c \ acl_entry.c \ + acl_equiv_mode_np.c \ acl_flag.c \ acl_free.c \ acl_from_mode_np.c \ @@ -56,6 +57,7 @@ MAN+= acl.3 \ acl_delete_flag_np.3 \ acl_delete_perm.3 \ acl_dup.3 \ + acl_equiv_mode_np.3 \ acl_free.3 \ acl_from_mode_np.3 \ acl_from_text.3 \ diff --git a/lib/libc/posix1e/Symbol.map b/lib/libc/posix1e/Symbol.map index a83d69e9a887..40098d42d13d 100644 --- a/lib/libc/posix1e/Symbol.map +++ b/lib/libc/posix1e/Symbol.map @@ -87,5 +87,6 @@ FBSD_1.1 { FBSD_1.7 { acl_cmp_np; + acl_equiv_mode_np; acl_from_mode_np; }; diff --git a/lib/libc/posix1e/acl_equiv_mode_np.3 b/lib/libc/posix1e/acl_equiv_mode_np.3 new file mode 100644 index 000000000000..33281e349fba --- /dev/null +++ b/lib/libc/posix1e/acl_equiv_mode_np.3 @@ -0,0 +1,95 @@ +.\"- +.\" Copyright (c) 2021 Gleb Popov +.\" All rights reserved. +.\" +.\" 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. +.\" +.Dd January 20, 2021 +.Dt ACL_EQUIV_MODE_NP 3 +.Os +.Sh NAME +.Nm acl_equiv_mode_np +.Nd check if ACL can be represented as UNIX permissions +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In sys/acl.h +.Ft int +.Fn acl_equiv_mode_np "acl_t acl" "mode_t* mode_p" +.Sh DESCRIPTION +The +.Fn acl_equiv_mode_np +function is a non-portable call which checks that entries contained in the +.Va acl +argument use only the ACL_USER_OBJ, ACL_GROUP_OBJ, and ACL_OTHER tag types, and that +permissions contained in these entries consist only of ACL_READ, ACL_WRITE and +ACL_EXECUTE. +If the check succeeds, the ACL can be represented as traditional UNIX +file permissions bits set. +.Pp +If +.Va mode_p +is not NULL and the check succeeds, the function fills the argument with a mode +value corresponding to permissions contained in the ACL. +.Sh RETURN VALUES +Upon successful completion, the function returns 0 if the ACL can be represented +as UNIX permissions and 1 if it is not possible. +Otherwise, a value +of +.Va -1 +is returned, and +.Va errno +is set to indicate the error. +.Sh ERRORS +If any of the following conditions occur, the +.Fn acl_equiv_mode_np +function returns a value of +.Va -1 +and set +.Va errno +to the corresponding value: +.Bl -tag -width Er +.It Bq Er EINVAL +Argument +.Fa acl +does not point to a valid ACL. +.El +.Sh SEE ALSO +.Xr acl 3 , +.Xr acl_from_mode_np 3 , +.Xr posix1e 3 +.Sh STANDARDS +POSIX.1e is described in IEEE POSIX.1e draft 17. +Discussion +of the draft continues on the cross-platform POSIX.1e implementation +mailing list. +To join this list, see the +.Fx +POSIX.1e implementation +page for more information. +.Sh HISTORY +POSIX.1e support was introduced in +.Fx 4.0 , +and development continues. +.Sh AUTHORS +.An Gleb Popov diff --git a/lib/libc/posix1e/acl_equiv_mode_np.c b/lib/libc/posix1e/acl_equiv_mode_np.c new file mode 100644 index 000000000000..a6dfb03bfc46 --- /dev/null +++ b/lib/libc/posix1e/acl_equiv_mode_np.c @@ -0,0 +1,101 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 Gleb Popov + * All rights reserved. + * + * 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. + */ +/* + * acl_equiv_mode_np: Check if an ACL can be represented as a mode_t. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include + +#include "acl_support.h" + +int +acl_equiv_mode_np(acl_t acl, mode_t *mode_p) +{ + mode_t ret_mode = 0; + + if (acl == NULL) { + errno = EINVAL; + return (-1); + } + + /* Linux returns 0 for ACL returned by acl_init() */ + if (_acl_brand(acl) == ACL_BRAND_UNKNOWN && acl->ats_acl.acl_cnt == 0) + return (0); + + // TODO: Do we want to handle ACL_BRAND_NFS4 in this function? */ + if (_acl_brand(acl) != ACL_BRAND_POSIX) + return (1); + + for (int cur_entry = 0; cur_entry < acl->ats_acl.acl_cnt; cur_entry++) { + acl_entry_t entry = &acl->ats_acl.acl_entry[cur_entry]; + + if ((entry->ae_perm & ACL_PERM_BITS) != entry->ae_perm) + return (1); + + switch (entry->ae_tag) { + case ACL_USER_OBJ: + if (entry->ae_perm & ACL_READ) + ret_mode |= S_IRUSR; + if (entry->ae_perm & ACL_WRITE) + ret_mode |= S_IWUSR; + if (entry->ae_perm & ACL_EXECUTE) + ret_mode |= S_IXUSR; + break; + case ACL_GROUP_OBJ: + if (entry->ae_perm & ACL_READ) + ret_mode |= S_IRGRP; + if (entry->ae_perm & ACL_WRITE) + ret_mode |= S_IWGRP; + if (entry->ae_perm & ACL_EXECUTE) + ret_mode |= S_IXGRP; + break; + case ACL_OTHER: + if (entry->ae_perm & ACL_READ) + ret_mode |= S_IROTH; + if (entry->ae_perm & ACL_WRITE) + ret_mode |= S_IWOTH; + if (entry->ae_perm & ACL_EXECUTE) + ret_mode |= S_IXOTH; + break; + default: + return (1); + } + } + + if (mode_p != NULL) + *mode_p = ret_mode; + + return (0); +} diff --git a/sys/sys/acl.h b/sys/sys/acl.h index bbf0987a75e4..7c81570739c6 100644 --- a/sys/sys/acl.h +++ b/sys/sys/acl.h @@ -379,6 +379,7 @@ int acl_delete_def_link_np(const char *_path_p); int acl_delete_flag_np(acl_flagset_t _flagset_d, acl_flag_t _flag); int acl_delete_perm(acl_permset_t _permset_d, acl_perm_t _perm); acl_t acl_dup(acl_t _acl); +int acl_equiv_mode_np(acl_t acl, mode_t *mode_p); int acl_free(void *_obj_p); acl_t acl_from_mode_np(const mode_t mode); acl_t acl_from_text(const char *_buf_p); From owner-dev-commits-src-main@freebsd.org Fri Aug 27 08:52:47 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id ED68965B359; Fri, 27 Aug 2021 08:52:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GwtlM2qZ1z4r3K; Fri, 27 Aug 2021 08:52:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 36C232051E; Fri, 27 Aug 2021 08:52:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17R8qlRG051158; Fri, 27 Aug 2021 08:52:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17R8qlXE051157; Fri, 27 Aug 2021 08:52:47 GMT (envelope-from git) Date: Fri, 27 Aug 2021 08:52:47 GMT Message-Id: <202108270852.17R8qlXE051157@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Popov Subject: git: f8b88be850a5 - main - tests/sys/acl: Add ATF C test for newly added acl_* functions. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arrowd X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f8b88be850a51eb982a476b27b74686a445e9a38 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 08:52:48 -0000 The branch main has been updated by arrowd (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=f8b88be850a51eb982a476b27b74686a445e9a38 commit f8b88be850a51eb982a476b27b74686a445e9a38 Author: Gleb Popov AuthorDate: 2021-01-23 10:00:47 +0000 Commit: Gleb Popov CommitDate: 2021-08-27 08:52:21 +0000 tests/sys/acl: Add ATF C test for newly added acl_* functions. Reviewed by: kib, debdrup, gbe Approved by: kib Differential Revision: https://reviews.freebsd.org/D28255 --- tests/sys/acl/Makefile | 2 + tests/sys/acl/acl-api-test.c | 194 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 196 insertions(+) diff --git a/tests/sys/acl/Makefile b/tests/sys/acl/Makefile index bd548f06951e..abc505efe90b 100644 --- a/tests/sys/acl/Makefile +++ b/tests/sys/acl/Makefile @@ -14,6 +14,8 @@ ${PACKAGE}FILES+= tools-posix.test SCRIPTS+= run +ATF_TESTS_C+= acl-api-test + TAP_TESTS_SH+= 00 TAP_TESTS_SH+= 01 TAP_TESTS_SH+= 02 diff --git a/tests/sys/acl/acl-api-test.c b/tests/sys/acl/acl-api-test.c new file mode 100644 index 000000000000..3bd288313fed --- /dev/null +++ b/tests/sys/acl/acl-api-test.c @@ -0,0 +1,194 @@ +/*- + * Copyright (c) 2021 Gleb Popov + * All rights reserved. + * + * 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 +#include +#include + +#include +#include + +#include + +/* Compatibility shim to make it possible to run this test on Linux + * gcc -I/path/to/atf/include -L/path/to/atf/lib -latf-c -lacl acl-api-test.c + */ +#ifdef __linux__ +#include +#define acl_from_mode_np acl_from_mode +#define acl_equiv_mode_np acl_equiv_mode +#define acl_cmp_np acl_cmp +#endif + +static const mode_t all_modes[] = { + S_IRUSR, + S_IWUSR, + S_IXUSR, + S_IRGRP, + S_IWGRP, + S_IXGRP, + S_IROTH, + S_IWOTH, + S_IXOTH +}; + +static mode_t gen_random_mode(void) +{ + mode_t mode = 0; + + for (unsigned i = 0; i < sizeof(all_modes) / sizeof(mode_t); i++) { + if (rand() % 2) + mode |= all_modes[i]; + } + + return (mode); +} + +/* Generate a random mode_t, produce an acl_t from it, + * then use acl_equiv_mode_np to produce a mode_t again. + * The call should succeed and mode_t's should be equal + */ +ATF_TC_WITHOUT_HEAD(acl_mode_roundup); +ATF_TC_BODY(acl_mode_roundup, tc) +{ + int num_tests = 100; + + while (num_tests--) { + mode_t src_mode, equiv_mode; + acl_t acl; + + src_mode = gen_random_mode(); + + acl = acl_from_mode_np(src_mode); + ATF_REQUIRE(acl != NULL); + + ATF_CHECK_EQ(0, acl_equiv_mode_np(acl, &equiv_mode)); + ATF_CHECK_EQ(src_mode, equiv_mode); + + acl_free(acl); + } +} + +/* Successfull acl_equiv_mode_np calls are tested in acl_mode_roundup. + * Here some specific cases are tested. + */ +ATF_TC_WITHOUT_HEAD(acl_equiv_mode_test); +ATF_TC_BODY(acl_equiv_mode_test, tc) +{ + acl_t acl; + acl_entry_t entry; + mode_t mode; + int uid = 0; + + acl = acl_init(1); + ATF_REQUIRE(acl != NULL); + + /* empty acl maps to 0000 UNIX mode */ + ATF_CHECK_EQ(0, acl_equiv_mode_np(acl, &mode)); + ATF_CHECK_EQ(0, mode); + +#ifndef __linux__ + /* NFS-branded acl's can't be converted to UNIX mode */ + ATF_REQUIRE_EQ(0, acl_create_entry(&acl, &entry)); + ATF_REQUIRE_EQ(0, acl_set_tag_type(entry, ACL_EVERYONE)); + ATF_CHECK_EQ(1, acl_equiv_mode_np(acl, &mode)); +#endif + + /* acl's with qualified user entries can't be converted to UNIX mode */ + acl_free(acl); + acl = acl_init(1); + ATF_REQUIRE(acl != NULL); + ATF_REQUIRE_EQ(0, acl_create_entry(&acl, &entry)); + ATF_REQUIRE_EQ(0, acl_set_tag_type(entry, ACL_USER)); + ATF_REQUIRE_EQ(0, acl_set_qualifier(entry, &uid)); + ATF_CHECK_EQ(1, acl_equiv_mode_np(acl, &mode)); + + /* passing NULL causes EINVAL */ + ATF_CHECK_ERRNO(EINVAL, acl_equiv_mode_np(NULL, &mode)); +} + +ATF_TC_WITHOUT_HEAD(acl_cmp_test); +ATF_TC_BODY(acl_cmp_test, tc) +{ + acl_t empty_acl, acl1, acl2; + acl_entry_t entry; + acl_permset_t perms; + + empty_acl = acl_init(1); + ATF_REQUIRE(empty_acl != NULL); + + acl1 = acl_init(3); + ATF_REQUIRE(acl1 != NULL); + + /* first, check that two empty acls are equal */ + ATF_CHECK_EQ(0, acl_cmp_np(acl1, empty_acl)); + + /* now create an entry and compare against empty acl */ + ATF_REQUIRE_EQ(0, acl_create_entry(&acl1, &entry)); + ATF_REQUIRE_EQ(0, acl_set_tag_type(entry, ACL_USER_OBJ)); + ATF_REQUIRE_EQ(0, acl_get_permset(entry, &perms)); + ATF_REQUIRE_EQ(0, acl_clear_perms(perms)); + ATF_REQUIRE_EQ(0, acl_add_perm(perms, ACL_READ)); + ATF_CHECK_EQ(1, acl_cmp_np(empty_acl, acl1)); + + /* make a dup of non-empty acl and check that they are equal */ + acl2 = acl_dup(acl1); + ATF_REQUIRE(acl2 != NULL); + ATF_CHECK_EQ(0, acl_cmp_np(acl1, acl2)); + + /* change the tag type and compare */ + ATF_REQUIRE_EQ(1, acl_get_entry(acl1, ACL_FIRST_ENTRY, &entry)); + ATF_REQUIRE_EQ(0, acl_set_tag_type(entry, ACL_GROUP_OBJ)); + ATF_CHECK_EQ(1, acl_cmp_np(acl1, acl2)); + + /* change the permset and compare */ + acl_free(acl2); + acl2 = acl_dup(acl1); + ATF_REQUIRE(acl2 != NULL); + ATF_REQUIRE_EQ(1, acl_get_entry(acl1, ACL_FIRST_ENTRY, &entry)); + ATF_REQUIRE_EQ(0, acl_get_permset(entry, &perms)); + ATF_REQUIRE_EQ(0, acl_clear_perms(perms)); + ATF_CHECK_EQ(1, acl_cmp_np(acl1, acl2)); + + /* check that passing NULL yields EINVAL */ + ATF_CHECK_ERRNO(EINVAL, acl_cmp_np(NULL, NULL)); + ATF_CHECK_ERRNO(EINVAL, acl_cmp_np(acl1, NULL)); + ATF_CHECK_ERRNO(EINVAL, acl_cmp_np(NULL, acl1)); + + acl_free(empty_acl); + acl_free(acl1); + acl_free(acl2); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, acl_mode_roundup); + ATF_TP_ADD_TC(tp, acl_equiv_mode_test); + ATF_TP_ADD_TC(tp, acl_cmp_test); + + return (atf_no_error()); +} From owner-dev-commits-src-main@freebsd.org Fri Aug 27 08:52:46 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7EAD865B601; Fri, 27 Aug 2021 08:52:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GwtlL2bzmz4rB8; Fri, 27 Aug 2021 08:52:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 191A32081F; Fri, 27 Aug 2021 08:52:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17R8qjK6051131; Fri, 27 Aug 2021 08:52:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17R8qjmr051130; Fri, 27 Aug 2021 08:52:45 GMT (envelope-from git) Date: Fri, 27 Aug 2021 08:52:45 GMT Message-Id: <202108270852.17R8qjmr051130@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Popov Subject: git: fcef0684f108 - main - Fix build of bin/getfacl after libc changes. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arrowd X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fcef0684f1084aeacae556adc5d4d5853b7e748e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 08:52:46 -0000 The branch main has been updated by arrowd (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=fcef0684f1084aeacae556adc5d4d5853b7e748e commit fcef0684f1084aeacae556adc5d4d5853b7e748e Author: Gleb Popov AuthorDate: 2021-01-20 09:47:44 +0000 Commit: Gleb Popov CommitDate: 2021-08-27 08:52:18 +0000 Fix build of bin/getfacl after libc changes. Reviewed by: kib, debdrup, gbe Approved by: kib Differential Revision: https://reviews.freebsd.org/D28255 --- bin/getfacl/getfacl.c | 93 +-------------------------------------------------- 1 file changed, 1 insertion(+), 92 deletions(-) diff --git a/bin/getfacl/getfacl.c b/bin/getfacl/getfacl.c index d59ddbcfc871..ecdc73f74fbc 100644 --- a/bin/getfacl/getfacl.c +++ b/bin/getfacl/getfacl.c @@ -83,97 +83,6 @@ getgname(gid_t gid) return (gr->gr_name); } -/* - * return an ACL corresponding to the permissions - * contained in mode_t - */ -static acl_t -acl_from_mode(const mode_t mode) -{ - acl_t acl; - acl_entry_t entry; - acl_permset_t perms; - - /* create the ACL */ - acl = acl_init(3); - if (!acl) - return NULL; - - /* First entry: ACL_USER_OBJ */ - if (acl_create_entry(&acl, &entry) == -1) - return NULL; - if (acl_set_tag_type(entry, ACL_USER_OBJ) == -1) - return NULL; - - if (acl_get_permset(entry, &perms) == -1) - return NULL; - if (acl_clear_perms(perms) == -1) - return NULL; - - /* calculate user mode */ - if (mode & S_IRUSR) - if (acl_add_perm(perms, ACL_READ) == -1) - return NULL; - if (mode & S_IWUSR) - if (acl_add_perm(perms, ACL_WRITE) == -1) - return NULL; - if (mode & S_IXUSR) - if (acl_add_perm(perms, ACL_EXECUTE) == -1) - return NULL; - if (acl_set_permset(entry, perms) == -1) - return NULL; - - /* Second entry: ACL_GROUP_OBJ */ - if (acl_create_entry(&acl, &entry) == -1) - return NULL; - if (acl_set_tag_type(entry, ACL_GROUP_OBJ) == -1) - return NULL; - - if (acl_get_permset(entry, &perms) == -1) - return NULL; - if (acl_clear_perms(perms) == -1) - return NULL; - - /* calculate group mode */ - if (mode & S_IRGRP) - if (acl_add_perm(perms, ACL_READ) == -1) - return NULL; - if (mode & S_IWGRP) - if (acl_add_perm(perms, ACL_WRITE) == -1) - return NULL; - if (mode & S_IXGRP) - if (acl_add_perm(perms, ACL_EXECUTE) == -1) - return NULL; - if (acl_set_permset(entry, perms) == -1) - return NULL; - - /* Third entry: ACL_OTHER */ - if (acl_create_entry(&acl, &entry) == -1) - return NULL; - if (acl_set_tag_type(entry, ACL_OTHER) == -1) - return NULL; - - if (acl_get_permset(entry, &perms) == -1) - return NULL; - if (acl_clear_perms(perms) == -1) - return NULL; - - /* calculate other mode */ - if (mode & S_IROTH) - if (acl_add_perm(perms, ACL_READ) == -1) - return NULL; - if (mode & S_IWOTH) - if (acl_add_perm(perms, ACL_WRITE) == -1) - return NULL; - if (mode & S_IXOTH) - if (acl_add_perm(perms, ACL_EXECUTE) == -1) - return NULL; - if (acl_set_permset(entry, perms) == -1) - return NULL; - - return(acl); -} - static int print_acl(char *path, acl_type_t type, int hflag, int iflag, int nflag, int qflag, int vflag) @@ -229,7 +138,7 @@ print_acl(char *path, acl_type_t type, int hflag, int iflag, int nflag, errno = 0; if (type == ACL_TYPE_DEFAULT) return(0); - acl = acl_from_mode(sb.st_mode); + acl = acl_from_mode_np(sb.st_mode); if (!acl) { warn("%s: acl_from_mode() failed", path); return(-1); From owner-dev-commits-src-main@freebsd.org Fri Aug 27 08:52:49 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 05FBE65B689; Fri, 27 Aug 2021 08:52:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GwtlN51VBz4rKG; Fri, 27 Aug 2021 08:52:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5A9292051F; Fri, 27 Aug 2021 08:52:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17R8qmjP051182; Fri, 27 Aug 2021 08:52:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17R8qmh5051181; Fri, 27 Aug 2021 08:52:48 GMT (envelope-from git) Date: Fri, 27 Aug 2021 08:52:48 GMT Message-Id: <202108270852.17R8qmh5051181@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Popov Subject: git: c468923b2210 - main - libc/posix1e: Add acl_extended_file_np() function. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arrowd X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c468923b22104bd5fbc408a0a2ef815d5138914a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 08:52:49 -0000 The branch main has been updated by arrowd (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=c468923b22104bd5fbc408a0a2ef815d5138914a commit c468923b22104bd5fbc408a0a2ef815d5138914a Author: Gleb Popov AuthorDate: 2021-03-12 08:52:58 +0000 Commit: Gleb Popov CommitDate: 2021-08-27 08:52:26 +0000 libc/posix1e: Add acl_extended_file_np() function. Reviewed by: kib, debdrup, gbe Approved by: kib Differential Revision: https://reviews.freebsd.org/D28255 --- lib/libc/posix1e/Makefile.inc | 4 ++ lib/libc/posix1e/Symbol.map | 3 ++ lib/libc/posix1e/acl_extended_file_np.3 | 95 +++++++++++++++++++++++++++++++++ lib/libc/posix1e/acl_extended_file_np.c | 85 +++++++++++++++++++++++++++++ sys/sys/acl.h | 7 ++- 5 files changed, 192 insertions(+), 2 deletions(-) diff --git a/lib/libc/posix1e/Makefile.inc b/lib/libc/posix1e/Makefile.inc index 181e43026a6d..3bceef2ff7de 100644 --- a/lib/libc/posix1e/Makefile.inc +++ b/lib/libc/posix1e/Makefile.inc @@ -18,6 +18,7 @@ SRCS+= acl_branding.c \ acl_delete_entry.c \ acl_entry.c \ acl_equiv_mode_np.c \ + acl_extended_file_np.c \ acl_flag.c \ acl_free.c \ acl_from_mode_np.c \ @@ -58,6 +59,7 @@ MAN+= acl.3 \ acl_delete_perm.3 \ acl_dup.3 \ acl_equiv_mode_np.3 \ + acl_extended_file_np.3 \ acl_free.3 \ acl_from_mode_np.3 \ acl_from_text.3 \ @@ -98,6 +100,8 @@ MLINKS+=acl_create_entry.3 acl_create_entry_np.3\ acl_delete.3 acl_delete_file_np.3 \ acl_delete.3 acl_delete_fd_np.3 \ acl_delete_entry.3 acl_delete_entry_np.3\ + acl_extended_file_np.3 acl_extended_file_nofollow_np.3 \ + acl_extended_file_np.3 acl_extended_link_np.3 \ acl_get.3 acl_get_file.3 \ acl_get.3 acl_get_fd.3 \ acl_get.3 acl_get_fd_np.3 \ diff --git a/lib/libc/posix1e/Symbol.map b/lib/libc/posix1e/Symbol.map index 40098d42d13d..d78691419c90 100644 --- a/lib/libc/posix1e/Symbol.map +++ b/lib/libc/posix1e/Symbol.map @@ -88,5 +88,8 @@ FBSD_1.1 { FBSD_1.7 { acl_cmp_np; acl_equiv_mode_np; + acl_extended_file_np; + acl_extended_file_nofollow_np; + acl_extended_link_np; acl_from_mode_np; }; diff --git a/lib/libc/posix1e/acl_extended_file_np.3 b/lib/libc/posix1e/acl_extended_file_np.3 new file mode 100644 index 000000000000..26572be9d2b3 --- /dev/null +++ b/lib/libc/posix1e/acl_extended_file_np.3 @@ -0,0 +1,95 @@ +.\"- +.\" Copyright (c) 2021 Gleb Popov +.\" All rights reserved. +.\" +.\" 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. +.\" +.Dd February 26, 2021 +.Dt ACL_EXTENDED_FILE_NP 3 +.Os +.Sh NAME +.Nm acl_extended_file_np , +.Nm acl_extended_file_nofollow_np , +.Nm acl_extended_link_np +.Nd checks if the file has extended ACLs set +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In sys/acl.h +.Ft int +.Fn acl_extended_file_np "const char* path_p" +.Ft int +.Fn acl_extended_file_nofollow_np "const char* path_p" +.Ft int +.Fn acl_extended_link_np "const char* path_p" +.Sh DESCRIPTION +The +.Fn acl_extended_file_np +function is a non-portable call that checks if the file or directory referred to +by the argument +.Va path_p +contains extended access ACLs. The +.Fn acl_extended_file_nofollow_np +function works the same way, except it does not follow symlinks. The +.Fn acl_extended_link_np +function is a synonim to +.Fn acl_extended_file_nofollow_np +named in FreeBSD style. +An ACL is considered to be extended access one if it contains entries other +than the three required entries of tag types ACL_USER_OBJ, ACL_GROUP_OBJ and +ACL_OTHER. +.Sh RETURN VALUES +Upon successful completion, this function returns 0 if the file object does not +contain extended access ACLs and 1 in the other case. +Otherwise, the value -1 is returned, and +.Va errno +indicates the error. +.Sh ERRORS +If any of the following conditions occur, the +.Fn acl_extended_file_np +function shall return a value of +.Va -1 +and set +.Va errno +to the corresponding value: +.Bl -tag -width Er +.It Bq Er EACCES +Search permission is denied for a component of the path prefix. +.Sh SEE ALSO +.Xr extattr_get_file 2 , +.Xr posix1e 3 +.Sh STANDARDS +POSIX.1e is described in IEEE POSIX.1e draft 17. +Discussion +of the draft continues on the cross-platform POSIX.1e implementation +mailing list. +To join this list, see the +.Fx +POSIX.1e implementation +page for more information. +.Sh HISTORY +POSIX.1e support was introduced in +.Fx 4.0 , +and development continues. +.Sh AUTHORS +.An Gleb Popov diff --git a/lib/libc/posix1e/acl_extended_file_np.c b/lib/libc/posix1e/acl_extended_file_np.c new file mode 100644 index 000000000000..c2980825b6b6 --- /dev/null +++ b/lib/libc/posix1e/acl_extended_file_np.c @@ -0,0 +1,85 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 Gleb Popov + * All rights reserved. + * + * 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. + */ +/* + * acl_extended_file_np: Check if the file has extended ACLs set. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include + +#include + +typedef acl_t (*acl_get_func)(const char *, acl_type_t); +typedef long (*pathconf_func)(const char *, int); + +static int +_acl_extended_file(acl_get_func f, pathconf_func pathconf_f, const char* path_p); + +int +acl_extended_file_np(const char *path_p) +{ + return (_acl_extended_file(acl_get_file, pathconf, path_p)); +} + +int +acl_extended_file_nofollow_np(const char *path_p) +{ + return (_acl_extended_file(acl_get_link_np, lpathconf, path_p)); +} + +int +acl_extended_link_np(const char *path_p) +{ + return (_acl_extended_file(acl_get_link_np, lpathconf, path_p)); +} + +int +_acl_extended_file(acl_get_func acl_get, pathconf_func pathconf_f, const char* path_p) +{ + acl_t acl; + int retval, istrivial, acltype = ACL_TYPE_ACCESS; + + retval = pathconf_f(path_p, _PC_ACL_NFS4); + if (retval > 0) + acltype = ACL_TYPE_NFS4; + + acl = acl_get(path_p, acltype); + if (acl == NULL) + return (-1); + + retval = acl_is_trivial_np(acl, &istrivial); + acl_free(acl); + if (retval == -1) + return (-1); + + return (!istrivial); +} diff --git a/sys/sys/acl.h b/sys/sys/acl.h index 7c81570739c6..b6958e73c881 100644 --- a/sys/sys/acl.h +++ b/sys/sys/acl.h @@ -379,9 +379,12 @@ int acl_delete_def_link_np(const char *_path_p); int acl_delete_flag_np(acl_flagset_t _flagset_d, acl_flag_t _flag); int acl_delete_perm(acl_permset_t _permset_d, acl_perm_t _perm); acl_t acl_dup(acl_t _acl); -int acl_equiv_mode_np(acl_t acl, mode_t *mode_p); +int acl_equiv_mode_np(acl_t _acl, mode_t *_mode_p); +int acl_extended_file_np(const char* _path_p); +int acl_extended_file_nofollow_np(const char* _path_p); +int acl_extended_link_np(const char* _path_p); int acl_free(void *_obj_p); -acl_t acl_from_mode_np(const mode_t mode); +acl_t acl_from_mode_np(const mode_t _mode); acl_t acl_from_text(const char *_buf_p); int acl_get_brand_np(acl_t _acl, int *_brand_p); int acl_get_entry(acl_t _acl, int _entry_id, acl_entry_t *_entry_p); From owner-dev-commits-src-main@freebsd.org Fri Aug 27 10:51:55 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6DF9965D95A; Fri, 27 Aug 2021 10:51:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GwxNq2klpz4V77; Fri, 27 Aug 2021 10:51:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4633E22035; Fri, 27 Aug 2021 10:51:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17RApts0011785; Fri, 27 Aug 2021 10:51:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RApsmG011784; Fri, 27 Aug 2021 10:51:54 GMT (envelope-from git) Date: Fri, 27 Aug 2021 10:51:54 GMT Message-Id: <202108271051.17RApsmG011784@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Martin Matuska Subject: git: c577bdfce6b4 - main - libarchive: import bugfix from upstream MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mm X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c577bdfce6b4451ab897bfe5013543e78a7f9b62 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 10:51:55 -0000 The branch main has been updated by mm: URL: https://cgit.FreeBSD.org/src/commit/?id=c577bdfce6b4451ab897bfe5013543e78a7f9b62 commit c577bdfce6b4451ab897bfe5013543e78a7f9b62 Merge: c468923b2210 6c0d5e8e0e5f Author: Martin Matuska AuthorDate: 2021-08-27 10:51:01 +0000 Commit: Martin Matuska CommitDate: 2021-08-27 10:51:01 +0000 libarchive: import bugfix from upstream Reworked bugfix for upstream issue #1566: Do not follow symlinks when processing the fixup list MFC after: 2 weeks .../libarchive/archive_write_disk_posix.c | 62 +++++++++++++++------- .../libarchive/test/test_write_disk_fixup.c | 44 +++++++++++---- 2 files changed, 78 insertions(+), 28 deletions(-) From owner-dev-commits-src-main@freebsd.org Fri Aug 27 11:49:00 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6E49365E933; Fri, 27 Aug 2021 11:49:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gwyfh2cl9z4vhd; Fri, 27 Aug 2021 11:49:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 418E62292A; Fri, 27 Aug 2021 11:49:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17RBn0gF080743; Fri, 27 Aug 2021 11:49:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RBn0F3080742; Fri, 27 Aug 2021 11:49:00 GMT (envelope-from git) Date: Fri, 27 Aug 2021 11:49:00 GMT Message-Id: <202108271149.17RBn0F3080742@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Alfredo Dal'Ava Junior" Subject: git: 9a4d48a645a7 - main - llvm/powerpc64*: fix broken binaries generated by clang12 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: alfredo X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9a4d48a645a7a3ebee05fae25afd154a132b638a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 11:49:00 -0000 The branch main has been updated by alfredo: URL: https://cgit.FreeBSD.org/src/commit/?id=9a4d48a645a7a3ebee05fae25afd154a132b638a commit 9a4d48a645a7a3ebee05fae25afd154a132b638a Author: Alfredo Dal'Ava Junior AuthorDate: 2021-08-27 14:47:11 +0000 Commit: Alfredo Dal'Ava Junior CommitDate: 2021-08-27 14:47:11 +0000 llvm/powerpc64*: fix broken binaries generated by clang12 Amends LLVM commit 2518433f861fcb877d0a7bdd9aec1aec1f77505a that was pointed as the source of regression on LLVM12. This affects powerpc64*, making binaries crash with segmentation fault due to bad code generation around "__stack_chk_guard" Root cause and/or proper fix is under investigation by: https://bugs.llvm.org/show_bug.cgi?id=51590 Reviewed by: dim MFC after: 2 days Sponsored by: Instituto de Pesquisas Eldorado (eldorado.org.br) Differential Revision: https://reviews.freebsd.org/D31698 --- contrib/llvm-project/llvm/lib/CodeGen/TargetLoweringBase.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contrib/llvm-project/llvm/lib/CodeGen/TargetLoweringBase.cpp b/contrib/llvm-project/llvm/lib/CodeGen/TargetLoweringBase.cpp index 28c8bd0a7ded..74fea674f962 100644 --- a/contrib/llvm-project/llvm/lib/CodeGen/TargetLoweringBase.cpp +++ b/contrib/llvm-project/llvm/lib/CodeGen/TargetLoweringBase.cpp @@ -1961,7 +1961,8 @@ void TargetLoweringBase::insertSSPDeclarations(Module &M) const { GlobalVariable::ExternalLinkage, nullptr, "__stack_chk_guard"); if (TM.getRelocationModel() == Reloc::Static && - !TM.getTargetTriple().isWindowsGNUEnvironment()) + !TM.getTargetTriple().isWindowsGNUEnvironment() && + !(TM.getTargetTriple().isPPC64() && TM.getTargetTriple().isOSFreeBSD())) GV->setDSOLocal(true); } } From owner-dev-commits-src-main@freebsd.org Fri Aug 27 12:48:43 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4F50465FBC0; Fri, 27 Aug 2021 12:48:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gwzzb1l9Lz3jLQ; Fri, 27 Aug 2021 12:48:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 23E052383F; Fri, 27 Aug 2021 12:48:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17RCmh99060342; Fri, 27 Aug 2021 12:48:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RCmhoK060341; Fri, 27 Aug 2021 12:48:43 GMT (envelope-from git) Date: Fri, 27 Aug 2021 12:48:43 GMT Message-Id: <202108271248.17RCmhoK060341@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: d174534a273d - main - tcp: Remove unused v6 state definitions MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d174534a273d1b5a603656dbaf6b03a34a09273e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 12:48:43 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=d174534a273d1b5a603656dbaf6b03a34a09273e commit d174534a273d1b5a603656dbaf6b03a34a09273e Author: Mark Johnston AuthorDate: 2021-08-27 12:31:32 +0000 Commit: Mark Johnston CommitDate: 2021-08-27 12:31:32 +0000 tcp: Remove unused v6 state definitions These are supposedly for compatibility with KAME, but they are completely unused in our tree and don't exist in OpenBSD or NetBSD. Reviewed by: kbowling, bz, gnn Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31700 --- sys/netinet/tcp_fsm.h | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/sys/netinet/tcp_fsm.h b/sys/netinet/tcp_fsm.h index 8bd129f613cf..ecef72fef26e 100644 --- a/sys/netinet/tcp_fsm.h +++ b/sys/netinet/tcp_fsm.h @@ -59,20 +59,6 @@ #define TCPS_FIN_WAIT_2 9 /* have closed, fin is acked */ #define TCPS_TIME_WAIT 10 /* in 2*msl quiet wait after close */ -/* for KAME src sync over BSD*'s */ -#define TCP6_NSTATES TCP_NSTATES -#define TCP6S_CLOSED TCPS_CLOSED -#define TCP6S_LISTEN TCPS_LISTEN -#define TCP6S_SYN_SENT TCPS_SYN_SENT -#define TCP6S_SYN_RECEIVED TCPS_SYN_RECEIVED -#define TCP6S_ESTABLISHED TCPS_ESTABLISHED -#define TCP6S_CLOSE_WAIT TCPS_CLOSE_WAIT -#define TCP6S_FIN_WAIT_1 TCPS_FIN_WAIT_1 -#define TCP6S_CLOSING TCPS_CLOSING -#define TCP6S_LAST_ACK TCPS_LAST_ACK -#define TCP6S_FIN_WAIT_2 TCPS_FIN_WAIT_2 -#define TCP6S_TIME_WAIT TCPS_TIME_WAIT - #define TCPS_HAVERCVDSYN(s) ((s) >= TCPS_SYN_RECEIVED) #define TCPS_HAVEESTABLISHED(s) ((s) >= TCPS_ESTABLISHED) #define TCPS_HAVERCVDFIN(s) \ From owner-dev-commits-src-main@freebsd.org Fri Aug 27 12:48:44 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 90B9765F874; Fri, 27 Aug 2021 12:48:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gwzzc2hyhz3jGh; Fri, 27 Aug 2021 12:48:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3FA272395E; Fri, 27 Aug 2021 12:48:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17RCmin2060366; Fri, 27 Aug 2021 12:48:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RCmiP7060365; Fri, 27 Aug 2021 12:48:44 GMT (envelope-from git) Date: Fri, 27 Aug 2021 12:48:44 GMT Message-Id: <202108271248.17RCmiP7060365@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 091869def9ee - main - connect: Use soconnectat() unconditionally in kern_connect() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 091869def9eeb9796c3627ea95bf6cc46cf952a0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 12:48:45 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=091869def9eeb9796c3627ea95bf6cc46cf952a0 commit 091869def9eeb9796c3627ea95bf6cc46cf952a0 Author: Mark Johnston AuthorDate: 2021-08-27 12:32:07 +0000 Commit: Mark Johnston CommitDate: 2021-08-27 12:32:07 +0000 connect: Use soconnectat() unconditionally in kern_connect() soconnect(...) is equivalent to soconnectat(AT_FDCWD, ...), so rely on this to save a branch. No functional change intended. MFC after: 1 week Sponsored by: The FreeBSD Foundation --- sys/kern/uipc_syscalls.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index 18505b54d603..3208dc0491dd 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -511,10 +511,7 @@ kern_connectat(struct thread *td, int dirfd, int fd, struct sockaddr *sa) if (error != 0) goto bad; #endif - if (dirfd == AT_FDCWD) - error = soconnect(so, sa, td); - else - error = soconnectat(dirfd, so, sa, td); + error = soconnectat(dirfd, so, sa, td); if (error != 0) goto bad; if ((so->so_state & SS_NBIO) && (so->so_state & SS_ISCONNECTING)) { From owner-dev-commits-src-main@freebsd.org Fri Aug 27 13:44:35 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D5E80660B53; Fri, 27 Aug 2021 13:44:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gx1D32P4Kz4Ynx; Fri, 27 Aug 2021 13:44:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3666524744; Fri, 27 Aug 2021 13:44:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17RDiZKx039792; Fri, 27 Aug 2021 13:44:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RDiZdB039791; Fri, 27 Aug 2021 13:44:35 GMT (envelope-from git) Date: Fri, 27 Aug 2021 13:44:35 GMT Message-Id: <202108271344.17RDiZdB039791@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ka Ho Ng Subject: git: 6e1df1d14c6d - main - pmap_extract.9: Fix pmap_extract_and_hold()'s function type MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6e1df1d14c6dfcc209c1416ec0832e4d08191c72 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 13:44:36 -0000 The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=6e1df1d14c6dfcc209c1416ec0832e4d08191c72 commit 6e1df1d14c6dfcc209c1416ec0832e4d08191c72 Author: Ka Ho Ng AuthorDate: 2021-08-27 13:42:49 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-27 13:44:16 +0000 pmap_extract.9: Fix pmap_extract_and_hold()'s function type pmap_extract_and_hold() returns a vm_page_t instead of a physical page address. Sponsored by: The FreeBSD Foundation Reviewed by: alc MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D31691 --- share/man/man9/pmap_extract.9 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/share/man/man9/pmap_extract.9 b/share/man/man9/pmap_extract.9 index d2154ebe8a0b..77f3b47ec51e 100644 --- a/share/man/man9/pmap_extract.9 +++ b/share/man/man9/pmap_extract.9 @@ -38,7 +38,7 @@ .In vm/pmap.h .Ft vm_paddr_t .Fn pmap_extract "pmap_t pmap" "vm_offset_t va" -.Ft vm_paddr_t +.Ft vm_page_t .Fn pmap_extract_and_hold "pmap_t pmap" "vm_offset_t va" "vm_prot_t prot" .Sh DESCRIPTION The @@ -73,7 +73,9 @@ will be returned. .Pp The .Fn pmap_extract_and_hold -function will return the physical page address associated with the +function will return the +.Ft vm_page_t +associated with the virtual address .Fa va inside the physical map From owner-dev-commits-src-main@freebsd.org Fri Aug 27 15:39:53 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F10356620FE; Fri, 27 Aug 2021 15:39:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gx3n56JTvz3vLX; Fri, 27 Aug 2021 15:39:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id ABD9225579; Fri, 27 Aug 2021 15:39:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17RFdrDR089110; Fri, 27 Aug 2021 15:39:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RFdrJG089109; Fri, 27 Aug 2021 15:39:53 GMT (envelope-from git) Date: Fri, 27 Aug 2021 15:39:53 GMT Message-Id: <202108271539.17RFdrJG089109@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 92d4e088274c - main - msdosfs: unstaticise msdosfs_lookup_ MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 92d4e088274c7ada268645588503f22f390c5fb8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 15:39:54 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=92d4e088274c7ada268645588503f22f390c5fb8 commit 92d4e088274c7ada268645588503f22f390c5fb8 Author: Konstantin Belousov AuthorDate: 2021-08-01 17:11:40 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-27 15:39:45 +0000 msdosfs: unstaticise msdosfs_lookup_ and rename it to msdosfs_lookup_ino(), similarly to UFS Reviewed by: mckusick Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D31464 --- sys/fs/msdosfs/denode.h | 2 ++ sys/fs/msdosfs/msdosfs_lookup.c | 11 ++++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/sys/fs/msdosfs/denode.h b/sys/fs/msdosfs/denode.h index 7c838b5cc81c..f133f3f90cd6 100644 --- a/sys/fs/msdosfs/denode.h +++ b/sys/fs/msdosfs/denode.h @@ -267,6 +267,8 @@ extern struct vop_vector msdosfs_vnodeops; int msdosfs_lookup(struct vop_cachedlookup_args *); int msdosfs_inactive(struct vop_inactive_args *); int msdosfs_reclaim(struct vop_reclaim_args *); +int msdosfs_lookup_ino(struct vnode *vdp, struct vnode **vpp, + struct componentname *cnp, uint64_t *inum); #endif /* diff --git a/sys/fs/msdosfs/msdosfs_lookup.c b/sys/fs/msdosfs/msdosfs_lookup.c index a32b0372243c..bdfff7bf3206 100644 --- a/sys/fs/msdosfs/msdosfs_lookup.c +++ b/sys/fs/msdosfs/msdosfs_lookup.c @@ -63,14 +63,11 @@ #include #include -static int msdosfs_lookup_(struct vnode *vdp, struct vnode **vpp, - struct componentname *cnp, uint64_t *inum); - int msdosfs_lookup(struct vop_cachedlookup_args *ap) { - return (msdosfs_lookup_(ap->a_dvp, ap->a_vpp, ap->a_cnp, NULL)); + return (msdosfs_lookup_ino(ap->a_dvp, ap->a_vpp, ap->a_cnp, NULL)); } struct deget_dotdot { @@ -110,8 +107,8 @@ msdosfs_deget_dotdot(struct mount *mp, void *arg, int lkflags, * out to disk. This way disk blocks containing directory entries and in * memory denode's will be in synch. */ -static int -msdosfs_lookup_(struct vnode *vdp, struct vnode **vpp, +int +msdosfs_lookup_ino(struct vnode *vdp, struct vnode **vpp, struct componentname *cnp, uint64_t *dd_inum) { struct mbnambuf nb; @@ -558,7 +555,7 @@ foundroot: * Recheck that ".." still points to the inode we * looked up before pdp lock was dropped. */ - error = msdosfs_lookup_(pdp, NULL, cnp, &inode1); + error = msdosfs_lookup_ino(pdp, NULL, cnp, &inode1); if (error) { vput(*vpp); *vpp = NULL; From owner-dev-commits-src-main@freebsd.org Fri Aug 27 15:39:55 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 65C68662532; Fri, 27 Aug 2021 15:39:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gx3n706kqz3vJ3; Fri, 27 Aug 2021 15:39:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CC9B925D9B; Fri, 27 Aug 2021 15:39:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17RFdsRm089134; Fri, 27 Aug 2021 15:39:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RFdslW089133; Fri, 27 Aug 2021 15:39:54 GMT (envelope-from git) Date: Fri, 27 Aug 2021 15:39:54 GMT Message-Id: <202108271539.17RFdslW089133@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: ae7e8a02e6e9 - main - msdosfs deget(): add locking flags argument MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ae7e8a02e6e93455e026036132c4d053b2c12ad9 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 15:39:55 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=ae7e8a02e6e93455e026036132c4d053b2c12ad9 commit ae7e8a02e6e93455e026036132c4d053b2c12ad9 Author: Konstantin Belousov AuthorDate: 2021-08-01 17:53:12 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-27 15:39:45 +0000 msdosfs deget(): add locking flags argument LK_EXCLUSIVE must be passed always, some consumers need the ability to specify LK_NOWAIT Reviewed by: mckusick Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D31464 --- sys/fs/msdosfs/denode.h | 2 +- sys/fs/msdosfs/msdosfs_denode.c | 13 ++++++++----- sys/fs/msdosfs/msdosfs_lookup.c | 15 +++++++++------ sys/fs/msdosfs/msdosfs_vfsops.c | 5 +++-- usr.sbin/makefs/msdos/msdosfs_denode.c | 2 +- usr.sbin/makefs/msdos/msdosfs_lookup.c | 2 +- usr.sbin/makefs/msdos/msdosfs_vfsops.c | 2 +- 7 files changed, 24 insertions(+), 17 deletions(-) diff --git a/sys/fs/msdosfs/denode.h b/sys/fs/msdosfs/denode.h index f133f3f90cd6..80ebf250febf 100644 --- a/sys/fs/msdosfs/denode.h +++ b/sys/fs/msdosfs/denode.h @@ -275,7 +275,7 @@ int msdosfs_lookup_ino(struct vnode *vdp, struct vnode **vpp, * Internal service routine prototypes. */ struct componentname; -int deget(struct msdosfsmount *, u_long, u_long, struct denode **); +int deget(struct msdosfsmount *, u_long, u_long, int, struct denode **); int uniqdosname(struct denode *, struct componentname *, u_char *); int readep(struct msdosfsmount *pmp, u_long dirclu, u_long dirofs, struct buf **bpp, struct direntry **epp); diff --git a/sys/fs/msdosfs/msdosfs_denode.c b/sys/fs/msdosfs/msdosfs_denode.c index 369533067ce9..d97e61f7932c 100644 --- a/sys/fs/msdosfs/msdosfs_denode.c +++ b/sys/fs/msdosfs/msdosfs_denode.c @@ -92,11 +92,12 @@ de_vncmpf(struct vnode *vp, void *arg) * diroffset is relative to the beginning of the root directory, * otherwise it is cluster relative. * diroffset - offset past begin of cluster of denode we want + * lkflags - locking flags (LK_NOWAIT) * depp - returns the address of the gotten denode. */ int deget(struct msdosfsmount *pmp, u_long dirclust, u_long diroffset, - struct denode **depp) + int lkflags, struct denode **depp) { int error; uint64_t inode; @@ -107,9 +108,11 @@ deget(struct msdosfsmount *pmp, u_long dirclust, u_long diroffset, struct buf *bp; #ifdef MSDOSFS_DEBUG - printf("deget(pmp %p, dirclust %lu, diroffset %lx, depp %p)\n", - pmp, dirclust, diroffset, depp); + printf("deget(pmp %p, dirclust %lu, diroffset %lx, flags %#x, " + "depp %p)\n", + pmp, dirclust, diroffset, flags, depp); #endif + MPASS((lkflags & LK_TYPE_MASK) == LK_EXCLUSIVE); /* * On FAT32 filesystems, root is a (more or less) normal @@ -133,7 +136,7 @@ deget(struct msdosfsmount *pmp, u_long dirclust, u_long diroffset, */ inode = (uint64_t)pmp->pm_bpcluster * dirclust + diroffset; - error = vfs_hash_get(mntp, inode, LK_EXCLUSIVE, curthread, &nvp, + error = vfs_hash_get(mntp, inode, lkflags, curthread, &nvp, de_vncmpf, &inode); if (error) return (error); @@ -171,7 +174,7 @@ deget(struct msdosfsmount *pmp, u_long dirclust, u_long diroffset, *depp = NULL; return (error); } - error = vfs_hash_insert(nvp, inode, LK_EXCLUSIVE, curthread, &xvp, + error = vfs_hash_insert(nvp, inode, lkflags, curthread, &xvp, de_vncmpf, &inode); if (error) { *depp = NULL; diff --git a/sys/fs/msdosfs/msdosfs_lookup.c b/sys/fs/msdosfs/msdosfs_lookup.c index bdfff7bf3206..d47f2969904b 100644 --- a/sys/fs/msdosfs/msdosfs_lookup.c +++ b/sys/fs/msdosfs/msdosfs_lookup.c @@ -86,7 +86,8 @@ msdosfs_deget_dotdot(struct mount *mp, void *arg, int lkflags, pmp = VFSTOMSDOSFS(mp); dd_arg = arg; - error = deget(pmp, dd_arg->cluster, dd_arg->blkoff, &rdp); + error = deget(pmp, dd_arg->cluster, dd_arg->blkoff, + LK_EXCLUSIVE, &rdp); if (error == 0) *rvp = DETOV(rdp); return (error); @@ -495,7 +496,7 @@ foundroot: *vpp = vdp; return (0); } - error = deget(pmp, cluster, blkoff, &tdp); + error = deget(pmp, cluster, blkoff, LK_EXCLUSIVE, &tdp); if (error) return (error); *vpp = DETOV(tdp); @@ -523,7 +524,8 @@ foundroot: if (dp->de_StartCluster == scn && isadir) return (EISDIR); - if ((error = deget(pmp, cluster, blkoff, &tdp)) != 0) + if ((error = deget(pmp, cluster, blkoff, LK_EXCLUSIVE, + &tdp)) != 0) return (error); *vpp = DETOV(tdp); cnp->cn_flags |= SAVENAME; @@ -569,7 +571,8 @@ foundroot: VREF(vdp); /* we want ourself, ie "." */ *vpp = vdp; } else { - if ((error = deget(pmp, cluster, blkoff, &tdp)) != 0) + if ((error = deget(pmp, cluster, blkoff, LK_EXCLUSIVE, + &tdp)) != 0) return (error); *vpp = DETOV(tdp); } @@ -708,7 +711,7 @@ createde(struct denode *dep, struct denode *ddep, struct denode **depp, else diroffset = 0; } - return deget(pmp, dirclust, diroffset, depp); + return (deget(pmp, dirclust, diroffset, LK_EXCLUSIVE, depp)); } return 0; @@ -862,7 +865,7 @@ doscheckpath(struct denode *source, struct denode *target) brelse(bp); bp = NULL; /* NOTE: deget() clears dep on error */ - if ((error = deget(pmp, scn, 0, &dep)) != 0) + if ((error = deget(pmp, scn, 0, LK_EXCLUSIVE, &dep)) != 0) break; } out:; diff --git a/sys/fs/msdosfs/msdosfs_vfsops.c b/sys/fs/msdosfs/msdosfs_vfsops.c index 187463cc7f4d..68c8a93a18af 100644 --- a/sys/fs/msdosfs/msdosfs_vfsops.c +++ b/sys/fs/msdosfs/msdosfs_vfsops.c @@ -847,7 +847,7 @@ msdosfs_root(struct mount *mp, int flags, struct vnode **vpp) #ifdef MSDOSFS_DEBUG printf("msdosfs_root(); mp %p, pmp %p\n", mp, pmp); #endif - error = deget(pmp, MSDOSFSROOT, MSDOSFSROOT_OFS, &ndep); + error = deget(pmp, MSDOSFSROOT, MSDOSFSROOT_OFS, LK_EXCLUSIVE, &ndep); if (error) return (error); *vpp = DETOV(ndep); @@ -988,7 +988,8 @@ msdosfs_fhtovp(struct mount *mp, struct fid *fhp, int flags, struct vnode **vpp) struct denode *dep; int error; - error = deget(pmp, defhp->defid_dirclust, defhp->defid_dirofs, &dep); + error = deget(pmp, defhp->defid_dirclust, defhp->defid_dirofs, + LK_EXCLUSIVE, &dep); if (error) { *vpp = NULLVP; return (error); diff --git a/usr.sbin/makefs/msdos/msdosfs_denode.c b/usr.sbin/makefs/msdos/msdosfs_denode.c index 48c305824793..3fbd867275d2 100644 --- a/usr.sbin/makefs/msdos/msdosfs_denode.c +++ b/usr.sbin/makefs/msdos/msdosfs_denode.c @@ -84,7 +84,7 @@ __FBSDID("$FreeBSD$"); */ int deget(struct msdosfsmount *pmp, u_long dirclust, u_long diroffset, - struct denode **depp) + int lkflags __unused, struct denode **depp) { int error; uint64_t inode; diff --git a/usr.sbin/makefs/msdos/msdosfs_lookup.c b/usr.sbin/makefs/msdos/msdosfs_lookup.c index a4db6ae1a4a2..fb2f4deceaf2 100644 --- a/usr.sbin/makefs/msdos/msdosfs_lookup.c +++ b/usr.sbin/makefs/msdos/msdosfs_lookup.c @@ -187,7 +187,7 @@ createde(struct denode *dep, struct denode *ddep, struct denode **depp, else diroffset = 0; } - return deget(pmp, dirclust, diroffset, depp); + return deget(pmp, dirclust, diroffset, 0, depp); } return 0; diff --git a/usr.sbin/makefs/msdos/msdosfs_vfsops.c b/usr.sbin/makefs/msdos/msdosfs_vfsops.c index dd933bb2be61..508e044ac1ca 100644 --- a/usr.sbin/makefs/msdos/msdosfs_vfsops.c +++ b/usr.sbin/makefs/msdos/msdosfs_vfsops.c @@ -349,7 +349,7 @@ msdosfs_root(struct msdosfsmount *pmp, struct m_vnode *vp) { int error; *vp = *(struct m_vnode *)pmp->pm_devvp; - if ((error = deget(pmp, MSDOSFSROOT, MSDOSFSROOT_OFS, &ndep)) != 0) { + if ((error = deget(pmp, MSDOSFSROOT, MSDOSFSROOT_OFS, 0, &ndep)) != 0) { errno = error; return -1; } From owner-dev-commits-src-main@freebsd.org Fri Aug 27 15:39:57 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9243B66232C; Fri, 27 Aug 2021 15:39:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gx3n91WX9z3vNp; Fri, 27 Aug 2021 15:39:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E7ED925C6F; Fri, 27 Aug 2021 15:39:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17RFdtEH089164; Fri, 27 Aug 2021 15:39:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RFdt88089163; Fri, 27 Aug 2021 15:39:55 GMT (envelope-from git) Date: Fri, 27 Aug 2021 15:39:55 GMT Message-Id: <202108271539.17RFdt88089163@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 95d42526e92c - main - msdosfs: fix rename MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 95d42526e92cb2a9842d71d3c585aabf32da7534 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 15:39:57 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=95d42526e92cb2a9842d71d3c585aabf32da7534 commit 95d42526e92cb2a9842d71d3c585aabf32da7534 Author: Konstantin Belousov AuthorDate: 2021-08-01 17:46:59 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-27 15:39:45 +0000 msdosfs: fix rename Use the same locking algorithm for msdosfs_rename() as used by ufs_rename(). Convert doscheckpath() to non-sleeping version. Reported by: trasz PR: 257522 In collaboration with: pho Reviewed by: mckusick Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D31464 --- sys/fs/msdosfs/denode.h | 5 +- sys/fs/msdosfs/msdosfs_denode.c | 1 + sys/fs/msdosfs/msdosfs_lookup.c | 79 ++++---- sys/fs/msdosfs/msdosfs_vnops.c | 430 +++++++++++++++++++++------------------- 4 files changed, 274 insertions(+), 241 deletions(-) diff --git a/sys/fs/msdosfs/denode.h b/sys/fs/msdosfs/denode.h index 80ebf250febf..67ffa522000a 100644 --- a/sys/fs/msdosfs/denode.h +++ b/sys/fs/msdosfs/denode.h @@ -268,7 +268,7 @@ int msdosfs_lookup(struct vop_cachedlookup_args *); int msdosfs_inactive(struct vop_inactive_args *); int msdosfs_reclaim(struct vop_reclaim_args *); int msdosfs_lookup_ino(struct vnode *vdp, struct vnode **vpp, - struct componentname *cnp, uint64_t *inum); + struct componentname *cnp, daddr_t *scnp, u_long *blkoffp); #endif /* @@ -288,6 +288,7 @@ int createde(struct denode *dep, struct denode *ddep, struct denode **depp, stru int deupdat(struct denode *dep, int waitfor); int removede(struct denode *pdep, struct denode *dep); int detrunc(struct denode *dep, u_long length, int flags, struct ucred *cred); -int doscheckpath( struct denode *source, struct denode *target); +int doscheckpath( struct denode *source, struct denode *target, + daddr_t *wait_scn); #endif /* _KERNEL || MAKEFS */ #endif /* !_FS_MSDOSFS_DENODE_H_ */ diff --git a/sys/fs/msdosfs/msdosfs_denode.c b/sys/fs/msdosfs/msdosfs_denode.c index d97e61f7932c..64f75c267959 100644 --- a/sys/fs/msdosfs/msdosfs_denode.c +++ b/sys/fs/msdosfs/msdosfs_denode.c @@ -167,6 +167,7 @@ deget(struct msdosfsmount *pmp, u_long dirclust, u_long diroffset, ldep->de_inode = inode; cluster_init_vn(&ldep->de_clusterw); lockmgr(nvp->v_vnlock, LK_EXCLUSIVE, NULL); + VN_LOCK_AREC(nvp); /* for doscheckpath */ fc_purge(ldep, 0); /* init the FAT cache for this denode */ error = insmntque(nvp, mntp); if (error != 0) { diff --git a/sys/fs/msdosfs/msdosfs_lookup.c b/sys/fs/msdosfs/msdosfs_lookup.c index d47f2969904b..2c3d02db37a0 100644 --- a/sys/fs/msdosfs/msdosfs_lookup.c +++ b/sys/fs/msdosfs/msdosfs_lookup.c @@ -67,7 +67,8 @@ int msdosfs_lookup(struct vop_cachedlookup_args *ap) { - return (msdosfs_lookup_ino(ap->a_dvp, ap->a_vpp, ap->a_cnp, NULL)); + return (msdosfs_lookup_ino(ap->a_dvp, ap->a_vpp, ap->a_cnp, NULL, + NULL)); } struct deget_dotdot { @@ -109,8 +110,8 @@ msdosfs_deget_dotdot(struct mount *mp, void *arg, int lkflags, * memory denode's will be in synch. */ int -msdosfs_lookup_ino(struct vnode *vdp, struct vnode **vpp, - struct componentname *cnp, uint64_t *dd_inum) +msdosfs_lookup_ino(struct vnode *vdp, struct vnode **vpp, struct componentname + *cnp, daddr_t *scnp, u_long *blkoffp) { struct mbnambuf nb; daddr_t bn; @@ -119,11 +120,11 @@ msdosfs_lookup_ino(struct vnode *vdp, struct vnode **vpp, int slotoffset = 0; int frcn; u_long cluster; - int blkoff; + u_long blkoff; int diroff; int blsize; int isadir; /* ~0 if found direntry is a directory */ - u_long scn; /* starting cluster number */ + daddr_t scn; /* starting cluster number */ struct vnode *pdp; struct denode *dp; struct denode *tdp; @@ -464,8 +465,9 @@ foundroot: if (FAT32(pmp) && scn == MSDOSFSROOT) scn = pmp->pm_rootdirblk; - if (dd_inum != NULL) { - *dd_inum = (uint64_t)pmp->pm_bpcluster * scn + blkoff; + if (scnp != NULL) { + *scnp = cluster; + *blkoffp = blkoff; return (0); } @@ -557,12 +559,15 @@ foundroot: * Recheck that ".." still points to the inode we * looked up before pdp lock was dropped. */ - error = msdosfs_lookup_ino(pdp, NULL, cnp, &inode1); + error = msdosfs_lookup_ino(pdp, NULL, cnp, &scn, &blkoff); if (error) { vput(*vpp); *vpp = NULL; return (error); } + if (FAT32(pmp) && scn == MSDOSFSROOT) + scn = pmp->pm_rootdirblk; + inode1 = scn * pmp->pm_bpcluster + blkoff; if (VTODE(*vpp)->de_inode != inode1) { vput(*vpp); goto restart; @@ -794,10 +799,9 @@ dosdirempty(struct denode *dep) * * Returns 0 if target is NOT a subdirectory of source. * Otherwise returns a non-zero error number. - * The target inode is always unlocked on return. */ int -doscheckpath(struct denode *source, struct denode *target) +doscheckpath(struct denode *source, struct denode *target, daddr_t *wait_scn) { daddr_t scn; struct msdosfsmount *pmp; @@ -806,26 +810,25 @@ doscheckpath(struct denode *source, struct denode *target) struct buf *bp = NULL; int error = 0; - dep = target; + *wait_scn = 0; + + pmp = target->de_pmp; + KASSERT(pmp == source->de_pmp, + ("doscheckpath: source and target on different filesystems")); + if ((target->de_Attributes & ATTR_DIRECTORY) == 0 || - (source->de_Attributes & ATTR_DIRECTORY) == 0) { - error = ENOTDIR; - goto out; - } - if (dep->de_StartCluster == source->de_StartCluster) { - error = EEXIST; - goto out; - } - if (dep->de_StartCluster == MSDOSFSROOT) - goto out; - pmp = dep->de_pmp; -#ifdef DIAGNOSTIC - if (pmp != source->de_pmp) - panic("doscheckpath: source and target on different filesystems"); -#endif - if (FAT32(pmp) && dep->de_StartCluster == pmp->pm_rootdirblk) - goto out; + (source->de_Attributes & ATTR_DIRECTORY) == 0) + return (ENOTDIR); + + if (target->de_StartCluster == source->de_StartCluster) + return (EEXIST); + + if (target->de_StartCluster == MSDOSFSROOT || + (FAT32(pmp) && target->de_StartCluster == pmp->pm_rootdirblk)) + return (0); + dep = target; + vget(DETOV(dep), LK_EXCLUSIVE); for (;;) { if ((dep->de_Attributes & ATTR_DIRECTORY) == 0) { error = ENOTDIR; @@ -833,19 +836,22 @@ doscheckpath(struct denode *source, struct denode *target) } scn = dep->de_StartCluster; error = bread(pmp->pm_devvp, cntobn(pmp, scn), - pmp->pm_bpcluster, NOCRED, &bp); - if (error) + pmp->pm_bpcluster, NOCRED, &bp); + if (error != 0) break; - ep = (struct direntry *) bp->b_data + 1; + ep = (struct direntry *)bp->b_data + 1; if ((ep->deAttributes & ATTR_DIRECTORY) == 0 || bcmp(ep->deName, ".. ", 11) != 0) { error = ENOTDIR; + brelse(bp); break; } + scn = getushort(ep->deStartCluster); if (FAT32(pmp)) scn |= getushort(ep->deHighClust) << 16; + brelse(bp); if (scn == source->de_StartCluster) { error = EINVAL; @@ -862,15 +868,14 @@ doscheckpath(struct denode *source, struct denode *target) } vput(DETOV(dep)); - brelse(bp); - bp = NULL; + dep = NULL; /* NOTE: deget() clears dep on error */ - if ((error = deget(pmp, scn, 0, LK_EXCLUSIVE, &dep)) != 0) + error = deget(pmp, scn, 0, LK_EXCLUSIVE | LK_NOWAIT, &dep); + if (error != 0) { + *wait_scn = scn; break; + } } -out:; - if (bp) - brelse(bp); #ifdef MSDOSFS_DEBUG if (error == ENOTDIR) printf("doscheckpath(): .. not a directory?\n"); diff --git a/sys/fs/msdosfs/msdosfs_vnops.c b/sys/fs/msdosfs/msdosfs_vnops.c index 5cd2c27cb46b..c81e192a6158 100644 --- a/sys/fs/msdosfs/msdosfs_vnops.c +++ b/sys/fs/msdosfs/msdosfs_vnops.c @@ -937,24 +937,27 @@ msdosfs_link(struct vop_link_args *ap) static int msdosfs_rename(struct vop_rename_args *ap) { - struct vnode *tdvp = ap->a_tdvp; - struct vnode *fvp = ap->a_fvp; - struct vnode *fdvp = ap->a_fdvp; - struct vnode *tvp = ap->a_tvp; - struct componentname *tcnp = ap->a_tcnp; - struct componentname *fcnp = ap->a_fcnp; - struct denode *ip, *xp, *dp, *zp; + struct vnode *fdvp, *fvp, *tdvp, *tvp, *vp; + struct componentname *fcnp, *tcnp; + struct denode *fdip, *fip, *tdip, *tip, *nip; u_char toname[12], oldname[11]; u_long from_diroffset, to_diroffset; + bool doingdirectory, newparent; u_char to_count; - int doingdirectory = 0, newparent = 0; int error; - u_long cn, pcl; - daddr_t bn; + u_long cn, pcl, blkoff; + daddr_t bn, wait_scn, scn; struct msdosfsmount *pmp; + struct mount *mp; struct direntry *dotdotp; struct buf *bp; + tdvp = ap->a_tdvp; + fvp = ap->a_fvp; + fdvp = ap->a_fdvp; + tvp = ap->a_tvp; + tcnp = ap->a_tcnp; + fcnp = ap->a_fcnp; pmp = VFSTOMSDOSFS(fdvp->v_mount); #ifdef DIAGNOSTIC @@ -965,19 +968,11 @@ msdosfs_rename(struct vop_rename_args *ap) /* * Check for cross-device rename. */ + mp = fvp->v_mount; if (fvp->v_mount != tdvp->v_mount || - (tvp && fvp->v_mount != tvp->v_mount)) { + (tvp != NULL && fvp->v_mount != tvp->v_mount)) { error = EXDEV; -abortit: - if (tdvp == tvp) - vrele(tdvp); - else - vput(tdvp); - if (tvp) - vput(tvp); - vrele(fdvp); - vrele(fvp); - return (error); + goto abortit; } /* @@ -988,11 +983,99 @@ abortit: goto abortit; } - error = vn_lock(fvp, LK_EXCLUSIVE); - if (error) - goto abortit; - dp = VTODE(fdvp); - ip = VTODE(fvp); + /* + * When the target exists, both the directory + * and target vnodes are passed locked. + */ + VOP_UNLOCK(tdvp); + if (tvp != NULL && tvp != tdvp) + VOP_UNLOCK(tvp); + +relock: + doingdirectory = newparent = false; + + error = vn_lock(fdvp, LK_EXCLUSIVE); + if (error != 0) + goto releout; + if (vn_lock(tdvp, LK_EXCLUSIVE | LK_NOWAIT) != 0) { + VOP_UNLOCK(fdvp); + error = vn_lock(tdvp, LK_EXCLUSIVE); + if (error != 0) + goto releout; + VOP_UNLOCK(tdvp); + goto relock; + } + + error = msdosfs_lookup_ino(fdvp, NULL, fcnp, &scn, &blkoff); + if (error != 0) { + VOP_UNLOCK(fdvp); + VOP_UNLOCK(tdvp); + goto releout; + } + error = deget(pmp, scn, blkoff, LK_EXCLUSIVE | LK_NOWAIT, &nip); + if (error != 0) { + VOP_UNLOCK(fdvp); + VOP_UNLOCK(tdvp); + if (error != EBUSY) + goto releout; + error = deget(pmp, scn, blkoff, LK_EXCLUSIVE, &nip); + if (error != 0) + goto releout; + vp = fvp; + fvp = DETOV(nip); + VOP_UNLOCK(fvp); + vrele(vp); + goto relock; + } + vrele(fvp); + fvp = DETOV(nip); + from_diroffset = fdip->de_fndoffset; + + error = msdosfs_lookup_ino(tdvp, NULL, tcnp, &scn, &blkoff); + if (error != 0 && error != EJUSTRETURN) { + VOP_UNLOCK(fdvp); + VOP_UNLOCK(tdvp); + VOP_UNLOCK(fvp); + goto releout; + } + if (error == EJUSTRETURN && tvp != NULL) { + vrele(tvp); + tvp = NULL; + } + if (error == 0) { + nip = NULL; + error = deget(pmp, scn, blkoff, LK_EXCLUSIVE | LK_NOWAIT, + &nip); + if (tvp != NULL) { + vrele(tvp); + tvp = NULL; + } + if (error != 0) { + VOP_UNLOCK(fdvp); + VOP_UNLOCK(tdvp); + VOP_UNLOCK(fvp); + if (error != EBUSY) + goto releout; + error = deget(pmp, scn, blkoff, LK_EXCLUSIVE, + &nip); + if (error != 0) + goto releout; + vput(DETOV(nip)); + goto relock; + } + tvp = DETOV(nip); + } + + fdip = VTODE(fdvp); + fip = VTODE(fvp); + tdip = VTODE(tdvp); + tip = tvp != NULL ? VTODE(tvp) : NULL; + + /* + * Remember direntry place to use for destination + */ + to_diroffset = tdip->de_fndoffset; + to_count = tdip->de_fndcnt; /* * Be sure we are not renaming ".", "..", or an alias of ".". This @@ -1000,35 +1083,20 @@ abortit: * "ls" or "pwd" with the "." directory entry missing, and "cd .." * doesn't work if the ".." entry is missing. */ - if (ip->de_Attributes & ATTR_DIRECTORY) { + if ((fip->de_Attributes & ATTR_DIRECTORY) != 0) { /* * Avoid ".", "..", and aliases of "." for obvious reasons. */ if ((fcnp->cn_namelen == 1 && fcnp->cn_nameptr[0] == '.') || - dp == ip || - (fcnp->cn_flags & ISDOTDOT) || - (tcnp->cn_flags & ISDOTDOT) || - (ip->de_flag & DE_RENAME)) { - VOP_UNLOCK(fvp); + fdip == fip || + (fcnp->cn_flags & ISDOTDOT) != 0 || + (tcnp->cn_flags & ISDOTDOT) != 0) { error = EINVAL; - goto abortit; + goto unlock; } - ip->de_flag |= DE_RENAME; - doingdirectory++; + doingdirectory = true; } - /* - * When the target exists, both the directory - * and target vnodes are returned locked. - */ - dp = VTODE(tdvp); - xp = tvp ? VTODE(tvp) : NULL; - /* - * Remember direntry place to use for destination - */ - to_diroffset = dp->de_fndoffset; - to_count = dp->de_fndcnt; - /* * If ".." must be changed (ie the directory gets a new * parent) then the source directory must not be in the @@ -1040,55 +1108,59 @@ abortit: * call to doscheckpath(). */ error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred, tcnp->cn_thread); - VOP_UNLOCK(fvp); - if (VTODE(fdvp)->de_StartCluster != VTODE(tdvp)->de_StartCluster) - newparent = 1; + if (fdip->de_StartCluster != tdip->de_StartCluster) + newparent = true; if (doingdirectory && newparent) { - if (error) /* write access check above */ - goto bad; - if (xp != NULL) - vput(tvp); - /* - * doscheckpath() vput()'s dp, - * so we have to do a relookup afterwards - */ - error = doscheckpath(ip, dp); - if (error) - goto out; + if (error != 0) /* write access check above */ + goto unlock; + error = doscheckpath(fip, tdip, &wait_scn); + if (wait_scn != 0) { + VOP_UNLOCK(fdvp); + VOP_UNLOCK(tdvp); + VOP_UNLOCK(fvp); + if (tvp != NULL && tvp != tdvp) + VOP_UNLOCK(tvp); + error = deget(pmp, wait_scn, 0, LK_EXCLUSIVE, + &nip); + if (error == 0) { + vput(DETOV(nip)); + goto relock; + } + } + if (error != 0) + goto unlock; if ((tcnp->cn_flags & SAVESTART) == 0) panic("msdosfs_rename: lost to startdir"); - error = relookup(tdvp, &tvp, tcnp); - if (error) - goto out; - dp = VTODE(tdvp); - xp = tvp ? VTODE(tvp) : NULL; } - if (xp != NULL) { + if (tip != NULL) { /* * Target must be empty if a directory and have no links * to it. Also, ensure source and target are compatible * (both directories, or both not directories). */ - if (xp->de_Attributes & ATTR_DIRECTORY) { - if (!dosdirempty(xp)) { + if ((tip->de_Attributes & ATTR_DIRECTORY) != 0) { + if (!dosdirempty(tip)) { error = ENOTEMPTY; - goto bad; + goto unlock; } if (!doingdirectory) { error = ENOTDIR; - goto bad; + goto unlock; } cache_purge(tdvp); } else if (doingdirectory) { error = EISDIR; - goto bad; + goto unlock; } - error = removede(dp, xp); - if (error) - goto bad; + error = msdosfs_lookup_ino(tdvp, NULL, tcnp, &scn, &blkoff); + MPASS(error == 0); + error = removede(tdip, tip); + if (error != 0) + goto unlock; vput(tvp); - xp = NULL; + tvp = NULL; + tip = NULL; } /* @@ -1096,146 +1168,83 @@ abortit: * into the denode and directory entry for the destination * file/directory. */ - error = uniqdosname(VTODE(tdvp), tcnp, toname); - if (error) - goto abortit; + error = uniqdosname(tdip, tcnp, toname); + if (error != 0) + goto unlock; /* - * Since from wasn't locked at various places above, - * have to do a relookup here. + * First write a new entry in the destination + * directory and mark the entry in the source directory + * as deleted. Then move the denode to the correct hash + * chain for its new location in the filesystem. And, if + * we moved a directory, then update its .. entry to point + * to the new parent directory. */ - fcnp->cn_flags &= ~MODMASK; - fcnp->cn_flags |= LOCKPARENT | LOCKLEAF; - if ((fcnp->cn_flags & SAVESTART) == 0) - panic("msdosfs_rename: lost from startdir"); - if (!newparent) - VOP_UNLOCK(tdvp); - if (relookup(fdvp, &fvp, fcnp) == 0) - vrele(fdvp); - if (fvp == NULL) { - /* - * From name has disappeared. - */ - if (doingdirectory) - panic("rename: lost dir entry"); - if (newparent) - VOP_UNLOCK(tdvp); - vrele(tdvp); - vrele(ap->a_fvp); - /* - * fdvp may be locked and has a reference. We need to - * release the lock and reference, unless to and from - * directories are the same. In that case it is already - * unlocked. - */ - if (tdvp != fdvp) - vput(fdvp); - return 0; + memcpy(oldname, fip->de_Name, 11); + memcpy(fip->de_Name, toname, 11); /* update denode */ + error = msdosfs_lookup_ino(tdvp, NULL, tcnp, &scn, &blkoff); + MPASS(error == EJUSTRETURN); + error = createde(fip, tdip, NULL, tcnp); + if (error != 0) { + memcpy(fip->de_Name, oldname, 11); + goto unlock; } - xp = VTODE(fvp); - zp = VTODE(fdvp); - from_diroffset = zp->de_fndoffset; /* - * Ensure that the directory entry still exists and has not - * changed till now. If the source is a file the entry may - * have been unlinked or renamed. In either case there is - * no further work to be done. If the source is a directory - * then it cannot have been rmdir'ed or renamed; this is - * prohibited by the DE_RENAME flag. + * If fip is for a directory, then its name should always + * be "." since it is for the directory entry in the + * directory itself (msdosfs_lookup() always translates + * to the "." entry so as to get a unique denode, except + * for the root directory there are different + * complications). However, we just corrupted its name + * to pass the correct name to createde(). Undo this. */ - if (xp != ip) { - if (doingdirectory) - panic("rename: lost dir entry"); - if (newparent) - VOP_UNLOCK(fdvp); - vrele(ap->a_fvp); - xp = NULL; - } else { - vrele(fvp); - xp = NULL; - - /* - * First write a new entry in the destination - * directory and mark the entry in the source directory - * as deleted. Then move the denode to the correct hash - * chain for its new location in the filesystem. And, if - * we moved a directory, then update its .. entry to point - * to the new parent directory. - */ - memcpy(oldname, ip->de_Name, 11); - memcpy(ip->de_Name, toname, 11); /* update denode */ - dp->de_fndoffset = to_diroffset; - dp->de_fndcnt = to_count; - error = createde(ip, dp, (struct denode **)0, tcnp); - if (error) { - memcpy(ip->de_Name, oldname, 11); - if (newparent) - VOP_UNLOCK(fdvp); - VOP_UNLOCK(fvp); - goto bad; - } - /* - * If ip is for a directory, then its name should always - * be "." since it is for the directory entry in the - * directory itself (msdosfs_lookup() always translates - * to the "." entry so as to get a unique denode, except - * for the root directory there are different - * complications). However, we just corrupted its name - * to pass the correct name to createde(). Undo this. - */ - if ((ip->de_Attributes & ATTR_DIRECTORY) != 0) - memcpy(ip->de_Name, oldname, 11); - ip->de_refcnt++; - zp->de_fndoffset = from_diroffset; - error = removede(zp, ip); - if (error) { - /* XXX should downgrade to ro here, fs is corrupt */ - if (newparent) - VOP_UNLOCK(fdvp); - VOP_UNLOCK(fvp); - goto bad; - } - if (!doingdirectory) { - error = pcbmap(dp, de_cluster(pmp, to_diroffset), 0, - &ip->de_dirclust, 0); - if (error) { - /* XXX should downgrade to ro here, fs is corrupt */ - if (newparent) - VOP_UNLOCK(fdvp); - VOP_UNLOCK(fvp); - goto bad; - } - if (ip->de_dirclust == MSDOSFSROOT) - ip->de_diroffset = to_diroffset; - else - ip->de_diroffset = to_diroffset & pmp->pm_crbomask; + if ((fip->de_Attributes & ATTR_DIRECTORY) != 0) + memcpy(fip->de_Name, oldname, 11); + fip->de_refcnt++; + error = msdosfs_lookup_ino(fdvp, NULL, fcnp, &scn, &blkoff); + MPASS(error == 0); + error = removede(fdip, fip); + if (error != 0) { + /* XXX should downgrade to ro here, fs is corrupt */ + goto unlock; + } + if (!doingdirectory) { + error = pcbmap(tdip, de_cluster(pmp, to_diroffset), 0, + &fip->de_dirclust, 0); + if (error != 0) { + /* + * XXX should downgrade to ro here, + * fs is corrupt + */ + goto unlock; } - reinsert(ip); - if (newparent) - VOP_UNLOCK(fdvp); + if (fip->de_dirclust == MSDOSFSROOT) + fip->de_diroffset = to_diroffset; + else + fip->de_diroffset = to_diroffset & pmp->pm_crbomask; } + reinsert(fip); /* * If we moved a directory to a new parent directory, then we must * fixup the ".." entry in the moved directory. */ if (doingdirectory && newparent) { - cn = ip->de_StartCluster; + cn = fip->de_StartCluster; if (cn == MSDOSFSROOT) { /* this should never happen */ panic("msdosfs_rename(): updating .. in root directory?"); } else bn = cntobn(pmp, cn); error = bread(pmp->pm_devvp, bn, pmp->pm_bpcluster, - NOCRED, &bp); - if (error) { + NOCRED, &bp); + if (error != 0) { /* XXX should downgrade to ro here, fs is corrupt */ - VOP_UNLOCK(fvp); - goto bad; + goto unlock; } dotdotp = (struct direntry *)bp->b_data + 1; - pcl = dp->de_StartCluster; + pcl = tdip->de_StartCluster; if (FAT32(pmp) && pcl == pmp->pm_rootdirblk) pcl = MSDOSFSROOT; putushort(dotdotp->deStartCluster, pcl); @@ -1245,8 +1254,7 @@ abortit: bdwrite(bp); else if ((error = bwrite(bp)) != 0) { /* XXX should downgrade to ro here, fs is corrupt */ - VOP_UNLOCK(fvp); - goto bad; + goto unlock; } } @@ -1258,17 +1266,35 @@ abortit: * namecache entries that were installed for this direntry. */ cache_purge(fvp); - VOP_UNLOCK(fvp); -bad: - if (xp) - vput(tvp); + +unlock: + vput(fdvp); + vput(fvp); + if (tvp != NULL) { + if (tvp != tdvp) + vput(tvp); + else + vrele(tvp); + } vput(tdvp); -out: - ip->de_flag &= ~DE_RENAME; + return (error); +releout: + vrele(tdvp); + if (tvp != NULL) + vrele(tvp); + vrele(fdvp); + vrele(fvp); + return (error); +abortit: + if (tdvp == tvp) + vrele(tdvp); + else + vput(tdvp); + if (tvp != NULL) + vput(tvp); vrele(fdvp); vrele(fvp); return (error); - } static struct { @@ -1428,7 +1454,7 @@ msdosfs_rmdir(struct vop_rmdir_args *ap) * non-empty.) */ error = 0; - if (!dosdirempty(ip) || ip->de_flag & DE_RENAME) { + if (!dosdirempty(ip)) { error = ENOTEMPTY; goto out; } From owner-dev-commits-src-main@freebsd.org Fri Aug 27 15:39:58 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F39F866237C; Fri, 27 Aug 2021 15:39:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gx3n94t0dz3vWS; Fri, 27 Aug 2021 15:39:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3AB3625F02; Fri, 27 Aug 2021 15:39:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17RFduoX089189; Fri, 27 Aug 2021 15:39:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RFdu5v089188; Fri, 27 Aug 2021 15:39:56 GMT (envelope-from git) Date: Fri, 27 Aug 2021 15:39:56 GMT Message-Id: <202108271539.17RFdu5v089188@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 6ae13c0feb96 - main - msdosfs: add doscheckpath lock MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6ae13c0feb96a1ea97e814213271b41b3d090d2d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 15:39:58 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=6ae13c0feb96a1ea97e814213271b41b3d090d2d commit 6ae13c0feb96a1ea97e814213271b41b3d090d2d Author: Konstantin Belousov AuthorDate: 2021-08-07 20:18:26 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-27 15:39:45 +0000 msdosfs: add doscheckpath lock Similar to the UFS revision 8df4bc48c89a130207 Reviewed by: mckusick Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D31464 --- sys/fs/msdosfs/msdosfs_lookup.c | 1 + sys/fs/msdosfs/msdosfs_vfsops.c | 3 +++ sys/fs/msdosfs/msdosfs_vnops.c | 11 ++++++++++- sys/fs/msdosfs/msdosfsmount.h | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/sys/fs/msdosfs/msdosfs_lookup.c b/sys/fs/msdosfs/msdosfs_lookup.c index 2c3d02db37a0..9940800a72c2 100644 --- a/sys/fs/msdosfs/msdosfs_lookup.c +++ b/sys/fs/msdosfs/msdosfs_lookup.c @@ -813,6 +813,7 @@ doscheckpath(struct denode *source, struct denode *target, daddr_t *wait_scn) *wait_scn = 0; pmp = target->de_pmp; + lockmgr_assert(&pmp->pm_checkpath_lock, KA_XLOCKED); KASSERT(pmp == source->de_pmp, ("doscheckpath: source and target on different filesystems")); diff --git a/sys/fs/msdosfs/msdosfs_vfsops.c b/sys/fs/msdosfs/msdosfs_vfsops.c index 68c8a93a18af..0f6d41b3c77c 100644 --- a/sys/fs/msdosfs/msdosfs_vfsops.c +++ b/sys/fs/msdosfs/msdosfs_vfsops.c @@ -469,6 +469,7 @@ mountmsdosfs(struct vnode *devvp, struct mount *mp) pmp->pm_bo = bo; lockinit(&pmp->pm_fatlock, 0, msdosfs_lock_msg, 0, 0); + lockinit(&pmp->pm_checkpath_lock, 0, "msdoscp", 0, 0); /* * Initialize ownerships and permissions, since nothing else will @@ -740,6 +741,7 @@ error_exit: } if (pmp) { lockdestroy(&pmp->pm_fatlock); + lockdestroy(&pmp->pm_checkpath_lock); free(pmp->pm_inusemap, M_MSDOSFSFAT); free(pmp, M_MSDOSFSMNT); mp->mnt_data = NULL; @@ -829,6 +831,7 @@ msdosfs_unmount(struct mount *mp, int mntflags) dev_rel(pmp->pm_dev); free(pmp->pm_inusemap, M_MSDOSFSFAT); lockdestroy(&pmp->pm_fatlock); + lockdestroy(&pmp->pm_checkpath_lock); free(pmp, M_MSDOSFSMNT); mp->mnt_data = NULL; MNT_ILOCK(mp); diff --git a/sys/fs/msdosfs/msdosfs_vnops.c b/sys/fs/msdosfs/msdosfs_vnops.c index c81e192a6158..6197340e8943 100644 --- a/sys/fs/msdosfs/msdosfs_vnops.c +++ b/sys/fs/msdosfs/msdosfs_vnops.c @@ -942,7 +942,7 @@ msdosfs_rename(struct vop_rename_args *ap) struct denode *fdip, *fip, *tdip, *tip, *nip; u_char toname[12], oldname[11]; u_long from_diroffset, to_diroffset; - bool doingdirectory, newparent; + bool checkpath_locked, doingdirectory, newparent; u_char to_count; int error; u_long cn, pcl, blkoff; @@ -991,6 +991,8 @@ msdosfs_rename(struct vop_rename_args *ap) if (tvp != NULL && tvp != tdvp) VOP_UNLOCK(tvp); + checkpath_locked = false; + relock: doingdirectory = newparent = false; @@ -1113,8 +1115,12 @@ relock: if (doingdirectory && newparent) { if (error != 0) /* write access check above */ goto unlock; + lockmgr(&pmp->pm_checkpath_lock, LK_EXCLUSIVE, NULL); + checkpath_locked = true; error = doscheckpath(fip, tdip, &wait_scn); if (wait_scn != 0) { + lockmgr(&pmp->pm_checkpath_lock, LK_RELEASE, NULL); + checkpath_locked = false; VOP_UNLOCK(fdvp); VOP_UNLOCK(tdvp); VOP_UNLOCK(fvp); @@ -1268,6 +1274,8 @@ relock: cache_purge(fvp); unlock: + if (checkpath_locked) + lockmgr(&pmp->pm_checkpath_lock, LK_RELEASE, NULL); vput(fdvp); vput(fvp); if (tvp != NULL) { @@ -1279,6 +1287,7 @@ unlock: vput(tdvp); return (error); releout: + MPASS(!checkpath_locked); vrele(tdvp); if (tvp != NULL) vrele(tvp); diff --git a/sys/fs/msdosfs/msdosfsmount.h b/sys/fs/msdosfs/msdosfsmount.h index 75b187860270..46a02e611cf5 100644 --- a/sys/fs/msdosfs/msdosfsmount.h +++ b/sys/fs/msdosfs/msdosfsmount.h @@ -114,6 +114,7 @@ struct msdosfsmount { void *pm_d2u; /* DOS->Local iconv handle */ #ifndef MAKEFS struct lock pm_fatlock; /* lockmgr protecting allocations */ + struct lock pm_checkpath_lock; /* protects doscheckpath result */ #endif }; From owner-dev-commits-src-main@freebsd.org Fri Aug 27 15:40:01 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 613E066253C; Fri, 27 Aug 2021 15:40:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gx3nD6rJhz3vRf; Fri, 27 Aug 2021 15:40:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 765AF25CCE; Fri, 27 Aug 2021 15:40:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17RFe0J0089636; Fri, 27 Aug 2021 15:40:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RFe0RG089623; Fri, 27 Aug 2021 15:40:00 GMT (envelope-from git) Date: Fri, 27 Aug 2021 15:40:00 GMT Message-Id: <202108271540.17RFe0RG089623@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: f19063ab029b - main - vfs_hash_rehash(): require the vnode to be exclusively locked MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f19063ab029b067e1763780aebca4bd620453110 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 15:40:01 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=f19063ab029b067e1763780aebca4bd620453110 commit f19063ab029b067e1763780aebca4bd620453110 Author: Konstantin Belousov AuthorDate: 2021-08-18 11:14:42 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-27 15:39:45 +0000 vfs_hash_rehash(): require the vnode to be exclusively locked Rehash updates v_hash. Also, rehash moves the vnode to different hash bucket, which should be noticed in vfs_hash_get() after sleeping for the vnode lock. Reviewed by: mckusick, rmacklem Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D31464 --- sys/kern/vfs_hash.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/kern/vfs_hash.c b/sys/kern/vfs_hash.c index c5d67c8b2b33..2e446e69a314 100644 --- a/sys/kern/vfs_hash.c +++ b/sys/kern/vfs_hash.c @@ -196,6 +196,7 @@ vfs_hash_insert(struct vnode *vp, u_int hash, int flags, struct thread *td, void vfs_hash_rehash(struct vnode *vp, u_int hash) { + ASSERT_VOP_ELOCKED(vp, "rehash requires excl lock"); rw_wlock(&vfs_hash_lock); LIST_REMOVE(vp, v_hashlist); From owner-dev-commits-src-main@freebsd.org Fri Aug 27 15:40:00 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 23C25662809; Fri, 27 Aug 2021 15:40:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gx3nB6GqYz3vZ0; Fri, 27 Aug 2021 15:39:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 434322557B; Fri, 27 Aug 2021 15:39:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17RFdweA089213; Fri, 27 Aug 2021 15:39:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RFdwMY089212; Fri, 27 Aug 2021 15:39:58 GMT (envelope-from git) Date: Fri, 27 Aug 2021 15:39:58 GMT Message-Id: <202108271539.17RFdwMY089212@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 85fb840ebf3c - main - msdosfs: drop now unused DE_RENAME MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 85fb840ebf3c213e45939188303bd5fe0aca4422 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 15:40:00 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=85fb840ebf3c213e45939188303bd5fe0aca4422 commit 85fb840ebf3c213e45939188303bd5fe0aca4422 Author: Konstantin Belousov AuthorDate: 2021-08-07 20:21:27 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-27 15:39:45 +0000 msdosfs: drop now unused DE_RENAME Submitted by: trasz Reviewed by: mckusick Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D31464 --- sys/fs/msdosfs/denode.h | 1 - 1 file changed, 1 deletion(-) diff --git a/sys/fs/msdosfs/denode.h b/sys/fs/msdosfs/denode.h index 67ffa522000a..c8e2dd09e697 100644 --- a/sys/fs/msdosfs/denode.h +++ b/sys/fs/msdosfs/denode.h @@ -173,7 +173,6 @@ struct denode { #define DE_CREATE 0x0008 /* Creation time update */ #define DE_ACCESS 0x0010 /* Access time update */ #define DE_MODIFIED 0x0020 /* Denode has been modified */ -#define DE_RENAME 0x0040 /* Denode is in the process of being renamed */ /* Maximum size of a file on a FAT filesystem */ #define MSDOSFS_FILESIZE_MAX 0xFFFFFFFFLL From owner-dev-commits-src-main@freebsd.org Fri Aug 27 15:40:00 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9B588662782; Fri, 27 Aug 2021 15:40:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gx3nC5xgzz3vZ2; Fri, 27 Aug 2021 15:39:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6210225BD4; Fri, 27 Aug 2021 15:39:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17RFdxMf089237; Fri, 27 Aug 2021 15:39:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RFdxfP089236; Fri, 27 Aug 2021 15:39:59 GMT (envelope-from git) Date: Fri, 27 Aug 2021 15:39:59 GMT Message-Id: <202108271539.17RFdxfP089236@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 7c1e4aab7934 - main - vfs_hash_insert: ensure that predicate is true MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7c1e4aab7934933f0669c2b922976b30ed628a3f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 15:40:01 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=7c1e4aab7934933f0669c2b922976b30ed628a3f commit 7c1e4aab7934933f0669c2b922976b30ed628a3f Author: Konstantin Belousov AuthorDate: 2021-08-17 13:47:25 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-27 15:39:45 +0000 vfs_hash_insert: ensure that predicate is true After vnode lock, recheck v_hash. When vfs_hash_insert() is used with a predicate, recheck it after the selected vnode is locked. Since vfs_hash_lock is dropped, vnode could be rehashed during the sleep for the vnode lock, which could go unnoticed there. Reported and tested by: pho Reviewed by: mckusick, rmacklem Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D31464 --- sys/kern/vfs_hash.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sys/kern/vfs_hash.c b/sys/kern/vfs_hash.c index e10e9b57e316..c5d67c8b2b33 100644 --- a/sys/kern/vfs_hash.c +++ b/sys/kern/vfs_hash.c @@ -93,8 +93,14 @@ vfs_hash_get(const struct mount *mp, u_int hash, int flags, struct thread *td, error = vget_finish(vp, flags, vs); if (error == ENOENT && (flags & LK_NOWAIT) == 0) break; - if (error) + if (error != 0) return (error); + if (vp->v_hash != hash || + (fn != NULL && fn(vp, arg))) { + vput(vp); + /* Restart the bucket walk. */ + break; + } *vpp = vp; return (0); } From owner-dev-commits-src-main@freebsd.org Fri Aug 27 16:49:43 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B8CA066388E; Fri, 27 Aug 2021 16:49:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gx5Kg4R74z4t82; Fri, 27 Aug 2021 16:49:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8023F26CE5; Fri, 27 Aug 2021 16:49:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17RGnh4e082263; Fri, 27 Aug 2021 16:49:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RGnhMa082262; Fri, 27 Aug 2021 16:49:43 GMT (envelope-from git) Date: Fri, 27 Aug 2021 16:49:43 GMT Message-Id: <202108271649.17RGnhMa082262@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: b850806921a7 - main - Restore the definition of EFI_STAGING_SIZE MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b850806921a735f3f307bc4b2634c7e9008f5a9c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 16:49:43 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=b850806921a735f3f307bc4b2634c7e9008f5a9c commit b850806921a735f3f307bc4b2634c7e9008f5a9c Author: Konstantin Belousov AuthorDate: 2021-08-26 19:32:42 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-27 16:48:53 +0000 Restore the definition of EFI_STAGING_SIZE The definition can be overridden by users, and before f75caed644a5c it was in MBs. Make the symbol' unit MB, to be compatible with users customizations. Reported and tested by: Harry Schmalzbauer Sponsored by: The FreeBSD Foundation MFC after: 1 week --- stand/efi/loader/copy.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stand/efi/loader/copy.c b/stand/efi/loader/copy.c index ba5da28aee92..65f595c12b11 100644 --- a/stand/efi/loader/copy.c +++ b/stand/efi/loader/copy.c @@ -180,9 +180,9 @@ out: #ifndef EFI_STAGING_SIZE #if defined(__arm__) -#define EFI_STAGING_SIZE M(32) +#define EFI_STAGING_SIZE 32 #else -#define EFI_STAGING_SIZE M(64) +#define EFI_STAGING_SIZE 64 #endif #endif @@ -315,7 +315,7 @@ efi_copy_init(void) EFI_STATUS status; unsigned long nr_pages; - nr_pages = EFI_SIZE_TO_PAGES((EFI_STAGING_SIZE)); + nr_pages = EFI_SIZE_TO_PAGES(M(1) * (EFI_STAGING_SIZE)); #if defined(__i386__) || defined(__amd64__) /* From owner-dev-commits-src-main@freebsd.org Fri Aug 27 16:49:45 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D6E04663155; Fri, 27 Aug 2021 16:49:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gx5Kh5Nv8z4tDs; Fri, 27 Aug 2021 16:49:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A18C42675F; Fri, 27 Aug 2021 16:49:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17RGniwW082287; Fri, 27 Aug 2021 16:49:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RGnivU082286; Fri, 27 Aug 2021 16:49:44 GMT (envelope-from git) Date: Fri, 27 Aug 2021 16:49:44 GMT Message-Id: <202108271649.17RGnivU082286@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: b54eec836660 - main - efi loader: disallow user to configure staging area size less than default MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b54eec8366605d9c2303277cf2ab4b605289910a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 16:49:45 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=b54eec8366605d9c2303277cf2ab4b605289910a commit b54eec8366605d9c2303277cf2ab4b605289910a Author: Konstantin Belousov AuthorDate: 2021-08-26 21:46:48 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-27 16:49:01 +0000 efi loader: disallow user to configure staging area size less than default We need to round it up to 2M, for instance. Having staging area too small might cause the first resize to use negative size for memmove()/memcpy(), which kills loader. Tested by: Harry Schmalzbauer Sponsored by: The FreeBSD Foundation MFC after: 1 week --- stand/efi/loader/copy.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/stand/efi/loader/copy.c b/stand/efi/loader/copy.c index 65f595c12b11..2552ae86d966 100644 --- a/stand/efi/loader/copy.c +++ b/stand/efi/loader/copy.c @@ -178,12 +178,13 @@ out: } #endif /* __i386__ || __amd64__ */ -#ifndef EFI_STAGING_SIZE #if defined(__arm__) -#define EFI_STAGING_SIZE 32 +#define DEFAULT_EFI_STAGING_SIZE 32 #else -#define EFI_STAGING_SIZE 64 +#define DEFAULT_EFI_STAGING_SIZE 64 #endif +#ifndef EFI_STAGING_SIZE +#define EFI_STAGING_SIZE DEFAULT_EFI_STAGING_SIZE #endif #if defined(__aarch64__) || defined(__amd64__) || defined(__arm__) || \ @@ -314,8 +315,12 @@ efi_copy_init(void) { EFI_STATUS status; unsigned long nr_pages; + vm_offset_t ess; - nr_pages = EFI_SIZE_TO_PAGES(M(1) * (EFI_STAGING_SIZE)); + ess = EFI_STAGING_SIZE; + if (ess < DEFAULT_EFI_STAGING_SIZE) + ess = DEFAULT_EFI_STAGING_SIZE; + nr_pages = EFI_SIZE_TO_PAGES(M(1) * ess); #if defined(__i386__) || defined(__amd64__) /* From owner-dev-commits-src-main@freebsd.org Fri Aug 27 17:09:10 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0A82B663FAB; Fri, 27 Aug 2021 17:09:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gx5m56jsdz3Gq1; Fri, 27 Aug 2021 17:09:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CEDB926EFF; Fri, 27 Aug 2021 17:09:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17RH99nc009618; Fri, 27 Aug 2021 17:09:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RH99T3009617; Fri, 27 Aug 2021 17:09:09 GMT (envelope-from git) Date: Fri, 27 Aug 2021 17:09:09 GMT Message-Id: <202108271709.17RH99T3009617@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Stephen J. Kiernan" Subject: git: fd80208a5f92 - main - Add SDT probes virtqueue::enqueue_segments:{entry, return} MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: stevek X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fd80208a5f92a60381d7bb7b5225bcdc38ab6fd5 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 17:09:10 -0000 The branch main has been updated by stevek: URL: https://cgit.FreeBSD.org/src/commit/?id=fd80208a5f92a60381d7bb7b5225bcdc38ab6fd5 commit fd80208a5f92a60381d7bb7b5225bcdc38ab6fd5 Author: Stephen J. Kiernan AuthorDate: 2021-08-27 17:08:59 +0000 Commit: Stephen J. Kiernan CommitDate: 2021-08-27 17:08:59 +0000 Add SDT probes virtqueue::enqueue_segments:{entry,return} This allows one to be able to map the sglist entries passed into the vq_ring_enqueue_segments() function to the segment indexes used in the virtqueue. This function normally gets inlined and may not available via FBT probes. Differential Revision: https://reviews.freebsd.org/D31620 --- sys/dev/virtio/virtqueue.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sys/dev/virtio/virtqueue.c b/sys/dev/virtio/virtqueue.c index 14c2088b70a8..59aefb31d9ac 100644 --- a/sys/dev/virtio/virtqueue.c +++ b/sys/dev/virtio/virtqueue.c @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -137,6 +138,11 @@ static int vq_ring_must_notify_host(struct virtqueue *); static void vq_ring_notify_host(struct virtqueue *); static void vq_ring_free_chain(struct virtqueue *, uint16_t); +SDT_PROVIDER_DEFINE(virtqueue); +SDT_PROBE_DEFINE6(virtqueue, , enqueue_segments, entry, "struct virtqueue *", + "struct vring_desc *", "uint16_t", "struct sglist *", "int", "int"); +SDT_PROBE_DEFINE1(virtqueue, , enqueue_segments, return, "uint16_t"); + #define vq_modern(_vq) (((_vq)->vq_flags & VIRTQUEUE_FLAG_MODERN) != 0) #define vq_htog16(_vq, _val) virtio_htog16(vq_modern(_vq), _val) #define vq_htog32(_vq, _val) virtio_htog32(vq_modern(_vq), _val) @@ -703,6 +709,9 @@ vq_ring_enqueue_segments(struct virtqueue *vq, struct vring_desc *desc, int i, needed; uint16_t idx; + SDT_PROBE6(virtqueue, , enqueue_segments, entry, vq, desc, head_idx, + sg, readable, writable); + needed = readable + writable; for (i = 0, idx = head_idx, seg = sg->sg_segs; @@ -722,6 +731,7 @@ vq_ring_enqueue_segments(struct virtqueue *vq, struct vring_desc *desc, dp->flags |= vq_gtoh16(vq, VRING_DESC_F_WRITE); } + SDT_PROBE1(virtqueue, , enqueue_segments, return, idx); return (idx); } From owner-dev-commits-src-main@freebsd.org Fri Aug 27 17:47:11 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F0A926644D2; Fri, 27 Aug 2021 17:47:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gx6bz5QLnz3R1S; Fri, 27 Aug 2021 17:47:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8EDEB2792C; Fri, 27 Aug 2021 17:47:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17RHlBh5061970; Fri, 27 Aug 2021 17:47:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RHlBwD061969; Fri, 27 Aug 2021 17:47:11 GMT (envelope-from git) Date: Fri, 27 Aug 2021 17:47:11 GMT Message-Id: <202108271747.17RHlBwD061969@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dimitry Andric Subject: git: 4e5d32a445f9 - main - Fix null pointer subtraction in mergesort() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4e5d32a445f90d37966cd6de571978551654e3f3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 17:47:12 -0000 The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=4e5d32a445f90d37966cd6de571978551654e3f3 commit 4e5d32a445f90d37966cd6de571978551654e3f3 Author: Dimitry Andric AuthorDate: 2021-08-27 17:45:43 +0000 Commit: Dimitry Andric CommitDate: 2021-08-27 17:46:18 +0000 Fix null pointer subtraction in mergesort() Clang 13 produces the following warning for this function: lib/libc/stdlib/merge.c:137:41: error: performing pointer subtraction with a null pointer has undefined behavior [-Werror,-Wnull-pointer-subtraction] if (!(size % ISIZE) && !(((char *)base - (char *)0) % ISIZE)) ^ ~~~~~~~~~ This is meant to check whether the size and base parameters are aligned to the size of an int, so use our __is_aligned() macro instead. Also remove the comment that indicated this "stupid subtraction" was done to pacify some ancient and unknown Cray compiler, and which has been there since the BSD 4.4 Lite Lib Sources were imported. MFC after: 3 days --- lib/libc/stdlib/merge.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/libc/stdlib/merge.c b/lib/libc/stdlib/merge.c index 853d6ae93fcb..7d8484ed10b9 100644 --- a/lib/libc/stdlib/merge.c +++ b/lib/libc/stdlib/merge.c @@ -129,12 +129,8 @@ mergesort(void *base, size_t nmemb, size_t size, cmp_t cmp) if (nmemb == 0) return (0); - /* - * XXX - * Stupid subtraction for the Cray. - */ iflag = 0; - if (!(size % ISIZE) && !(((char *)base - (char *)0) % ISIZE)) + if (__is_aligned(size, ISIZE) && __is_aligned(base, ISIZE)) iflag = 1; if ((list2 = malloc(nmemb * size + PSIZE)) == NULL) From owner-dev-commits-src-main@freebsd.org Fri Aug 27 20:52:50 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2858F667A09; Fri, 27 Aug 2021 20:52:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GxBk96hYHz3Kwj; Fri, 27 Aug 2021 20:52:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CEB322397; Fri, 27 Aug 2021 20:52:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17RKqn2V015545; Fri, 27 Aug 2021 20:52:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RKqnrT015544; Fri, 27 Aug 2021 20:52:49 GMT (envelope-from git) Date: Fri, 27 Aug 2021 20:52:49 GMT Message-Id: <202108272052.17RKqnrT015544@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alan Somers Subject: git: f5c6c43d4c39 - main - Add a regression test for ggatec remote code execution MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f5c6c43d4c3910d5f8d61c0fae4582d863baa066 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 20:52:50 -0000 The branch main has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=f5c6c43d4c3910d5f8d61c0fae4582d863baa066 commit f5c6c43d4c3910d5f8d61c0fae4582d863baa066 Author: Alan Somers AuthorDate: 2021-08-27 20:40:05 +0000 Commit: Alan Somers CommitDate: 2021-08-27 20:52:45 +0000 Add a regression test for ggatec remote code execution Tests that ggatec appropriately handles unsupported BIO operations, rather than overflowing a buffer. Submitted by: Johannes Bruelltuete PR: 213479 Reviewed by: asomers Differential Revision: https://reviews.freebsd.org/D31318 --- tests/sys/geom/class/gate/ggate_test.sh | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/sys/geom/class/gate/ggate_test.sh b/tests/sys/geom/class/gate/ggate_test.sh index 7045d7292a75..d19d250215cc 100644 --- a/tests/sys/geom/class/gate/ggate_test.sh +++ b/tests/sys/geom/class/gate/ggate_test.sh @@ -5,6 +5,39 @@ PLAINFILES=plainfiles PORT=33080 CONF=gg.exports +atf_test_case ggatec_trim cleanup +ggatec_trim_head() +{ + atf_set "descr" "ggatec survives a trim" + atf_set "require.progs" "ggatec" + atf_set "require.user" "root" + atf_set "timeout" 60 +} + +ggatec_trim_body() +{ + load_ggate + + us=$(alloc_ggate_dev) + work=$(alloc_md) + atf_check -e ignore -o ignore dd if=/dev/random of=/dev/$work bs=1m count=1 conv=notrunc + echo $CONF >> $PLAINFILES + echo "localhost RW /dev/$work" > $CONF + atf_check ggated -p $PORT -F $PIDFILE $CONF + atf_check ggatec create -p $PORT -u $us localhost /dev/$work + ggate_dev=/dev/ggate${us} + wait_for_ggate_device ${ggate_dev} + + # ggatec only supports read or write. + atf_check -s not-exit:0 -e ignore -o ignore trim -q -f ${ggate_dev} +} + +ggatec_trim_cleanup() +{ + common_cleanup +} + + atf_test_case ggated cleanup ggated_head() { @@ -133,6 +166,7 @@ atf_init_test_cases() atf_add_test_case ggated atf_add_test_case ggatel_file atf_add_test_case ggatel_md + atf_add_test_case ggatec_trim } alloc_ggate_dev() From owner-dev-commits-src-main@freebsd.org Fri Aug 27 21:40:13 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 25D06668174; Fri, 27 Aug 2021 21:40:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GxCms09Gwz3nfp; Fri, 27 Aug 2021 21:40:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DED20277E; Fri, 27 Aug 2021 21:40:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17RLeCsw073554; Fri, 27 Aug 2021 21:40:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RLeCT4073548; Fri, 27 Aug 2021 21:40:12 GMT (envelope-from git) Date: Fri, 27 Aug 2021 21:40:12 GMT Message-Id: <202108272140.17RLeCT4073548@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dimitry Andric Subject: git: 5a3a8cb01ab8 - main - Silence more gtest warnings, now in fusefs tests MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5a3a8cb01ab8ef4aa16a1950b1ef804070ce1ac6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 21:40:13 -0000 The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=5a3a8cb01ab8ef4aa16a1950b1ef804070ce1ac6 commit 5a3a8cb01ab8ef4aa16a1950b1ef804070ce1ac6 Author: Dimitry Andric AuthorDate: 2021-08-27 21:39:23 +0000 Commit: Dimitry Andric CommitDate: 2021-08-27 21:39:36 +0000 Silence more gtest warnings, now in fusefs tests Follow-up d396c67f26b0 by also silencing warnings about deprecated implicit copy constructors in the fusefs tests, which use googletest. Fixes: d396c67f26b0 MFC after: 3 days --- tests/sys/fs/fusefs/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/sys/fs/fusefs/Makefile b/tests/sys/fs/fusefs/Makefile index 832b30dc6911..c3706e940840 100644 --- a/tests/sys/fs/fusefs/Makefile +++ b/tests/sys/fs/fusefs/Makefile @@ -77,6 +77,8 @@ CXXWARNFLAGS.readdir.cc+= -Wno-cast-align .if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 80000 CXXWARNFLAGS+= -Wno-class-memaccess .endif +# Supress warnings about deprecated implicit copy constructors in gtest. +CXXWARNFLAGS+= -Wno-deprecated-copy CXXFLAGS+= -I${SRCTOP}/tests CXXFLAGS+= -I${FUSEFS} CXXFLAGS+= -I${MOUNT} From owner-dev-commits-src-main@freebsd.org Sat Aug 28 01:29:22 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3D92D66ACDE; Sat, 28 Aug 2021 01:29:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GxJsG0mdMz3qTf; Sat, 28 Aug 2021 01:29:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F244F5D26; Sat, 28 Aug 2021 01:29:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17S1TLTH075280; Sat, 28 Aug 2021 01:29:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17S1TLst075279; Sat, 28 Aug 2021 01:29:21 GMT (envelope-from git) Date: Sat, 28 Aug 2021 01:29:21 GMT Message-Id: <202108280129.17S1TLst075279@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: da779f262c58 - main - vfs_default: Change vop_stddeallocate() from static to global MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: da779f262c58c65f7061e979371a89d1df1acccc Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 01:29:22 -0000 The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=da779f262c58c65f7061e979371a89d1df1acccc commit da779f262c58c65f7061e979371a89d1df1acccc Author: Rick Macklem AuthorDate: 2021-08-28 01:25:44 +0000 Commit: Rick Macklem CommitDate: 2021-08-28 01:25:44 +0000 vfs_default: Change vop_stddeallocate() from static to global A future commit to the NFS client uses vop_stddeallocate() for cases where the NFS server does not support a Deallocate operation. Change vop_stddeallocate() from static to global so that it can be called by the NFS client. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D31640 --- sys/kern/vfs_default.c | 3 +-- sys/sys/vnode.h | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index 9fd43004b8fd..d66443e6d6f0 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -93,7 +93,6 @@ static int vop_stdgetpages_async(struct vop_getpages_async_args *ap); static int vop_stdread_pgcache(struct vop_read_pgcache_args *ap); static int vop_stdstat(struct vop_stat_args *ap); static int vop_stdvput_pair(struct vop_vput_pair_args *ap); -static int vop_stddeallocate(struct vop_deallocate_args *ap); /* * This vnode table stores what we want to do if the filesystem doesn't @@ -1126,7 +1125,7 @@ vp_zerofill(struct vnode *vp, struct vattr *vap, off_t *offsetp, off_t *lenp, return (error); } -static int +int vop_stddeallocate(struct vop_deallocate_args *ap) { struct vnode *vp; diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 56591a8d8a8d..61c6a13010f6 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -861,6 +861,7 @@ int vop_stdadvlock(struct vop_advlock_args *ap); int vop_stdadvlockasync(struct vop_advlockasync_args *ap); int vop_stdadvlockpurge(struct vop_advlockpurge_args *ap); int vop_stdallocate(struct vop_allocate_args *ap); +int vop_stddeallocate(struct vop_deallocate_args *ap); int vop_stdset_text(struct vop_set_text_args *ap); int vop_stdpathconf(struct vop_pathconf_args *); int vop_stdpoll(struct vop_poll_args *); From owner-dev-commits-src-main@freebsd.org Sat Aug 28 01:35:29 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1FE7466B5A2; Sat, 28 Aug 2021 01:35:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GxK0J6rBzz3s0H; Sat, 28 Aug 2021 01:35:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AAA5F5F69; Sat, 28 Aug 2021 01:35:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17S1ZSd8088891; Sat, 28 Aug 2021 01:35:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17S1ZSZO088890; Sat, 28 Aug 2021 01:35:28 GMT (envelope-from git) Date: Sat, 28 Aug 2021 01:35:28 GMT Message-Id: <202108280135.17S1ZSZO088890@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: 08b9cc316a31 - main - nfscl: Add a VOP_DEALLOCATE() for the NFSv4.2 client MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 08b9cc316a319fba95af8bb13b262fe0d5526ec3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 01:35:29 -0000 The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=08b9cc316a319fba95af8bb13b262fe0d5526ec3 commit 08b9cc316a319fba95af8bb13b262fe0d5526ec3 Author: Rick Macklem AuthorDate: 2021-08-28 01:31:36 +0000 Commit: Rick Macklem CommitDate: 2021-08-28 01:31:36 +0000 nfscl: Add a VOP_DEALLOCATE() for the NFSv4.2 client This patch adds a VOP_DEALLOCATE() to the NFS client. For NFSv4.2 servers that support the Deallocate operation, it is used. Otherwise, it falls back on calling vop_stddeallocate(). Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D31640 --- sys/fs/nfs/nfs_var.h | 2 + sys/fs/nfsclient/nfs_clrpcops.c | 112 ++++++++++++++++++++++++++++++++++++++++ sys/fs/nfsclient/nfs_clvnops.c | 79 ++++++++++++++++++++++++++++ sys/fs/nfsclient/nfsmount.h | 1 + 4 files changed, 194 insertions(+) diff --git a/sys/fs/nfs/nfs_var.h b/sys/fs/nfs/nfs_var.h index 5ddae345f906..bae4affa72e2 100644 --- a/sys/fs/nfs/nfs_var.h +++ b/sys/fs/nfs/nfs_var.h @@ -553,6 +553,8 @@ int nfscl_findlayoutforio(struct nfscllayout *, uint64_t, uint32_t, void nfscl_freenfsclds(struct nfsclds *); int nfsrpc_allocate(vnode_t, off_t, off_t, struct nfsvattr *, int *, struct ucred *, NFSPROC_T *, void *); +int nfsrpc_deallocate(vnode_t, off_t, off_t, struct nfsvattr *, int *, + struct ucred *, NFSPROC_T *, void *); int nfsrpc_copy_file_range(vnode_t, off_t *, vnode_t, off_t *, size_t *, unsigned int, int *, struct nfsvattr *, int *, struct nfsvattr *, struct ucred *, bool, bool *); diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c index de4030876bfe..f9636bc28365 100644 --- a/sys/fs/nfsclient/nfs_clrpcops.c +++ b/sys/fs/nfsclient/nfs_clrpcops.c @@ -132,6 +132,8 @@ static int nfsrpc_readrpc(vnode_t , struct uio *, struct ucred *, static int nfsrpc_writerpc(vnode_t , struct uio *, int *, int *, struct ucred *, nfsv4stateid_t *, NFSPROC_T *, struct nfsvattr *, int *, void *); +static int nfsrpc_deallocaterpc(vnode_t, off_t, off_t, nfsv4stateid_t *, + struct nfsvattr *, int *, struct ucred *, NFSPROC_T *, void *); static int nfsrpc_createv23(vnode_t , char *, int, struct vattr *, nfsquad_t, int, struct ucred *, NFSPROC_T *, struct nfsvattr *, struct nfsvattr *, struct nfsfh **, int *, int *, void *); @@ -2089,6 +2091,116 @@ nfsmout: return (error); } +/* + * Do an nfs deallocate operation. + */ +int +nfsrpc_deallocate(vnode_t vp, off_t offs, off_t len, struct nfsvattr *nap, + int *attrflagp, struct ucred *cred, NFSPROC_T *p, void *stuff) +{ + int error, expireret = 0, openerr, retrycnt; + uint32_t clidrev = 0; + struct nfsmount *nmp = VFSTONFS(vp->v_mount); + struct nfsfh *nfhp; + nfsv4stateid_t stateid; + void *lckp; + + if (nmp->nm_clp != NULL) + clidrev = nmp->nm_clp->nfsc_clientidrev; + retrycnt = 0; + do { + lckp = NULL; + openerr = 1; + nfhp = VTONFS(vp)->n_fhp; + error = nfscl_getstateid(vp, nfhp->nfh_fh, nfhp->nfh_len, + NFSV4OPEN_ACCESSWRITE, 0, cred, p, &stateid, &lckp); + if (error != 0) { + /* + * No Open stateid, so try and open the file + * now. + */ + openerr = nfsrpc_open(vp, FWRITE, cred, p); + if (openerr == 0) + nfscl_getstateid(vp, nfhp->nfh_fh, + nfhp->nfh_len, NFSV4OPEN_ACCESSWRITE, 0, + cred, p, &stateid, &lckp); + } + error = nfsrpc_deallocaterpc(vp, offs, len, &stateid, nap, + attrflagp, cred, p, stuff); + if (error == NFSERR_STALESTATEID) + nfscl_initiate_recovery(nmp->nm_clp); + if (lckp != NULL) + nfscl_lockderef(lckp); + if (openerr == 0) + nfsrpc_close(vp, 0, p); + if (error == NFSERR_GRACE || error == NFSERR_STALESTATEID || + error == NFSERR_STALEDONTRECOVER || error == NFSERR_DELAY || + error == NFSERR_OLDSTATEID || error == NFSERR_BADSESSION) { + (void) nfs_catnap(PZERO, error, "nfs_deallocate"); + } else if ((error == NFSERR_EXPIRED || + error == NFSERR_BADSTATEID) && clidrev != 0) { + expireret = nfscl_hasexpired(nmp->nm_clp, clidrev, p); + } + retrycnt++; + } while (error == NFSERR_GRACE || error == NFSERR_STALESTATEID || + error == NFSERR_STALEDONTRECOVER || error == NFSERR_DELAY || + error == NFSERR_BADSESSION || + (error == NFSERR_OLDSTATEID && retrycnt < 20) || + ((error == NFSERR_EXPIRED || error == NFSERR_BADSTATEID) && + expireret == 0 && clidrev != 0 && retrycnt < 4)); + if (error && retrycnt >= 4) + error = EIO; + return (error); +} + +/* + * The actual deallocate RPC. + */ +static int +nfsrpc_deallocaterpc(vnode_t vp, off_t offs, off_t len, + nfsv4stateid_t *stateidp, struct nfsvattr *nap, int *attrflagp, + struct ucred *cred, NFSPROC_T *p, void *stuff) +{ + uint32_t *tl; + struct nfsnode *np = VTONFS(vp); + int error, wccflag; + struct nfsrv_descript nfsd; + struct nfsrv_descript *nd = &nfsd; + nfsattrbit_t attrbits; + + *attrflagp = 0; + NFSCL_REQSTART(nd, NFSPROC_DEALLOCATE, vp); + nfsm_stateidtom(nd, stateidp, NFSSTATEID_PUTSTATEID); + NFSM_BUILD(tl, uint32_t *, 2 * NFSX_HYPER); + txdr_hyper(offs, tl); + tl += 2; + txdr_hyper(len, tl); + NFSWRITEGETATTR_ATTRBIT(&attrbits); + NFSM_BUILD(tl, uint32_t *, NFSX_UNSIGNED); + *tl = txdr_unsigned(NFSV4OP_GETATTR); + nfsrv_putattrbit(nd, &attrbits); + error = nfscl_request(nd, vp, p, cred, stuff); + if (error != 0) + return (error); + wccflag = 0; + error = nfscl_wcc_data(nd, vp, nap, attrflagp, &wccflag, stuff); + if (error != 0) + goto nfsmout; + if (nd->nd_repstat == 0) { + NFSM_DISSECT(tl, uint32_t *, 2 * NFSX_UNSIGNED); + error = nfsm_loadattr(nd, nap); + if (error != 0) + goto nfsmout; + *attrflagp = NFS_LATTR_NOSHRINK; + } + NFSWRITERPC_SETTIME(wccflag, np, nap, 1); +nfsmout: + m_freem(nd->nd_mrep); + if (nd->nd_repstat != 0 && error == 0) + error = nd->nd_repstat; + return (error); +} + /* * nfs mknod rpc * For NFS v2 this is a kludge. Use a create rpc but with the IFMT bits of the diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c index 39340692563f..bfd77d50bc91 100644 --- a/sys/fs/nfsclient/nfs_clvnops.c +++ b/sys/fs/nfsclient/nfs_clvnops.c @@ -146,6 +146,7 @@ static vop_getacl_t nfs_getacl; static vop_setacl_t nfs_setacl; static vop_advise_t nfs_advise; static vop_allocate_t nfs_allocate; +static vop_deallocate_t nfs_deallocate; static vop_copy_file_range_t nfs_copy_file_range; static vop_ioctl_t nfs_ioctl; static vop_getextattr_t nfs_getextattr; @@ -193,6 +194,7 @@ static struct vop_vector newnfs_vnodeops_nosig = { .vop_setacl = nfs_setacl, .vop_advise = nfs_advise, .vop_allocate = nfs_allocate, + .vop_deallocate = nfs_deallocate, .vop_copy_file_range = nfs_copy_file_range, .vop_ioctl = nfs_ioctl, .vop_getextattr = nfs_getextattr, @@ -3681,6 +3683,83 @@ nfs_allocate(struct vop_allocate_args *ap) return (error); } +/* + * nfs deallocate call + */ +static int +nfs_deallocate(struct vop_deallocate_args *ap) +{ + struct vnode *vp = ap->a_vp; + struct thread *td = curthread; + struct nfsvattr nfsva; + struct nfsmount *nmp; + off_t tlen; + int attrflag, error, ret; + + error = 0; + attrflag = 0; + nmp = VFSTONFS(vp->v_mount); + mtx_lock(&nmp->nm_mtx); + if (NFSHASNFSV4(nmp) && nmp->nm_minorvers >= NFSV42_MINORVERSION && + (nmp->nm_privflag & NFSMNTP_NODEALLOCATE) == 0) { + mtx_unlock(&nmp->nm_mtx); + tlen = omin(OFF_MAX - *ap->a_offset, *ap->a_len); + NFSCL_DEBUG(4, "dealloc: off=%jd len=%jd maxfilesize=%ju\n", + (intmax_t)*ap->a_offset, (intmax_t)tlen, + (uintmax_t)nmp->nm_maxfilesize); + if ((uint64_t)*ap->a_offset >= nmp->nm_maxfilesize) { + /* Avoid EFBIG error return from the NFSv4.2 server. */ + *ap->a_len = 0; + return (0); + } + if ((uint64_t)*ap->a_offset + tlen > nmp->nm_maxfilesize) + tlen = nmp->nm_maxfilesize - *ap->a_offset; + if (error == 0) + error = ncl_vinvalbuf(vp, V_SAVE, td, 1); + if (error == 0) { + vnode_pager_purge_range(vp, *ap->a_offset, + *ap->a_offset + tlen); + error = nfsrpc_deallocate(vp, *ap->a_offset, tlen, + &nfsva, &attrflag, ap->a_cred, td, NULL); + NFSCL_DEBUG(4, "dealloc: rpc=%d\n", error); + } + if (error == 0) { + NFSCL_DEBUG(4, "dealloc: attrflag=%d na_size=%ju\n", + attrflag, (uintmax_t)nfsva.na_size); + if (attrflag != 0) { + if ((uint64_t)*ap->a_offset < nfsva.na_size) + *ap->a_offset += omin((off_t) + nfsva.na_size - *ap->a_offset, + tlen); + } + *ap->a_len = 0; + } else if (error == NFSERR_NOTSUPP) { + mtx_lock(&nmp->nm_mtx); + nmp->nm_privflag |= NFSMNTP_NODEALLOCATE; + mtx_unlock(&nmp->nm_mtx); + } + } else { + mtx_unlock(&nmp->nm_mtx); + error = EIO; + } + /* + * If the NFS server cannot perform the Deallocate operation, just call + * vop_stddeallocate() to perform it. + */ + if (error != 0 && error != NFSERR_FBIG && error != NFSERR_INVAL) { + error = vop_stddeallocate(ap); + NFSCL_DEBUG(4, "dealloc: stddeallocate=%d\n", error); + } + if (attrflag != 0) { + ret = nfscl_loadattrcache(&vp, &nfsva, NULL, NULL, 0, 1); + if (error == 0 && ret != 0) + error = ret; + } + if (error != 0) + error = nfscl_maperr(td, error, (uid_t)0, (gid_t)0); + return (error); +} + /* * nfs copy_file_range call */ diff --git a/sys/fs/nfsclient/nfsmount.h b/sys/fs/nfsclient/nfsmount.h index a5997e474be9..d5771f157034 100644 --- a/sys/fs/nfsclient/nfsmount.h +++ b/sys/fs/nfsclient/nfsmount.h @@ -124,6 +124,7 @@ struct nfsmount { #define NFSMNTP_NOADVISE 0x00000100 #define NFSMNTP_NOALLOCATE 0x00000200 #define NFSMNTP_DELEGISSUED 0x00000400 +#define NFSMNTP_NODEALLOCATE 0x00000800 /* New mount flags only used by the kernel via nmount(2). */ #define NFSMNT_TLS 0x00000001 From owner-dev-commits-src-main@freebsd.org Sat Aug 28 13:38:42 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 983CF67499A; Sat, 28 Aug 2021 13:38:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gxd2p3fF1z4c3P; Sat, 28 Aug 2021 13:38:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 60EFE1796C; Sat, 28 Aug 2021 13:38:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17SDcgBD054622; Sat, 28 Aug 2021 13:38:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17SDcgnx054621; Sat, 28 Aug 2021 13:38:42 GMT (envelope-from git) Date: Sat, 28 Aug 2021 13:38:42 GMT Message-Id: <202108281338.17SDcgnx054621@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dimitry Andric Subject: git: 4544929cb55e - main - Silence unused parameter warnings in fspacectl(2) bootstrap stub MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4544929cb55e0cb8496ec23e565aab8251e22e81 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 13:38:42 -0000 The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=4544929cb55e0cb8496ec23e565aab8251e22e81 commit 4544929cb55e0cb8496ec23e565aab8251e22e81 Author: Dimitry Andric AuthorDate: 2021-08-28 13:37:24 +0000 Commit: Dimitry Andric CommitDate: 2021-08-28 13:37:43 +0000 Silence unused parameter warnings in fspacectl(2) bootstrap stub While here, replace spaces with tabs and add a newline at EOF. Fixes: 5425ba8332571e57f9fe623346cb9d83293264d4 MFC after: 3 days --- tools/build/fspacectl.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/build/fspacectl.c b/tools/build/fspacectl.c index c17802c51e01..13abca23a318 100644 --- a/tools/build/fspacectl.c +++ b/tools/build/fspacectl.c @@ -36,9 +36,10 @@ __FBSDID("$FreeBSD$"); * This is currently a stub implementation of fspacectl(2). */ int -fspacectl(int fd, int cmd, const struct spacectl_range *rqsr, int flags, - struct spacectl_range *rmsr) +fspacectl(int fd __unused, int cmd __unused, + const struct spacectl_range *rqsr __unused, int flags __unused, + struct spacectl_range *rmsr __unused) { - errno = ENOSYS; - return (-1); -} \ No newline at end of file + errno = ENOSYS; + return (-1); +} From owner-dev-commits-src-main@freebsd.org Sat Aug 28 14:12:00 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DADD5674FF2; Sat, 28 Aug 2021 14:12:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GxdnD5SwQz4qsn; Sat, 28 Aug 2021 14:12:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A13231875C; Sat, 28 Aug 2021 14:12:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17SEC0kJ008303; Sat, 28 Aug 2021 14:12:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17SEC01m008302; Sat, 28 Aug 2021 14:12:00 GMT (envelope-from git) Date: Sat, 28 Aug 2021 14:12:00 GMT Message-Id: <202108281412.17SEC01m008302@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Baptiste Daroussin Subject: git: 3ae61b972b04 - main - sh: improve emacs mode MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bapt X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3ae61b972b042f2ea35d1670bd2ce5820400d27b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 14:12:01 -0000 The branch main has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=3ae61b972b042f2ea35d1670bd2ce5820400d27b commit 3ae61b972b042f2ea35d1670bd2ce5820400d27b Author: Baptiste Daroussin AuthorDate: 2021-08-28 12:59:53 +0000 Commit: Baptiste Daroussin CommitDate: 2021-08-28 14:11:57 +0000 sh: improve emacs mode in emacs mode ^W should delete the previous word by default Note that upstreaming this change directly into libedit is in process. Reported by: manu Reviewed by: jills, pstef, manu Differential Revision: https://reviews.freebsd.org/D29493 --- bin/sh/histedit.c | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/sh/histedit.c b/bin/sh/histedit.c index bd82016c33cb..b680a99c4ace 100644 --- a/bin/sh/histedit.c +++ b/bin/sh/histedit.c @@ -204,6 +204,7 @@ bad: else if (Eflag) { el_set(el, EL_EDITOR, "emacs"); el_set(el, EL_BIND, "^R", "em-inc-search-prev", NULL); + el_set(el, EL_BIND, "^W", "ed-delete-prev-word", NULL); } el_set(el, EL_BIND, "^I", "sh-complete", NULL); el_source(el, NULL); From owner-dev-commits-src-main@freebsd.org Sat Aug 28 16:28:56 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6F4B26766D7; Sat, 28 Aug 2021 16:28:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GxhqD2NQFz4j6M; Sat, 28 Aug 2021 16:28:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3AEF01A6C7; Sat, 28 Aug 2021 16:28:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17SGSu7W082308; Sat, 28 Aug 2021 16:28:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17SGSut3082307; Sat, 28 Aug 2021 16:28:56 GMT (envelope-from git) Date: Sat, 28 Aug 2021 16:28:56 GMT Message-Id: <202108281628.17SGSut3082307@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: 16b71d98d96a - main - ocs_fs(4): Fix some common typos in source code comments MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 16b71d98d96a3a9a2ac666440aa80f12d478959d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 16:28:56 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=16b71d98d96a3a9a2ac666440aa80f12d478959d commit 16b71d98d96a3a9a2ac666440aa80f12d478959d Author: Gordon Bergling AuthorDate: 2021-08-28 16:24:08 +0000 Commit: Gordon Bergling CommitDate: 2021-08-28 16:24:08 +0000 ocs_fs(4): Fix some common typos in source code comments - s/transfered/transferred/ - s/associted/associated/ MFC after: 3 days --- sys/dev/ocs_fc/ocs_gendump.c | 2 +- sys/dev/ocs_fc/ocs_hw_queues.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/ocs_fc/ocs_gendump.c b/sys/dev/ocs_fc/ocs_gendump.c index d24870f39668..83155d90c3a3 100644 --- a/sys/dev/ocs_fc/ocs_gendump.c +++ b/sys/dev/ocs_fc/ocs_gendump.c @@ -234,7 +234,7 @@ ocs_fdb_dump(ocs_t *ocs) * @par Description * This function creates a DMA buffer to hold a Lancer dump, * sets the dump location to point to that buffer, then calls - * ocs_gen_dump to cause a dump to be transfered to the buffer. + * ocs_gen_dump to cause a dump to be transferred to the buffer. * After the dump is complete it copies the dump to the provided * user space buffer. * diff --git a/sys/dev/ocs_fc/ocs_hw_queues.c b/sys/dev/ocs_fc/ocs_hw_queues.c index 242b2f0df115..704eb951d2b7 100644 --- a/sys/dev/ocs_fc/ocs_hw_queues.c +++ b/sys/dev/ocs_fc/ocs_hw_queues.c @@ -966,7 +966,7 @@ hw_queue_teardown(ocs_hw_t *hw) * If wq_steering is OCS_HW_WQ_STEERING_REQUEST, then a WQ from the EQ that * the IO request came in on is selected. * - * If wq_steering is OCS_HW_WQ_STEERING_CPU, then a WQ associted with the + * If wq_steering is OCS_HW_WQ_STEERING_CPU, then a WQ associated with the * CPU the request is made on is selected. * * @param hw pointer to HW object From owner-dev-commits-src-main@freebsd.org Sat Aug 28 16:54:27 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BE1BA676DF8; Sat, 28 Aug 2021 16:54:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GxjNg4gXVz4qWp; Sat, 28 Aug 2021 16:54:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 893D01B06F; Sat, 28 Aug 2021 16:54:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17SGsRlk020890; Sat, 28 Aug 2021 16:54:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17SGsRSr020889; Sat, 28 Aug 2021 16:54:27 GMT (envelope-from git) Date: Sat, 28 Aug 2021 16:54:27 GMT Message-Id: <202108281654.17SGsRSr020889@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: 586c9dc37470 - main - inet(3): Fix a few common typos in source code comments MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 586c9dc37470a2b862b50c041d70229026dd530a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 16:54:27 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=586c9dc37470a2b862b50c041d70229026dd530a commit 586c9dc37470a2b862b50c041d70229026dd530a Author: Gordon Bergling AuthorDate: 2021-08-28 16:53:02 +0000 Commit: Gordon Bergling CommitDate: 2021-08-28 16:53:02 +0000 inet(3): Fix a few common typos in source code comments - s/funtion/function/ MFC after: 3 days --- sys/netinet/in_pcbgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/netinet/in_pcbgroup.c b/sys/netinet/in_pcbgroup.c index cade2574db5d..11ed75be1198 100644 --- a/sys/netinet/in_pcbgroup.c +++ b/sys/netinet/in_pcbgroup.c @@ -186,7 +186,7 @@ in_pcbgroup_init(struct inpcbinfo *pcbinfo, u_int hashfields, * XXXRW: The notion of a bucket to CPU mapping is common at * both pcbgroup and RSS layers -- does that mean that we * should migrate it all from RSS to here, and just leave RSS - * responsible only for providing hashing and mapping funtions? + * responsible only for providing hashing and mapping functions? */ #ifdef RSS pcbgroup->ipg_cpu = rss_getcpu(pgn); From owner-dev-commits-src-main@freebsd.org Sat Aug 28 16:54:29 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 062EE6764F9; Sat, 28 Aug 2021 16:54:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GxjNh69gVz4qNS; Sat, 28 Aug 2021 16:54:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A4D441B070; Sat, 28 Aug 2021 16:54:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17SGsSVe020918; Sat, 28 Aug 2021 16:54:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17SGsSrr020917; Sat, 28 Aug 2021 16:54:28 GMT (envelope-from git) Date: Sat, 28 Aug 2021 16:54:28 GMT Message-Id: <202108281654.17SGsSrr020917@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: 10e0082fff4e - main - inet6(4): Fix a few common typos in source code comments MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 10e0082fff4ec9392db2763ce3b095bc010526df Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 16:54:29 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=10e0082fff4ec9392db2763ce3b095bc010526df commit 10e0082fff4ec9392db2763ce3b095bc010526df Author: Gordon Bergling AuthorDate: 2021-08-28 16:53:59 +0000 Commit: Gordon Bergling CommitDate: 2021-08-28 16:53:59 +0000 inet6(4): Fix a few common typos in source code comments - s/reshedule/reschedule/ MFC after: 3 days --- sys/netinet6/nd6.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index 14312f0a30a3..6a9e2a4fdd7c 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -666,7 +666,7 @@ nd6_is_stale(struct llentry *lle, long *pdelay, int *do_switch) /* * V_nd6_delay still not passed since the first * hit in STALE state. - * Reshedule timer and return. + * Reschedule timer and return. */ *pdelay = (long)(nd_delay - delay) * hz; return (1); @@ -850,7 +850,7 @@ nd6_llinfo_timer(void *arg) if (nd6_is_stale(ln, &delay, &do_switch) != 0) { /* * No packet has used this entry and GC timeout - * has not been passed. Reshedule timer and + * has not been passed. Reschedule timer and * return. */ nd6_llinfo_settimer_locked(ln, delay); From owner-dev-commits-src-main@freebsd.org Sat Aug 28 16:57:52 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 185FD676F84; Sat, 28 Aug 2021 16:57:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GxjSc09N6z4qv1; Sat, 28 Aug 2021 16:57:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E10411ABDA; Sat, 28 Aug 2021 16:57:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17SGvpr3021268; Sat, 28 Aug 2021 16:57:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17SGvpDg021267; Sat, 28 Aug 2021 16:57:51 GMT (envelope-from git) Date: Sat, 28 Aug 2021 16:57:51 GMT Message-Id: <202108281657.17SGvpDg021267@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: 5bdf58e19609 - main - Fix some common typos in source code comments MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5bdf58e196096993758b3e50291db17104025b65 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 16:57:52 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=5bdf58e196096993758b3e50291db17104025b65 commit 5bdf58e196096993758b3e50291db17104025b65 Author: Gordon Bergling AuthorDate: 2021-08-28 16:57:23 +0000 Commit: Gordon Bergling CommitDate: 2021-08-28 16:57:23 +0000 Fix some common typos in source code comments - s/priviledged/privileged/ - s/funtion/function/ - s/doens't/doesn't/ - s/sychronization/synchronization/ MFC after: 3 days --- sys/arm/arm/trap-v6.c | 4 ++-- sys/dev/cxgbe/cudbg/fastlz_api.c | 2 +- sys/dev/mii/lxtphy.c | 2 +- sys/dev/oce/oce_mbox.c | 2 +- sys/dev/qlnx/qlnxe/ecore.h | 2 +- sys/dev/rtsx/rtsx.c | 2 +- sys/dev/sfxge/sfxge.c | 2 +- sys/geom/journal/g_journal.c | 2 +- sys/i386/i386/perfmon.c | 2 +- usr.bin/tip/tip/tip.h | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/sys/arm/arm/trap-v6.c b/sys/arm/arm/trap-v6.c index cd141376d381..7bd5780af338 100644 --- a/sys/arm/arm/trap-v6.c +++ b/sys/arm/arm/trap-v6.c @@ -114,7 +114,7 @@ struct abort { * for cache operations working on virtual addresses. For now, we will * consider this abort as fatal. In fact, no cache maintenance on * not mapped virtual addresses should be called. As cache maintenance - * operation (except DMB, DSB, and Flush Prefetch Buffer) are priviledged, + * operation (except DMB, DSB, and Flush Prefetch Buffer) are privileged, * the abort is fatal for user mode as well for now. (This is good place to * note that cache maintenance on virtual address fill TLB.) * Acces Bit (L1 & L2): @@ -654,7 +654,7 @@ abort_align(struct trapframe *tf, u_int idx, u_int fsr, u_int far, * According to manual, FAULT_ICACHE is translation fault during cache * maintenance operation. In fact, no cache maintenance operation on * not mapped virtual addresses should be called. As cache maintenance - * operation (except DMB, DSB, and Flush Prefetch Buffer) are priviledged, + * operation (except DMB, DSB, and Flush Prefetch Buffer) are privileged, * the abort is concider as fatal for now. However, all the matter with * cache maintenance operation on virtual addresses could be really complex * and fuzzy in SMP case, so maybe in future standard fault mechanism diff --git a/sys/dev/cxgbe/cudbg/fastlz_api.c b/sys/dev/cxgbe/cudbg/fastlz_api.c index a513557ad352..7a8131f6da3e 100644 --- a/sys/dev/cxgbe/cudbg/fastlz_api.c +++ b/sys/dev/cxgbe/cudbg/fastlz_api.c @@ -442,7 +442,7 @@ int decompress_buffer(struct cudbg_buffer *pc_buff, remaining = chunk_size; checksum = 1L; for (;;) { - /* Write a funtion for this */ + /* Write a function for this */ r = (CUDBG_BLOCK_SIZE < remaining) ? CUDBG_BLOCK_SIZE : remaining; bytes_read = diff --git a/sys/dev/mii/lxtphy.c b/sys/dev/mii/lxtphy.c index 699c1d6f83b6..31900cc5a34b 100644 --- a/sys/dev/mii/lxtphy.c +++ b/sys/dev/mii/lxtphy.c @@ -203,7 +203,7 @@ lxtphy_status(struct mii_softc *sc) /* * Get link status from the CSR; we need to read the CSR * for media type anyhow, and the link status in the CSR - * doens't latch, so fewer register reads are required. + * doesn't latch, so fewer register reads are required. */ csr = PHY_READ(sc, MII_LXTPHY_CSR); if (csr & CSR_LINK) diff --git a/sys/dev/oce/oce_mbox.c b/sys/dev/oce/oce_mbox.c index 7470d7a13b07..321775c13d1e 100644 --- a/sys/dev/oce/oce_mbox.c +++ b/sys/dev/oce/oce_mbox.c @@ -118,7 +118,7 @@ oce_reset_fun(POCE_SOFTC sc) } /** - * @brief This funtions tells firmware we are + * @brief This functions tells firmware we are * done with commands. * @param sc software handle to the device * @returns 0 on success, ETIMEDOUT on failure diff --git a/sys/dev/qlnx/qlnxe/ecore.h b/sys/dev/qlnx/qlnxe/ecore.h index 33af8f124658..32a6b98156c5 100644 --- a/sys/dev/qlnx/qlnxe/ecore.h +++ b/sys/dev/qlnx/qlnxe/ecore.h @@ -702,7 +702,7 @@ struct ecore_hwfn { struct ecore_ptt *p_main_ptt; struct ecore_ptt *p_dpc_ptt; - /* PTP will be used only by the leading funtion. + /* PTP will be used only by the leading function. * Usage of all PTP-apis should be synchronized as result. */ struct ecore_ptt *p_ptp_ptt; diff --git a/sys/dev/rtsx/rtsx.c b/sys/dev/rtsx/rtsx.c index cb85685c875c..cae35243d137 100644 --- a/sys/dev/rtsx/rtsx.c +++ b/sys/dev/rtsx/rtsx.c @@ -624,7 +624,7 @@ rtsx_handle_card_present(struct rtsx_softc *sc) } /* - * This funtion is called at startup. + * This function is called at startup. */ static void rtsx_card_task(void *arg, int pending __unused) diff --git a/sys/dev/sfxge/sfxge.c b/sys/dev/sfxge/sfxge.c index 866f940a7b29..62daadf35ae5 100644 --- a/sys/dev/sfxge/sfxge.c +++ b/sys/dev/sfxge/sfxge.c @@ -984,7 +984,7 @@ sfxge_vpd_init(struct sfxge_softc *sc) if ((rc = efx_vpd_size(sc->enp, &sc->vpd_size)) != 0) { /* - * Unpriviledged functions deny VPD access. + * Unprivileged functions deny VPD access. * Simply skip VPD in this case. */ if (rc == EACCES) diff --git a/sys/geom/journal/g_journal.c b/sys/geom/journal/g_journal.c index 7c8c60183bff..97516ed293e7 100644 --- a/sys/geom/journal/g_journal.c +++ b/sys/geom/journal/g_journal.c @@ -256,7 +256,7 @@ struct meminfo { #endif /* - * We use our own malloc/realloc/free funtions, so we can collect statistics + * We use our own malloc/realloc/free functions, so we can collect statistics * and force journal switch when we're running out of cache. */ static void * diff --git a/sys/i386/i386/perfmon.c b/sys/i386/i386/perfmon.c index 3f35b59faa80..cb8c0acfc0dc 100644 --- a/sys/i386/i386/perfmon.c +++ b/sys/i386/i386/perfmon.c @@ -62,7 +62,7 @@ static d_open_t perfmon_open; static d_ioctl_t perfmon_ioctl; /* - * XXX perfmon_init_dev(void *) is a split from the perfmon_init() funtion. + * XXX perfmon_init_dev(void *) is a split from the perfmon_init() function. * This solves a problem for DEVFS users. It loads the "perfmon" driver after * the DEVFS subsystem has been kicked into action. The SI_ORDER_ANY is to * assure that it is the most lowest priority task which, guarantees the diff --git a/usr.bin/tip/tip/tip.h b/usr.bin/tip/tip/tip.h index 298b08cb6692..a5d53b9a6aad 100644 --- a/usr.bin/tip/tip/tip.h +++ b/usr.bin/tip/tip/tip.h @@ -247,7 +247,7 @@ EXTERN int gotdefterm; EXTERN FILE *fscript; /* FILE for scripting */ EXTERN int fildes[2]; /* file transfer synchronization channel */ -EXTERN int repdes[2]; /* read process sychronization channel */ +EXTERN int repdes[2]; /* read process synchronization channel */ EXTERN int FD; /* open file descriptor to remote host */ EXTERN int AC; /* open file descriptor to dialer (v831 only) */ EXTERN int vflag; /* print .tiprc initialization sequence */ From owner-dev-commits-src-main@freebsd.org Sat Aug 28 17:24:55 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BC8B16772A0; Sat, 28 Aug 2021 17:24:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gxk3q4gxsz3DQT; Sat, 28 Aug 2021 17:24:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 848FB1B608; Sat, 28 Aug 2021 17:24:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17SHOthv061395; Sat, 28 Aug 2021 17:24:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17SHOtem061394; Sat, 28 Aug 2021 17:24:55 GMT (envelope-from git) Date: Sat, 28 Aug 2021 17:24:55 GMT Message-Id: <202108281724.17SHOtem061394@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: b1603638e38b - main - Fix a common typo in man pages and src comments MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b1603638e38b3d8c23da6599e389db9a9218c240 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 17:24:55 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=b1603638e38b3d8c23da6599e389db9a9218c240 commit b1603638e38b3d8c23da6599e389db9a9218c240 Author: Gordon Bergling AuthorDate: 2021-08-28 17:24:27 +0000 Commit: Gordon Bergling CommitDate: 2021-08-28 17:24:27 +0000 Fix a common typo in man pages and src comments - s/desciptor/descriptor/ MFC after: 5 days --- sbin/mount_fusefs/mount_fusefs.8 | 2 +- share/man/man4/proto.4 | 2 +- sys/dev/aic7xxx/aic79xx.h | 2 +- sys/dev/aic7xxx/aic7xxx.h | 2 +- sys/dev/isci/scil/sci_memory_descriptor_list.h | 2 +- sys/dev/isci/scil/scif_sas_controller.h | 2 +- sys/dev/mge/if_mge.c | 2 +- sys/dev/nge/if_nge.c | 2 +- sys/dev/sk/if_sk.c | 2 +- sys/dev/ti/if_ti.c | 2 +- sys/dev/usb/input/uhid_snes.c | 2 +- sys/dev/vr/if_vr.c | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/sbin/mount_fusefs/mount_fusefs.8 b/sbin/mount_fusefs/mount_fusefs.8 index b4ab86c57ae2..051a5c273ef7 100644 --- a/sbin/mount_fusefs/mount_fusefs.8 +++ b/sbin/mount_fusefs/mount_fusefs.8 @@ -309,7 +309,7 @@ If not set, the multiplexer path .Ar /dev/fuse is used. .It Ev FUSE_DEV_FD -File desciptor of an opened Fuse device to use. +File descriptor of an opened Fuse device to use. Overrides .Ev FUSE_DEV_NAME . .It Ev FUSE_NO_MOUNT diff --git a/share/man/man4/proto.4 b/share/man/man4/proto.4 index 39f585dad65c..bd861697c10d 100644 --- a/share/man/man4/proto.4 +++ b/share/man/man4/proto.4 @@ -267,7 +267,7 @@ single contigous region of physical memory. In practice this also tends to give a single contigous region in bus space. This may change over time. .It PROTO_IOC_BUSDMA_MEM_FREE -Free previously allocated memory and destroy the memory desciptor. +Free previously allocated memory and destroy the memory descriptor. The .Nm driver is not in a position to track whether the memory has been mapped in diff --git a/sys/dev/aic7xxx/aic79xx.h b/sys/dev/aic7xxx/aic79xx.h index 38b152ef4051..bb3949c5f749 100644 --- a/sys/dev/aic7xxx/aic79xx.h +++ b/sys/dev/aic7xxx/aic79xx.h @@ -696,7 +696,7 @@ struct scb_data { /************************ Target Mode Definitions *****************************/ /* - * Connection desciptor for select-in requests in target mode. + * Connection descriptor for select-in requests in target mode. */ struct target_cmd { uint8_t scsiid; /* Our ID and the initiator's ID */ diff --git a/sys/dev/aic7xxx/aic7xxx.h b/sys/dev/aic7xxx/aic7xxx.h index a3abc456f8c5..f48e793fea6a 100644 --- a/sys/dev/aic7xxx/aic7xxx.h +++ b/sys/dev/aic7xxx/aic7xxx.h @@ -644,7 +644,7 @@ struct scb_data { /************************ Target Mode Definitions *****************************/ /* - * Connection desciptor for select-in requests in target mode. + * Connection descriptor for select-in requests in target mode. */ struct target_cmd { uint8_t scsiid; /* Our ID and the initiator's ID */ diff --git a/sys/dev/isci/scil/sci_memory_descriptor_list.h b/sys/dev/isci/scil/sci_memory_descriptor_list.h index 6b78fbc6055d..21516c13231c 100644 --- a/sys/dev/isci/scil/sci_memory_descriptor_list.h +++ b/sys/dev/isci/scil/sci_memory_descriptor_list.h @@ -96,7 +96,7 @@ typedef struct SCI_PHYSICAL_MEMORY_DESCRIPTOR void * virtual_address; /** - * This field contains the physical address associated with this desciptor + * This field contains the physical address associated with this descriptor * element. This field shall be zero when the descriptor is retrieved from * the SCI implementation. The user shall set this field prior * sci_controller_start() diff --git a/sys/dev/isci/scil/scif_sas_controller.h b/sys/dev/isci/scil/scif_sas_controller.h index fc7583e84367..3de39864811c 100644 --- a/sys/dev/isci/scil/scif_sas_controller.h +++ b/sys/dev/isci/scil/scif_sas_controller.h @@ -121,7 +121,7 @@ typedef struct SCIF_SAS_CONTROLLER SCI_BASE_CONTROLLER_STATE_HANDLER_T * state_handlers; /** - * This field contains the memory desciptors defining the physical + * This field contains the memory descriptors defining the physical * memory requirements for this controller. */ SCI_PHYSICAL_MEMORY_DESCRIPTOR_T mdes[SCIF_SAS_MAX_MEMORY_DESCRIPTORS]; diff --git a/sys/dev/mge/if_mge.c b/sys/dev/mge/if_mge.c index dc044749ae72..16deb330c06c 100644 --- a/sys/dev/mge/if_mge.c +++ b/sys/dev/mge/if_mge.c @@ -697,7 +697,7 @@ static void mge_free_dma(struct mge_softc *sc) { - /* Free desciptors and mbufs */ + /* Free descriptors and mbufs */ mge_free_desc(sc, sc->mge_rx_desc, MGE_RX_DESC_NUM, sc->mge_rx_dtag, 1); mge_free_desc(sc, sc->mge_tx_desc, MGE_TX_DESC_NUM, sc->mge_tx_dtag, 0); diff --git a/sys/dev/nge/if_nge.c b/sys/dev/nge/if_nge.c index c099896d7bc8..67e1f03ebdd2 100644 --- a/sys/dev/nge/if_nge.c +++ b/sys/dev/nge/if_nge.c @@ -1950,7 +1950,7 @@ nge_encap(struct nge_softc *sc, struct mbuf **m_head) if ((m->m_flags & M_VLANTAG) != 0) desc->nge_extsts |= htole32(NGE_TXEXTSTS_VLANPKT | bswap16(m->m_pkthdr.ether_vtag)); - /* Set EOP on the last desciptor. */ + /* Set EOP on the last descriptor. */ desc->nge_cmdsts &= htole32(~NGE_CMDSTS_MORE); /* Set checksum offload in the first descriptor. */ diff --git a/sys/dev/sk/if_sk.c b/sys/dev/sk/if_sk.c index a6431044e30f..809cfa6f9e14 100644 --- a/sys/dev/sk/if_sk.c +++ b/sys/dev/sk/if_sk.c @@ -2445,7 +2445,7 @@ sk_encap(sc_if, m_head) } sc_if->sk_cdata.sk_tx_prod = frag; - /* set EOF on the last desciptor */ + /* set EOF on the last descriptor */ frag = (frag + SK_TX_RING_CNT - 1) % SK_TX_RING_CNT; f = &sc_if->sk_rdata.sk_tx_ring[frag]; f->sk_ctl |= htole32(SK_TXCTL_LASTFRAG | SK_TXCTL_EOF_INTR); diff --git a/sys/dev/ti/if_ti.c b/sys/dev/ti/if_ti.c index 06769bc97c9f..9871212d6379 100644 --- a/sys/dev/ti/if_ti.c +++ b/sys/dev/ti/if_ti.c @@ -53,7 +53,7 @@ * * The Tigon 2 contains 2 R4000 CPUs and requires a newer firmware * revision, which supports new features such as extended commands, - * extended jumbo receive ring desciptors and a mini receive ring. + * extended jumbo receive ring descriptors and a mini receive ring. * * Alteon Networks is to be commended for releasing such a vast amount * of development material for the Tigon NIC without requiring an NDA diff --git a/sys/dev/usb/input/uhid_snes.c b/sys/dev/usb/input/uhid_snes.c index 5b68560a47e9..181e38eba7b1 100644 --- a/sys/dev/usb/input/uhid_snes.c +++ b/sys/dev/usb/input/uhid_snes.c @@ -296,7 +296,7 @@ uhid_snes_ioctl(struct usb_fifo *fifo, u_long cmd, void *data, int fflags) ugd->ugd_actlen = size; if (ugd->ugd_data == NULL) - break; /*desciptor length only*/ + break; /* descriptor length only*/ error = copyout(sc->sc_repdesc_ptr, ugd->ugd_data, size); break; diff --git a/sys/dev/vr/if_vr.c b/sys/dev/vr/if_vr.c index e81c027cf2cd..3a3490b7095c 100644 --- a/sys/dev/vr/if_vr.c +++ b/sys/dev/vr/if_vr.c @@ -1934,7 +1934,7 @@ vr_encap(struct vr_softc *sc, struct mbuf **m_head) desc = &sc->vr_rdata.vr_tx_ring[prod]; /* - * Set EOP on the last desciptor and reuqest Tx completion + * Set EOP on the last descriptor and reuqest Tx completion * interrupt for every VR_TX_INTR_THRESH-th frames. */ VR_INC(sc->vr_cdata.vr_tx_pkts, VR_TX_INTR_THRESH); From owner-dev-commits-src-main@freebsd.org Sat Aug 28 18:23:46 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 57E8C677FD1; Sat, 28 Aug 2021 18:23:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GxlMk215rz3l2L; Sat, 28 Aug 2021 18:23:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2D47D1C32C; Sat, 28 Aug 2021 18:23:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17SINkrI041613; Sat, 28 Aug 2021 18:23:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17SINkg2041612; Sat, 28 Aug 2021 18:23:46 GMT (envelope-from git) Date: Sat, 28 Aug 2021 18:23:46 GMT Message-Id: <202108281823.17SINkg2041612@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dimitry Andric Subject: git: 9fae47666957 - main - Explicitly link zfsd with libspl to avoid undefined references MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9fae476669574792d75706a5401bbdc927ab2b9a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 18:23:46 -0000 The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=9fae476669574792d75706a5401bbdc927ab2b9a commit 9fae476669574792d75706a5401bbdc927ab2b9a Author: Dimitry Andric AuthorDate: 2021-08-28 18:23:15 +0000 Commit: Dimitry Andric CommitDate: 2021-08-28 18:23:28 +0000 Explicitly link zfsd with libspl to avoid undefined references Because lld 13.0.0 is more strict about undefined references when linking to shared libraries, it produces the following errors for zfsd: ld: error: /home/dim/obj/home/dim/src/llvm-13-update/amd64.amd64/tmp/usr/lib/libzfs_core.so: undefined reference to libspl_assertf [--no-allow-shlib-undefined] ld: error: /home/dim/obj/home/dim/src/llvm-13-update/amd64.amd64/tmp/usr/lib/libnvpair.so: undefined reference to libspl_assertf [--no-allow-shlib-undefined] ld: error: /home/dim/obj/home/dim/src/llvm-13-update/amd64.amd64/tmp/usr/lib/libavl.so: undefined reference to libspl_assertf [--no-allow-shlib-undefined] *** [zfsd.full] Error code 1 Fix this by adding libspl (where libspl_assertf lives) to zfsd's LIBADD. MFC after: 3 days --- cddl/usr.sbin/zfsd/Makefile.common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cddl/usr.sbin/zfsd/Makefile.common b/cddl/usr.sbin/zfsd/Makefile.common index c09f47e733dc..c18c796ce0ed 100644 --- a/cddl/usr.sbin/zfsd/Makefile.common +++ b/cddl/usr.sbin/zfsd/Makefile.common @@ -26,7 +26,7 @@ CFLAGS+= -I${SRCTOP}/cddl/usr.sbin # use issetugid(2) CFLAGS+= -D_MACHINE_FLOAT_H_ -DHAVE_ISSETUGID -LIBADD+= devdctl zfs zfs_core util geom bsdxml sbuf nvpair avl uutil zutil +LIBADD+= devdctl zfs zfs_core util geom bsdxml sbuf nvpair avl spl uutil zutil cscope: find ${.CURDIR} -type f -a \( -name "*.[ch]" -o -name "*.cc" \) \ From owner-dev-commits-src-main@freebsd.org Sat Aug 28 19:55:26 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 699A46791A2; Sat, 28 Aug 2021 19:55:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GxnPV27Sbz4f6f; Sat, 28 Aug 2021 19:55:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2C46A1CE74; Sat, 28 Aug 2021 19:55:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17SJtQPq060405; Sat, 28 Aug 2021 19:55:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17SJtQTQ060404; Sat, 28 Aug 2021 19:55:26 GMT (envelope-from git) Date: Sat, 28 Aug 2021 19:55:26 GMT Message-Id: <202108281955.17SJtQTQ060404@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 7326e8589cc2 - main - fsetown: Avoid process group lock recursion MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7326e8589cc21431d62f25802eac7c5dd6f74122 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 19:55:26 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=7326e8589cc21431d62f25802eac7c5dd6f74122 commit 7326e8589cc21431d62f25802eac7c5dd6f74122 Author: Mark Johnston AuthorDate: 2021-08-28 19:50:44 +0000 Commit: Mark Johnston CommitDate: 2021-08-28 19:50:44 +0000 fsetown: Avoid process group lock recursion Restore the pre-1d874ba4f8ba behaviour of disassociating the current SIGIO recipient before looking up the specified process or process group. This avoids a lock recursion in the scenario where a process group is configured to receive SIGIO for an fd when it has already been so configured. Reported by: pho Tested by: pho Reviewed by: kib MFC after: 3 days --- sys/kern/kern_descrip.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index f78e999ab3b5..ed7fe83cf02f 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1158,14 +1158,12 @@ fsetown(pid_t pgid, struct sigio **sigiop) sigio->sio_ucred = crhold(curthread->td_ucred); sigio->sio_myref = sigiop; - osigio = NULL; ret = 0; if (pgid > 0) { ret = pget(pgid, PGET_NOTWEXIT | PGET_NOTID | PGET_HOLD, &proc); SIGIO_LOCK(); + osigio = funsetown_locked(*sigiop); if (ret == 0) { - osigio = funsetown_locked(*sigiop); - PROC_LOCK(proc); _PRELE(proc); if ((proc->p_flag & P_WEXIT) != 0) { @@ -1191,12 +1189,11 @@ fsetown(pid_t pgid, struct sigio **sigiop) } else /* if (pgid < 0) */ { sx_slock(&proctree_lock); SIGIO_LOCK(); + osigio = funsetown_locked(*sigiop); pgrp = pgfind(-pgid); if (pgrp == NULL) { ret = ESRCH; } else { - osigio = funsetown_locked(*sigiop); - if (pgrp->pg_session != curthread->td_proc->p_session) { /* * Policy - Don't allow a process to FSETOWN a From owner-dev-commits-src-main@freebsd.org Sat Aug 28 20:39:23 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F419467956D; Sat, 28 Aug 2021 20:39:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GxpNB60TTz4rCP; Sat, 28 Aug 2021 20:39:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B1E5D1D7FE; Sat, 28 Aug 2021 20:39:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17SKdMGH014056; Sat, 28 Aug 2021 20:39:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17SKdMMO014055; Sat, 28 Aug 2021 20:39:22 GMT (envelope-from git) Date: Sat, 28 Aug 2021 20:39:22 GMT Message-Id: <202108282039.17SKdMMO014055@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 31607861e2ea - main - Style MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 31607861e2ea3adae26a4ce3f6fbd61dfbc37894 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 20:39:23 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=31607861e2ea3adae26a4ce3f6fbd61dfbc37894 commit 31607861e2ea3adae26a4ce3f6fbd61dfbc37894 Author: Konstantin Belousov AuthorDate: 2021-08-27 14:28:19 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-28 20:39:16 +0000 Style Sponsored by: The FreeBSD Foundation MFC after: 3 days --- sys/i386/i386/elf_machdep.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/i386/i386/elf_machdep.c b/sys/i386/i386/elf_machdep.c index 3754b36d9e33..5d472e4db4a2 100644 --- a/sys/i386/i386/elf_machdep.c +++ b/sys/i386/i386/elf_machdep.c @@ -261,6 +261,7 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data, if (*where != addr) *where = addr; break; + default: printf("kldload: unexpected relocation type %d, " "symbol index %d\n", rtype, symidx); From owner-dev-commits-src-main@freebsd.org Sat Aug 28 20:39:24 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0CB73679769; Sat, 28 Aug 2021 20:39:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GxpNC6g72z4rFD; Sat, 28 Aug 2021 20:39:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CC5631DA68; Sat, 28 Aug 2021 20:39:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17SKdNaq014080; Sat, 28 Aug 2021 20:39:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17SKdNCc014079; Sat, 28 Aug 2021 20:39:23 GMT (envelope-from git) Date: Sat, 28 Aug 2021 20:39:23 GMT Message-Id: <202108282039.17SKdNCc014079@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 17fc43bc0101 - main - ldd: Remove non-functional -v option MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 17fc43bc01011ed05f614f266350d37f7020a59d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 20:39:24 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=17fc43bc01011ed05f614f266350d37f7020a59d commit 17fc43bc01011ed05f614f266350d37f7020a59d Author: Konstantin Belousov AuthorDate: 2021-08-28 17:28:54 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-28 20:39:16 +0000 ldd: Remove non-functional -v option It seems -v only worked for a.out. Remove it, not even keeping the current nop for compat. Also remove more mentions of a.out format from the man page. Reviewed by: dim, emaste Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D31708 --- usr.bin/ldd/ldd.1 | 18 +----------------- usr.bin/ldd/ldd.c | 20 ++++++-------------- 2 files changed, 7 insertions(+), 31 deletions(-) diff --git a/usr.bin/ldd/ldd.1 b/usr.bin/ldd/ldd.1 index 2a90d5ac537d..d263eabcf4ff 100644 --- a/usr.bin/ldd/ldd.1 +++ b/usr.bin/ldd/ldd.1 @@ -1,6 +1,6 @@ .\" $FreeBSD$ .\" -.Dd October 23, 2018 +.Dd August 28, 2021 .Dt LDD 1 .Os .Sh NAME @@ -9,7 +9,6 @@ .Sh SYNOPSIS .Nm .Op Fl a -.Op Fl v .Op Fl f Ar format .Ar program ... .Sh DESCRIPTION @@ -47,16 +46,6 @@ The .Fl a option displays the list of all objects that are needed by each loaded object. -This option does not work with -.Xr a.out 5 -binaries. -.Pp -The -.Fl v -option displays a verbose listing of the dynamic linking headers -encoded in the executable. -See the source code and include -files for the definitive meaning of all the fields. .Sh IMPLEMENTATION NOTES .Nm lists the dependencies of an executable by setting @@ -82,8 +71,3 @@ A .Nm utility first appeared in SunOS 4.0, it appeared in its current form in .Fx 1.1 . -.Pp -The -.Fl v -support is based on code written by -.An John Polstra Aq Mt jdp@polstra.com diff --git a/usr.bin/ldd/ldd.c b/usr.bin/ldd/ldd.c index f948b7312863..3353345d549d 100644 --- a/usr.bin/ldd/ldd.c +++ b/usr.bin/ldd/ldd.c @@ -83,7 +83,7 @@ static void usage(void); #define _PATH_LDD32 "/usr/bin/ldd32" static int -execldd32(char *file, char *fmt1, char *fmt2, int aflag, int vflag) +execldd32(char *file, char *fmt1, char *fmt2, int aflag) { char *argv[9]; int i, rval, status; @@ -94,8 +94,6 @@ execldd32(char *file, char *fmt1, char *fmt2, int aflag, int vflag) argv[i++] = strdup(_PATH_LDD32); if (aflag) argv[i++] = strdup("-a"); - if (vflag) - argv[i++] = strdup("-v"); if (fmt1 != NULL) { argv[i++] = strdup("-f"); argv[i++] = strdup(fmt1); @@ -136,12 +134,12 @@ int main(int argc, char *argv[]) { char *fmt1, *fmt2; - int rval, c, aflag, vflag; + int rval, c, aflag; - aflag = vflag = 0; + aflag = 0; fmt1 = fmt2 = NULL; - while ((c = getopt(argc, argv, "af:v")) != -1) { + while ((c = getopt(argc, argv, "af:")) != -1) { switch (c) { case 'a': aflag++; @@ -154,9 +152,6 @@ main(int argc, char *argv[]) } else fmt1 = optarg; break; - case 'v': - vflag++; - break; default: usage(); /* NOTREACHED */ @@ -165,9 +160,6 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; - if (vflag && fmt1 != NULL) - errx(1, "-v may not be used with -f"); - if (argc <= 0) { usage(); /* NOTREACHED */ @@ -194,7 +186,7 @@ main(int argc, char *argv[]) break; #if __ELF_WORD_SIZE > 32 && defined(ELF32_SUPPORTED) case TYPE_ELF32: - rval |= execldd32(*argv, fmt1, fmt2, aflag, vflag); + rval |= execldd32(*argv, fmt1, fmt2, aflag); continue; #endif case TYPE_UNKNOWN: @@ -259,7 +251,7 @@ static void usage(void) { - fprintf(stderr, "usage: ldd [-a] [-v] [-f format] program ...\n"); + fprintf(stderr, "usage: ldd [-a] [-f format] program ...\n"); exit(1); } From owner-dev-commits-src-main@freebsd.org Sun Aug 29 03:52:19 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9C68A67E80C for ; Sun, 29 Aug 2021 03:52:19 +0000 (UTC) (envelope-from 0100017b90094515-bb815e35-b0f9-45d0-bcbd-961069419375-000000@amazonses.com) Received: from a8-60.smtp-out.amazonses.com (a8-60.smtp-out.amazonses.com [54.240.8.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gxzzk39P4z4tLG for ; Sun, 29 Aug 2021 03:52:18 +0000 (UTC) (envelope-from 0100017b90094515-bb815e35-b0f9-45d0-bcbd-961069419375-000000@amazonses.com) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=dqtolf56kk3wpt62c3jnwboqvr7iedax; d=tarsnap.com; t=1630209131; h=Subject:To:References:From:Message-ID:Date:MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=j1mGbeZKH/1uEWUFUYVupe8aFOPK+sKPM5mF3ECytGU=; b=Aat/bMvifPxxMiy+mQ/pN0RMoMsJ+TEMYKPJRuZecgCb5oDwnQxMvmTFcx4v0r63 Pu5wOJvvst4PgqiMNgUxX4fGCR7Al/B+9Q9Bp9Xss//YILvLw5lss4HoasaQd88xEjD +evhedqJivfVPyZvNWWX7z/a4jZ4wEOY78zpdLLY= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug; d=amazonses.com; t=1630209131; h=Subject:To:References:From:Message-ID:Date:MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding:Feedback-ID; bh=j1mGbeZKH/1uEWUFUYVupe8aFOPK+sKPM5mF3ECytGU=; b=BTAtL0NaD/OGmCv46Jv9BLaYY8bLggBPr6xZ2eDTvkQiArAkx50i0mh9gAR9wHYC l7xMT1pVXdeHNKWZ5Ni5ANwCBGlAkGZEbuXqLv5V+KTugy10b1QFWpMB3xKA2mzOl2D bHx53qIC4TlDCYo86UwOStVku9dPjee6nEUvYmEw= Subject: Re: git: 6c69c6bb4c7f - main - kvm_clock: KVM paravirtual clock support To: Konstantin Belousov , src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org References: <202108141258.17ECwEWF031182@gitrepo.freebsd.org> From: Colin Percival Message-ID: <0100017b90094515-bb815e35-b0f9-45d0-bcbd-961069419375-000000@email.amazonses.com> Date: Sun, 29 Aug 2021 03:52:11 +0000 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <202108141258.17ECwEWF031182@gitrepo.freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Feedback-ID: 1.us-east-1.Lv9FVjaNvvR5llaqfLoOVbo2VxOELl7cjN0AOyXnPlk=:AmazonSES X-SES-Outgoing: 2021.08.29-54.240.8.60 X-Rspamd-Queue-Id: 4Gxzzk39P4z4tLG X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=pass header.d=tarsnap.com header.s=dqtolf56kk3wpt62c3jnwboqvr7iedax header.b="Aat/bMvi"; dkim=pass header.d=amazonses.com header.s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug header.b=BTAtL0Na; dmarc=pass (policy=none) header.from=tarsnap.com; spf=pass (mx1.freebsd.org: domain of 0100017b90094515-bb815e35-b0f9-45d0-bcbd-961069419375-000000@amazonses.com designates 54.240.8.60 as permitted sender) smtp.mailfrom=0100017b90094515-bb815e35-b0f9-45d0-bcbd-961069419375-000000@amazonses.com X-Spamd-Result: default: False [-1.20 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[tarsnap.com:s=dqtolf56kk3wpt62c3jnwboqvr7iedax,amazonses.com:s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; R_SPF_ALLOW(-0.20)[+ip4:54.240.0.0/18:c]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; DWL_DNSWL_NONE(0.00)[amazonses.com:dkim]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[tarsnap.com:+,amazonses.com:+]; DMARC_POLICY_ALLOW(-0.50)[tarsnap.com,none]; RCVD_IN_DNSWL_NONE(0.00)[54.240.8.60:from]; NEURAL_HAM_SHORT(-1.00)[-1.000]; FORGED_SENDER(0.30)[cperciva@tarsnap.com,0100017b90094515-bb815e35-b0f9-45d0-bcbd-961069419375-000000@amazonses.com]; RCVD_COUNT_ZERO(0.00)[0]; RWL_MAILSPIKE_POSSIBLE(0.00)[54.240.8.60:from]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:14618, ipnet:54.240.8.0/21, country:US]; FORGED_MUA_THUNDERBIRD_MSGID_UNKNOWN(2.50)[]; FROM_NEQ_ENVFROM(0.00)[cperciva@tarsnap.com,0100017b90094515-bb815e35-b0f9-45d0-bcbd-961069419375-000000@amazonses.com]; MAILMAN_DEST(0.00)[dev-commits-src-main] X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 03:52:19 -0000 Will this be MFCed to stable/13 ? I'd really really like to have it in 13.1 since it fixes a regression in EC2. Colin Percival On 8/14/21 5:58 AM, Konstantin Belousov wrote: > The branch main has been updated by kib: > > URL: https://cgit.FreeBSD.org/src/commit/?id=6c69c6bb4c7ffde48b130df707799d4eca21ca9f > > commit 6c69c6bb4c7ffde48b130df707799d4eca21ca9f > Author: Adam Fenn > AuthorDate: 2021-08-04 15:42:48 +0000 > Commit: Konstantin Belousov > CommitDate: 2021-08-14 12:57:54 +0000 > > kvm_clock: KVM paravirtual clock support > > Add support for the KVM paravirtual clock device. > > Sponsored by: Juniper Networks, Inc. > Sponsored by: Klara, Inc. > Reviewed by: kib > Differential Revision: https://reviews.freebsd.org/D29733 > --- > sys/amd64/conf/GENERIC | 3 + > sys/amd64/conf/MINIMAL | 3 + > sys/amd64/conf/NOTES | 3 + > sys/conf/files.x86 | 3 +- > sys/dev/kvm_clock/kvm_clock.c | 240 ++++++++++++++++++++++++++++++++++++++++++ > sys/i386/conf/GENERIC | 3 + > sys/i386/conf/MINIMAL | 3 + > sys/i386/conf/NOTES | 3 + > sys/x86/include/kvm.h | 80 ++++++++++++++ > 9 files changed, 340 insertions(+), 1 deletion(-) > > diff --git a/sys/amd64/conf/GENERIC b/sys/amd64/conf/GENERIC > index f7b41919575d..78b5e0e299f6 100644 > --- a/sys/amd64/conf/GENERIC > +++ b/sys/amd64/conf/GENERIC > @@ -376,6 +376,9 @@ device virtio_blk # VirtIO Block device > device virtio_scsi # VirtIO SCSI device > device virtio_balloon # VirtIO Memory Balloon device > > +# Linux KVM paravirtualization support > +device kvm_clock # KVM paravirtual clock driver > + > # HyperV drivers and enhancement support > device hyperv # HyperV drivers > > diff --git a/sys/amd64/conf/MINIMAL b/sys/amd64/conf/MINIMAL > index 14f91e6c8eaf..f724cbd2e3f1 100644 > --- a/sys/amd64/conf/MINIMAL > +++ b/sys/amd64/conf/MINIMAL > @@ -131,6 +131,9 @@ device ether # Ethernet support > # Note that 'bpf' is required for DHCP. > device bpf # Berkeley packet filter > > +# Linux KVM paravirtualization support > +device kvm_clock # KVM paravirtual clock driver > + > # Xen HVM Guest Optimizations > # NOTE: XENHVM depends on xenpci and xentimer. > # They must be added or removed together. > diff --git a/sys/amd64/conf/NOTES b/sys/amd64/conf/NOTES > index 501ceaedb222..c1db8ef7512f 100644 > --- a/sys/amd64/conf/NOTES > +++ b/sys/amd64/conf/NOTES > @@ -498,6 +498,9 @@ device virtio_balloon # VirtIO Memory Balloon device > device virtio_random # VirtIO Entropy device > device virtio_console # VirtIO Console device > > +# Linux KVM paravirtualization support > +device kvm_clock # KVM paravirtual clock driver > + > # Microsoft Hyper-V enhancement support > device hyperv # HyperV drivers > > diff --git a/sys/conf/files.x86 b/sys/conf/files.x86 > index d1fc234c4182..d0cda2da8580 100644 > --- a/sys/conf/files.x86 > +++ b/sys/conf/files.x86 > @@ -263,6 +263,7 @@ dev/isci/scil/scif_sas_task_request_state_handlers.c optional isci > dev/isci/scil/scif_sas_task_request_states.c optional isci > dev/isci/scil/scif_sas_timer.c optional isci > dev/itwd/itwd.c optional itwd > +dev/kvm_clock/kvm_clock.c optional kvm_clock > dev/qat/qat.c optional qat > dev/qat/qat_ae.c optional qat > dev/qat/qat_c2xxx.c optional qat > @@ -318,7 +319,7 @@ x86/x86/x86_mem.c optional mem > x86/x86/mp_x86.c optional smp > x86/x86/mp_watchdog.c optional mp_watchdog smp > x86/x86/nexus.c standard > -x86/x86/pvclock.c optional xenhvm > +x86/x86/pvclock.c optional kvm_clock | xenhvm > x86/x86/stack_machdep.c optional ddb | stack > x86/x86/tsc.c standard > x86/x86/ucode.c standard > diff --git a/sys/dev/kvm_clock/kvm_clock.c b/sys/dev/kvm_clock/kvm_clock.c > new file mode 100644 > index 000000000000..1a76432e417d > --- /dev/null > +++ b/sys/dev/kvm_clock/kvm_clock.c > @@ -0,0 +1,240 @@ > +/*- > + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD > + * > + * Copyright (c) 2014 Bryan Venteicher > + * Copyright (c) 2021 Mathieu Chouquet-Stringer > + * Copyright (c) 2021 Juniper Networks, Inc. > + * Copyright (c) 2021 Klara, Inc. > + * > + * 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. > + */ > + > +/* > + * Linux KVM paravirtual clock support > + * > + * References: > + * - [1] https://www.kernel.org/doc/html/latest/virt/kvm/cpuid.html > + * - [2] https://www.kernel.org/doc/html/latest/virt/kvm/msr.html > + */ > + > +#include > +__FBSDID("$FreeBSD$"); > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > +#include > + > +#include > +#include > + > +#include "clock_if.h" > + > +#define KVM_CLOCK_DEVNAME "kvmclock" > +/* > + * Note: Chosen to be (1) above HPET's value (always 950), (2) above the TSC's > + * default value of 800, and (3) below the TSC's value when it supports the > + * "Invariant TSC" feature and is believed to be synchronized across all CPUs. > + */ > +#define KVM_CLOCK_TC_QUALITY 975 > + > +struct kvm_clock_softc { > + struct pvclock pvc; > + struct pvclock_wall_clock wc; > + struct pvclock_vcpu_time_info *timeinfos; > + u_int msr_tc; > + u_int msr_wc; > +}; > + > +static devclass_t kvm_clock_devclass; > + > +static struct pvclock_wall_clock *kvm_clock_get_wallclock(void *arg); > +static void kvm_clock_system_time_enable(struct kvm_clock_softc *sc); > +static void kvm_clock_system_time_enable_pcpu(void *arg); > + > +static struct pvclock_wall_clock * > +kvm_clock_get_wallclock(void *arg) > +{ > + struct kvm_clock_softc *sc = arg; > + > + wrmsr(sc->msr_wc, vtophys(&sc->wc)); > + return (&sc->wc); > +} > + > +static void > +kvm_clock_system_time_enable(struct kvm_clock_softc *sc) > +{ > + smp_rendezvous(NULL, kvm_clock_system_time_enable_pcpu, NULL, sc); > +} > + > +static void > +kvm_clock_system_time_enable_pcpu(void *arg) > +{ > + struct kvm_clock_softc *sc = arg; > + > + /* > + * See [2]; the lsb of this MSR is the system time enable bit. > + */ > + wrmsr(sc->msr_tc, vtophys(&(sc->timeinfos)[curcpu]) | 1); > +} > + > +static void > +kvm_clock_identify(driver_t *driver, device_t parent) > +{ > + u_int regs[4]; > + > + kvm_cpuid_get_features(regs); > + if ((regs[0] & > + (KVM_FEATURE_CLOCKSOURCE2 | KVM_FEATURE_CLOCKSOURCE)) == 0) > + return; > + if (device_find_child(parent, KVM_CLOCK_DEVNAME, -1)) > + return; > + BUS_ADD_CHILD(parent, 0, KVM_CLOCK_DEVNAME, 0); > +} > + > +static int > +kvm_clock_probe(device_t dev) > +{ > + device_set_desc(dev, "KVM paravirtual clock"); > + return (BUS_PROBE_DEFAULT); > +} > + > +static int > +kvm_clock_attach(device_t dev) > +{ > + u_int regs[4]; > + struct kvm_clock_softc *sc = device_get_softc(dev); > + bool stable_flag_supported; > + > + /* Process KVM "features" CPUID leaf content: */ > + kvm_cpuid_get_features(regs); > + if ((regs[0] & KVM_FEATURE_CLOCKSOURCE2) != 0) { > + sc->msr_tc = KVM_MSR_SYSTEM_TIME_NEW; > + sc->msr_wc = KVM_MSR_WALL_CLOCK_NEW; > + } else { > + KASSERT((regs[0] & KVM_FEATURE_CLOCKSOURCE) != 0, > + ("Clocksource feature flags disappeared since " > + "kvm_clock_identify: regs[0] %#0x.", regs[0])); > + sc->msr_tc = KVM_MSR_SYSTEM_TIME; > + sc->msr_wc = KVM_MSR_WALL_CLOCK; > + } > + stable_flag_supported = > + (regs[0] & KVM_FEATURE_CLOCKSOURCE_STABLE_BIT) != 0; > + > + /* Set up 'struct pvclock_vcpu_time_info' page(s): */ > + sc->timeinfos = (struct pvclock_vcpu_time_info *)kmem_malloc(mp_ncpus * > + sizeof(struct pvclock_vcpu_time_info), M_WAITOK | M_ZERO); > + kvm_clock_system_time_enable(sc); > + > + /* > + * Init pvclock; register KVM clock wall clock, register KVM clock > + * timecounter, and set up the requisite infrastructure for vDSO access > + * to this timecounter. > + * Regarding 'tc_flags': Since the KVM MSR documentation does not > + * specifically discuss suspend/resume scenarios, conservatively > + * leave 'TC_FLAGS_SUSPEND_SAFE' cleared and assume that the system > + * time must be re-inited in such cases. > + */ > + sc->pvc.get_wallclock = kvm_clock_get_wallclock; > + sc->pvc.get_wallclock_arg = sc; > + sc->pvc.timeinfos = sc->timeinfos; > + sc->pvc.stable_flag_supported = stable_flag_supported; > + pvclock_init(&sc->pvc, dev, KVM_CLOCK_DEVNAME, KVM_CLOCK_TC_QUALITY, 0); > + return (0); > +} > + > +static int > +kvm_clock_detach(device_t dev) > +{ > + struct kvm_clock_softc *sc = device_get_softc(dev); > + > + return (pvclock_destroy(&sc->pvc)); > +} > + > +static int > +kvm_clock_suspend(device_t dev) > +{ > + return (0); > +} > + > +static int > +kvm_clock_resume(device_t dev) > +{ > + /* > + * See note in 'kvm_clock_attach()' regarding 'TC_FLAGS_SUSPEND_SAFE'; > + * conservatively assume that the system time must be re-inited in > + * suspend/resume scenarios. > + */ > + kvm_clock_system_time_enable(device_get_softc(dev)); > + pvclock_resume(); > + inittodr(time_second); > + return (0); > +} > + > +static int > +kvm_clock_gettime(device_t dev, struct timespec *ts) > +{ > + struct kvm_clock_softc *sc = device_get_softc(dev); > + > + pvclock_gettime(&sc->pvc, ts); > + return (0); > +} > + > +static int > +kvm_clock_settime(device_t dev, struct timespec *ts) > +{ > + /* > + * Even though it is not possible to set the KVM clock's wall clock, to > + * avoid the possibility of periodic benign error messages from > + * 'settime_task_func()', report success rather than, e.g., 'ENODEV'. > + */ > + return (0); > +} > + > +static device_method_t kvm_clock_methods[] = { > + DEVMETHOD(device_identify, kvm_clock_identify), > + DEVMETHOD(device_probe, kvm_clock_probe), > + DEVMETHOD(device_attach, kvm_clock_attach), > + DEVMETHOD(device_detach, kvm_clock_detach), > + DEVMETHOD(device_suspend, kvm_clock_suspend), > + DEVMETHOD(device_resume, kvm_clock_resume), > + /* clock interface */ > + DEVMETHOD(clock_gettime, kvm_clock_gettime), > + DEVMETHOD(clock_settime, kvm_clock_settime), > + > + DEVMETHOD_END > +}; > + > +static driver_t kvm_clock_driver = { > + KVM_CLOCK_DEVNAME, > + kvm_clock_methods, > + sizeof(struct kvm_clock_softc), > +}; > + > +DRIVER_MODULE(kvm_clock, nexus, kvm_clock_driver, kvm_clock_devclass, 0, 0); > diff --git a/sys/i386/conf/GENERIC b/sys/i386/conf/GENERIC > index 86c062effd81..5447c452c4f7 100644 > --- a/sys/i386/conf/GENERIC > +++ b/sys/i386/conf/GENERIC > @@ -337,6 +337,9 @@ device virtio_blk # VirtIO Block device > device virtio_scsi # VirtIO SCSI device > device virtio_balloon # VirtIO Memory Balloon device > > +# Linux KVM paravirtualization support > +device kvm_clock # KVM paravirtual clock driver > + > # HyperV drivers and enhancement support > # NOTE: HYPERV depends on hyperv. They must be added or removed together. > options HYPERV # Kernel support for HyperV drivers > diff --git a/sys/i386/conf/MINIMAL b/sys/i386/conf/MINIMAL > index 37b8e074ac65..9d735dbb0580 100644 > --- a/sys/i386/conf/MINIMAL > +++ b/sys/i386/conf/MINIMAL > @@ -145,6 +145,9 @@ device gif # IPv6 and IPv4 tunneling > # Note that 'bpf' is required for DHCP. > device bpf # Berkeley packet filter > > +# Linux KVM paravirtualization support > +device kvm_clock # KVM paravirtual clock driver > + > # Xen HVM Guest Optimizations > # NOTE: XENHVM depends on xenpci. They must be added or removed together. > options XENHVM # Xen HVM kernel infrastructure > diff --git a/sys/i386/conf/NOTES b/sys/i386/conf/NOTES > index df9ff4fb3aed..27cebf0c48a0 100644 > --- a/sys/i386/conf/NOTES > +++ b/sys/i386/conf/NOTES > @@ -719,6 +719,9 @@ device virtio_balloon # VirtIO Memory Balloon device > device virtio_random # VirtIO Entropy device > device virtio_console # VirtIO Console device > > +# Linux KVM paravirtualization support > +device kvm_clock # KVM paravirtual clock driver > + > options HYPERV > device hyperv # HyperV drivers > > diff --git a/sys/x86/include/kvm.h b/sys/x86/include/kvm.h > new file mode 100644 > index 000000000000..beec6447d7d6 > --- /dev/null > +++ b/sys/x86/include/kvm.h > @@ -0,0 +1,80 @@ > +/*- > + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD > + * > + * Copyright (c) 2014 Bryan Venteicher > + * Copyright (c) 2021 Mathieu Chouquet-Stringer > + * Copyright (c) 2021 Juniper Networks, Inc. > + * Copyright (c) 2021 Klara, Inc. > + * > + * 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$ > + */ > + > +/* > + * Linux KVM paravirtualization: common definitions > + * > + * References: > + * - [1] https://www.kernel.org/doc/html/latest/virt/kvm/cpuid.html > + * - [2] https://www.kernel.org/doc/html/latest/virt/kvm/msr.html > + */ > + > +#ifndef _X86_KVM_H_ > +#define _X86_KVM_H_ > + > +#include > +#include > + > +#include > + > +#define KVM_CPUID_SIGNATURE 0x40000000 > +#define KVM_CPUID_FEATURES_LEAF 0x40000001 > + > +#define KVM_FEATURE_CLOCKSOURCE 0x00000001 > +#define KVM_FEATURE_CLOCKSOURCE2 0x00000008 > +#define KVM_FEATURE_CLOCKSOURCE_STABLE_BIT 0x01000000 > + > +/* Deprecated: for the CLOCKSOURCE feature. */ > +#define KVM_MSR_WALL_CLOCK 0x11 > +#define KVM_MSR_SYSTEM_TIME 0x12 > + > +#define KVM_MSR_WALL_CLOCK_NEW 0x4b564d00 > +#define KVM_MSR_SYSTEM_TIME_NEW 0x4b564d01 > + > +static inline bool > +kvm_cpuid_features_leaf_supported(void) > +{ > + return (vm_guest == VM_GUEST_KVM && > + KVM_CPUID_FEATURES_LEAF > hv_base && > + KVM_CPUID_FEATURES_LEAF <= hv_high); > +} > + > +static inline void > +kvm_cpuid_get_features(u_int *regs) > +{ > + if (!kvm_cpuid_features_leaf_supported()) > + regs[0] = regs[1] = regs[2] = regs[3] = 0; > + else > + do_cpuid(KVM_CPUID_FEATURES_LEAF, regs); > +} > + > +#endif /* !_X86_KVM_H_ */ > -- Colin Percival Security Officer Emeritus, FreeBSD | The power to serve Founder, Tarsnap | www.tarsnap.com | Online backups for the truly paranoid From owner-dev-commits-src-main@freebsd.org Sun Aug 29 04:03:57 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E4C4667EAD6; Sun, 29 Aug 2021 04:03:57 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gy0F74Tp5z3DML; Sun, 29 Aug 2021 04:03:55 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.16.1/8.16.1) with ESMTPS id 17T43kdQ018646 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sun, 29 Aug 2021 07:03:49 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 17T43kdQ018646 Received: (from kostik@localhost) by tom.home (8.16.1/8.16.1/Submit) id 17T43kGK018645; Sun, 29 Aug 2021 07:03:46 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 29 Aug 2021 07:03:46 +0300 From: Konstantin Belousov To: Colin Percival Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 6c69c6bb4c7f - main - kvm_clock: KVM paravirtual clock support Message-ID: References: <202108141258.17ECwEWF031182@gitrepo.freebsd.org> <0100017b90094507-d735fec4-16d5-4a6f-9851-9634d464e0aa-000000@email.amazonses.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0100017b90094507-d735fec4-16d5-4a6f-9851-9634d464e0aa-000000@email.amazonses.com> X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.5 X-Spam-Checker-Version: SpamAssassin 3.4.5 (2021-03-20) on tom.home X-Rspamd-Queue-Id: 4Gy0F74Tp5z3DML X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=gmail.com (policy=none); spf=softfail (mx1.freebsd.org: 2001:470:d5e7:1::1 is neither permitted nor denied by domain of kostikbel@gmail.com) smtp.mailfrom=kostikbel@gmail.com X-Spamd-Result: default: False [-1.00 / 15.00]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; DMARC_POLICY_SOFTFAIL(0.10)[gmail.com : No valid SPF, No valid DKIM,none]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FREEMAIL_FROM(0.00)[gmail.com]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; HAS_XAW(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_SOFTFAIL(0.00)[~all]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_SPAM_SHORT(1.00)[0.999]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US]; MIME_TRACE(0.00)[0:+]; MAILMAN_DEST(0.00)[dev-commits-src-all,dev-commits-src-main]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 04:03:58 -0000 On Sun, Aug 29, 2021 at 03:52:11AM +0000, Colin Percival wrote: > Will this be MFCed to stable/13 ? I'd really really like to have it in 13.1 > since it fixes a regression in EC2. Yes I plan to. I am not sure when: there was at least one report of a breakage under vbox, and I did not get any feedback on HEAD. The patches sit on my staging stable/13 branch FWIW. > > Colin Percival > > On 8/14/21 5:58 AM, Konstantin Belousov wrote: > > The branch main has been updated by kib: > > > > URL: https://cgit.FreeBSD.org/src/commit/?id=6c69c6bb4c7ffde48b130df707799d4eca21ca9f > > > > commit 6c69c6bb4c7ffde48b130df707799d4eca21ca9f > > Author: Adam Fenn > > AuthorDate: 2021-08-04 15:42:48 +0000 > > Commit: Konstantin Belousov > > CommitDate: 2021-08-14 12:57:54 +0000 > > > > kvm_clock: KVM paravirtual clock support > > > > Add support for the KVM paravirtual clock device. > > > > Sponsored by: Juniper Networks, Inc. > > Sponsored by: Klara, Inc. > > Reviewed by: kib > > Differential Revision: https://reviews.freebsd.org/D29733 > > --- > > sys/amd64/conf/GENERIC | 3 + > > sys/amd64/conf/MINIMAL | 3 + > > sys/amd64/conf/NOTES | 3 + > > sys/conf/files.x86 | 3 +- > > sys/dev/kvm_clock/kvm_clock.c | 240 ++++++++++++++++++++++++++++++++++++++++++ > > sys/i386/conf/GENERIC | 3 + > > sys/i386/conf/MINIMAL | 3 + > > sys/i386/conf/NOTES | 3 + > > sys/x86/include/kvm.h | 80 ++++++++++++++ > > 9 files changed, 340 insertions(+), 1 deletion(-) > > > > diff --git a/sys/amd64/conf/GENERIC b/sys/amd64/conf/GENERIC > > index f7b41919575d..78b5e0e299f6 100644 > > --- a/sys/amd64/conf/GENERIC > > +++ b/sys/amd64/conf/GENERIC > > @@ -376,6 +376,9 @@ device virtio_blk # VirtIO Block device > > device virtio_scsi # VirtIO SCSI device > > device virtio_balloon # VirtIO Memory Balloon device > > > > +# Linux KVM paravirtualization support > > +device kvm_clock # KVM paravirtual clock driver > > + > > # HyperV drivers and enhancement support > > device hyperv # HyperV drivers > > > > diff --git a/sys/amd64/conf/MINIMAL b/sys/amd64/conf/MINIMAL > > index 14f91e6c8eaf..f724cbd2e3f1 100644 > > --- a/sys/amd64/conf/MINIMAL > > +++ b/sys/amd64/conf/MINIMAL > > @@ -131,6 +131,9 @@ device ether # Ethernet support > > # Note that 'bpf' is required for DHCP. > > device bpf # Berkeley packet filter > > > > +# Linux KVM paravirtualization support > > +device kvm_clock # KVM paravirtual clock driver > > + > > # Xen HVM Guest Optimizations > > # NOTE: XENHVM depends on xenpci and xentimer. > > # They must be added or removed together. > > diff --git a/sys/amd64/conf/NOTES b/sys/amd64/conf/NOTES > > index 501ceaedb222..c1db8ef7512f 100644 > > --- a/sys/amd64/conf/NOTES > > +++ b/sys/amd64/conf/NOTES > > @@ -498,6 +498,9 @@ device virtio_balloon # VirtIO Memory Balloon device > > device virtio_random # VirtIO Entropy device > > device virtio_console # VirtIO Console device > > > > +# Linux KVM paravirtualization support > > +device kvm_clock # KVM paravirtual clock driver > > + > > # Microsoft Hyper-V enhancement support > > device hyperv # HyperV drivers > > > > diff --git a/sys/conf/files.x86 b/sys/conf/files.x86 > > index d1fc234c4182..d0cda2da8580 100644 > > --- a/sys/conf/files.x86 > > +++ b/sys/conf/files.x86 > > @@ -263,6 +263,7 @@ dev/isci/scil/scif_sas_task_request_state_handlers.c optional isci > > dev/isci/scil/scif_sas_task_request_states.c optional isci > > dev/isci/scil/scif_sas_timer.c optional isci > > dev/itwd/itwd.c optional itwd > > +dev/kvm_clock/kvm_clock.c optional kvm_clock > > dev/qat/qat.c optional qat > > dev/qat/qat_ae.c optional qat > > dev/qat/qat_c2xxx.c optional qat > > @@ -318,7 +319,7 @@ x86/x86/x86_mem.c optional mem > > x86/x86/mp_x86.c optional smp > > x86/x86/mp_watchdog.c optional mp_watchdog smp > > x86/x86/nexus.c standard > > -x86/x86/pvclock.c optional xenhvm > > +x86/x86/pvclock.c optional kvm_clock | xenhvm > > x86/x86/stack_machdep.c optional ddb | stack > > x86/x86/tsc.c standard > > x86/x86/ucode.c standard > > diff --git a/sys/dev/kvm_clock/kvm_clock.c b/sys/dev/kvm_clock/kvm_clock.c > > new file mode 100644 > > index 000000000000..1a76432e417d > > --- /dev/null > > +++ b/sys/dev/kvm_clock/kvm_clock.c > > @@ -0,0 +1,240 @@ > > +/*- > > + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD > > + * > > + * Copyright (c) 2014 Bryan Venteicher > > + * Copyright (c) 2021 Mathieu Chouquet-Stringer > > + * Copyright (c) 2021 Juniper Networks, Inc. > > + * Copyright (c) 2021 Klara, Inc. > > + * > > + * 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. > > + */ > > + > > +/* > > + * Linux KVM paravirtual clock support > > + * > > + * References: > > + * - [1] https://www.kernel.org/doc/html/latest/virt/kvm/cpuid.html > > + * - [2] https://www.kernel.org/doc/html/latest/virt/kvm/msr.html > > + */ > > + > > +#include > > +__FBSDID("$FreeBSD$"); > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#include > > +#include > > +#include > > + > > +#include > > +#include > > + > > +#include "clock_if.h" > > + > > +#define KVM_CLOCK_DEVNAME "kvmclock" > > +/* > > + * Note: Chosen to be (1) above HPET's value (always 950), (2) above the TSC's > > + * default value of 800, and (3) below the TSC's value when it supports the > > + * "Invariant TSC" feature and is believed to be synchronized across all CPUs. > > + */ > > +#define KVM_CLOCK_TC_QUALITY 975 > > + > > +struct kvm_clock_softc { > > + struct pvclock pvc; > > + struct pvclock_wall_clock wc; > > + struct pvclock_vcpu_time_info *timeinfos; > > + u_int msr_tc; > > + u_int msr_wc; > > +}; > > + > > +static devclass_t kvm_clock_devclass; > > + > > +static struct pvclock_wall_clock *kvm_clock_get_wallclock(void *arg); > > +static void kvm_clock_system_time_enable(struct kvm_clock_softc *sc); > > +static void kvm_clock_system_time_enable_pcpu(void *arg); > > + > > +static struct pvclock_wall_clock * > > +kvm_clock_get_wallclock(void *arg) > > +{ > > + struct kvm_clock_softc *sc = arg; > > + > > + wrmsr(sc->msr_wc, vtophys(&sc->wc)); > > + return (&sc->wc); > > +} > > + > > +static void > > +kvm_clock_system_time_enable(struct kvm_clock_softc *sc) > > +{ > > + smp_rendezvous(NULL, kvm_clock_system_time_enable_pcpu, NULL, sc); > > +} > > + > > +static void > > +kvm_clock_system_time_enable_pcpu(void *arg) > > +{ > > + struct kvm_clock_softc *sc = arg; > > + > > + /* > > + * See [2]; the lsb of this MSR is the system time enable bit. > > + */ > > + wrmsr(sc->msr_tc, vtophys(&(sc->timeinfos)[curcpu]) | 1); > > +} > > + > > +static void > > +kvm_clock_identify(driver_t *driver, device_t parent) > > +{ > > + u_int regs[4]; > > + > > + kvm_cpuid_get_features(regs); > > + if ((regs[0] & > > + (KVM_FEATURE_CLOCKSOURCE2 | KVM_FEATURE_CLOCKSOURCE)) == 0) > > + return; > > + if (device_find_child(parent, KVM_CLOCK_DEVNAME, -1)) > > + return; > > + BUS_ADD_CHILD(parent, 0, KVM_CLOCK_DEVNAME, 0); > > +} > > + > > +static int > > +kvm_clock_probe(device_t dev) > > +{ > > + device_set_desc(dev, "KVM paravirtual clock"); > > + return (BUS_PROBE_DEFAULT); > > +} > > + > > +static int > > +kvm_clock_attach(device_t dev) > > +{ > > + u_int regs[4]; > > + struct kvm_clock_softc *sc = device_get_softc(dev); > > + bool stable_flag_supported; > > + > > + /* Process KVM "features" CPUID leaf content: */ > > + kvm_cpuid_get_features(regs); > > + if ((regs[0] & KVM_FEATURE_CLOCKSOURCE2) != 0) { > > + sc->msr_tc = KVM_MSR_SYSTEM_TIME_NEW; > > + sc->msr_wc = KVM_MSR_WALL_CLOCK_NEW; > > + } else { > > + KASSERT((regs[0] & KVM_FEATURE_CLOCKSOURCE) != 0, > > + ("Clocksource feature flags disappeared since " > > + "kvm_clock_identify: regs[0] %#0x.", regs[0])); > > + sc->msr_tc = KVM_MSR_SYSTEM_TIME; > > + sc->msr_wc = KVM_MSR_WALL_CLOCK; > > + } > > + stable_flag_supported = > > + (regs[0] & KVM_FEATURE_CLOCKSOURCE_STABLE_BIT) != 0; > > + > > + /* Set up 'struct pvclock_vcpu_time_info' page(s): */ > > + sc->timeinfos = (struct pvclock_vcpu_time_info *)kmem_malloc(mp_ncpus * > > + sizeof(struct pvclock_vcpu_time_info), M_WAITOK | M_ZERO); > > + kvm_clock_system_time_enable(sc); > > + > > + /* > > + * Init pvclock; register KVM clock wall clock, register KVM clock > > + * timecounter, and set up the requisite infrastructure for vDSO access > > + * to this timecounter. > > + * Regarding 'tc_flags': Since the KVM MSR documentation does not > > + * specifically discuss suspend/resume scenarios, conservatively > > + * leave 'TC_FLAGS_SUSPEND_SAFE' cleared and assume that the system > > + * time must be re-inited in such cases. > > + */ > > + sc->pvc.get_wallclock = kvm_clock_get_wallclock; > > + sc->pvc.get_wallclock_arg = sc; > > + sc->pvc.timeinfos = sc->timeinfos; > > + sc->pvc.stable_flag_supported = stable_flag_supported; > > + pvclock_init(&sc->pvc, dev, KVM_CLOCK_DEVNAME, KVM_CLOCK_TC_QUALITY, 0); > > + return (0); > > +} > > + > > +static int > > +kvm_clock_detach(device_t dev) > > +{ > > + struct kvm_clock_softc *sc = device_get_softc(dev); > > + > > + return (pvclock_destroy(&sc->pvc)); > > +} > > + > > +static int > > +kvm_clock_suspend(device_t dev) > > +{ > > + return (0); > > +} > > + > > +static int > > +kvm_clock_resume(device_t dev) > > +{ > > + /* > > + * See note in 'kvm_clock_attach()' regarding 'TC_FLAGS_SUSPEND_SAFE'; > > + * conservatively assume that the system time must be re-inited in > > + * suspend/resume scenarios. > > + */ > > + kvm_clock_system_time_enable(device_get_softc(dev)); > > + pvclock_resume(); > > + inittodr(time_second); > > + return (0); > > +} > > + > > +static int > > +kvm_clock_gettime(device_t dev, struct timespec *ts) > > +{ > > + struct kvm_clock_softc *sc = device_get_softc(dev); > > + > > + pvclock_gettime(&sc->pvc, ts); > > + return (0); > > +} > > + > > +static int > > +kvm_clock_settime(device_t dev, struct timespec *ts) > > +{ > > + /* > > + * Even though it is not possible to set the KVM clock's wall clock, to > > + * avoid the possibility of periodic benign error messages from > > + * 'settime_task_func()', report success rather than, e.g., 'ENODEV'. > > + */ > > + return (0); > > +} > > + > > +static device_method_t kvm_clock_methods[] = { > > + DEVMETHOD(device_identify, kvm_clock_identify), > > + DEVMETHOD(device_probe, kvm_clock_probe), > > + DEVMETHOD(device_attach, kvm_clock_attach), > > + DEVMETHOD(device_detach, kvm_clock_detach), > > + DEVMETHOD(device_suspend, kvm_clock_suspend), > > + DEVMETHOD(device_resume, kvm_clock_resume), > > + /* clock interface */ > > + DEVMETHOD(clock_gettime, kvm_clock_gettime), > > + DEVMETHOD(clock_settime, kvm_clock_settime), > > + > > + DEVMETHOD_END > > +}; > > + > > +static driver_t kvm_clock_driver = { > > + KVM_CLOCK_DEVNAME, > > + kvm_clock_methods, > > + sizeof(struct kvm_clock_softc), > > +}; > > + > > +DRIVER_MODULE(kvm_clock, nexus, kvm_clock_driver, kvm_clock_devclass, 0, 0); > > diff --git a/sys/i386/conf/GENERIC b/sys/i386/conf/GENERIC > > index 86c062effd81..5447c452c4f7 100644 > > --- a/sys/i386/conf/GENERIC > > +++ b/sys/i386/conf/GENERIC > > @@ -337,6 +337,9 @@ device virtio_blk # VirtIO Block device > > device virtio_scsi # VirtIO SCSI device > > device virtio_balloon # VirtIO Memory Balloon device > > > > +# Linux KVM paravirtualization support > > +device kvm_clock # KVM paravirtual clock driver > > + > > # HyperV drivers and enhancement support > > # NOTE: HYPERV depends on hyperv. They must be added or removed together. > > options HYPERV # Kernel support for HyperV drivers > > diff --git a/sys/i386/conf/MINIMAL b/sys/i386/conf/MINIMAL > > index 37b8e074ac65..9d735dbb0580 100644 > > --- a/sys/i386/conf/MINIMAL > > +++ b/sys/i386/conf/MINIMAL > > @@ -145,6 +145,9 @@ device gif # IPv6 and IPv4 tunneling > > # Note that 'bpf' is required for DHCP. > > device bpf # Berkeley packet filter > > > > +# Linux KVM paravirtualization support > > +device kvm_clock # KVM paravirtual clock driver > > + > > # Xen HVM Guest Optimizations > > # NOTE: XENHVM depends on xenpci. They must be added or removed together. > > options XENHVM # Xen HVM kernel infrastructure > > diff --git a/sys/i386/conf/NOTES b/sys/i386/conf/NOTES > > index df9ff4fb3aed..27cebf0c48a0 100644 > > --- a/sys/i386/conf/NOTES > > +++ b/sys/i386/conf/NOTES > > @@ -719,6 +719,9 @@ device virtio_balloon # VirtIO Memory Balloon device > > device virtio_random # VirtIO Entropy device > > device virtio_console # VirtIO Console device > > > > +# Linux KVM paravirtualization support > > +device kvm_clock # KVM paravirtual clock driver > > + > > options HYPERV > > device hyperv # HyperV drivers > > > > diff --git a/sys/x86/include/kvm.h b/sys/x86/include/kvm.h > > new file mode 100644 > > index 000000000000..beec6447d7d6 > > --- /dev/null > > +++ b/sys/x86/include/kvm.h > > @@ -0,0 +1,80 @@ > > +/*- > > + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD > > + * > > + * Copyright (c) 2014 Bryan Venteicher > > + * Copyright (c) 2021 Mathieu Chouquet-Stringer > > + * Copyright (c) 2021 Juniper Networks, Inc. > > + * Copyright (c) 2021 Klara, Inc. > > + * > > + * 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$ > > + */ > > + > > +/* > > + * Linux KVM paravirtualization: common definitions > > + * > > + * References: > > + * - [1] https://www.kernel.org/doc/html/latest/virt/kvm/cpuid.html > > + * - [2] https://www.kernel.org/doc/html/latest/virt/kvm/msr.html > > + */ > > + > > +#ifndef _X86_KVM_H_ > > +#define _X86_KVM_H_ > > + > > +#include > > +#include > > + > > +#include > > + > > +#define KVM_CPUID_SIGNATURE 0x40000000 > > +#define KVM_CPUID_FEATURES_LEAF 0x40000001 > > + > > +#define KVM_FEATURE_CLOCKSOURCE 0x00000001 > > +#define KVM_FEATURE_CLOCKSOURCE2 0x00000008 > > +#define KVM_FEATURE_CLOCKSOURCE_STABLE_BIT 0x01000000 > > + > > +/* Deprecated: for the CLOCKSOURCE feature. */ > > +#define KVM_MSR_WALL_CLOCK 0x11 > > +#define KVM_MSR_SYSTEM_TIME 0x12 > > + > > +#define KVM_MSR_WALL_CLOCK_NEW 0x4b564d00 > > +#define KVM_MSR_SYSTEM_TIME_NEW 0x4b564d01 > > + > > +static inline bool > > +kvm_cpuid_features_leaf_supported(void) > > +{ > > + return (vm_guest == VM_GUEST_KVM && > > + KVM_CPUID_FEATURES_LEAF > hv_base && > > + KVM_CPUID_FEATURES_LEAF <= hv_high); > > +} > > + > > +static inline void > > +kvm_cpuid_get_features(u_int *regs) > > +{ > > + if (!kvm_cpuid_features_leaf_supported()) > > + regs[0] = regs[1] = regs[2] = regs[3] = 0; > > + else > > + do_cpuid(KVM_CPUID_FEATURES_LEAF, regs); > > +} > > + > > +#endif /* !_X86_KVM_H_ */ > > > > -- > Colin Percival > Security Officer Emeritus, FreeBSD | The power to serve > Founder, Tarsnap | www.tarsnap.com | Online backups for the truly paranoid From owner-dev-commits-src-main@freebsd.org Sun Aug 29 06:38:41 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 080BE658124; Sun, 29 Aug 2021 06:38:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gy3gh6XF9z4d54; Sun, 29 Aug 2021 06:38:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C8FFE25B8C; Sun, 29 Aug 2021 06:38:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17T6cek5013144; Sun, 29 Aug 2021 06:38:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17T6ceHv013143; Sun, 29 Aug 2021 06:38:40 GMT (envelope-from git) Date: Sun, 29 Aug 2021 06:38:40 GMT Message-Id: <202108290638.17T6ceHv013143@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Peter Holm Subject: git: 22f5f4a14e97 - main - stress2: Added new msdosfs rename() tests MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pho X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 22f5f4a14e976a9b322ea4abf8af5afe6520ff8e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 06:38:41 -0000 The branch main has been updated by pho: URL: https://cgit.FreeBSD.org/src/commit/?id=22f5f4a14e976a9b322ea4abf8af5afe6520ff8e commit 22f5f4a14e976a9b322ea4abf8af5afe6520ff8e Author: Peter Holm AuthorDate: 2021-08-29 06:37:54 +0000 Commit: Peter Holm CommitDate: 2021-08-29 06:37:54 +0000 stress2: Added new msdosfs rename() tests --- tools/test/stress2/misc/msdos11.sh | 80 +++++++++++++++++++++++++ tools/test/stress2/misc/msdos12.sh | 89 +++++++++++++++++++++++++++ tools/test/stress2/misc/msdos13.sh | 97 ++++++++++++++++++++++++++++++ tools/test/stress2/misc/msdos14.sh | 119 +++++++++++++++++++++++++++++++++++++ tools/test/stress2/misc/nfs18.sh | 90 ++++++++++++++++++++++++++++ 5 files changed, 475 insertions(+) diff --git a/tools/test/stress2/misc/msdos11.sh b/tools/test/stress2/misc/msdos11.sh new file mode 100755 index 000000000000..af0958686118 --- /dev/null +++ b/tools/test/stress2/misc/msdos11.sh @@ -0,0 +1,80 @@ +#!/bin/sh + +# +# SPDX-License-Identifier: BSD-2-Clause-FreeBSD +# +# Copyright (c) 2021 Peter Holm +# +# 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. +# + +# https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=257522 +# https://people.freebsd.org/~pho/stress/log/log0158.txt +# Original test scenario by trasz@FreeBSD.org + +. ../default.cfg +[ `id -u` -ne 0 ] && echo "Must be root!" && exit 1 + +[ -x /sbin/mount_msdosfs ] || exit 0 +log=/tmp/msdos11.log +dir=/tmp +odir=`pwd` +cd $dir +cd $odir +mount | grep "$mntpoint" | grep -q md$mdstart && umount -f $mntpoint +mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart + +set -e +mdconfig -a -t swap -s 4g -u $mdstart +bsdlabel -w md$mdstart auto +newfs_msdos -b 1024 /dev/md${mdstart}$part > /dev/null +mount -t msdosfs /dev/md${mdstart}$part $mntpoint +set +e + +(cd $odir/../testcases/swap; ./swap -t 2m -i 20 -l 100) > /dev/null & +sleep 2 +cd $mntpoint +for i in `jot 2`; do + for i in `jot 10000`; do + mkdir a + mv a b + rmdir b + done > /dev/null 2>&1 & +done +wait +cd $odir + +while mount | grep "$mntpoint" | grep -q md$mdstart; do + umount $mntpoint || sleep 1 +done +fsck -t msdosfs -y /dev/md${mdstart}$part > $log 2>&1 +if egrep -q "BAD|INCONSISTENCY|MODIFIED" $log; then + cat $log + s=1 + + mount -t msdosfs /dev/md${mdstart}$part $mntpoint || exit 1 + ls -lR $mntpoint + umount $mntpoint +fi +mdconfig -d -u $mdstart +rm $log +exit $s diff --git a/tools/test/stress2/misc/msdos12.sh b/tools/test/stress2/misc/msdos12.sh new file mode 100755 index 000000000000..0c1c518575e8 --- /dev/null +++ b/tools/test/stress2/misc/msdos12.sh @@ -0,0 +1,89 @@ +#!/bin/sh + +# +# SPDX-License-Identifier: BSD-2-Clause-FreeBSD +# +# Copyright (c) 2021 Peter Holm +# +# 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. +# + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +# Copy of rename15.sh, modified for msdosfs. + +. ../default.cfg + +[ -x /sbin/mount_msdosfs ] || exit 0 +log=/tmp/msdos12.log + +set -e +mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint +[ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart +mdconfig -a -t swap -s 2g -u $mdstart +bsdlabel -w md$mdstart auto +newfs_msdos -F 32 -b 8192 /dev/md$mdstart$part > /dev/null +mount -t msdosfs /dev/md$mdstart$part $mntpoint +mkdir $mntpoint/stressX +chmod 0777 $mntpoint/stressX +set +e + +export LOAD=80 +export MAXSWAPPCT=80 +export RUNDIR=$mntpoint/stressX +export dirnprenameLOAD=100 +export dirrenameLOAD=100 +export renameLOAD=100 +export runRUNTIME=5m +export rwLOAD=80 +export TESTPROGS=' +testcases/rename/rename +testcases/swap/swap +' + +su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' + +../tools/killall.sh +leftover=`find $mntpoint -type f | wc -l` +if [ $leftover -gt 0 ]; then + s=1 + find $mntpoint -type f | head -5 +fi +for i in `jot 6`; do + mount | grep -q "on $mntpoint " || break + umount $mntpoint && break || sleep 10 + [ $i -eq 6 ] && + { echo FATAL; fstat -mf $mntpoint; exit 1; } +done +fsck -t msdosfs -y /dev/md$mdstart$part > $log 2>&1 +if egrep -q "BAD|INCONSISTENCY|MODIFIED" $log; then + echo "fsck problems:" + cat $log + s=2 + + mount -t msdosfs /dev/md$mdstart$part $mntpoint || exit 1 + ls -lR $mntpoint | head -5 + umount $mntpoint +fi +mdconfig -d -u $mdstart +rm -f $log +exit $s diff --git a/tools/test/stress2/misc/msdos13.sh b/tools/test/stress2/misc/msdos13.sh new file mode 100755 index 000000000000..1e6ee205e4f6 --- /dev/null +++ b/tools/test/stress2/misc/msdos13.sh @@ -0,0 +1,97 @@ +#!/bin/sh + +# +# SPDX-License-Identifier: BSD-2-Clause-FreeBSD +# +# Copyright (c) 2021 Peter Holm +# +# 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. +# + +# Simple msdosfs rename example + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +. ../default.cfg + +[ -x /sbin/mount_msdosfs ] || exit 0 +log=/tmp/msdos13.log + +set -e +mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint +[ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart +mdconfig -a -t swap -s 2g -u $mdstart +bsdlabel -w md$mdstart auto +newfs_msdos -F 32 -b 8192 /dev/md$mdstart$part > /dev/null +mount -t msdosfs /dev/md$mdstart$part $mntpoint +mkdir $mntpoint/stressX +chmod 0777 $mntpoint/stressX +set +e + +here=`pwd` +cd $mntpoint/stressX +N=4000 +s=0 +sort /dev/zero & pid=$! +sleep 2 +for j in `jot $N`; do + touch f$i-$j +done +for j in `jot $N`; do + mv f$i-$j g$i-$j + [ -f f$i-$j ] && s=1 +done +for j in `jot $N`; do + mv g$i-$j f$i-$j +done +for j in `jot $N`; do + rm f$i-$j +done +kill $pid +wait +leftover=`find . -type f | wc -l` +if [ $leftover -gt 0 ]; then + echo "Unexpected leftover files:" + s=2 + find . -type f | head -5 +fi +cd $here + +for i in `jot 6`; do + mount | grep -q "on $mntpoint " || break + umount $mntpoint && break || sleep 10 + [ $i -eq 6 ] && + { echo FATAL; fstat -mf $mntpoint; exit 1; } +done +fsck -t msdosfs -y /dev/md$mdstart$part > $log 2>&1 +if egrep -q "BAD|INCONSISTENCY|MODIFIED" $log; then + echo "fsck problems:" + cat $log + s=3 + + mount -t msdosfs /dev/md$mdstart$part $mntpoint || exit 1 + ls -lR $mntpoint | head -5 + umount $mntpoint +fi +mdconfig -d -u $mdstart +rm -f $log +exit $s diff --git a/tools/test/stress2/misc/msdos14.sh b/tools/test/stress2/misc/msdos14.sh new file mode 100755 index 000000000000..1a39d60f0781 --- /dev/null +++ b/tools/test/stress2/misc/msdos14.sh @@ -0,0 +1,119 @@ +#!/bin/sh + +# +# SPDX-License-Identifier: BSD-2-Clause-FreeBSD +# +# Copyright (c) 2021 Peter Holm +# +# 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. +# + +# Rename(2) test with msdosfs(5) +# Test scenario by kib@ + +. ../default.cfg +[ `id -u` -ne 0 ] && echo "Must be root!" && exit 1 + +[ -x /sbin/mount_msdosfs ] || exit 0 +dir=/tmp +odir=`pwd` +cd $dir +cat > /tmp/msdos14.c < +#include +#include +#include +#include +#include +#include + +int +main(void) +{ + struct stat sb; + uint64_t x; + int error, fd; + char from[64], to[64]; + + for (x = 0;; x++) { + snprintf(from, sizeof(from), "x.%" PRIu64 ".from", x); + snprintf(to, sizeof(to), "x.%" PRIu64 ".to", x); + + fd = open(from, O_CREAT | O_TRUNC | O_EXCL, 0666); + if (fd == -1) + err(1, "open %s", from); + close(fd); + error = rename(from, to); + if (error == -1) + err(1, "rename %s %s", from, to); + error = stat(to, &sb); + if (error == -1) + err(1, "stat %s", to); + error = unlink(to); + if (error == -1) + err(1, "unlink %s", to); + } +} + +EOF +cc -o msdos14 -Wall -Wextra -O2 msdos14.c || exit 1 +rm -f msdos14.c +cd $odir +log=/tmp/msdos14sh..log +mount | grep "$mntpoint" | grep -q md$mdstart && umount -f $mntpoint +mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart + +set -e +mdconfig -a -t swap -s 4g -u $mdstart +bsdlabel -w md$mdstart auto +newfs_msdos -b 1024 /dev/md${mdstart}$part > /dev/null +mount -t msdosfs /dev/md${mdstart}$part $mntpoint +set +e + +cp /tmp/msdos14 $mntpoint +cd $mntpoint + +(cd $odir/../testcases/swap; ./swap -t 5m -i 20 -l 100) > /dev/null & +sleep 2 +timeout 5m ./msdos14 +while pkill swap; do :; done +wait +cd $odir + +while mount | grep "$mntpoint" | grep -q md$mdstart; do + umount $mntpoint || sleep 1 +done +fsck -t msdosfs -y /dev/md${mdstart}$part > $log 2>&1 +if egrep -q "BAD|INCONSISTENCY|MODIFIED" $log; then + echo "fsck issues:" + cat $log + s=1 + + mount -t msdosfs /dev/md${mdstart}$part $mntpoint || exit 1 + ls -lR $mntpoint + umount $mntpoint +fi +mdconfig -d -u $mdstart +rm /tmp/msdos14 $log +exit $s diff --git a/tools/test/stress2/misc/nfs18.sh b/tools/test/stress2/misc/nfs18.sh new file mode 100755 index 000000000000..bf9e0fc8010e --- /dev/null +++ b/tools/test/stress2/misc/nfs18.sh @@ -0,0 +1,90 @@ +#!/bin/sh + +# +# SPDX-License-Identifier: BSD-2-Clause-FreeBSD +# +# Copyright (c) 2021 Peter Holm +# +# 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. +# + +# msdosfs rename test over nfs loopback mount +# This needs to be in /etc/exports: /mnt -maproot=root 127.0.0.1 + +. ../default.cfg + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 +mp1=$mntpoint +mp2=$mntpoint$((mdstart + 1)) +grep -q $mp1 /etc/exports || + { echo "$mp1 missing from /etc/exports"; exit 0; } +[ -x /sbin/mount_msdosfs ] || exit + +mount | grep "$mp2 " | grep nfs > /dev/null && umount -f $mp2 +mount | grep "$mp1 " | grep /md > /dev/null && umount -f $mp1 +mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart + +kill -HUP `pgrep mountd` # loopback workaround +mdconfig -a -t swap -s 1g -u $mdstart +set -e + +bsdlabel -w md$mdstart auto +newfs_msdos -F 32 -b 8192 /dev/md${mdstart}$part > /dev/null +mkdir -p $mp1; chmod 777 $mp1 +mount -t msdosfs -o rw /dev/md${mdstart}$part $mp1 +set +e + +mkdir $mp1/stressX +chmod 777 $mp1/stressX + +mkdir -p $mp2 +chmod 777 $mp2 + +mount -t nfs -o tcp -o retrycnt=3 -o rw \ + 127.0.0.1:$mp1 $mp2; s=$? + +export LOAD=80 +export renameLOAD=100 +export TESTPROGS=" +testcases/rename/rename +testcases/swap/swap +" +export INODES=9999 # No inodes on a msdos fs + +export RUNDIR=$mp2/stressX +export runRUNTIME=2m +if [ $s -eq 0 ]; then + su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' + + for i in `jot 10`; do + umount $mp2 && break + sleep 2 + done +fi +sleep .5 +for i in `jot 10`; do + umount $mp1 && break + sleep 2 +done +mount | grep -q "on $mp1 " && umount -f $mp1 +mdconfig -d -u $mdstart +exit 0 From owner-dev-commits-src-main@freebsd.org Sun Aug 29 07:55:41 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6A4026594B3; Sun, 29 Aug 2021 07:55:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gy5NY2K8Nz4yd5; Sun, 29 Aug 2021 07:55:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2DB8526E04; Sun, 29 Aug 2021 07:55:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17T7tffk019340; Sun, 29 Aug 2021 07:55:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17T7tflB019339; Sun, 29 Aug 2021 07:55:41 GMT (envelope-from git) Date: Sun, 29 Aug 2021 07:55:41 GMT Message-Id: <202108290755.17T7tflB019339@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: 2dfcc3a91dd4 - main - isci(4): Fix a common typo in src comments MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2dfcc3a91dd4d21c16269b7add3141c99dfa48ab Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 07:55:41 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=2dfcc3a91dd4d21c16269b7add3141c99dfa48ab commit 2dfcc3a91dd4d21c16269b7add3141c99dfa48ab Author: Gordon Bergling AuthorDate: 2021-08-29 07:55:10 +0000 Commit: Gordon Bergling CommitDate: 2021-08-29 07:55:10 +0000 isci(4): Fix a common typo in src comments - s/exlusive/exclusive/ MFC after: 3 days --- sys/dev/isci/isci_timer.c | 2 +- sys/dev/isci/scil/scic_user_callback.h | 2 +- sys/dev/isci/scil/scif_user_callback.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/dev/isci/isci_timer.c b/sys/dev/isci/isci_timer.c index 60dfb63d83eb..9bba29c85242 100644 --- a/sys/dev/isci/isci_timer.c +++ b/sys/dev/isci/isci_timer.c @@ -109,7 +109,7 @@ scif_cb_timer_stop(SCI_CONTROLLER_HANDLE_T controller, void *timer) * a handle for this timer for use in further timer interactions. * * @warning The "timer_callback" method should be executed in a mutually - * exlusive manner from the controller completion handler + * exclusive manner from the controller completion handler * handler (refer to scic_controller_get_handler_methods()). * * @param[in] timer_callback This parameter specifies the callback method diff --git a/sys/dev/isci/scil/scic_user_callback.h b/sys/dev/isci/scil/scic_user_callback.h index 292237062ae3..2260f14c2705 100644 --- a/sys/dev/isci/scil/scic_user_callback.h +++ b/sys/dev/isci/scil/scic_user_callback.h @@ -76,7 +76,7 @@ extern "C" { * a handle for this timer for use in further timer interactions. * * @warning The "timer_callback" method should be executed in a mutually - * exlusive manner from the controller completion handler + * exclusive manner from the controller completion handler * handler (refer to scic_controller_get_handler_methods()). * * @param[in] controller This parameter specifies the controller with diff --git a/sys/dev/isci/scil/scif_user_callback.h b/sys/dev/isci/scil/scif_user_callback.h index 39c6718b6f3e..3a44b772ae20 100644 --- a/sys/dev/isci/scil/scif_user_callback.h +++ b/sys/dev/isci/scil/scif_user_callback.h @@ -80,7 +80,7 @@ extern "C" { * a handle for this timer for use in further timer interactions. * * @warning The "timer_callback" method should be executed in a mutually - * exlusive manner from the controller completion handler + * exclusive manner from the controller completion handler * handler (refer to scic_controller_get_handler_methods()). * * @param[in] timer_callback This parameter specifies the callback method From owner-dev-commits-src-main@freebsd.org Sun Aug 29 08:10:36 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 039CE659B07; Sun, 29 Aug 2021 08:10:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gy5jl6NMVz52M4; Sun, 29 Aug 2021 08:10:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C056D2694E; Sun, 29 Aug 2021 08:10:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17T8AZXN041750; Sun, 29 Aug 2021 08:10:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17T8AZiJ041749; Sun, 29 Aug 2021 08:10:35 GMT (envelope-from git) Date: Sun, 29 Aug 2021 08:10:35 GMT Message-Id: <202108290810.17T8AZiJ041749@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: 005fe24f2a4c - main - libsa: Fix a typo in source code comments MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 005fe24f2a4c873a96f446604e0453cf99e9bcd7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 08:10:36 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=005fe24f2a4c873a96f446604e0453cf99e9bcd7 commit 005fe24f2a4c873a96f446604e0453cf99e9bcd7 Author: Gordon Bergling AuthorDate: 2021-08-29 08:09:58 +0000 Commit: Gordon Bergling CommitDate: 2021-08-29 08:09:58 +0000 libsa: Fix a typo in source code comments - s/mininum/minimum/ MFC after: 3 days --- stand/libsa/ext2fs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stand/libsa/ext2fs.c b/stand/libsa/ext2fs.c index 068e307253a9..b81654552af3 100644 --- a/stand/libsa/ext2fs.c +++ b/stand/libsa/ext2fs.c @@ -127,8 +127,8 @@ struct fs_ops ext2fs_fsops = { #define EXT2_R0_ISIZE 128 /* inode size */ #define EXT2_R0_FIRSTINO 11 /* first inode */ -#define EXT2_MINBSHIFT 10 /* mininum block shift */ -#define EXT2_MINFSHIFT 10 /* mininum frag shift */ +#define EXT2_MINBSHIFT 10 /* minimum block shift */ +#define EXT2_MINFSHIFT 10 /* minimum frag shift */ #define EXT2_NDADDR 12 /* # of direct blocks */ #define EXT2_NIADDR 3 /* # of indirect blocks */ From owner-dev-commits-src-main@freebsd.org Sun Aug 29 08:26:38 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4A581659CBF; Sun, 29 Aug 2021 08:26:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gy64G1P4Kz56pH; Sun, 29 Aug 2021 08:26:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 157B12738F; Sun, 29 Aug 2021 08:26:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17T8QbYg059863; Sun, 29 Aug 2021 08:26:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17T8QbZM059862; Sun, 29 Aug 2021 08:26:37 GMT (envelope-from git) Date: Sun, 29 Aug 2021 08:26:37 GMT Message-Id: <202108290826.17T8QbZM059862@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ka Ho Ng Subject: git: a58e222b3bcc - main - vfs: yield in vn_deallocate_impl() loop MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a58e222b3bcc5294ffbff88ff5f4c8d88b9dc324 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 08:26:38 -0000 The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=a58e222b3bcc5294ffbff88ff5f4c8d88b9dc324 commit a58e222b3bcc5294ffbff88ff5f4c8d88b9dc324 Author: Ka Ho Ng AuthorDate: 2021-08-29 08:26:00 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-29 08:26:00 +0000 vfs: yield in vn_deallocate_impl() loop Yield at the end of each loop iteration if there are remaining works as indicated by the value of *len updated by VOP_DEALLOCATE. Without this, when calling vop_stddeallocate to zero a large region, the implementation only zerofills a relatively small chunk and returns. Sponsored by: The FreeBSD Foundation Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D31705 --- sys/kern/vfs_vnops.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 3fce590519a8..bd512f73eae5 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -3519,6 +3519,8 @@ vn_deallocate_impl(struct vnode *vp, off_t *offset, off_t *length, int flags, mp = NULL; } } + if (error == 0 && len != 0) + maybe_yield(); } out: if (rl_cookie != NULL) From owner-dev-commits-src-main@freebsd.org Sun Aug 29 09:45:34 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 19B3C65AFB7; Sun, 29 Aug 2021 09:45:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gy7qK73K7z3lgR; Sun, 29 Aug 2021 09:45:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DB74816F; Sun, 29 Aug 2021 09:45:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17T9jX1n066009; Sun, 29 Aug 2021 09:45:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17T9jXLG066008; Sun, 29 Aug 2021 09:45:33 GMT (envelope-from git) Date: Sun, 29 Aug 2021 09:45:33 GMT Message-Id: <202108290945.17T9jXLG066008@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: 5d785ad65e00 - main - Fix a common typo in source code comments MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5d785ad65e000f9ff636a777599bfa414b88d970 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 09:45:34 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=5d785ad65e000f9ff636a777599bfa414b88d970 commit 5d785ad65e000f9ff636a777599bfa414b88d970 Author: Gordon Bergling AuthorDate: 2021-08-29 09:45:09 +0000 Commit: Gordon Bergling CommitDate: 2021-08-29 09:45:09 +0000 Fix a common typo in source code comments - s/concurently/concurrently/ MFC after: 3 days --- sys/dev/acpica/acpi_video.c | 2 +- sys/dev/aic7xxx/aic79xx.h | 2 +- sys/dev/gpio/gpiopps.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/dev/acpica/acpi_video.c b/sys/dev/acpica/acpi_video.c index dc4a4385f3b5..917c6548f3a2 100644 --- a/sys/dev/acpica/acpi_video.c +++ b/sys/dev/acpica/acpi_video.c @@ -233,7 +233,7 @@ acpi_video_push_evdev_event(struct evdev_dev *evdev, UINT32 notify) int i; uint16_t key; - /* Do not allow to execute 2 instances this routine concurently */ + /* Do not allow to execute 2 instances this routine concurrently */ ACPI_SERIAL_ASSERT(video_output); for (i = 0; i < nitems(acpi_video_evdev_map); i++) { diff --git a/sys/dev/aic7xxx/aic79xx.h b/sys/dev/aic7xxx/aic79xx.h index bb3949c5f749..42059a351271 100644 --- a/sys/dev/aic7xxx/aic79xx.h +++ b/sys/dev/aic7xxx/aic79xx.h @@ -288,7 +288,7 @@ typedef enum { */ AHD_NONPACKFIFO_BUG = 0x4000, /* - * Writing to a DFF SCBPTR register may fail if concurent with + * Writing to a DFF SCBPTR register may fail if concurrent with * a hardware write to the other DFF SCBPTR register. This is * not currently a concern in our sequencer since all chips with * this bug have the AHD_NONPACKFIFO_BUG and all writes of concern diff --git a/sys/dev/gpio/gpiopps.c b/sys/dev/gpio/gpiopps.c index 8a6f1a6a3f6b..4700acf19bcd 100644 --- a/sys/dev/gpio/gpiopps.c +++ b/sys/dev/gpio/gpiopps.c @@ -130,7 +130,7 @@ gpiopps_ifltr(void *arg) * written only by the pps_capture() routine and read only by the * pps_event() routine. We don't need lock-based management of access * to the capture area because we have time-based access management: we - * can't be reading and writing concurently because we can't be running + * can't be reading and writing concurrently because we can't be running * both the threaded and filter handlers concurrently (because a new * hardware interrupt can't happen until the threaded handler for the * current interrupt exits, after which the system does the EOI that From owner-dev-commits-src-main@freebsd.org Sun Aug 29 13:26:58 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 85B2265E90C; Sun, 29 Aug 2021 13:26:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GyDkp3FbMz3mcg; Sun, 29 Aug 2021 13:26:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5730C305F; Sun, 29 Aug 2021 13:26:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17TDQwHL059660; Sun, 29 Aug 2021 13:26:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17TDQwt7059659; Sun, 29 Aug 2021 13:26:58 GMT (envelope-from git) Date: Sun, 29 Aug 2021 13:26:58 GMT Message-Id: <202108291326.17TDQwt7059659@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 2b10cf85f868 - main - pf: Introduce nvlist variant of DIOCGETSTATUS MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2b10cf85f8684f822511d7b9377e256ab623abbc Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 13:26:58 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=2b10cf85f8684f822511d7b9377e256ab623abbc commit 2b10cf85f8684f822511d7b9377e256ab623abbc Author: Kristof Provost AuthorDate: 2021-08-16 19:55:27 +0000 Commit: Kristof Provost CommitDate: 2021-08-29 12:59:04 +0000 pf: Introduce nvlist variant of DIOCGETSTATUS Make it possible to extend the GETSTATUS call (e.g. when we want to add new counters, such as for syncookie support) by introducing an nvlist-based alternative. MFC after: 1 week Sponsored by: Modirum MDPay Differential Revision: https://reviews.freebsd.org/D31694 --- sys/net/pfvar.h | 1 + sys/netpfil/pf/pf.h | 9 ++++ sys/netpfil/pf/pf_ioctl.c | 133 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 143 insertions(+) diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index 17d1e8c1a047..47f7c1efbffd 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -1667,6 +1667,7 @@ struct pfioc_iface { #define DIOCGETSTATENV _IOWR('D', 19, struct pfioc_nv) #define DIOCSETSTATUSIF _IOWR('D', 20, struct pfioc_if) #define DIOCGETSTATUS _IOWR('D', 21, struct pf_status) +#define DIOCGETSTATUSNV _IOWR('D', 21, struct pfioc_nv) #define DIOCCLRSTATUS _IO ('D', 22) #define DIOCNATLOOK _IOWR('D', 23, struct pfioc_natlook) #define DIOCSETDEBUG _IOWR('D', 24, u_int32_t) diff --git a/sys/netpfil/pf/pf.h b/sys/netpfil/pf/pf.h index d8ee43506d99..2fa76def4385 100644 --- a/sys/netpfil/pf/pf.h +++ b/sys/netpfil/pf/pf.h @@ -179,6 +179,15 @@ enum { PF_ADDR_ADDRMASK, PF_ADDR_NOROUTE, PF_ADDR_DYNIFTL, #define FCNT_STATE_REMOVALS 2 #define FCNT_MAX 3 +#ifdef _KERNEL +#define FCNT_NAMES { \ + "searches", \ + "inserts", \ + "removals", \ + NULL \ +} +#endif + /* src_node operation counters */ #define SCNT_SRC_NODE_SEARCH 0 #define SCNT_SRC_NODE_INSERT 1 diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index b2d7fc33d8b8..ec2c7108c1d2 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -208,6 +208,7 @@ static int pf_killstates_row(struct pf_kstate_kill *, static int pf_killstates_nv(struct pfioc_nv *); static int pf_clearstates_nv(struct pfioc_nv *); static int pf_getstate(struct pfioc_nv *); +static int pf_getstatus(struct pfioc_nv *); static int pf_clear_tables(void); static void pf_clear_srcnodes(struct pf_ksrc_node *); static void pf_kill_srcnodes(struct pfioc_src_node_kill *); @@ -2179,6 +2180,7 @@ pfioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct thread *td case DIOCGETSTATENV: case DIOCSETSTATUSIF: case DIOCGETSTATUS: + case DIOCGETSTATUSNV: case DIOCCLRSTATUS: case DIOCNATLOOK: case DIOCSETDEBUG: @@ -2236,6 +2238,7 @@ pfioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct thread *td case DIOCGETSTATE: case DIOCGETSTATENV: case DIOCGETSTATUS: + case DIOCGETSTATUSNV: case DIOCGETSTATES: case DIOCGETSTATESV2: case DIOCGETTIMEOUT: @@ -3096,6 +3099,11 @@ DIOCGETSTATESV2_full: break; } + case DIOCGETSTATUSNV: { + error = pf_getstatus((struct pfioc_nv *)addr); + break; + } + case DIOCSETSTATUSIF: { struct pfioc_if *pi = (struct pfioc_if *)addr; @@ -4887,6 +4895,131 @@ pf_tbladdr_copyout(struct pf_addr_wrap *aw) kt->pfrkt_cnt : -1; } +static int +pf_add_status_counters(nvlist_t *nvl, const char *name, counter_u64_t *counters, + size_t number, char **names) +{ + nvlist_t *nvc; + + nvc = nvlist_create(0); + if (nvc == NULL) + return (ENOMEM); + + for (int i = 0; i < number; i++) { + nvlist_append_number_array(nvc, "counters", + counter_u64_fetch(counters[i])); + nvlist_append_string_array(nvc, "names", + names[i]); + nvlist_append_number_array(nvc, "ids", + i); + } + nvlist_add_nvlist(nvl, name, nvc); + nvlist_destroy(nvc); + + return (0); +} + +static int +pf_getstatus(struct pfioc_nv *nv) +{ + nvlist_t *nvl = NULL, *nvc = NULL; + void *nvlpacked = NULL; + int error; + struct pf_status s; + char *pf_reasons[PFRES_MAX+1] = PFRES_NAMES; + char *pf_lcounter[LCNT_MAX+1] = LCNT_NAMES; + char *pf_fcounter[FCNT_MAX+1] = FCNT_NAMES; + PF_RULES_RLOCK_TRACKER; + +#define ERROUT(x) ERROUT_FUNCTION(errout, x) + + PF_RULES_RLOCK(); + + nvl = nvlist_create(0); + if (nvl == NULL) + ERROUT(ENOMEM); + + nvlist_add_bool(nvl, "running", V_pf_status.running); + nvlist_add_number(nvl, "since", V_pf_status.since); + nvlist_add_number(nvl, "debug", V_pf_status.debug); + nvlist_add_number(nvl, "hostid", V_pf_status.hostid); + nvlist_add_number(nvl, "states", V_pf_status.states); + nvlist_add_number(nvl, "src_nodes", V_pf_status.src_nodes); + + /* counters */ + error = pf_add_status_counters(nvl, "counters", V_pf_status.counters, + PFRES_MAX, pf_reasons); + if (error != 0) + ERROUT(error); + + /* lcounters */ + error = pf_add_status_counters(nvl, "lcounters", V_pf_status.lcounters, + LCNT_MAX, pf_lcounter); + if (error != 0) + ERROUT(error); + + /* fcounters */ + nvc = nvlist_create(0); + if (nvc == NULL) + ERROUT(ENOMEM); + + for (int i = 0; i < FCNT_MAX; i++) { + nvlist_append_number_array(nvc, "counters", + pf_counter_u64_fetch(&V_pf_status.fcounters[i])); + nvlist_append_string_array(nvc, "names", + pf_fcounter[i]); + nvlist_append_number_array(nvc, "ids", + i); + } + nvlist_add_nvlist(nvl, "fcounters", nvc); + nvlist_destroy(nvc); + nvc = NULL; + + /* scounters */ + error = pf_add_status_counters(nvl, "scounters", V_pf_status.scounters, + SCNT_MAX, pf_fcounter); + if (error != 0) + ERROUT(error); + + nvlist_add_string(nvl, "ifname", V_pf_status.ifname); + nvlist_add_binary(nvl, "chksum", V_pf_status.pf_chksum, + PF_MD5_DIGEST_LENGTH); + + pfi_update_status(V_pf_status.ifname, &s); + + /* pcounters / bcounters */ + for (int i = 0; i < 2; i++) { + for (int j = 0; j < 2; j++) { + for (int k = 0; k < 2; k++) { + nvlist_append_number_array(nvl, "pcounters", + s.pcounters[i][j][k]); + } + nvlist_append_number_array(nvl, "bcounters", + s.bcounters[i][j]); + } + } + + nvlpacked = nvlist_pack(nvl, &nv->len); + if (nvlpacked == NULL) + ERROUT(ENOMEM); + + if (nv->size == 0) + ERROUT(0); + else if (nv->size < nv->len) + ERROUT(ENOSPC); + + error = copyout(nvlpacked, nv->data, nv->len); + +#undef ERROUT +errout: + PF_RULES_RUNLOCK(); + free(nvlpacked, M_NVLIST); + nvlist_destroy(nvc); + nvlist_destroy(nvl); + + return (error); +} + /* * XXX - Check for version missmatch!!! */ From owner-dev-commits-src-main@freebsd.org Sun Aug 29 13:27:00 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EEC5D65E793; Sun, 29 Aug 2021 13:27:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GyDkr5Swhz3ml7; Sun, 29 Aug 2021 13:27:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9AB542F39; Sun, 29 Aug 2021 13:27:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17TDR0l9059715; Sun, 29 Aug 2021 13:27:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17TDR0bv059714; Sun, 29 Aug 2021 13:27:00 GMT (envelope-from git) Date: Sun, 29 Aug 2021 13:27:00 GMT Message-Id: <202108291327.17TDR0bv059714@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 46fb68b1de49 - main - libpfctl: Implement DIOCGETSTATUS wrappers MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 46fb68b1de49c8d235024374b71c1249af9e62ef Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 13:27:01 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=46fb68b1de49c8d235024374b71c1249af9e62ef commit 46fb68b1de49c8d235024374b71c1249af9e62ef Author: Kristof Provost AuthorDate: 2021-08-26 15:06:15 +0000 Commit: Kristof Provost CommitDate: 2021-08-29 12:59:38 +0000 libpfctl: Implement DIOCGETSTATUS wrappers MFC after: 1 week Sponsored by: Modirum MDPay Differential Revision: https://reviews.freebsd.org/D31696 --- lib/libpfctl/libpfctl.c | 115 ++++++++++++++++++++++++++++++++++++++++++++++++ lib/libpfctl/libpfctl.h | 30 +++++++++++++ 2 files changed, 145 insertions(+) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index 7e6bc1b14a2a..3d52502f9ba8 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -121,6 +121,121 @@ pf_nvuint_64_array(const nvlist_t *nvl, const char *name, size_t maxelems, *nelems = elems; } +static void +_pfctl_get_status_counters(const nvlist_t *nvl, + struct pfctl_status_counters *counters) +{ + const uint64_t *ids, *counts; + const char *const *names; + size_t id_len, counter_len, names_len; + + ids = nvlist_get_number_array(nvl, "ids", &id_len); + counts = nvlist_get_number_array(nvl, "counters", &counter_len); + names = nvlist_get_string_array(nvl, "names", &names_len); + assert(id_len == counter_len); + assert(counter_len == names_len); + + TAILQ_INIT(counters); + + for (size_t i = 0; i < id_len; i++) { + struct pfctl_status_counter *c; + + c = malloc(sizeof(*c)); + + c->id = ids[i]; + c->counter = counts[i]; + c->name = strdup(names[i]); + + TAILQ_INSERT_TAIL(counters, c, entry); + } +} + +struct pfctl_status * +pfctl_get_status(int dev) +{ + struct pfioc_nv nv; + struct pfctl_status *status; + nvlist_t *nvl; + size_t len; + const void *chksum; + + status = calloc(1, sizeof(*status)); + if (status == NULL) + return (NULL); + + nv.data = malloc(4096); + nv.len = nv.size = 4096; + + if (ioctl(dev, DIOCGETSTATUSNV, &nv)) { + free(nv.data); + free(status); + return (NULL); + } + + nvl = nvlist_unpack(nv.data, nv.len, 0); + free(nv.data); + if (nvl == NULL) { + free(status); + return (NULL); + } + + status->running = nvlist_get_bool(nvl, "running"); + status->since = nvlist_get_number(nvl, "since"); + status->debug = nvlist_get_number(nvl, "debug"); + status->hostid = nvlist_get_number(nvl, "hostid"); + status->states = nvlist_get_number(nvl, "states"); + status->src_nodes = nvlist_get_number(nvl, "src_nodes"); + + strlcpy(status->ifname, nvlist_get_string(nvl, "ifname"), + IFNAMSIZ); + chksum = nvlist_get_binary(nvl, "chksum", &len); + assert(len == PF_MD5_DIGEST_LENGTH); + memcpy(status->pf_chksum, chksum, len); + + _pfctl_get_status_counters(nvlist_get_nvlist(nvl, "counters"), + &status->counters); + _pfctl_get_status_counters(nvlist_get_nvlist(nvl, "lcounters"), + &status->lcounters); + _pfctl_get_status_counters(nvlist_get_nvlist(nvl, "fcounters"), + &status->fcounters); + _pfctl_get_status_counters(nvlist_get_nvlist(nvl, "scounters"), + &status->scounters); + + pf_nvuint_64_array(nvl, "pcounters", 2 * 2 * 3, + (uint64_t *)status->pcounters, NULL); + pf_nvuint_64_array(nvl, "bcounters", 2 * 2, + (uint64_t *)status->bcounters, NULL); + + nvlist_destroy(nvl); + + return (status); +} + +void +pfctl_free_status(struct pfctl_status *status) +{ + struct pfctl_status_counter *c, *tmp; + + TAILQ_FOREACH_SAFE(c, &status->counters, entry, tmp) { + free(c->name); + free(c); + } + TAILQ_FOREACH_SAFE(c, &status->lcounters, entry, tmp) { + free(c->name); + free(c); + } + TAILQ_FOREACH_SAFE(c, &status->fcounters, entry, tmp) { + free(c->name); + free(c); + } + TAILQ_FOREACH_SAFE(c, &status->scounters, entry, tmp) { + free(c->name); + free(c); + } + + free(status); +} + static void pfctl_nv_add_addr(nvlist_t *nvparent, const char *name, const struct pf_addr *addr) diff --git a/lib/libpfctl/libpfctl.h b/lib/libpfctl/libpfctl.h index d57241dd59fd..70de7627f0a6 100644 --- a/lib/libpfctl/libpfctl.h +++ b/lib/libpfctl/libpfctl.h @@ -38,6 +38,33 @@ struct pfctl_anchor; +struct pfctl_status_counter { + uint64_t id; + uint64_t counter; + char *name; + + TAILQ_ENTRY(pfctl_status_counter) entry; +}; +TAILQ_HEAD(pfctl_status_counters, pfctl_status_counter); + +struct pfctl_status { + bool running; + uint32_t since; + uint32_t debug; + uint32_t hostid; + uint64_t states; + uint64_t src_nodes; + char ifname[IFNAMSIZ]; + uint8_t pf_chksum[PF_MD5_DIGEST_LENGTH]; + + struct pfctl_status_counters counters; + struct pfctl_status_counters lcounters; + struct pfctl_status_counters fcounters; + struct pfctl_status_counters scounters; + uint64_t pcounters[2][2][3]; + uint64_t bcounters[2][2]; +}; + struct pfctl_pool { struct pf_palist list; struct pf_pooladdr *cur; @@ -253,6 +280,9 @@ struct pfctl_syncookies { enum pfctl_syncookies_mode mode; }; +struct pfctl_status* pfctl_get_status(int dev); +void pfctl_free_status(struct pfctl_status *status); + int pfctl_get_rule(int dev, u_int32_t nr, u_int32_t ticket, const char *anchor, u_int32_t ruleset, struct pfctl_rule *rule, char *anchor_call); From owner-dev-commits-src-main@freebsd.org Sun Aug 29 13:26:59 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A343565E9CB; Sun, 29 Aug 2021 13:26:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GyDkq47hyz3mcj; Sun, 29 Aug 2021 13:26:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 779052F38; Sun, 29 Aug 2021 13:26:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17TDQxvk059684; Sun, 29 Aug 2021 13:26:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17TDQxFf059683; Sun, 29 Aug 2021 13:26:59 GMT (envelope-from git) Date: Sun, 29 Aug 2021 13:26:59 GMT Message-Id: <202108291326.17TDQxFf059683@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: b0ccc2e277ac - main - libpfctl: fix double free MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b0ccc2e277acddd33c65b444e7841b780b3094d7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 13:26:59 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=b0ccc2e277acddd33c65b444e7841b780b3094d7 commit b0ccc2e277acddd33c65b444e7841b780b3094d7 Author: Kristof Provost AuthorDate: 2021-08-22 14:20:15 +0000 Commit: Kristof Provost CommitDate: 2021-08-29 12:59:29 +0000 libpfctl: fix double free Reviewed by: donner MFC after: 1 week Sponsored by: Modirum MDPay Differential Revision: https://reviews.freebsd.org/D31695 --- lib/libpfctl/libpfctl.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index 7f1e72513018..7e6bc1b14a2a 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -860,7 +860,6 @@ pfctl_get_syncookies(int dev, struct pfctl_syncookies *s) nvl = nvlist_unpack(nv.data, nv.len, 0); free(nv.data); if (nvl == NULL) { - free(nv.data); return (EIO); } From owner-dev-commits-src-main@freebsd.org Sun Aug 29 13:27:02 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 56B6265E9D0; Sun, 29 Aug 2021 13:27:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GyDks6yM0z3mlJ; Sun, 29 Aug 2021 13:27:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BEC4A2FEC; Sun, 29 Aug 2021 13:27:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17TDR1Lh059739; Sun, 29 Aug 2021 13:27:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17TDR1hT059738; Sun, 29 Aug 2021 13:27:01 GMT (envelope-from git) Date: Sun, 29 Aug 2021 13:27:01 GMT Message-Id: <202108291327.17TDR1hT059738@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 80078d9d38fd - main - pfctl: use libpfctl to retrieve pf status MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 80078d9d38fde6f146de28809640b2c7bff45a6c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 13:27:02 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=80078d9d38fde6f146de28809640b2c7bff45a6c commit 80078d9d38fde6f146de28809640b2c7bff45a6c Author: Kristof Provost AuthorDate: 2021-08-26 15:09:48 +0000 Commit: Kristof Provost CommitDate: 2021-08-29 12:59:38 +0000 pfctl: use libpfctl to retrieve pf status Rather than call DIOCGETSTATUS ourselves use the new libpfctl functions. MFC after: 1 week Sponsored by: Modirum MDPay Differential Revision: https://reviews.freebsd.org/D31697 --- sbin/pfctl/pfctl.c | 20 +++++++++++++------- sbin/pfctl/pfctl_parser.c | 46 ++++++++++++++++++---------------------------- sbin/pfctl/pfctl_parser.h | 4 ++-- 3 files changed, 33 insertions(+), 37 deletions(-) diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index 016075058b21..8f3698e398f6 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -1307,35 +1307,41 @@ pfctl_show_states(int dev, const char *iface, int opts) int pfctl_show_status(int dev, int opts) { - struct pf_status status; + struct pfctl_status *status; struct pfctl_syncookies cookies; - if (ioctl(dev, DIOCGETSTATUS, &status)) { + if ((status = pfctl_get_status(dev)) == NULL) { warn("DIOCGETSTATUS"); return (-1); } if (pfctl_get_syncookies(dev, &cookies)) { + pfctl_free_status(status); warn("DIOCGETSYNCOOKIES"); return (-1); } if (opts & PF_OPT_SHOWALL) pfctl_print_title("INFO:"); - print_status(&status, &cookies, opts); + print_status(status, &cookies, opts); + pfctl_free_status(status); return (0); } int pfctl_show_running(int dev) { - struct pf_status status; + struct pfctl_status *status; + int running; - if (ioctl(dev, DIOCGETSTATUS, &status)) { + if ((status = pfctl_get_status(dev)) == NULL) { warn("DIOCGETSTATUS"); return (-1); } - print_running(&status); - return (!status.running); + running = status->running; + + print_running(status); + pfctl_free_status(status); + return (!running); } int diff --git a/sbin/pfctl/pfctl_parser.c b/sbin/pfctl/pfctl_parser.c index 8991073ec693..e9a227630f28 100644 --- a/sbin/pfctl/pfctl_parser.c +++ b/sbin/pfctl/pfctl_parser.c @@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include "pfctl_parser.h" @@ -497,8 +498,9 @@ const char * const pf_fcounters[FCNT_MAX+1] = FCNT_NAMES; const char * const pf_scounters[FCNT_MAX+1] = FCNT_NAMES; void -print_status(struct pf_status *s, struct pfctl_syncookies *cookies, int opts) +print_status(struct pfctl_status *s, struct pfctl_syncookies *cookies, int opts) { + struct pfctl_status_counter *c; char statline[80], *running; time_t runtime; int i; @@ -574,56 +576,44 @@ print_status(struct pf_status *s, struct pfctl_syncookies *cookies, int opts) (unsigned long long)s->pcounters[1][1][PF_DROP]); } printf("%-27s %14s %16s\n", "State Table", "Total", "Rate"); - printf(" %-25s %14u %14s\n", "current entries", s->states, ""); - for (i = 0; i < FCNT_MAX; i++) { - printf(" %-25s %14llu ", pf_fcounters[i], - (unsigned long long)s->fcounters[i]); + printf(" %-25s %14" PRIu64 " %14s\n", "current entries", s->states, ""); + TAILQ_FOREACH(c, &s->fcounters, entry) { + printf(" %-25s %14lu ", c->name, c->counter); if (runtime > 0) printf("%14.1f/s\n", - (double)s->fcounters[i] / (double)runtime); + (double)c->counter / (double)runtime); else printf("%14s\n", ""); } if (opts & PF_OPT_VERBOSE) { printf("Source Tracking Table\n"); - printf(" %-25s %14u %14s\n", "current entries", + printf(" %-25s %14" PRIu64 " %14s\n", "current entries", s->src_nodes, ""); - for (i = 0; i < SCNT_MAX; i++) { - printf(" %-25s %14lld ", pf_scounters[i], -#ifdef __FreeBSD__ - (long long)s->scounters[i]); -#else - s->scounters[i]); -#endif + TAILQ_FOREACH(c, &s->scounters, entry) { + printf(" %-25s %14lu ", c->name, c->counter); if (runtime > 0) printf("%14.1f/s\n", - (double)s->scounters[i] / (double)runtime); + (double)c->counter / (double)runtime); else printf("%14s\n", ""); } } printf("Counters\n"); - for (i = 0; i < PFRES_MAX; i++) { - printf(" %-25s %14llu ", pf_reasons[i], - (unsigned long long)s->counters[i]); + TAILQ_FOREACH(c, &s->counters, entry) { + printf(" %-25s %14" PRIu64 " ", c->name, c->counter); if (runtime > 0) printf("%14.1f/s\n", - (double)s->counters[i] / (double)runtime); + (double)c->counter / (double)runtime); else printf("%14s\n", ""); } if (opts & PF_OPT_VERBOSE) { printf("Limit Counters\n"); - for (i = 0; i < LCNT_MAX; i++) { - printf(" %-25s %14lld ", pf_lcounters[i], -#ifdef __FreeBSD__ - (unsigned long long)s->lcounters[i]); -#else - s->lcounters[i]); -#endif + TAILQ_FOREACH(c, &s->lcounters, entry) { + printf(" %-25s %14" PRIu64 " ", c->name, c->counter); if (runtime > 0) printf("%14.1f/s\n", - (double)s->lcounters[i] / (double)runtime); + (double)c->counter / (double)runtime); else printf("%14s\n", ""); } @@ -636,7 +626,7 @@ print_status(struct pf_status *s, struct pfctl_syncookies *cookies, int opts) } void -print_running(struct pf_status *status) +print_running(struct pfctl_status *status) { printf("%s\n", status->running ? "Enabled" : "Disabled"); } diff --git a/sbin/pfctl/pfctl_parser.h b/sbin/pfctl/pfctl_parser.h index 0c64238ecefa..12a66e1ae710 100644 --- a/sbin/pfctl/pfctl_parser.h +++ b/sbin/pfctl/pfctl_parser.h @@ -279,8 +279,8 @@ void print_pool(struct pfctl_pool *, u_int16_t, u_int16_t, sa_family_t, int); void print_src_node(struct pf_src_node *, int); void print_rule(struct pfctl_rule *, const char *, int, int); void print_tabledef(const char *, int, int, struct node_tinithead *); -void print_status(struct pf_status *, struct pfctl_syncookies *, int); -void print_running(struct pf_status *); +void print_status(struct pfctl_status *, struct pfctl_syncookies *, int); +void print_running(struct pfctl_status *); int eval_pfaltq(struct pfctl *, struct pf_altq *, struct node_queue_bw *, struct node_queue_opt *); From owner-dev-commits-src-main@freebsd.org Sun Aug 29 13:54:17 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 15E1B65F1AC; Sun, 29 Aug 2021 13:54:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GyFLJ6tdqz3vWt; Sun, 29 Aug 2021 13:54:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D42793BED; Sun, 29 Aug 2021 13:54:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17TDsGn1099674; Sun, 29 Aug 2021 13:54:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17TDsG20099673; Sun, 29 Aug 2021 13:54:16 GMT (envelope-from git) Date: Sun, 29 Aug 2021 13:54:16 GMT Message-Id: <202108291354.17TDsG20099673@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dimitry Andric Subject: git: 22b8ab15c41a - main - Remove -simplifycfg-dup-ret from CLANG_OPT_SMALL flags for clang 13 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 22b8ab15c41a9efac201691b40e961b83698aa9c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 13:54:17 -0000 The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=22b8ab15c41a9efac201691b40e961b83698aa9c commit 22b8ab15c41a9efac201691b40e961b83698aa9c Author: Dimitry Andric AuthorDate: 2021-08-29 13:39:16 +0000 Commit: Dimitry Andric CommitDate: 2021-08-29 13:39:16 +0000 Remove -simplifycfg-dup-ret from CLANG_OPT_SMALL flags for clang 13 After llvm/clang 13.0.0, the -simplifycfg-dup-ret backend flag is no longer supported. This was part of CLANG_OPT_SMALL, which is only still used for stand/i386/boot2 and stand/i386/isoboot, to achieve the very small binary size required. Luckily clang 13.0.0 does not need any additional flags for this (I get 240 bytes available when building boot2). MFC after: 3 days --- share/mk/bsd.sys.mk | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk index 80cc3080e552..a4bb54e19890 100644 --- a/share/mk/bsd.sys.mk +++ b/share/mk/bsd.sys.mk @@ -228,8 +228,10 @@ CFLAGS+=-nobuiltininc -idirafter ${COMPILER_RESOURCE_DIR}/include .endif .endif -CLANG_OPT_SMALL= -mstack-alignment=8 -mllvm -inline-threshold=3\ - -mllvm -simplifycfg-dup-ret +CLANG_OPT_SMALL= -mstack-alignment=8 -mllvm -inline-threshold=3 +.if ${COMPILER_VERSION} < 130000 +CLANG_OPT_SMALL+= -mllvm -simplifycfg-dup-ret +.endif CLANG_OPT_SMALL+= -mllvm -enable-load-pre=false CFLAGS.clang+= -Qunused-arguments # The libc++ headers use c++11 extensions. These are normally silenced because From owner-dev-commits-src-main@freebsd.org Sun Aug 29 13:54:18 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4C7FD65F06F; Sun, 29 Aug 2021 13:54:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GyFLL1HGrz3vRk; Sun, 29 Aug 2021 13:54:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0262C38BB; Sun, 29 Aug 2021 13:54:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17TDsHWx099698; Sun, 29 Aug 2021 13:54:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17TDsH4L099697; Sun, 29 Aug 2021 13:54:17 GMT (envelope-from git) Date: Sun, 29 Aug 2021 13:54:17 GMT Message-Id: <202108291354.17TDsH4L099697@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dimitry Andric Subject: git: 395d46caaed7 - main - Don't error out on unused but set variables with clang 13 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 395d46caaed73228b84dfaeb37c702304a46ba8f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 13:54:18 -0000 The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=395d46caaed73228b84dfaeb37c702304a46ba8f commit 395d46caaed73228b84dfaeb37c702304a46ba8f Author: Dimitry Andric AuthorDate: 2021-08-29 13:53:40 +0000 Commit: Dimitry Andric CommitDate: 2021-08-29 13:53:40 +0000 Don't error out on unused but set variables with clang 13 Clang 13.0.0 now has a -Wunused-but-set-variable warning similar to the one gcc has had for quite a while. Since this triggers *very* often for our kernel builds, don't make it a hard error, but leave the warning visible so is some incentive to fix the instances. MFC after: 3 days --- sys/conf/kern.mk | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sys/conf/kern.mk b/sys/conf/kern.mk index 56bddb35398b..f6767ba76a46 100644 --- a/sys/conf/kern.mk +++ b/sys/conf/kern.mk @@ -25,6 +25,9 @@ NO_WUNNEEDED_INTERNAL_DECL= -Wno-error=unneeded-internal-declaration NO_WSOMETIMES_UNINITIALIZED= -Wno-error=sometimes-uninitialized NO_WCAST_QUAL= -Wno-error=cast-qual NO_WTAUTOLOGICAL_POINTER_COMPARE= -Wno-tautological-pointer-compare +.if ${COMPILER_VERSION} >= 100000 +NO_WMISLEADING_INDENTATION= -Wno-misleading-indentation +.endif # Several other warnings which might be useful in some cases, but not severe # enough to error out the whole kernel build. Display them anyway, so there is # some incentive to fix them eventually. @@ -33,8 +36,8 @@ CWARNEXTRA?= -Wno-error=tautological-compare -Wno-error=empty-body \ -Wno-error=pointer-sign CWARNEXTRA+= -Wno-error=shift-negative-value CWARNEXTRA+= -Wno-address-of-packed-member -.if ${COMPILER_VERSION} >= 100000 -NO_WMISLEADING_INDENTATION= -Wno-misleading-indentation +.if ${COMPILER_VERSION} >= 130000 +CWARNFLAGS+= -Wno-error=unused-but-set-variable .endif .endif # clang From owner-dev-commits-src-main@freebsd.org Sun Aug 29 15:31:50 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 56CE96605C1; Sun, 29 Aug 2021 15:31:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GyHVt1sxRz4tgR; Sun, 29 Aug 2021 15:31:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 291CF50DA; Sun, 29 Aug 2021 15:31:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17TFVoKa033311; Sun, 29 Aug 2021 15:31:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17TFVoah033310; Sun, 29 Aug 2021 15:31:50 GMT (envelope-from git) Date: Sun, 29 Aug 2021 15:31:50 GMT Message-Id: <202108291531.17TFVoah033310@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dimitry Andric Subject: git: 5b8f07b12f84 - main - Fix -Wformat errors in pfctl on 32-bit architectures MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5b8f07b12f8477f1679013d6b3abdab8d33c7243 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 15:31:50 -0000 The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=5b8f07b12f8477f1679013d6b3abdab8d33c7243 commit 5b8f07b12f8477f1679013d6b3abdab8d33c7243 Author: Dimitry Andric AuthorDate: 2021-08-29 15:31:28 +0000 Commit: Dimitry Andric CommitDate: 2021-08-29 15:31:28 +0000 Fix -Wformat errors in pfctl on 32-bit architectures Use PRIu64 to printf(3) uint64_t quantities, otherwise this will result in "error: format specifies type 'unsigned long' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Werror,-Wformat]" on 32-bit architectures. Fixes: 80078d9d38fd MFC after: 1 week --- sbin/pfctl/pfctl_parser.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sbin/pfctl/pfctl_parser.c b/sbin/pfctl/pfctl_parser.c index e9a227630f28..9f955a8b1c96 100644 --- a/sbin/pfctl/pfctl_parser.c +++ b/sbin/pfctl/pfctl_parser.c @@ -578,7 +578,7 @@ print_status(struct pfctl_status *s, struct pfctl_syncookies *cookies, int opts) printf("%-27s %14s %16s\n", "State Table", "Total", "Rate"); printf(" %-25s %14" PRIu64 " %14s\n", "current entries", s->states, ""); TAILQ_FOREACH(c, &s->fcounters, entry) { - printf(" %-25s %14lu ", c->name, c->counter); + printf(" %-25s %14" PRIu64 " ", c->name, c->counter); if (runtime > 0) printf("%14.1f/s\n", (double)c->counter / (double)runtime); @@ -590,7 +590,7 @@ print_status(struct pfctl_status *s, struct pfctl_syncookies *cookies, int opts) printf(" %-25s %14" PRIu64 " %14s\n", "current entries", s->src_nodes, ""); TAILQ_FOREACH(c, &s->scounters, entry) { - printf(" %-25s %14lu ", c->name, c->counter); + printf(" %-25s %14" PRIu64 " ", c->name, c->counter); if (runtime > 0) printf("%14.1f/s\n", (double)c->counter / (double)runtime); From owner-dev-commits-src-main@freebsd.org Sun Aug 29 16:00:41 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DCC2C660C50; Sun, 29 Aug 2021 16:00:41 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GyJ895ryfz3J2p; Sun, 29 Aug 2021 16:00:41 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from venus.codepro.be (venus.codepro.be [5.9.86.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mx1.codepro.be", Issuer "R3" (verified OK)) (Authenticated sender: kp) by smtp.freebsd.org (Postfix) with ESMTPSA id 98DBD259AE; Sun, 29 Aug 2021 16:00:41 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: by venus.codepro.be (Postfix, authenticated sender kp) id C1D0228EAF; Sun, 29 Aug 2021 18:00:39 +0200 (CEST) From: Kristof Provost To: Dimitry Andric Cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: 5b8f07b12f84 - main - Fix -Wformat errors in pfctl on 32-bit architectures Date: Sun, 29 Aug 2021 18:00:38 +0200 X-Mailer: MailMate (1.14r5818) Message-ID: <6A084192-562D-404D-9833-51A708FA1BC0@FreeBSD.org> In-Reply-To: <202108291531.17TFVoah033310@gitrepo.freebsd.org> References: <202108291531.17TFVoah033310@gitrepo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 16:00:41 -0000 On 29 Aug 2021, at 17:31, Dimitry Andric wrote: > The branch main has been updated by dim: > > URL: https://cgit.FreeBSD.org/src/commit/?id=3D5b8f07b12f8477f1679013d6= b3abdab8d33c7243 > > commit 5b8f07b12f8477f1679013d6b3abdab8d33c7243 > Author: Dimitry Andric > AuthorDate: 2021-08-29 15:31:28 +0000 > Commit: Dimitry Andric > CommitDate: 2021-08-29 15:31:28 +0000 > > Fix -Wformat errors in pfctl on 32-bit architectures > > Use PRIu64 to printf(3) uint64_t quantities, otherwise this will re= sult > in "error: format specifies type 'unsigned long' but the argument h= as > type 'uint64_t' (aka 'unsigned long long') [-Werror,-Wformat]" on 3= 2-bit > architectures. > > Fixes: 80078d9d38fd > MFC after: 1 week Thanks! I was running test builds for a fix, but it is so much more convenient wh= en other people fix my mistakes for me. Kristof From owner-dev-commits-src-main@freebsd.org Sun Aug 29 17:40:22 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1640B662E05; Sun, 29 Aug 2021 17:40:22 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GyLM96mwbz4W13; Sun, 29 Aug 2021 17:40:21 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (tensor.andric.com [87.251.56.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "tensor.andric.com", Issuer "R3" (verified OK)) (Authenticated sender: dim) by smtp.freebsd.org (Postfix) with ESMTPSA id ADD3626395; Sun, 29 Aug 2021 17:40:21 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from smtpclient.apple (unknown [IPv6:2001:470:7a58:0:5cbd:d688:6797:952]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 6186F5E3A8; Sun, 29 Aug 2021 19:40:19 +0200 (CEST) From: Dimitry Andric Message-Id: Content-Type: multipart/signed; boundary="Apple-Mail=_7CE347AC-857C-4CBF-97A9-D02D66DCD0A5"; protocol="application/pgp-signature"; micalg=pgp-sha1 Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: Re: git: 5b8f07b12f84 - main - Fix -Wformat errors in pfctl on 32-bit architectures Date: Sun, 29 Aug 2021 19:40:09 +0200 In-Reply-To: <6A084192-562D-404D-9833-51A708FA1BC0@FreeBSD.org> Cc: "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" To: Kristof Provost References: <202108291531.17TFVoah033310@gitrepo.freebsd.org> <6A084192-562D-404D-9833-51A708FA1BC0@FreeBSD.org> X-Mailer: Apple Mail (2.3654.120.0.1.13) X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 17:40:22 -0000 --Apple-Mail=_7CE347AC-857C-4CBF-97A9-D02D66DCD0A5 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii On 29 Aug 2021, at 18:00, Kristof Provost wrote: >=20 > On 29 Aug 2021, at 17:31, Dimitry Andric wrote: >> The branch main has been updated by dim: >>=20 >> URL: = https://cgit.FreeBSD.org/src/commit/?id=3D5b8f07b12f8477f1679013d6b3abdab8= d33c7243 >>=20 >> commit 5b8f07b12f8477f1679013d6b3abdab8d33c7243 >> Author: Dimitry Andric >> AuthorDate: 2021-08-29 15:31:28 +0000 >> Commit: Dimitry Andric >> CommitDate: 2021-08-29 15:31:28 +0000 >>=20 >> Fix -Wformat errors in pfctl on 32-bit architectures >>=20 >> Use PRIu64 to printf(3) uint64_t quantities, otherwise this will = result >> in "error: format specifies type 'unsigned long' but the argument = has >> type 'uint64_t' (aka 'unsigned long long') [-Werror,-Wformat]" on = 32-bit >> architectures. >>=20 >> Fixes: 80078d9d38fd >> MFC after: 1 week >=20 > Thanks! >=20 > I was running test builds for a fix, but it is so much more convenient = when other people fix my mistakes for me. I was trying buildworld on i386 for something totally unrelated, and ran into these -Wformat errors so I took the liberty of patching them up quickly. :) -Dimitry --Apple-Mail=_7CE347AC-857C-4CBF-97A9-D02D66DCD0A5 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.2 iF0EARECAB0WIQR6tGLSzjX8bUI5T82wXqMKLiCWowUCYSvGeQAKCRCwXqMKLiCW oypoAKDix9DoDSRfCE4vcpAZjSAQkIbL8wCeLJKDpgyR8w/axdbSsvA9xG/VTjU= =eLwf -----END PGP SIGNATURE----- --Apple-Mail=_7CE347AC-857C-4CBF-97A9-D02D66DCD0A5-- From owner-dev-commits-src-main@freebsd.org Sun Aug 29 17:44:45 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F0F93662F31; Sun, 29 Aug 2021 17:44:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GyLSF67zyz4YTj; Sun, 29 Aug 2021 17:44:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BB1326E22; Sun, 29 Aug 2021 17:44:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17THijxs007117; Sun, 29 Aug 2021 17:44:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17THijbo007116; Sun, 29 Aug 2021 17:44:45 GMT (envelope-from git) Date: Sun, 29 Aug 2021 17:44:45 GMT Message-Id: <202108291744.17THijbo007116@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dimitry Andric Subject: git: 8e3c56d6b676 - main - xen: Fix warning by adding KERNBASE to modlist_paddr before casting MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8e3c56d6b676a175e974bad4c20797fb35017db8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 17:44:46 -0000 The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=8e3c56d6b676a175e974bad4c20797fb35017db8 commit 8e3c56d6b676a175e974bad4c20797fb35017db8 Author: Dimitry Andric AuthorDate: 2021-08-29 14:02:31 +0000 Commit: Dimitry Andric CommitDate: 2021-08-29 17:43:00 +0000 xen: Fix warning by adding KERNBASE to modlist_paddr before casting Clang 13 produces the following warning for hammer_time_xen(): sys/x86/xen/pv.c:183:19: error: the pointer incremented by -2147483648 refers past the last possible element for an array in 64-bit address space containing 256-bit (32-byte) elements (max possible 576460752303423488 elements) [-Werror,-Warray-bounds] (vm_paddr_t)start_info->modlist_paddr + KERNBASE; ^ ~~~~~~~~ sys/xen/interface/arch-x86/hvm/start_info.h:131:5: note: array 'modlist_paddr' declared here uint64_t modlist_paddr; /* Physical address of an array of */ ^ This is because the expression first casts start_info->modlist_paddr to struct hvm_modlist_entry * (via vmpaddr_t), and *then* adds KERNBASE, which is then interpreted as KERNBASE * sizeof(struct hvm_modlist_entry). Instead, parenthesize the addition to get the intended result, and cast it to struct hvm_modlist_entry * afterwards. Also remove the cast to vmpaddr_t since it is not necessary. Reviewed by: royger MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D31711 --- sys/x86/xen/pv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/x86/xen/pv.c b/sys/x86/xen/pv.c index 6e1bba691171..a316d4ee8857 100644 --- a/sys/x86/xen/pv.c +++ b/sys/x86/xen/pv.c @@ -180,7 +180,7 @@ hammer_time_xen(vm_paddr_t start_info_paddr) HYPERVISOR_shutdown(SHUTDOWN_crash); } mod = (struct hvm_modlist_entry *) - (vm_paddr_t)start_info->modlist_paddr + KERNBASE; + (start_info->modlist_paddr + KERNBASE); if (mod[0].paddr >= physfree) { xc_printf("ERROR: unexpected module memory address\n"); HYPERVISOR_shutdown(SHUTDOWN_crash); From owner-dev-commits-src-main@freebsd.org Sun Aug 29 19:25:23 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6E60B665A1A; Sun, 29 Aug 2021 19:25:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GyNhM2LLlz3HNn; Sun, 29 Aug 2021 19:25:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 33DB51045D; Sun, 29 Aug 2021 19:25:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17TJPNjd043204; Sun, 29 Aug 2021 19:25:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17TJPN6W043203; Sun, 29 Aug 2021 19:25:23 GMT (envelope-from git) Date: Sun, 29 Aug 2021 19:25:23 GMT Message-Id: <202108291925.17TJPN6W043203@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Piotr Pawel Stefaniak Subject: git: 0939f965d80d - main - Update a sysctl name to nbuffers_pcpu in hwpmc.4 and pmcstat.c MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pstef X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0939f965d80d00e783b3319a57e7d71e0b3f202e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 19:25:23 -0000 The branch main has been updated by pstef: URL: https://cgit.FreeBSD.org/src/commit/?id=0939f965d80d00e783b3319a57e7d71e0b3f202e commit 0939f965d80d00e783b3319a57e7d71e0b3f202e Author: Piotr Pawel Stefaniak AuthorDate: 2021-08-28 08:01:19 +0000 Commit: Piotr Pawel Stefaniak CommitDate: 2021-08-29 19:24:50 +0000 Update a sysctl name to nbuffers_pcpu in hwpmc.4 and pmcstat.c This change was missed in r333509 (e6b475e0af). Differential Revision: https://reviews.freebsd.org/D31704 Reviewed by: mjg --- share/man/man4/hwpmc.4 | 2 +- sys/dev/hwpmc/hwpmc_logging.c | 2 +- usr.sbin/pmcstat/pmcstat.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/share/man/man4/hwpmc.4 b/share/man/man4/hwpmc.4 index d1bd576fcb9c..77fe4b9a075a 100644 --- a/share/man/man4/hwpmc.4 +++ b/share/man/man4/hwpmc.4 @@ -419,7 +419,7 @@ The default buffer size is 4KB. .It Va kern.hwpmc.mtxpoolsize Pq integer, read-only The size of the spin mutex pool used by the PMC driver. The default is 32. -.It Va kern.hwpmc.nbuffers Pq integer, read-only +.It Va kern.hwpmc.nbuffers_pcpu Pq integer, read-only The number of log buffers used by .Nm for logging. diff --git a/sys/dev/hwpmc/hwpmc_logging.c b/sys/dev/hwpmc/hwpmc_logging.c index c13b87f4165f..c16adff8c842 100644 --- a/sys/dev/hwpmc/hwpmc_logging.c +++ b/sys/dev/hwpmc/hwpmc_logging.c @@ -86,7 +86,7 @@ SYSCTL_INT(_kern_hwpmc, OID_AUTO, logbuffersize, CTLFLAG_RDTUN, &pmclog_buffer_size, 0, "size of log buffers in kilobytes"); /* - * kern.hwpmc.nbuffer -- number of global log buffers + * kern.hwpmc.nbuffers_pcpu -- number of global log buffers */ static int pmc_nlogbuffers_pcpu = PMC_NLOGBUFFERS_PCPU; diff --git a/usr.sbin/pmcstat/pmcstat.c b/usr.sbin/pmcstat/pmcstat.c index 997005cec269..3e2d101ab113 100644 --- a/usr.sbin/pmcstat/pmcstat.c +++ b/usr.sbin/pmcstat/pmcstat.c @@ -1455,7 +1455,7 @@ main(int argc, char **argv) args.pa_verbosity > 0) warnx( "WARNING: at least %u event%s were discarded while running.\n" -"Please consider tuning the \"kern.hwpmc.nbuffers\" tunable.", +"Please consider tuning the \"kern.hwpmc.nbuffers_pcpu\" tunable.", ds_end.pm_buffer_requests_failed - ds_start.pm_buffer_requests_failed, ((ds_end.pm_buffer_requests_failed - From owner-dev-commits-src-main@freebsd.org Sun Aug 29 20:13:44 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 921136671FC; Sun, 29 Aug 2021 20:13:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GyPm83hdMz3lc8; Sun, 29 Aug 2021 20:13:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 63CED110FA; Sun, 29 Aug 2021 20:13:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17TKDiJf011295; Sun, 29 Aug 2021 20:13:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17TKDitd011294; Sun, 29 Aug 2021 20:13:44 GMT (envelope-from git) Date: Sun, 29 Aug 2021 20:13:44 GMT Message-Id: <202108292013.17TKDitd011294@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: d98954e22981 - main - routing: Bring back the ability to specify transmit interface via its name. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: melifaro X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d98954e229812eee2fa6bf97714fecbbdcc56e4c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 20:13:44 -0000 The branch main has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=d98954e229812eee2fa6bf97714fecbbdcc56e4c commit d98954e229812eee2fa6bf97714fecbbdcc56e4c Author: Alexander V. Chernikov AuthorDate: 2021-08-29 19:51:28 +0000 Commit: Alexander V. Chernikov CommitDate: 2021-08-29 20:05:14 +0000 routing: Bring back the ability to specify transmit interface via its name. Some software references outgoing interfaces by specifying name instead of index. Use rti_ifp from rt_addrinfo if provided instead of always using address interface when constructing nexthop. PR: 255678 Reported by: martin.larsson2 at gmail.com MFC after: 1 week --- sys/net/route.c | 45 ++++++++++++++++++++++++++++++++++++--------- sys/net/route/nhop_ctl.c | 2 +- 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/sys/net/route.c b/sys/net/route.c index 4f7eb6f64210..e4ed7d1a2fd1 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -502,6 +502,38 @@ rt_flushifroutes(struct ifnet *ifp) rib_foreach_table_walk_del(AF_UNSPEC, rt_ifdelroute, ifp); } +/* + * Tries to extract interface from RTAX_IFP passed in rt_addrinfo. + * Interface can be specified ether as interface index (sdl_index) or + * the interface name (sdl_data). + * + * Returns found ifp or NULL + */ +static struct ifnet * +info_get_ifp(struct rt_addrinfo *info) +{ + const struct sockaddr_dl *sdl; + + sdl = (const struct sockaddr_dl *)info->rti_info[RTAX_IFP]; + if (sdl->sdl_family != AF_LINK) + return (NULL); + + if (sdl->sdl_index != 0) + return (ifnet_byindex(sdl->sdl_index)); + if (sdl->sdl_nlen > 0) { + char if_name[IF_NAMESIZE]; + if (sdl->sdl_nlen + offsetof(struct sockaddr_dl, sdl_data) > sdl->sdl_len) + return (NULL); + if (sdl->sdl_nlen >= IF_NAMESIZE) + return (NULL); + bzero(if_name, sizeof(if_name)); + memcpy(if_name, sdl->sdl_data, sdl->sdl_nlen); + return (ifunit(if_name)); + } + + return (NULL); +} + /* * Look up rt_addrinfo for a specific fib. * @@ -511,12 +543,11 @@ rt_flushifroutes(struct ifnet *ifp) int rt_getifa_fib(struct rt_addrinfo *info, u_int fibnum) { - const struct sockaddr *dst, *gateway, *ifpaddr, *ifaaddr; + const struct sockaddr *dst, *gateway, *ifaaddr; int error, flags; dst = info->rti_info[RTAX_DST]; gateway = info->rti_info[RTAX_GATEWAY]; - ifpaddr = info->rti_info[RTAX_IFP]; ifaaddr = info->rti_info[RTAX_IFA]; flags = info->rti_flags; @@ -526,13 +557,9 @@ rt_getifa_fib(struct rt_addrinfo *info, u_int fibnum) */ error = 0; - /* If we have interface specified by the ifindex in the address, use it */ - if (info->rti_ifp == NULL && ifpaddr != NULL && - ifpaddr->sa_family == AF_LINK) { - const struct sockaddr_dl *sdl = (const struct sockaddr_dl *)ifpaddr; - if (sdl->sdl_index != 0) - info->rti_ifp = ifnet_byindex(sdl->sdl_index); - } + /* If we have interface specified by RTAX_IFP address, try to use it */ + if ((info->rti_ifp == NULL) && (info->rti_info[RTAX_IFP] != NULL)) + info->rti_ifp = info_get_ifp(info); /* * If we have source address specified, try to find it * TODO: avoid enumerating all ifas on all interfaces. diff --git a/sys/net/route/nhop_ctl.c b/sys/net/route/nhop_ctl.c index 92b43871d604..21aefcc7a83b 100644 --- a/sys/net/route/nhop_ctl.c +++ b/sys/net/route/nhop_ctl.c @@ -286,7 +286,7 @@ fill_nhop_from_info(struct nhop_priv *nh_priv, struct rt_addrinfo *info) if ((error = set_nhop_gw_from_info(nh, info)) != 0) return (error); - nh->nh_ifp = info->rti_ifa->ifa_ifp; + nh->nh_ifp = (info->rti_ifp != NULL) ? info->rti_ifp : info->rti_ifa->ifa_ifp; nh->nh_ifa = info->rti_ifa; /* depends on the gateway */ nh->nh_aifp = get_aifp(nh); From owner-dev-commits-src-main@freebsd.org Sun Aug 29 23:49:40 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7262766C803; Sun, 29 Aug 2021 23:49:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GyVYJ2Y8rz3v0C; Sun, 29 Aug 2021 23:49:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3B4C213C48; Sun, 29 Aug 2021 23:49:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17TNne4l090753; Sun, 29 Aug 2021 23:49:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17TNneFI090752; Sun, 29 Aug 2021 23:49:40 GMT (envelope-from git) Date: Sun, 29 Aug 2021 23:49:40 GMT Message-Id: <202108292349.17TNneFI090752@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: 13914e51eb8d - main - nfsd: Make loop calling VOP_ALLOCATE() iterate until done MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 13914e51eb8de6fe9f627c9c1d48c09880b2607e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 23:49:40 -0000 The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=13914e51eb8de6fe9f627c9c1d48c09880b2607e commit 13914e51eb8de6fe9f627c9c1d48c09880b2607e Author: Rick Macklem AuthorDate: 2021-08-29 23:46:27 +0000 Commit: Rick Macklem CommitDate: 2021-08-29 23:46:27 +0000 nfsd: Make loop calling VOP_ALLOCATE() iterate until done The NFSv4.2 Deallocate operation loops on VOP_DEALLOCATE() while progress is being made (remaining length decreasing). This patch changes the loop on VOP_ALLOCATE() for the NFSv4.2 Allocate operation do the same, instead of stopping after an arbitrary 20 iterations. MFC after: 2 weeks --- sys/fs/nfsserver/nfs_nfsdport.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/sys/fs/nfsserver/nfs_nfsdport.c b/sys/fs/nfsserver/nfs_nfsdport.c index d93c547c5530..9250c0ce0a23 100644 --- a/sys/fs/nfsserver/nfs_nfsdport.c +++ b/sys/fs/nfsserver/nfs_nfsdport.c @@ -6564,7 +6564,8 @@ int nfsvno_allocate(struct vnode *vp, off_t off, off_t len, struct ucred *cred, NFSPROC_T *p) { - int error, trycnt; + int error; + off_t olen; ASSERT_VOP_ELOCKED(vp, "nfsvno_allocate vp"); /* @@ -6575,15 +6576,17 @@ nfsvno_allocate(struct vnode *vp, off_t off, off_t len, struct ucred *cred, NULL, NULL, NULL, NULL, &len, 0, NULL); if (error != ENOENT) return (error); - error = 0; /* - * Do the actual VOP_ALLOCATE(), looping a reasonable number of - * times to achieve completion. + * Do the actual VOP_ALLOCATE(), looping so long as + * progress is being made, to achieve completion. */ - trycnt = 0; - while (error == 0 && len > 0 && trycnt++ < 20) + do { + olen = len; error = VOP_ALLOCATE(vp, &off, &len); + if (error == 0 && len > 0 && olen > len) + maybe_yield(); + } while (error == 0 && len > 0 && olen > len); if (error == 0 && len > 0) error = NFSERR_IO; NFSEXITCODE(error);