]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agoAdd an entry to RELNOTES about renaming ACPI_DMAR to IOMMU
Mateusz Piotrowski [Tue, 10 Nov 2020 10:17:11 +0000 (10:17 +0000)]
Add an entry to RELNOTES about renaming ACPI_DMAR to IOMMU

Reviewed by: br (earlier version)
Differential Revision: https://reviews.freebsd.org/D26813

3 years agong_nat: unbreak ABI
Eugene Grosbein [Tue, 10 Nov 2020 02:26:44 +0000 (02:26 +0000)]
ng_nat: unbreak ABI

The revision r342168 broke ABI of ng_nat needlessly and
the change was merged to stable branches breaking ABI there, too.
Unbreak it.

PR: 250722
MFC after: 1 week

3 years agothread: retire thread_find
Mateusz Guzik [Tue, 10 Nov 2020 01:57:48 +0000 (01:57 +0000)]
thread: retire thread_find

tdfind should be used instead.

3 years agothread: use tdfind in sysctl_kern_proc_kstack
Mateusz Guzik [Tue, 10 Nov 2020 01:57:19 +0000 (01:57 +0000)]
thread: use tdfind in sysctl_kern_proc_kstack

This treads linear scans for locked lookup, but more importantly removes
the only consumer of thread_find.

3 years agothreads: remove the unused TID_BUFFER_SIZE macro
Mateusz Guzik [Tue, 10 Nov 2020 01:31:06 +0000 (01:31 +0000)]
threads: remove the unused TID_BUFFER_SIZE macro

3 years agothread: adds newer bits for r367537
Mateusz Guzik [Tue, 10 Nov 2020 01:13:58 +0000 (01:13 +0000)]
thread: adds newer bits for r367537

The committed patch was an older version.

3 years agousb_hub: fix whitespace
Bjoern A. Zeeb [Mon, 9 Nov 2020 23:36:51 +0000 (23:36 +0000)]
usb_hub: fix whitespace

Fix a whitespace "error" introduced in r367435 noticed when
preparing the MFC.  No functional changes.

3 years agoarm64: bs_sr_<N> take II
Bjoern A. Zeeb [Mon, 9 Nov 2020 23:34:32 +0000 (23:34 +0000)]
arm64: bs_sr_<N> take II

In r367327 generic_bs_sr_<n> were derived from mips.  Given we are calling
generic_bs_w_<n> and no write directly, we do not have to do the address
calculations ourselves as eneric_bs_w_<n> will do a str val [bsh, offset].
All we actually have to do is increment offset.

MFC after: 3 days

3 years agothreads: reimplement tid allocation on top of a bitmap
Mateusz Guzik [Mon, 9 Nov 2020 23:05:28 +0000 (23:05 +0000)]
threads: reimplement tid allocation on top of a bitmap

There are workloads with very bursty tid allocation and since unr tries very
hard to have small-sized bitmaps it keeps reallocating memory. Just doing
buildkernel gives almost 150k calls to free coming from unr.

This also gets rid of the hack which tried to postpone TID reuse.

Reviewed by: kib, markj
Tested by: pho
Differential Revision: https://reviews.freebsd.org/D27101

3 years agothreads: introduce a limit for total number
Mateusz Guzik [Mon, 9 Nov 2020 23:04:30 +0000 (23:04 +0000)]
threads: introduce a limit for total number

The intent is to replace the current id allocation method and a known upper
bound will be useful.

Reviewed by: kib (previous version), markj (previous version)
Tested by: pho
Differential Revision: https://reviews.freebsd.org/D27100

3 years agovfs: group mount per-cpu vars into one struct
Mateusz Guzik [Mon, 9 Nov 2020 23:02:13 +0000 (23:02 +0000)]
vfs: group mount per-cpu vars into one struct

While here move frequently read stuff into the same cacheline.

This shrinks struct mount by 64 bytes.

Tested by: pho

3 years agovmstat: drop the HighUse field from malloc dump
Mateusz Guzik [Mon, 9 Nov 2020 23:00:29 +0000 (23:00 +0000)]
vmstat: drop the HighUse field from malloc dump

It is hardwired to "-" since its introduction in 2005.

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D27141

3 years agomalloc: provide 384 byte zone
Mateusz Guzik [Mon, 9 Nov 2020 22:59:41 +0000 (22:59 +0000)]
malloc: provide 384 byte zone

Total page count after buildworld on ZFS for 384 (if present) and 512 zones:
before: 29713
after: 25946

per-zone page use:
vm.uma.malloc_384.keg.domain.1.pages: 11621
vm.uma.malloc_384.keg.domain.0.pages: 11597
vm.uma.malloc_512.keg.domain.1.pages: 1280
vm.uma.malloc_512.keg.domain.0.pages: 1448

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D27145

3 years agomalloc: retire mt_stats_zone in favor of pcpu_zone_64
Mateusz Guzik [Mon, 9 Nov 2020 22:58:29 +0000 (22:58 +0000)]
malloc: retire mt_stats_zone in favor of pcpu_zone_64

Reviewed by: markj, imp
Differential Revision: https://reviews.freebsd.org/D27142

3 years agoRFC 7323 specifies that:
Michael Tuexen [Mon, 9 Nov 2020 21:49:40 +0000 (21:49 +0000)]
RFC 7323 specifies that:
* TCP segments without timestamps should be dropped when support for
  the timestamp option has been negotiated.
* TCP segments with timestamps should be processed normally if support
  for the timestamp option has not been negotiated.
This patch enforces the above.

PR: 250499
Reviewed by: gnn, rrs
MFC after: 1 week
Sponsored by: Netflix, Inc
Differential Revision: https://reviews.freebsd.org/D27148

3 years agoBump __FreeBSD_version after linuxkpi changes
Emmanuel Vadot [Mon, 9 Nov 2020 13:20:44 +0000 (13:20 +0000)]
Bump __FreeBSD_version after linuxkpi changes

3 years agoLinuxKPI: Implement ACPI bits required by drm-kmod in base system
Emmanuel Vadot [Mon, 9 Nov 2020 13:20:14 +0000 (13:20 +0000)]
LinuxKPI: Implement ACPI bits required by drm-kmod in base system

It includes:

ACPI_HANDLE() implementation.
AC and VIDEO ACPI events notification support.
Replacement of hand-rolled GPLed _DSM method evaluation helpers
with in-base ones.

Submitted by: wulf
Differential Revision: https://reviews.freebsd.org/D26603

3 years agoFix a potential use-after-free bug introduced in
Michael Tuexen [Mon, 9 Nov 2020 13:12:07 +0000 (13:12 +0000)]
Fix a potential use-after-free bug introduced in
https://svnweb.freebsd.org/changeset/base/363046

Thanks to Taylor Brandstetter for finding this issue using fuzz testing
and reporting it in https://github.com/sctplab/usrsctp/issues/547

3 years agoMake it possible to mount a fuse filesystem, such as squashfuse,
Edward Tomasz Napierala [Mon, 9 Nov 2020 08:53:15 +0000 (08:53 +0000)]
Make it possible to mount a fuse filesystem, such as squashfuse,
from a Linux binary.  Should come handy for AppImages.

Reviewed by: asomers
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D26959

3 years agoRemove newline from bxe description, it's not done elsewhere.
Warner Losh [Mon, 9 Nov 2020 03:02:34 +0000 (03:02 +0000)]
Remove newline from bxe description, it's not done elsewhere.

3 years agoAdd more per-cpu zones.
Mateusz Guzik [Mon, 9 Nov 2020 00:34:23 +0000 (00:34 +0000)]
Add more per-cpu zones.

This covers powers of 2 up to 64.

Example pending user is ZFS.

3 years agocxgbe(4): Allow the PF driver to set a VF's MAC address.
Navdeep Parhar [Mon, 9 Nov 2020 00:08:35 +0000 (00:08 +0000)]
cxgbe(4): Allow the PF driver to set a VF's MAC address.

The MAC address can be set with the optional mac-addr property in the VF
section of the iovctl.conf(5) used to instantiate the VFs.

MFC after: 2 weeks
Sponsored by: Chelsio Communications

3 years agovmstat: remove spurious newlines when reporting zones
Mateusz Guzik [Mon, 9 Nov 2020 00:05:45 +0000 (00:05 +0000)]
vmstat: remove spurious newlines when reporting zones

3 years agoprocdesc: convert the zone to a malloc type
Mateusz Guzik [Mon, 9 Nov 2020 00:05:21 +0000 (00:05 +0000)]
procdesc: convert the zone to a malloc type

The object is 128 bytes in size.

3 years agobufcache: convert bo_numoutput from long to int
Mateusz Guzik [Mon, 9 Nov 2020 00:04:58 +0000 (00:04 +0000)]
bufcache: convert bo_numoutput from long to int

int is wide enough and it plugs a hole in struct vnode, taking it down
from 496 to 488 bytes.

3 years agokqueue: save space by using only one func pointer for assertions
Mateusz Guzik [Mon, 9 Nov 2020 00:04:35 +0000 (00:04 +0000)]
kqueue: save space by using only one func pointer for assertions

3 years agocxgbev(4): Use the MAC address set by the the PF if there is one.
Navdeep Parhar [Mon, 9 Nov 2020 00:01:13 +0000 (00:01 +0000)]
cxgbev(4): Use the MAC address set by the the PF if there is one.

Query the firmware for the MAC address set by the PF for the VF and use
it instead of the firmware generated MAC if it's available.

MFC after: 2 weeks
Sponsored by: Chelsio Communications

3 years ago[PowerPC] Fix powerpc64le boot after HPT superpages addition
Brandon Bergren [Sun, 8 Nov 2020 23:34:06 +0000 (23:34 +0000)]
[PowerPC] Fix powerpc64le boot after HPT superpages addition

The HPT is always stored in big-endian, as it is accessed directly by the
hardware as well as the kernel. As such, it is necessary to convert values
to and from native endian when running on LE.

Some unconverted accesses snuck in accidentally with r367417.

Apply the appropriate conversions to fix boot hanging on powerpc64le.

Sponsored by: Tag1 Consulting, Inc.

3 years agocxgbe(4): Add the firmware binaries missing in r367428.
Navdeep Parhar [Sun, 8 Nov 2020 22:30:13 +0000 (22:30 +0000)]
cxgbe(4): Add the firmware binaries missing in r367428.

Obtained from: Chelsio Communications
MFC after: 5 days
Sponsored by: Chelsio Communications

3 years agoFix definition of rn_addmask()
Mitchell Horne [Sun, 8 Nov 2020 19:02:22 +0000 (19:02 +0000)]
Fix definition of rn_addmask()

Add the missing static keyword present in the declaration.

Reviewed by: melifaro
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D27024

3 years agoigmp: convert igmpstat to use PCPU counters
Mitchell Horne [Sun, 8 Nov 2020 18:49:23 +0000 (18:49 +0000)]
igmp: convert igmpstat to use PCPU counters

Currently there is no locking done to protect this structure. It is
likely okay due to the low-volume nature of IGMP, but allows for
the possibility of underflow. This appears to be one of the only
holdouts of the conversion to counter(9) which was done for most
protocol stat structures around 2013.

This also updates the visibility of this stats structure so that it can
be consumed from elsewhere in the kernel, consistent with the vast
majority of VNET_PCPUSTAT structures.

Reviewed by: kp
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D27023

3 years agoPrevent premature SACK block transmission during loss recovery
Richard Scheffenegger [Sun, 8 Nov 2020 18:47:05 +0000 (18:47 +0000)]
Prevent premature SACK block transmission during loss recovery

Under specific conditions, a window update can be sent with
outdated SACK information. Some clients react to this by
subsequently delaying loss recovery, making TCP perform very
poorly.

Reported by: chengc_netapp.com
Reviewed by: rrs, jtl
MFC after: 2 weeks
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D24237

3 years agoSwitch net.add_addr_allfibs default to 0.
Alexander V. Chernikov [Sun, 8 Nov 2020 18:27:49 +0000 (18:27 +0000)]
Switch net.add_addr_allfibs default to 0.

The goal of the fib support is to provide multiple independent
 routing tables, isolated from each other.
net.add_addr_allfibs default tries to shift gears in the opposite
 direction, unconditionally inserting all addresses to all of the fibs.

There are use cases when this is necessary, however this is not a
 default expected behaviour, especially compared to other implementations.

Provide WARNING message for the setups with multiple fibs to notify
 potential users of the feature.

Differential Revision: https://reviews.freebsd.org/D26076

3 years agoTemporarily revert setting net.add_addr_allfibs to 0.
Alexander V. Chernikov [Sun, 8 Nov 2020 18:11:12 +0000 (18:11 +0000)]
Temporarily revert setting net.add_addr_allfibs to 0.
It accidentally sweeped in r367486.
Revert to allow for proper commit message & warning.

3 years agoMove syscall_thread_{enter,exit}() into the slow path. This is only
Edward Tomasz Napierala [Sun, 8 Nov 2020 15:54:59 +0000 (15:54 +0000)]
Move syscall_thread_{enter,exit}() into the slow path.  This is only
needed for syscalls from unloadable modules.

Reviewed by: kib
MFC after: 2 weeks
Sponsored by: EPSRC
Differential Revision: https://reviews.freebsd.org/D26988

3 years agoCheck if the ZVOL has been written before calling zil_async_to_sync.
Mariusz Zaborski [Sun, 8 Nov 2020 14:08:00 +0000 (14:08 +0000)]
Check if the ZVOL has been written before calling zil_async_to_sync.
The ZIL will be opened on the first write, not earlier.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Mariusz Zaborski <oshogbo@vexillium.org>
OpenZFS Pull Request: https://github.com/openzfs/zfs/pull/11152
PR: 250934

3 years agoFix build broken by r367484: add route_ifaddrs.c.
Alexander V. Chernikov [Sun, 8 Nov 2020 13:30:44 +0000 (13:30 +0000)]
Fix build broken by r367484: add route_ifaddrs.c.

Pointy hat to: melifaro
Reported by: jenkins

3 years agoMerge commit 354d3106c from llvm git (by Kai Luo):
Dimitry Andric [Sun, 8 Nov 2020 12:47:35 +0000 (12:47 +0000)]
Merge commit 354d3106c from llvm git (by Kai Luo):

  [PowerPC] Skip combining (uint_to_fp x) if x is not simple type

  Current powerpc64le backend hits
  ```
  Combining: t7: f64 = uint_to_fp t6
  llc: llvm-project/llvm/include/llvm/CodeGen/ValueTypes.h:291:
  llvm::MVT llvm::EVT::getSimpleVT() const: Assertion `isSimple() &&
  "Expected a SimpleValueType!"' failed.
  ```
  This patch fixes it by skipping combination if `t6` is not simple
  type.
  Fixed https://bugs.llvm.org/show_bug.cgi?id=47660.

  Reviewed By: #powerpc, steven.zhang

  Differential Revision: https://reviews.llvm.org/D88388

This should fix the llvm assertion mentioned above when building the
following ports for powerpc64le:

* audio/traverso
* databases/percona57-pam-for-mysql
* databases/percona57-server
* emulators/citra
* emulators/citra-qt5
* games/7kaa
* graphics/dia
* graphics/mandelbulber
* graphics/pcl-pointclouds
* net-p2p/libtorrent-rasterbar
* textproc/htmldoc

Requested by: pkubaj
MFC after: 3 days

3 years agoMove all ifaddr route creation business logic to net/route/route_ifaddr.c
Alexander V. Chernikov [Sun, 8 Nov 2020 11:12:00 +0000 (11:12 +0000)]
Move all ifaddr route creation business logic to net/route/route_ifaddr.c

Differential Revision: https://reviews.freebsd.org/D26318

3 years ago - add more linux socket options (sorted by value)
Alexander Leidinger [Sun, 8 Nov 2020 09:50:58 +0000 (09:50 +0000)]
 - add more linux socket options (sorted by value)
 - map those IPv4 / IPv6 socket options which exist in FreeBSD
   + most of them visually verified to have the same type/layout of arguments
   + not tested with linux programs to behave as intended
 - be more human readable for known options which are not handled
 - be more verbose for unhandled socket message flags we know about
 - print the jail ID in linux_msg if run in a jail
 - add possibility to print debug message about known missing parts only once
 - add multiple levels of sysctl linux.debug:
   1: print debug messages, tell about unimplemented stuff (only once)
   2: like 1, but also print messages about implemented but not tested
      stuff (only once)
   3+: like 2, but no rate limiting of messages
 - increase default linux debug level from 1 to 3

We are a lot more verbose in as we need to be (e.g. some of the IP socket
options which are the same, and share the same memory layout, and are
believed to work). The reason is that we have no good testsuite to test those
linux-bits. The LTP or other test suites like the python one, are not fully
up to the task we need. As such the excessive messages about emulated but not
tested socket options.

IMO any MFC (possible, but most probably not by me) should set the default
debug level to 1.

Discussed with: trasz

3 years agoloader: cstyle cleanup of bootstrap.h did miss a bit
Toomas Soome [Sun, 8 Nov 2020 09:49:51 +0000 (09:49 +0000)]
loader: cstyle cleanup of bootstrap.h did miss a bit

correct small issues - misplaced comment and typos.

3 years agoloader: cstyle cleanup of bootstrap.h
Toomas Soome [Sun, 8 Nov 2020 09:35:41 +0000 (09:35 +0000)]
loader: cstyle cleanup of bootstrap.h

No functional changes intended.

3 years agoReturn the same value for smbios.chassis.maker as smbios.system.maker (and prevents...
Olivier Cochard [Sun, 8 Nov 2020 07:49:39 +0000 (07:49 +0000)]
Return the same value for smbios.chassis.maker as smbios.system.maker (and prevents returning a space character).

Reviewed by: grehan
Approved by: grehan
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D27123

3 years agoimgact_binmisc: limit the extent of match on incoming entries
Kyle Evans [Sun, 8 Nov 2020 04:24:29 +0000 (04:24 +0000)]
imgact_binmisc: limit the extent of match on incoming entries

imgact_binmisc matches magic/mask from imgp->image_header, which is only a
single page in size mapped from the first page of an image. One can specify
an interpreter that matches on, e.g., --offset 4096 --size 256 to read up to
256 bytes past the mapped first page.

The limitation is that we cannot specify a magic string that exceeds a
single page, and we can't allow offset + size to exceed a single page
either.  A static assert has been added in case someone finds it useful to
try and expand the size, but it does seem a little unlikely.

While this looks kind of exploitable at a sideways squinty-glance, there are
a couple of mitigating factors:

1.) imgact_binmisc is not enabled by default,
2.) entries may only be added by the superuser,
3.) trying to exploit this information to read what's mapped past the end
  would be worse than a root canal or some other relatably painful
  experience, and
4.) there's no way one could pull this off without it being completely
  obvious.

The first page is mapped out of an sf_buf, the implementation of which (or
lack thereof) depends on your platform.

MFC after: 1 week

3 years agoAdd collation version support to querylocale(3).
Thomas Munro [Sun, 8 Nov 2020 02:50:34 +0000 (02:50 +0000)]
Add collation version support to querylocale(3).

Provide a way to ask for an opaque version string for a locale_t, so
that potential changes in sort order can be detected.  Similar to
ICU's ucol_getVersion() and Windows' GetNLSVersionEx(), this API is
intended to allow databases to detect when text order-based indexes
might need to be rebuilt.

The CLDR version is extracted from CLDR source data by the Makefile
under tools/tools/locale, written into the machine-generated Makefile
under shared/colldef, passed to localedef -V, and then written into
LC_COLLATE file headers.  The initial version is 34.0.
tools/tools/locale was recently updated to pull down 35.0, but the
output hasn't been committed under share/colldef yet, so that will
provide the first observable change when it happens.  Other versioning
schemes are possible in future, because the format is unspecified.

Reviewed by: bapt, 0mp, kib, yuripv (albeit a long time ago)
Differential Revision: https://reviews.freebsd.org/D17166

3 years agoAlso mention PORTS_MODULES
Warner Losh [Sun, 8 Nov 2020 02:46:04 +0000 (02:46 +0000)]
Also mention PORTS_MODULES

PORTS_MODULES is also an effective way to update the tree. Also
a minor rejustify on this an an adjacent paragraph.

Suggested by: David Wolfskill

3 years agoBe explicit about recompiling all the modules...
Warner Losh [Sun, 8 Nov 2020 02:20:21 +0000 (02:20 +0000)]
Be explicit about recompiling all the modules...

Add a note about always recompiling all modules on every new kernel
change / update. In addition, suggest using /usr/local/sys/modules
so this happens automatically.

3 years agoUpdate to bmake-20201101
Simon J. Gerraty [Sat, 7 Nov 2020 21:46:27 +0000 (21:46 +0000)]
Update to bmake-20201101

Lots of new unit-tests increase code coverage.

Lots of refactoring, cleanup and simlpification to reduce
code size.

Fixes for Bug 223564 and 245807

Updates to dirdeps.mk and meta2deps.py

3 years agoThe ioctl() calls using FIONREAD, FIONWRITE, FIONSPACE, and SIOCATMARK
Michael Tuexen [Sat, 7 Nov 2020 21:17:49 +0000 (21:17 +0000)]
The ioctl() calls using FIONREAD, FIONWRITE, FIONSPACE, and SIOCATMARK
access the socket send or receive buffer. This is not possible for
listening sockets since r319722.
Because send()/recv() calls fail on listening sockets, fail also ioctl()
indicating EINVAL.

PR: 250366
Reported by: Yong-Hao Zou
Reviewed by: glebius, rscheff
MFC after: 1 week
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D26897

3 years agoImport bmake-20201101
Simon J. Gerraty [Sat, 7 Nov 2020 19:39:21 +0000 (19:39 +0000)]
Import bmake-20201101

Lots of new unit-tests increase code coverage.

Lots of refactoring, cleanup and simlpification to reduce
code size.

Fixes for Bug 223564 and 245807

Updates to dirdeps.mk and meta2deps.py

3 years agoFix build post-r367455.
Cy Schubert [Sat, 7 Nov 2020 19:17:37 +0000 (19:17 +0000)]
Fix build post-r367455.

MFC after: 2 weeks
X-MFC with: r367455

3 years agoimgact_binmisc: move some calculations out of the exec path
Kyle Evans [Sat, 7 Nov 2020 18:07:55 +0000 (18:07 +0000)]
imgact_binmisc: move some calculations out of the exec path

The offset we need to account for in the interpreter string comes in two
variants:

1. Fixed - macros other than #a that will not vary from invocation to
   invocation
2. Variable - #a, which is substitued with the argv0 that we're replacing

Note that we don't have a mechanism to modify an existing entry.  By
recording both of these offset requirements when the interpreter is added,
we can avoid some unnecessary calculations in the exec path.

Most importantly, we can know up-front whether we need to grab
calculate/grab the the filename for this interpreter. We also get to avoid
walking the string a first time looking for macros. For most invocations,
it's a swift exit as they won't have any, but there's no point entering a
loop and searching for the macro indicator if we already know there will not
be one.

While we're here, go ahead and only calculate the argv0 name length once per
invocation. While it's unlikely that we'll have more than one #a, there's no
reason to recalculate it every time we encounter an #a when it will not
change.

I have not bothered trying to benchmark this at all, because it's arguably a
minor and straightforward/obvious improvement.

MFC after: 1 week

3 years agosyslogd: Stop trying to send remote messages through special sockets
Bryan Drewery [Sat, 7 Nov 2020 17:18:44 +0000 (17:18 +0000)]
syslogd: Stop trying to send remote messages through special sockets

Specifically this was causing the /dev/klog fd and the signal pipe
handling fd to get a sendmsg(2) called on them and always returned
[ENOTSOCK].

r310350 combined these sockets into the main socket list and properly
skipped AF_UNSPEC at the sendmsg(2) call but later in r344739 it was
broken such that these special sockets were no longer excluded since
the AF_UNSPEC check specifically excluded these special sockets. Only
these special sockets have sl_sa = NULL. The sl_family checks should
be redundant now but are left in case of future changes so the intent
is clearer.

MFC after: 2 weeks

3 years agozfs: remove 2 assertions that teardown lock is not held
Mateusz Guzik [Sat, 7 Nov 2020 16:58:38 +0000 (16:58 +0000)]
zfs: remove 2 assertions that teardown lock is not held

They are not very useful and hard to implement with rms.

This has a side effect of simplying the code.

3 years agorms: several cleanups + debug read lockers handling
Mateusz Guzik [Sat, 7 Nov 2020 16:57:53 +0000 (16:57 +0000)]
rms: several cleanups + debug read lockers handling

This adds a dedicated counter updated with atomics when INVARIANTS
is used. As a side effect one can reliably determine the lock is held
for reading by at least one thread, but it's still not possible to
find out whether curthread has the lock in said mode.

This should be good enough in practice.

Problem spotted by avg.

3 years agoimgact_binmisc: reorder members of struct imgact_binmisc_entry (NFC)
Kyle Evans [Sat, 7 Nov 2020 16:41:59 +0000 (16:41 +0000)]
imgact_binmisc: reorder members of struct imgact_binmisc_entry (NFC)

This doesn't change anything at the moment since the out-of-order elements
were a pair of uint32_t, but future additions may have caused unnecessary
padding by following the existing precedent.

MFC after: 1 week

3 years agovt: resolve conflict between VT_ALT_TO_ESC_HACK and DBG
Kyle Evans [Sat, 7 Nov 2020 15:38:01 +0000 (15:38 +0000)]
vt: resolve conflict between VT_ALT_TO_ESC_HACK and DBG

When using the ALT+CTRL+ESC sequence to break into kdb, the keyboard is
completely borked when you return. watch(8) shows that it's working, but
it's inserting escape sequences.

Further investigation revealed that VT_ALT_TO_ESC_HACK is the default and
directly conflicts with this sequence, so upon return from the debugger
ALKED is set.

If they triggered the break to debugger, it's safe to assume they didn't
mean to use VT_ALT_TO_ESC_HACK, so just unset it to reduce the surprise when
the keyboard seems non-functional upon return.

Reviewed by: tsoome
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D27109

3 years agoAdd a method to determine whether given interrupt is per CPU or not.
Michal Meloun [Sat, 7 Nov 2020 14:58:01 +0000 (14:58 +0000)]
Add a method to determine whether given interrupt is per CPU or not.

MFC after: 2 weeks

3 years agoMove TDB_USERWR check under 'if (traced)'.
Edward Tomasz Napierala [Sat, 7 Nov 2020 13:09:51 +0000 (13:09 +0000)]
Move TDB_USERWR check under 'if (traced)'.

If we hadn't been traced in the first place when syscallenter()
started executing, we can ignore TDB_USERWR.  TDB_USERWR can get set,
sure, but if it does, it's because the debugger raced with the syscall,
and it cannot depend on winning that race.

Reviewed by: kib
MFC after: 2 weeks
Sponsored by: EPSRC
Differential Revision: https://reviews.freebsd.org/D26585

3 years agoimgact_binmisc: abstract away the list lock (NFC)
Kyle Evans [Sat, 7 Nov 2020 05:10:46 +0000 (05:10 +0000)]
imgact_binmisc: abstract away the list lock (NFC)

This module handles relatively few execs (initial qemu-user-static, then
qemu-user-static handles exec'ing itself for binaries it's already running),
but all execs pay the price of at least taking the relatively expensive
sx/slock to check for a match when this module is loaded. Future work will
almost certainly swap this out for another lock, perhaps an rmslock.

The RLOCK/WLOCK phrasing was chosen based on what the callers are really
wanting, rather than using the verbiage typically appropriate for an sx.

MFC after: 1 week

3 years agoAdd a periodic script to backup output generated from `gmirror list`.
Robert Wing [Sat, 7 Nov 2020 04:15:24 +0000 (04:15 +0000)]
Add a periodic script to backup output generated from `gmirror list`.

Disabled by default.

PR:             86388
Submitted by:   Miroslav Lachman <000.fbsd@quip.cz>
Reviewed by:    allanjude, gbe
Approved by:    allanjude (mentor)
MFC after:      4 weeks
Event:          July 2020 Bugathon
Differential Revision:  https://reviews.freebsd.org/D25631

3 years agoimgact_binmisc: validate flags coming from userland
Kyle Evans [Sat, 7 Nov 2020 04:10:23 +0000 (04:10 +0000)]
imgact_binmisc: validate flags coming from userland

We may want to reserve bits in the future for kernel-only use, so start
rejecting any that aren't the two that we're currently expecting from
userland.

MFC after: 1 week

3 years agobinmiscctl(8): miscellaneous cleanup
Kyle Evans [Sat, 7 Nov 2020 03:43:45 +0000 (03:43 +0000)]
binmiscctl(8): miscellaneous cleanup

- Bad whitespace in Makefile.
- Reordered headers, sys/ first.
- Annotated fatal/usage __dead2 to help `make analyze` out a little bit.
- Spell a couple of sizeof constructs as "nitems" and "howmany" instead.

MFC after: 1 week

3 years agoepoch: support non-preemptible epochs checking in_epoch()
Kyle Evans [Sat, 7 Nov 2020 03:29:04 +0000 (03:29 +0000)]
epoch: support non-preemptible epochs checking in_epoch()

Previously, non-preemptible epochs could not check; in_epoch() would always
fail, usually because non-preemptible epochs don't imply THREAD_NO_SLEEPING.

For default epochs, it's easy enough to verify that we're in the given
epoch: if we're in a critical section and our record for the given epoch
is active, then we're in it.

This patch also adds some additional INVARIANTS bookkeeping. Notably, we set
and check the recorded thread in epoch_enter/epoch_exit to try and catch
some edge-cases for the caller. It also checks upon freeing that none of the
records had a thread in the epoch, which may make it a little easier to
diagnose some improper use if epoch_free() took place while some other
thread was inside.

This version differs slightly from what was just previously reviewed by the
below-listed, in that in_epoch() will assert that no CPU has this thread
recorded even if it *is* currently in a critical section. This is intended
to catch cases where the caller might have somehow messed up critical
section nesting, we can catch both if they exited the critical section or if
they exited, migrated, then re-entered (on the wrong CPU).

Reviewed by: kib, markj (both previous version)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D27098

3 years agoimgact_binmisc: minor re-organization of imgact_binmisc_exec exits
Kyle Evans [Sat, 7 Nov 2020 03:28:32 +0000 (03:28 +0000)]
imgact_binmisc: minor re-organization of imgact_binmisc_exec exits

Notably, streamline error paths through the existing 'done' label, making it
easier to quickly verify correct cleanup.

Future work might add a kernel-only flag to indicate that a interpreter uses
#a. Currently, all executions via imgact_binmisc pay the penalty of
constructing sname/fname, even if they will not use it. qemu-user-static
doesn't need it, the stock rc script for qemu-user-static certainly doesn't
use it, and I suspect these are the vast majority of (if not the only)
current users.

MFC after: 1 week

3 years agomalloc: tweak the version check in r367432 to include type name
Mateusz Guzik [Sat, 7 Nov 2020 01:32:16 +0000 (01:32 +0000)]
malloc: tweak the version check in r367432 to include type name

While here fix a whitespace problem.

3 years agoUpdate copies of ioctl structures to match recent changes in head.
John Baldwin [Fri, 6 Nov 2020 23:37:59 +0000 (23:37 +0000)]
Update copies of ioctl structures to match recent changes in head.

- Update for C99 types and void pointers.
- Update example algorithms to not use removed algorithms.

3 years agoAdd a periodic script to backup output generated from `zfs list`, `zfs get`,
Robert Wing [Fri, 6 Nov 2020 22:58:31 +0000 (22:58 +0000)]
Add a periodic script to backup output generated from `zfs list`, `zfs get`,
`zpool list`, and `zpool get` commands.

Disabled by default.

PR:             86388
Submitted by:   Miroslav Lachman <000.fbsd@quip.cz>
Reviewed by:    allanjude, 0mp
Approved by:    allanjude (mentor)
MFC after:      4 weeks
Event:          July 2020 Bugathon
Differential Revision:  https://reviews.freebsd.org/D25638

3 years agousb_hub: giving up port reset - device vanished
Bjoern A. Zeeb [Fri, 6 Nov 2020 22:40:00 +0000 (22:40 +0000)]
usb_hub: giving up port reset - device vanished

Improve the output of the recently often experienced debug message in order
to gather further data.

PR: 237666
Reviewed by: hselasky
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D27108

3 years agofix up docs, if signature checking is enabled, the file MUST exist...
John-Mark Gurney [Fri, 6 Nov 2020 22:11:05 +0000 (22:11 +0000)]
fix up docs, if signature checking is enabled, the file MUST exist...

3 years agolinux(4): Fix loadable modules after r367395
Conrad Meyer [Fri, 6 Nov 2020 22:04:57 +0000 (22:04 +0000)]
linux(4): Fix loadable modules after r367395

Move dtrace SDT definitions into linux_common module code.  Also, build
linux_dummy.c into the linux_common kld -- we don't need separate
versions of these stubs for 32- and 64-bit emulation.

Reported by: several
PR: 250897
Discussed with: emaste, trasz
Tested by: John Kennedy, Yasuhiro KIMURA, Oleg Sidorkin
X-MFC-With: r367395
Differential Revision: https://reviews.freebsd.org/D27124

3 years agomalloc: move malloc_type_internal into malloc_type
Mateusz Guzik [Fri, 6 Nov 2020 21:33:59 +0000 (21:33 +0000)]
malloc: move malloc_type_internal into malloc_type

According to code comments the original motivation was to allow for
malloc_type_internal changes without ABI breakage. This can be trivially
accomplished by providing spare fields and versioning the struct, as
implemented in the patch below.

The upshots are one less memory indirection on each alloc and disappearance
of mt_zone.

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D27104

3 years agoefifb: vt_generate_cons_palette() takes max color, not mask
Toomas Soome [Fri, 6 Nov 2020 21:27:54 +0000 (21:27 +0000)]
efifb: vt_generate_cons_palette() takes max color, not mask

vt_generate_cons_palette() does take max values of RGB component colours, not
mask. Also we need to set info->fb_cmsize, or vt_fb_init() will re-initialize
the info->fb_cmap.

3 years agoMake powerpc use MAXARGS (defined as 8) instead of hardcoding '10'.
Edward Tomasz Napierala [Fri, 6 Nov 2020 19:27:27 +0000 (19:27 +0000)]
Make powerpc use MAXARGS (defined as 8) instead of hardcoding '10'.
This brings its 'struct syscall_args' in sync with other architectures.

Reviewed by: bdragon, jhibbits
MFC after: 2 weeks
Sponsored by: EPSRC
Differential Revision: https://reviews.freebsd.org/D26605

3 years agoRemove 'struct trapframe' pointer from mips64's 'struct syscall_args'.
Edward Tomasz Napierala [Fri, 6 Nov 2020 19:19:51 +0000 (19:19 +0000)]
Remove 'struct trapframe' pointer from mips64's 'struct syscall_args'.
While here, use MAXARGS.  This brings its 'struct syscall_args' in sync
with most other architectures.

Reviewed by: arichardson, brooks
MFC after: 2 weeks
Sponsored by: EPSRC
Differential Revision: https://reviews.freebsd.org/D26619

3 years agocxgbe(4): Update firmwares to 1.25.0.40.
Navdeep Parhar [Fri, 6 Nov 2020 19:04:20 +0000 (19:04 +0000)]
cxgbe(4):  Update firmwares to 1.25.0.40.

This fixes a potential crash in firmware 1.25.0.0 on the passive open
side during TOE operation.

Obtained from: Chelsio Communications
MFC after: 1 week
Sponsored by: Chelsio Communications

3 years agoFix powerpc and LINT builds
Leandro Lupori [Fri, 6 Nov 2020 18:50:00 +0000 (18:50 +0000)]
Fix powerpc and LINT builds

Fix build errors introduced by r367417 and r367390:

- Guard label reached only by powerpc64
- Guard vm_reserv_level_iffullpop call, that is not defined on powerpc
  variants that don't support superpages
- Add missing hwpmc file, for when hwpmc is built into kernel

3 years agoUse void * in place of caddr_t.
John Baldwin [Fri, 6 Nov 2020 18:09:52 +0000 (18:09 +0000)]
Use void * in place of caddr_t.

Reviewed by: markj
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D27065

3 years agoGroup session management routines together before first use.
John Baldwin [Fri, 6 Nov 2020 18:05:29 +0000 (18:05 +0000)]
Group session management routines together before first use.

- Rename cse*() to cse_*() to more closely match other local APIs in
  this file.

- Merge the old csecreate() into cryptodev_create_session() and rename
  the new function to cse_create().

Reviewed by: markj
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D27070

3 years agoAdd support for the new mountd -R option.
Rick Macklem [Fri, 6 Nov 2020 16:33:42 +0000 (16:33 +0000)]
Add support for the new mountd -R option.

r376026 added a new "-R" option to mountd, which tells it to
not support the Mount protocol (not used by NFSv4) and not
register with rpcbind.
Rpcbind is considered a security issue by some sites now.

This patch adds a new yes/no variable called nfsv4_server_only.
When that is set, make vfs.nfsd.server_min_vers=4 and set "=R"
for mountd.
Setting vfs.nfsd.server_min_vers=4 tells nfsd to not register with rpcbind.
While here, add a check for "load_kld nfsd" failing to nfsd.

Reviewed by: 0mp
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D26938

3 years agoAdd firmware modules for qat(4), take two
Mark Johnston [Fri, 6 Nov 2020 16:12:06 +0000 (16:12 +0000)]
Add firmware modules for qat(4), take two

My script to convert git commits to svn patch does not handle binary
files correctly, and r367387 committed a set of empty files as a result.

MFC with: r367387
Sponsored by: Rubicon Communications, LLC (Netgate)

3 years agoUse Cm macros instead of Ar when referring to a specific memory disk type
Mateusz Piotrowski [Fri, 6 Nov 2020 15:55:13 +0000 (15:55 +0000)]
Use Cm macros instead of Ar when referring to a specific memory disk type

MFC after: 3 days

3 years agoFix a typo and remove Xr's to vn(4) and vnconfig(4)
Mateusz Piotrowski [Fri, 6 Nov 2020 15:38:51 +0000 (15:38 +0000)]
Fix a typo and remove Xr's to vn(4) and vnconfig(4)

"mandoc -Tlint" complained about the Xr to vnconfig, which was removed in
r238202.  I am not sure but maybe it's time to do the same to vn(4).

MFC after: 2 weeks

3 years agopkgbase: Remove %VCS_REVISION% from utilities comments
Emmanuel Vadot [Fri, 6 Nov 2020 15:21:53 +0000 (15:21 +0000)]
pkgbase: Remove %VCS_REVISION% from utilities comments

We don't do that on other packages so be consistent.
It also don't work when building from git.

3 years agoImplement superpages for PowerPC64 (HPT)
Leandro Lupori [Fri, 6 Nov 2020 14:12:45 +0000 (14:12 +0000)]
Implement superpages for PowerPC64 (HPT)

This change adds support for transparent superpages for PowerPC64
systems using Hashed Page Tables (HPT). All pmap operations are
supported.

The changes were inspired by RISC-V implementation of superpages,
by @markj (r344106), but heavily adapted to fit PPC64 HPT architecture
and existing MMU OEA64 code.

While these changes are not better tested, superpages support is disabled by
default. To enable it, use vm.pmap.superpages_enabled=1.

In this initial implementation, when superpages are disabled, system
performance stays at the same level as without these changes. When
superpages are enabled, buildworld time increases a bit (~2%). However,
for workloads that put a heavy pressure on the TLB the performance boost
is much bigger (see HPC Challenge and pgbench on D25237).

Reviewed by: jhibbits
Sponsored by: Eldorado Research Institute (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D25237

3 years ago[POWERPC] Floating-Point Exception trap support
Alfredo Dal'Ava Junior [Fri, 6 Nov 2020 13:34:30 +0000 (13:34 +0000)]
[POWERPC] Floating-Point Exception trap support

Add support for Floating-Point Exception traps on 32 and 64 bit platforms.
Also make sure to clean FPSCR on EXEC and thread exit

Author of initial version: Renato Riolino <renato.riolino@eldorad.org.br>

Reviewed by: jhibbits
Sponsored by: Eldorado Research Institute (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D23623

3 years agoMove cryptof_ioctl() below the routines it calls.
John Baldwin [Fri, 6 Nov 2020 00:15:52 +0000 (00:15 +0000)]
Move cryptof_ioctl() below the routines it calls.

Reviewed by: markj
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D27069

3 years agoSplit logic to create new sessions into a separate function.
John Baldwin [Fri, 6 Nov 2020 00:10:58 +0000 (00:10 +0000)]
Split logic to create new sessions into a separate function.

This simplifies cryptof_ioctl as it now a wrapper around functions that
contain the bulk of the per-ioctl logic.

Reviewed by: markj
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D27068

3 years agoMove cryptodev_cb earlier before it is used.
John Baldwin [Thu, 5 Nov 2020 23:42:36 +0000 (23:42 +0000)]
Move cryptodev_cb earlier before it is used.

This is consistent with cryptodevkey_cb being defined before it is used
and removes a prototype in the middle of the file.

Reviewed by: markj
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D27067

3 years agoCheck cipher key lengths during probesession.
John Baldwin [Thu, 5 Nov 2020 23:31:58 +0000 (23:31 +0000)]
Check cipher key lengths during probesession.

OCF drivers in general should perform as many session parameter checks
as possible during probesession rather than when creating a new
session.  I got this wrong for aesni(4) in r359374.  In addition,
aesni(4) was performing the check for digest-only requests and failing
to create digest-only sessions as a result.

Reported by: jkim
Tested by: jkim
Sponsored by: Chelsio Communications

3 years agoStyle fixes for function prototypes and definitions.
John Baldwin [Thu, 5 Nov 2020 23:28:05 +0000 (23:28 +0000)]
Style fixes for function prototypes and definitions.

Reviewed by: markj
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D27066

3 years agoDon't modify the destination pointer in ioctl requests.
John Baldwin [Thu, 5 Nov 2020 23:26:02 +0000 (23:26 +0000)]
Don't modify the destination pointer in ioctl requests.

This breaks the case where the original pointer was NULL but an
in-line IV was used.

Reviewed by: markj
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D27064

3 years agonvme: change namei_request_zone into a malloc type
Mateusz Guzik [Thu, 5 Nov 2020 21:44:58 +0000 (21:44 +0000)]
nvme: change namei_request_zone into a malloc type

Both the size (128 bytes) and ephemeral nature of allocations make it a great
fit for malloc.

A dedicated zone unnecessarily avoids sharing buckets with 128-byte objects.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D27103

3 years agosnmpmod(3): fix typo under the COMMUNITIES section
Enji Cooper [Thu, 5 Nov 2020 21:37:24 +0000 (21:37 +0000)]
snmpmod(3): fix typo under the COMMUNITIES section

"recipte" should be spelled like "receipt".

.Dd is intentionally not being bumped for the change.

MFC after: 1 week
Sponsored by: DellEMC

3 years agoSuspend all writeable local filesystems on power suspend.
Konstantin Belousov [Thu, 5 Nov 2020 20:52:49 +0000 (20:52 +0000)]
Suspend all writeable local filesystems on power suspend.

This ensures that no writes are pending in memory, either metadata or
user data, but not including dirty pages not yet converted to fs writes.

Only filesystems declared local are suspended.

Note that this does not guarantee absence of the metadata errors or
leaks if resume is not done: for instance, on UFS unlinked but opened
inodes are leaked and require fsck to gc.

Reviewed by: markj
Discussed with: imp
Tested by: imp (previous version), pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D27054

3 years agoFix powerpc and powerpcspe builds
Leandro Lupori [Thu, 5 Nov 2020 20:18:00 +0000 (20:18 +0000)]
Fix powerpc and powerpcspe builds

This change fixes 32-bit PowerPC builds, that r367390 broke
(shift count >= width of type).

3 years agolinux(4): Deduplicate unimpl/dummy syscall handlers
Conrad Meyer [Thu, 5 Nov 2020 19:30:31 +0000 (19:30 +0000)]
linux(4): Deduplicate unimpl/dummy syscall handlers

No functional change.

Reviewed by: emaste, trasz
Differential Revision: https://reviews.freebsd.org/D27099

3 years agoRemove the 'nap' field from ARM's 'struct syscall_args', to bring it
Edward Tomasz Napierala [Thu, 5 Nov 2020 18:10:03 +0000 (18:10 +0000)]
Remove the 'nap' field from ARM's 'struct syscall_args', to bring it
in sync with (most) other architectures.  No functional changes.

Reviewed by: manu
Tested by: mmel
MFC after: 2 weeks
Sponsored by: EPSRC
Differential Revision: https://reviews.freebsd.org/D26604

3 years agoVirtIO: Make sure the guest knows the TRIM alignment requirements
Allan Jude [Thu, 5 Nov 2020 17:10:14 +0000 (17:10 +0000)]
VirtIO: Make sure the guest knows the TRIM alignment requirements

If bhyve is used to emulate 512e access in guest OS, then discard addresses should be properly aligned.
Otherwise ioctl DIOCGDELETE fails for 512b requires on devices with 4K sector size.
see g_dev_ioctl() in sys/geom/geom_dev.c

Submitted by: Vitaliy Gusev <gusev.vitaliy@gmail.com>
MFC after: 1 week
Sponsored by: vStack.com
Differential Revision: https://reviews.freebsd.org/D27075

3 years agopmcstat: fix PPC kernel symbol resolution
Leandro Lupori [Thu, 5 Nov 2020 16:47:23 +0000 (16:47 +0000)]
pmcstat: fix PPC kernel symbol resolution

PowerPC kernel is of DYN type and it has a base address where it is
initially loaded, before being relocated. As the start address passed to
pmcstat_image_link() is where the kernel was relocated to, but the symbols
always use the original base address, we need to subtract it to get the
correct offset.

Reviewed by: jhibbits
Sponsored by: Eldorado Research Institute (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D26114