]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agoFix a problem with r367686 related to the use of ssize_t. Not sure how this
scottl [Sat, 14 Nov 2020 19:04:36 +0000 (19:04 +0000)]
Fix a problem with r367686 related to the use of ssize_t.  Not sure how this
escaped prior testing, but it should be better now.

Reported by: lots

3 years agoMakefile: re-wordsmith the blurb about xtoolchain ports
kevans [Sat, 14 Nov 2020 18:06:35 +0000 (18:06 +0000)]
Makefile: re-wordsmith the blurb about xtoolchain ports

The new version only includes a specific version once, and uses the one
that's currently advised by tinderbox: -gcc6.

It also advises just installing the pkg, but mentions in a side-note at the
end where to find the source in the ports tree.

Reviewed by: jrtc27
Suggested by: jhb (use default from tinderbox)
Differential Revision: https://reviews.freebsd.org/D26820

3 years agoReplace hardcoded references to _PATH_LOCALBASE with calls to getlocalbase.3
scottl [Sat, 14 Nov 2020 18:01:14 +0000 (18:01 +0000)]
Replace hardcoded references to _PATH_LOCALBASE with calls to getlocalbase.3

Reviewed by: imp, se

3 years agoAdd the library function getlocalbase and its manual page. This helps to
scottl [Sat, 14 Nov 2020 17:57:50 +0000 (17:57 +0000)]
Add the library function getlocalbase and its manual page.  This helps to
unify the retrieval of the various ways that the local software base directory,
typically "/usr/local", is expressed in the system.

Reviewed by: se
Differential Revision: https://reviews.freebsd.org/D27022

3 years agoAdd a regression test for the port-selection behavior fixed in r367680.
jtl [Sat, 14 Nov 2020 15:44:28 +0000 (15:44 +0000)]
Add a regression test for the port-selection behavior fixed in r367680.

Reviewed by: markj, olivier, tuexen
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D27173

3 years agoFix implicit automatic local port selection for IPv6 during connect calls.
jtl [Sat, 14 Nov 2020 14:50:34 +0000 (14:50 +0000)]
Fix implicit automatic local port selection for IPv6 during connect calls.

When a user creates a TCP socket and tries to connect to the socket without
explicitly binding the socket to a local address, the connect call
implicitly chooses an appropriate local port. When evaluating candidate
local ports, the algorithm checks for conflicts with existing ports by
doing a lookup in the connection hash table.

In this circumstance, both the IPv4 and IPv6 code look for exact matches
in the hash table. However, the IPv4 code goes a step further and checks
whether the proposed 4-tuple will match wildcard (e.g. TCP "listen")
entries. The IPv6 code has no such check.

The missing wildcard check can cause problems when connecting to a local
server. It is possible that the algorithm will choose the same value for
the local port as the foreign port uses. This results in a connection with
identical source and destination addresses and ports. Changing the IPv6
code to align with the IPv4 code's behavior fixes this problem.

Reviewed by: tuexen
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D27164

3 years agoDocument the PAGER environment variable
0mp [Sat, 14 Nov 2020 13:07:41 +0000 (13:07 +0000)]
Document the PAGER environment variable

Sometimes users want to use freebsd-update(8) in a non-interactive way and
what they often miss is that they have to set PAGER to cat(1) in order to
avoid interactive prompts from less(1).

MFC after: 4 weeks

3 years agoloader: cstyle cleanup of console.c
tsoome [Sat, 14 Nov 2020 10:56:40 +0000 (10:56 +0000)]
loader: cstyle cleanup of console.c

cstyle cleanup only, no functional changes intended.

3 years agoLinuxKPI: Exclude linux/acpi.h content on non-ACPI archs.
wulf [Sat, 14 Nov 2020 10:34:18 +0000 (10:34 +0000)]
LinuxKPI: Exclude linux/acpi.h content on non-ACPI archs.

LinuxKPI ACPI support is based on FreeBSD import of ACPICA which can be
compiled only on aarch64, amd64 and i386. Ifdef-out broken parts on our
side to avoid patching of vendor code.

This fixes drm-devel-kmod build on powerpc64(le).

Reported by: pkubaj

3 years agoHandle LoR in flush_pagedep_deps().
kib [Sat, 14 Nov 2020 05:30:10 +0000 (05:30 +0000)]
Handle LoR in flush_pagedep_deps().

When operating in SU or SU+J mode, ffs_syncvnode() might need to
instantiate other vnode by inode number while owning syncing vnode
lock.  Typically this other vnode is the parent of our vnode, but due
to renames occuring right before fsync (or during fsync when we drop
the syncing vnode lock, see below) it might be no longer parent.

More, the called function flush_pagedep_deps() needs to lock other
vnode while owning the lock for vnode which owns the buffer, for which
the dependencies are flushed.  This creates another instance of the
same LoR as was fixed in softdep_sync().

Put the generic code for safe relocking into new SU helper
get_parent_vp() and use it in flush_pagedep_deps().  The case for safe
relocking of two vnodes with undefined lock order was extracted into
vn helper vn_lock_pair().

Due to call sequence
     ffs_syncvnode()->softdep_sync_buf()->flush_pagedep_deps(),
ffs_syncvnode() indicates with ERELOOKUP that passed vnode was
unlocked in process, and can return ENOENT if the passed vnode
reclaimed.  All callers of the function were inspected.

Because UFS namei lookups store auxiliary information about directory
entry in in-memory directory inode, and this information is then used
by UFS code that creates/removed directory entry in the actual
mutating VOPs, it is critical that directory vnode lock is not dropped
between lookup and VOP.  For softdep_prelink(), which ensures that
later link/unlink operation can proceed without overflowing the
journal, calls were moved to the place where it is safe to drop
processing VOP because mutations are not yet applied.  Then, ERELOOKUP
causes restart of the whole VFS operation (typically VFS syscall) at
top level, including the re-lookup of the involved pathes.  [Note that
we already do the same restart for failing calls to vn_start_write(),
so formally this patch does not introduce new behavior.]

Similarly, unsafe calls to fsync in snapshot creation code were
plugged.  A possible view on these failures is that it does not make
sense to continue creating snapshot if the snapshot vnode was
reclaimed due to forced unmount.

It is possible that relock/ERELOOKUP situation occurs in
ffs_truncate() called from ufs_inactive().  In this case, dropping the
vnode lock is not safe.  Detect the situation with VI_DOINGINACT and
reschedule inactivation by setting VI_OWEINACT.  ufs_inactive()
rechecks VI_OWEINACT and avoids reclaiming vnode is truncation failed
this way.

In ffs_truncate(), allocation of the EOF block for partial truncation
is re-done after vnode is synced, since we cannot leave the buffer
locked through ffs_syncvnode().

In collaboration with: pho
Reviewed by: mckusick (previous version), markj
Tested by: markj (syzkaller), pho
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D26136

3 years agoAdd ffs_inode_bwrite() helper.
kib [Sat, 14 Nov 2020 05:19:59 +0000 (05:19 +0000)]
Add ffs_inode_bwrite() helper.

In collaboration with: pho
Reviewed by: mckusick (previous version), markj
Tested by: markj (syzkaller), pho
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D26136

3 years agoRevert r367669 to re-commit with proper message
kib [Sat, 14 Nov 2020 05:19:44 +0000 (05:19 +0000)]
Revert r367669 to re-commit with proper message

3 years agoAdd a framework that tracks exclusive vnode lock generation count for UFS.
kib [Sat, 14 Nov 2020 05:17:04 +0000 (05:17 +0000)]
Add a framework that tracks exclusive vnode lock generation count for UFS.

This count is memoized together with the lookup metadata in directory
inode, and we assert that accesses to lookup metadata are done under
the same lock generation as they were stored.  Enabled under DIAGNOSTICS.

UFS saves additional data for parent dirent when doing lookup
(i_offset, i_count, i_endoff), and this data is used later by VOPs
operating on dirents.  If parent vnode exclusive lock is dropped and
re-acquired between lookup and the VOP call, we corrupt directories.

Framework asserts that corruption cannot occur that way, by tracking
vnode lock generation counter.  Updates to inode dirent members also
save the counter, while users compare current and saved counters
values.

Also, fix a case in ufs_lookup_ino() where i_offset and i_count could
be updated under shared lock.  It is not a bug on its own since dvp
i_offset results from such lookup cannot be used, but it causes false
positive in the checker.

In collaboration with: pho
Reviewed by: mckusick (previous version), markj
Tested by: markj (syzkaller), pho
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D26136

3 years agoAdd a framework that tracks exclusive vnode lock generation count for UFS.
kib [Sat, 14 Nov 2020 05:10:39 +0000 (05:10 +0000)]
Add a framework that tracks exclusive vnode lock generation count for UFS.

This count is memoized together with the lookup metadata in directory
inode, and we assert that accesses to lookup metadata are done under
the same lock generation as they were stored.  Enabled under DIAGNOSTICS.

UFS saves additional data for parent dirent when doing lookup
(i_offset, i_count, i_endoff), and this data is used later by VOPs
operating on dirents.  If parent vnode exclusive lock is dropped and
re-acquired between lookup and the VOP call, we corrupt directories.

Framework asserts that corruption cannot occur that way, by tracking
vnode lock generation counter.  Updates to inode dirent members also
save the counter, while users compare current and saved counters
values.

Also, fix a case in ufs_lookup_ino() where i_offset and i_count could
be updated under shared lock.  It is not a bug on its own since dvp
i_offset results from such lookup cannot be used, but it causes false
positive in the checker.

In collaboration with: pho
Reviewed by: mckusick (previous version), markj
Tested by: markj (syzkaller), pho
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D26136

3 years agoAdd a entry for r367660.
rmacklem [Sat, 14 Nov 2020 01:55:02 +0000 (01:55 +0000)]
Add a entry for r367660.

3 years agoFix startup of gssd when /usr is a separately mounted local file system.
rmacklem [Sat, 14 Nov 2020 01:49:49 +0000 (01:49 +0000)]
Fix startup of gssd when /usr is a separately mounted local file system.

meowthink@gmail.com reported that the gssd daemon was not
starting, because /etc/rc.d/gssd was executed before his local
/usr file system was mounted.
He fixed the problem by adding mountcritlocal to the REQUIRED
line.

This fix seems safe and works for a separately mounted /usr file
system on a local disk.
The case of a separately mounted remote /usr file system (such as
NFS) is still broken, but there is no obvious solution for that.
Adding mountcritremote would fix the problem, but it would
cause a POLA violation, because all kerberized NFS mounts
in /etc/fstab would need the "late" option specified to work.

Submitted by: meowthink@gmail.com
Reported by: meowthink@gmail.com
Reviewed by: 0mp
MFC after: 2 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D27203

3 years agoAdd PMRCAP printing and fix earlier CAP_HI.
mav [Sat, 14 Nov 2020 01:45:34 +0000 (01:45 +0000)]
Add PMRCAP printing and fix earlier CAP_HI.

MFC after: 3 days

3 years agoAdd an entry for r367026, r367423.
rmacklem [Sat, 14 Nov 2020 01:39:27 +0000 (01:39 +0000)]
Add an entry for r367026, r367423.

3 years agoAdd missing src.opts.mk include
brooks [Fri, 13 Nov 2020 23:18:04 +0000 (23:18 +0000)]
Add missing src.opts.mk include

This was missed in r364221 so tests were not built.

Reviewed by: bdrewery
Obtained from: CheriBSD
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D27210

3 years agoMFV: r367652
jkim [Fri, 13 Nov 2020 22:45:26 +0000 (22:45 +0000)]
MFV: r367652

Merge ACPICA 20201113.

3 years agobhyve: update smbiostbl.c to bump the version and release date
bcran [Fri, 13 Nov 2020 19:47:16 +0000 (19:47 +0000)]
bhyve: update smbiostbl.c to bump the version and release date

Since lots of work has been done on bhyve since 2014, increase the version
to 13.0 to match 13-CURRENT, and update the release date.

Reviewed by: grehan
Differential Revision: https://reviews.freebsd.org/D27147

3 years agomalloc: retire MALLOC_PROFILE
mjg [Fri, 13 Nov 2020 19:22:53 +0000 (19:22 +0000)]
malloc: retire MALLOC_PROFILE

The global array has prohibitive performance impact on multicore systems.

The same data (and more) can be obtained with dtrace.

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

3 years agosrc.conf.5: regenerate after r367577
emaste [Fri, 13 Nov 2020 19:09:21 +0000 (19:09 +0000)]
src.conf.5: regenerate after r367577

INIT_ALL_ZERO / INIT_ALL_PATTERN

3 years agoFix `make makeman` after r367577
emaste [Fri, 13 Nov 2020 19:08:42 +0000 (19:08 +0000)]
Fix `make makeman` after r367577

WITH_INIT_ALL_ZERO and WITH_INIT_ALL_PATTERN are mutually exclusive.
The .error when they were both set broke makeman so demote it to a
warning (and presumably the compiler will fail on an error later on).

We could improve this to make one take precedence but this is sufficient
for now.

MFC with: r367577
Sponsored by: The FreeBSD Foundation

3 years ago[tests] Fix unused variable warning in gcc
adrian [Fri, 13 Nov 2020 18:50:24 +0000 (18:50 +0000)]
[tests] Fix unused variable warning in gcc

Reviewed by: markj, imp, cem,
Approved by: markj
Differential Revision: https://reviews.freebsd.org/D26792

3 years agoDisable kernel INIT_ALL_ZERO on amd64
emaste [Fri, 13 Nov 2020 18:34:13 +0000 (18:34 +0000)]
Disable kernel INIT_ALL_ZERO on amd64

It is currently incompatible with kernel ifunc memset.

PR: 251083
MFC with: r367577
Sponsored by: The FreeBSD Foundation

3 years agoip_fastfwd: style(9) tidy for r367628
emaste [Fri, 13 Nov 2020 18:25:07 +0000 (18:25 +0000)]
ip_fastfwd: style(9) tidy for r367628

Discussed with: gnn
MFC with: r367628

3 years ago[PowerPC64LE] Radix MMU fixes for LE.
bdragon [Fri, 13 Nov 2020 16:56:03 +0000 (16:56 +0000)]
[PowerPC64LE] Radix MMU fixes for LE.

There were many, many endianness fixes needed for Radix MMU. The Radix
pagetable is stored in BE (as it is read and written to by the MMU hw),
so we need to convert back and forth every time we interact with it when
running in LE.

With these changes, I can successfully boot with radix enabled on POWER9 hw.

Reviewed by: luporl, jhibbits
Sponsored by: Tag1 Consulting, Inc.
Differential Revision: https://reviews.freebsd.org/D27181

3 years ago[PowerPC] Allow traversal of oversize OF properties.
bdragon [Fri, 13 Nov 2020 16:49:41 +0000 (16:49 +0000)]
[PowerPC] Allow traversal of oversize OF properties.

In standards such as LoPAPR, property names in excess of the usual 31
characters exist.

This breaks property traversal.

While in IEEE 1275-1994, nextprop is defined explicitly to work with a
32-byte region of memory, using a larger buffer should be fine. There is
actually no way to pass a buffer length to the nextprop call in the OF
client interface, so SLOF actually just blindly overflows the buffer.

So we have to defensively make the buffer larger, to avoid memory
corruption when reading out long properties on live OF systems.

Note also that on real-mode OF, things are pretty tight because we are
allocating against a static bounce buffer in low memory, so we can't just
use a huge buffer to work around this without it being wasteful of our
limited amount of 32-bit physical memory.

This allows a patched ofwdump to operate properly on SLOF (i.e. pseries)
systems, as well as any other PowerPC systems with overlength properties.

Reviewed by: jhibbits
MFC after: 2 weeks
Sponsored by: Tag1 Consulting, Inc.
Differential Revision: https://reviews.freebsd.org/D26669

3 years agodf: Remove support for mounting devices
markj [Fri, 13 Nov 2020 16:47:42 +0000 (16:47 +0000)]
df: Remove support for mounting devices

This was marked deprecated in r329092, over two and a half years ago.
This functionality is also buggy per PR 237368.

PR: 237368
Reviewed by: brooks, cem, emaste, imp
Differential Revision: https://reviews.freebsd.org/D27197

3 years agoAdd a missing Nm macro
0mp [Fri, 13 Nov 2020 14:56:34 +0000 (14:56 +0000)]
Add a missing Nm macro

All functions documented in a manual page should be enumerated
with the Nm macros.

3 years agoExplicitly note in the EXAMPLES section that uname(3) contains more details
0mp [Fri, 13 Nov 2020 14:48:37 +0000 (14:48 +0000)]
Explicitly note in the EXAMPLES section that uname(3) contains more details

MFC after: 1 week

3 years agoReference setprogname(3) in setproctitle(3)
0mp [Fri, 13 Nov 2020 13:47:18 +0000 (13:47 +0000)]
Reference setprogname(3) in setproctitle(3)

The reference to setproctitle(3) in the setprogname(3) manual is already
in place.

MFC after: 3 days

3 years agoMakefile.inc1: remove no-longer required variable
arichardson [Fri, 13 Nov 2020 13:18:48 +0000 (13:18 +0000)]
Makefile.inc1: remove no-longer required variable

This variable is unsed since r364760 but I forgot to delete it in that commit.

Reported By: bdrewery

3 years agoFollowup pointed out by ae@
gnn [Fri, 13 Nov 2020 13:07:44 +0000 (13:07 +0000)]
Followup pointed out by ae@

3 years agoAllow some VOPs to return ERELOOKUP to indicate VFS operation restart at top level.
kib [Fri, 13 Nov 2020 09:42:32 +0000 (09:42 +0000)]
Allow some VOPs to return ERELOOKUP to indicate VFS operation restart at top level.

Restart syscalls and some sync operations when filesystem indicated
ERELOOKUP condition, mostly for VOPs operating on metdata.  In
particular, lookup results cached in the inode/v_data is no longer
valid and needs recalculating.  Right now this should be nop.

Assert that ERELOOKUP is catched everywhere and not returned to
userspace, by asserting that td_errno != ERELOOKUP on syscall return
path.

In collaboration with: pho
Reviewed by: mckusick (previous version), markj
Tested by: markj (syzkaller), pho
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D26136

3 years agoImplement vn_lock_pair().
kib [Fri, 13 Nov 2020 09:31:57 +0000 (09:31 +0000)]
Implement vn_lock_pair().

In collaboration with: pho
Reviewed by: mckusick (previous version), markj (previous version)
Tested by: markj (syzkaller), pho
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D26136

3 years agoImprove nvmecontrol error reporting.
mav [Fri, 13 Nov 2020 02:05:45 +0000 (02:05 +0000)]
Improve nvmecontrol error reporting.

MFC after: 1 week
Sponsored by: iXsystems, Inc.

3 years ago[malloc] quieten -Werror=missing-braces with malloc.h wth gcc-6.4
adrian [Fri, 13 Nov 2020 01:53:59 +0000 (01:53 +0000)]
[malloc] quieten -Werror=missing-braces with malloc.h wth gcc-6.4

This sets off gcc-6.4 to spit out a 'error: missing braces around initializer'
error when compiling this.

Remove it as it isn't needed.

Reviewed by: brooks
Differential Revision:  https://reviews.freebsd.org/D27183

3 years agoAn earlier commit effectively turned out the fast forwading path
gnn [Thu, 12 Nov 2020 21:58:47 +0000 (21:58 +0000)]
An earlier commit effectively turned out the fast forwading path
due to its lack of support for ICMP redirects. The following commit
adds redirects to the fastforward path, again allowing for decent
forwarding performance in the kernel.

Reviewed by: ae, melifaro
Sponsored by: Rubicon Communications, LLC (d/b/a "Netgate")

3 years agomalloc: retire malloc_last_fail
mjg [Thu, 12 Nov 2020 20:22:58 +0000 (20:22 +0000)]
malloc: retire malloc_last_fail

The routine does not serve any practical purpose.

Memory can be allocated in many other ways and most consumers pass the
M_WAITOK flag, making malloc not fail in the first place.

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

3 years agogbde: replace malloc_last_fail with a kludge
mjg [Thu, 12 Nov 2020 20:20:57 +0000 (20:20 +0000)]
gbde: replace malloc_last_fail with a kludge

This facilitates removal of malloc_last_fail without really impacting
anything.

3 years agoFix panic if NVMe is detached before the intrhook call.
mav [Thu, 12 Nov 2020 20:20:43 +0000 (20:20 +0000)]
Fix panic if NVMe is detached before the intrhook call.

MFC after: 1 week
Sponsored by: iXsystems, Inc.

3 years agocxgbe/t4_tom: Handle VXLAN-encapsulated SYNs correctly.
np [Thu, 12 Nov 2020 20:02:48 +0000 (20:02 +0000)]
cxgbe/t4_tom: Handle VXLAN-encapsulated SYNs correctly.

TCP SYNs in inner traffic will hit hardware listeners when VXLAN/NVGRE
rx parsing is enabled in the chip.  t4_tom should pass on these SYNs to
the kernel and let it deal with them as if they arrived on the non-TOE
path.

Reported by: Sony at Chelsio
MFC after: 1 week
Sponsored by: Chelsio Communications

3 years agoMerge commit 8df4e6094 from llvm git (by Fangrui Song):
dim [Thu, 12 Nov 2020 19:25:31 +0000 (19:25 +0000)]
Merge commit 8df4e6094 from llvm git (by Fangrui Song):

  [ELF] Don't consider SHF_ALLOC ".debug*" sections debug sections

  Fixes PR48071

  * The Rust compiler produces SHF_ALLOC `.debug_gdb_scripts` (which
    normally does not have the flag)
  * `.debug_gdb_scripts` sections are removed from `inputSections` due
    to --strip-debug/--strip-all
  * When processing --gc-sections, pieces of a SHF_MERGE section can be
    marked live separately

  `=>` segfault when marking liveness of a `.debug_gdb_scripts` which
  is not split into pieces (because it is not in `inputSections`)

  This patch circumvents the problem by not treating SHF_ALLOC
  ".debug*" as debug sections (to prevent --strip-debug's stripping)
  (which is still useful on its own).

  Reviewed By: grimar

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

This should fix lld segfaulting when linking the rust-based parts of the
devel/py-maturin port.

Reported by: Nick Venenga <nijave@gmail.com>
PR: 250783
MFC after: 3 days

3 years agoAdd more USB quirks.
hselasky [Thu, 12 Nov 2020 18:24:37 +0000 (18:24 +0000)]
Add more USB quirks.

PR: 230038
MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoRemove macros from the width arguments passed to Bl macros
0mp [Thu, 12 Nov 2020 17:28:29 +0000 (17:28 +0000)]
Remove macros from the width arguments passed to Bl macros

I've not removed the Er macro from one of the lists in example.9, however,
because it seems to be doing some special kind of magic. Let's leave it
there for now.

3 years agoAdd a missing period and remove a macro from Bl's width argument
0mp [Thu, 12 Nov 2020 16:44:56 +0000 (16:44 +0000)]
Add a missing period and remove a macro from Bl's width argument

MFC after: 3 days

3 years agoFix a typo in a license comment
0mp [Thu, 12 Nov 2020 15:50:18 +0000 (15:50 +0000)]
Fix a typo in a license comment

Approved by: kaktus (src)

3 years agoqat: Fix nits reported by Coverity
markj [Thu, 12 Nov 2020 15:00:48 +0000 (15:00 +0000)]
qat: Fix nits reported by Coverity

MFC after: 3 days
Sponsored by: Rubicon Communications, LLC (Netgate)

3 years agopkgbase: Move libprivatezstd from utilities to runtime
manu [Thu, 12 Nov 2020 14:04:08 +0000 (14:04 +0000)]
pkgbase: Move libprivatezstd from utilities to runtime

libarchive depends on it by default and tar uses libarchive.
So on a update :
1/ runtime contain tar
2/ runtime have libarchive in shlibs_required
3/ libarchive packages depends on utilities
4/ utilities depends on runtime
5/ kaboom

All users of libprivatezstd (libarchive related stuff and objcopy/ar)
are already in utilities.

Discussed with: bapt

3 years agoAdd a tunable sysctl, hw.usb.uaudio.handle_hid, to allow disabling the
hselasky [Thu, 12 Nov 2020 09:26:01 +0000 (09:26 +0000)]
Add a tunable sysctl, hw.usb.uaudio.handle_hid, to allow disabling the
the HID volume keys support in the USB audio driver.

While at it re-organize the USB audio sysctls a bit.

Differential Revision: https://reviews.freebsd.org/D27180
MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoWhen doing a USB alternate setting on an USB interface we need to
hselasky [Thu, 12 Nov 2020 09:15:07 +0000 (09:15 +0000)]
When doing a USB alternate setting on an USB interface we need to
re-configure the XHCI endpoint context.

Differential Revision: https://reviews.freebsd.org/D27174
MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agobhyve: remove a hack to map all 8G BARs 1:1
kib [Thu, 12 Nov 2020 02:52:01 +0000 (02:52 +0000)]
bhyve: remove a hack to map all 8G BARs 1:1

Suggested and reviewed by: grehan
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D27186

3 years agomlx5en: Set ifmr_current same as ifmr_active.
kib [Thu, 12 Nov 2020 02:25:10 +0000 (02:25 +0000)]
mlx5en: Set ifmr_current same as ifmr_active.

This both:
- makes ifconfig media line similar to that of other drivers.
- fixes ENXIO in case when paradoxical current media word is not registered.

Now e.g.
      ifconfig mce0 -mediaopt txpause,rxpause
works by disabling pauses if enabled.

Sponsored by: Mellanox Technologies/NVidia Networking
MFC after: 1 week

3 years agomlx5en: stop ignoring pauses and flow in the media reqs.
kib [Thu, 12 Nov 2020 02:23:27 +0000 (02:23 +0000)]
mlx5en: stop ignoring pauses and flow in the media reqs.

Sponsored by: Mellanox Technologies/NVidia Networking
MFC after: 1 week

3 years agomlx5en: Register all combinations of FDX/RXPAUSE/TXPAUSE as valid media types.
kib [Thu, 12 Nov 2020 02:22:16 +0000 (02:22 +0000)]
mlx5en: Register all combinations of FDX/RXPAUSE/TXPAUSE as valid media types.

Sponsored by: Mellanox Technologies/NVidia Networking
MFC after: 1 week

3 years agomlx5en: Refactor repeated code to register media type to mlx5e_ifm_add().
kib [Thu, 12 Nov 2020 02:21:14 +0000 (02:21 +0000)]
mlx5en: Refactor repeated code to register media type to mlx5e_ifm_add().

Sponsored by: Mellanox Technologies/NVidia Networking
MFC after: 1 week

3 years agocxgbev(4): Make sure that the iq/eq map sizes are correct for VFs.
np [Thu, 12 Nov 2020 01:18:05 +0000 (01:18 +0000)]
cxgbev(4): Make sure that the iq/eq map sizes are correct for VFs.

This should have been part of r366929.

MFC after: 3 days
Sponsored by: Chelsio Communications

3 years agobhyve: increase allowed size for 64bit BAR allocation below 4G from 32 to 128 MB.
kib [Thu, 12 Nov 2020 00:51:53 +0000 (00:51 +0000)]
bhyve: increase allowed size for 64bit BAR allocation below 4G from 32 to 128 MB.

Reviewed by: grehan
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D27095

3 years agobhyve: avoid allocating BARs above the end of supported physical addresses.
kib [Thu, 12 Nov 2020 00:46:53 +0000 (00:46 +0000)]
bhyve: avoid allocating BARs above the end of supported physical addresses.

Read CPUID leaf 0x8000008 to determine max supported phys address and
create BAR region right below it, reserving 1/4 of the supported guest
physical address space to the 64bit BARs mappings.

PR:    250802 (although the issue from PR is not fixed by the change)
Noted and reviewed by: grehan
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D27095

3 years agothread: move nthread management out of tid_alloc
mjg [Thu, 12 Nov 2020 00:29:23 +0000 (00:29 +0000)]
thread: move nthread management out of tid_alloc

While this adds more work single-threaded, it also enables SMP-related
speed ups.

3 years agoumtx: drop incorrect timespec32 definition
kevans [Wed, 11 Nov 2020 22:35:23 +0000 (22:35 +0000)]
umtx: drop incorrect timespec32 definition

This works for amd64, but none others -- drop it, because we already have a
proper definition in sys/compat/freebsd32/freebsd32.h that correctly uses
time32_t.

MFC after: 1 week

3 years agoMake CTL nicer to increased MAXPHYS.
mav [Wed, 11 Nov 2020 21:59:39 +0000 (21:59 +0000)]
Make CTL nicer to increased MAXPHYS.

Before this CTL always allocated MAXPHYS-sized buffers, even for 4KB I/O,
that is even more overkill for MAXPHYS of 1MB.  This change limits maximum
allocation to 512KB if MAXPHYS is bigger, plus if one is above 128KB, adds
new 128KB UMA zone for smaller I/Os.  The patch factors out alloc/free,
so later we could make it use more zones or malloc() if we'd like.

MFC after: 1 week
Sponsored by: iXsystems, Inc.

3 years agothread: batch tid_free calls in thread_reap
mjg [Wed, 11 Nov 2020 18:45:06 +0000 (18:45 +0000)]
thread: batch tid_free calls in thread_reap

This eliminates the highly pessimal pattern of relocking from multiple
CPUs in quick succession. Note this is still globally serialized.

3 years agothread: lockless zombie list manipulation
mjg [Wed, 11 Nov 2020 18:43:51 +0000 (18:43 +0000)]
thread: lockless zombie list manipulation

This gets rid of the most contended spinlock seen when creating/destroying
threads in a loop. (modulo kstack)

Tested by: alfredo (ppc64), bdragon (ppc64)

3 years agoiflib: Free full mbuf chains when draining transmit queues
markj [Wed, 11 Nov 2020 18:00:06 +0000 (18:00 +0000)]
iflib: Free full mbuf chains when draining transmit queues

Submitted by: Sai Rajesh Tallamraju <stallamr@netapp.com>
Reviewed by: gallatin, hselasky
MFC after: 1 week
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D27179

3 years agovm_map: Handle kernel map entry allocator recursion
markj [Wed, 11 Nov 2020 17:16:39 +0000 (17:16 +0000)]
vm_map: Handle kernel map entry allocator recursion

On platforms without a direct map[*], vm_map_insert() may in rare
situations need to allocate a kernel map entry in order to allocate
kernel map entries.  This poses a problem similar to the one solved for
vmem boundary tags by vmem_bt_alloc().  In fact the kernel map case is a
bit more complicated since we must allocate entries with the kernel map
locked, whereas vmem can recurse into itself because boundary tags are
allocated up-front.

The solution is to add a custom slab allocator for kmapentzone which
allocates KVA directly from kernel_map, bypassing the kmem_* layer.
This avoids mutual recursion with the vmem btag allocator.  Then, when
vm_map_insert() allocates a new kernel map entry, it avoids triggering
allocation of a new slab with M_NOVM until after the insertion is
complete.  Instead, vm_map_insert() allocates from the reserve and sets
a flag in kernel_map to trigger re-population of the reserve just before
the map is unlocked.  This places an implicit upper bound on the number
of kernel map entries that may be allocated before the kernel map lock
is released, but in general a bound of 1 suffices.

[*] This also comes up on amd64 with UMA_MD_SMALL_ALLOC undefined, a
configuration required by some kernel sanitizers.

Discussed with: kib, rlibby
Reported by: andrew
Tested by: pho (i386 and amd64 with !UMA_MD_SMALL_ALLOC)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D26851

3 years agoFix possible NULL pointer dereference.
ae [Wed, 11 Nov 2020 15:53:36 +0000 (15:53 +0000)]
Fix possible NULL pointer dereference.

lagg(4) replaces if_output method of its child interfaces and expects
that this method can be called only by child interfaces. But it is
possible that lagg_port_output() could be called by children of child
interfaces. In this case ifnet's if_lagg field is NULL. Add check that
lp is not NULL.

Obtained from: Yandex LLC
MFC after: 1 week
Sponsored by: Yandex LLC

3 years agovmm: Make pmap_invalidate_ept() wait synchronously for guest exits
markj [Wed, 11 Nov 2020 15:01:17 +0000 (15:01 +0000)]
vmm: Make pmap_invalidate_ept() wait synchronously for guest exits

Currently EPT TLB invalidation is done by incrementing a generation
counter and issuing an IPI to all CPUs currently running vCPU threads.
The VMM inner loop caches the most recently observed generation on each
host CPU and invalidates TLB entries before executing the VM if the
cached generation number is not the most recent value.
pmap_invalidate_ept() issues IPIs to force each vCPU to stop executing
guest instructions and reload the generation number.  However, it does
not actually wait for vCPUs to exit, potentially creating a window where
guests may continue to reference stale TLB entries.

Fix the problem by bracketing guest execution with an SMR read section
which is entered before loading the invalidation generation.  Then,
pmap_invalidate_ept() increments the current write sequence before
loading pm_active and sending IPIs, and polls readers to ensure that all
vCPUs potentially operating with stale TLB entries have exited before
pmap_invalidate_ept() returns.

Also ensure that unsynchronized loads of the generation counter are
wrapped with atomic(9), and stop (inconsistently) updating the
invalidation counter and pm_active bitmask with acquire semantics.

Reviewed by: grehan, kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D26910

3 years agoDocument in the synopsis that -0 cannot be used with the utility argument
0mp [Wed, 11 Nov 2020 14:53:03 +0000 (14:53 +0000)]
Document in the synopsis that -0 cannot be used with the utility argument

3 years agoRemove an extraneous parameter from SIGIO_ASSERT_LOCKED()
markj [Wed, 11 Nov 2020 14:03:49 +0000 (14:03 +0000)]
Remove an extraneous parameter from SIGIO_ASSERT_LOCKED()

Reported by: hselasky
MFC with: r367588

3 years agoffs: Clamp BIO_SPEEDUP length
markj [Wed, 11 Nov 2020 13:48:07 +0000 (13:48 +0000)]
ffs: Clamp BIO_SPEEDUP length

On 32-bit platforms, the computed size of the BIO_SPEEDUP requested by
softdep_request_cleanup() may be negative when assigned to bp->b_bcount,
which has type "long".

Clamp the size to LONG_MAX.  Also convert the unused g_io_speedup() to
use an off_t for the magnitude of the shortage for consistency with
softdep_send_speedup().

Reviewed by: chs, kib
Reported by: pho
Tested by: pho
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27081

3 years agoFix a pair of races in SIGIO registration
markj [Wed, 11 Nov 2020 13:44:27 +0000 (13:44 +0000)]
Fix a pair of races in SIGIO registration

First, funsetownlst() list looks at the first element of the list to see
whether it's processing a process or a process group list.  Then it
acquires the global sigio lock and processes the list.  However, nothing
prevents the first sigio tracker from being freed by a concurrent
funsetown() before the sigio lock is acquired.

Fix this by acquiring the global sigio lock immediately after checking
whether the list is empty.  Callers of funsetownlst() ensure that new
sigio trackers cannot be added concurrently.

Second, fsetown() uses funsetown() to remove an existing sigio structure
from a file object.  However, funsetown() uses a racy check to avoid the
sigio lock, so two threads may call fsetown() on the same file object,
both observe that no sigio tracker is present, and enqueue two sigio
trackers for the same file object.  However, if the file object is
destroyed, funsetown() will only remove one sigio tracker, and
funsetownlst() may later trigger a use-after-free when it clears the
file object reference for each entry in the list.

Fix this by introducing funsetown_locked(), which avoids the racy check.

Reviewed by: kib
Reported by: pho
Tested by: pho
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27157

3 years agothread: add more fine-grained tidhash locking
mjg [Wed, 11 Nov 2020 08:51:04 +0000 (08:51 +0000)]
thread: add more fine-grained tidhash locking

Note this still does not scale but is enough to move it out of the way
for the foreseable future.

In particular a trivial benchmark spawning/killing threads stops contesting
on tidhash.

3 years agothread: rework tidhash vs proc lock interaction
mjg [Wed, 11 Nov 2020 08:50:04 +0000 (08:50 +0000)]
thread: rework tidhash vs proc lock interaction

Apart from minor clean up this gets rid of proc unlock/lock cycle on thread
exit to work around LOR against tidhash lock.

3 years agothread: fix thread0 tid allocation
mjg [Wed, 11 Nov 2020 08:48:43 +0000 (08:48 +0000)]
thread: fix thread0 tid allocation

Startup code hardcodes the value instead of allocating it.
The first spawned thread would then be a duplicate.

Pointy hat: mjg

3 years agoAdd INIT_ALL_ZERO and INIT_ALL_PATTERN to kern.opts.mk
imp [Tue, 10 Nov 2020 23:25:16 +0000 (23:25 +0000)]
Add INIT_ALL_ZERO and INIT_ALL_PATTERN to kern.opts.mk

These options need to be in the kern.opts.mk file to be alive for kernel
and module builds. This also reverts r367579 since that's not needed with
this fix: the host's bsd.opts.mk is irrelevant.

Reviewed by: brooks@
Differential Revision:  https://reviews.freebsd.org/D27170

3 years agothread: tidy up r367543
mjg [Tue, 10 Nov 2020 21:29:10 +0000 (21:29 +0000)]
thread: tidy up r367543

"locked" variable is spurious in the committed version.

3 years agoBe more tolerant of share/mk and kern.mk mismatch
brooks [Tue, 10 Nov 2020 21:12:32 +0000 (21:12 +0000)]
Be more tolerant of share/mk and kern.mk mismatch

When building out-of-tree modules, it appears that the system share/mk
is used, but sys/conf/kern.mk is used.  That results in MK_INIT_ALL_ZERO
being undefined.  In the interest of maximum compatability, check
that MK_INIT_ALL_* and COMPILER_FEATURES are defined before comparing
their values.

Reported by: mmacy
Sponsored by: DARPA

3 years agoClear tp->tod in t4_pcb_detach().
jhb [Tue, 10 Nov 2020 19:54:39 +0000 (19:54 +0000)]
Clear tp->tod in t4_pcb_detach().

Otherwise, a socket can have a non-NULL tp->tod while TF_TOE is clear.
In particular, if a newly accepted socket falls back to non-TOE due to
an active open failure, the non-TOE socket will still have tp->tod set
even though TF_TOE is clear.

Reviewed by: np
MFC after: 2 weeks
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D27028

3 years agoSupport initializing stack variables on function entry
brooks [Tue, 10 Nov 2020 19:15:13 +0000 (19:15 +0000)]
Support initializing stack variables on function entry

There are two options:
 - WITH_INIT_ALL_ZERO: Zero all variables on the stack.
 - WITH_INIT_ALL_PATTERN: Initialize variables with well-defined patterns.

The exact pattern are a compiler implementation detail and vary by type.
They are somewhat documented in the LLVM commit message:
https://reviews.llvm.org/rL349442
I've used WITH_INIT_ALL_* to match Microsoft's InitAll feature rather
than naming them after the LLVM specific compiler flags.

In a range of consumer products, options like these are used in
both debug and production builds with debugs builds using patterns
(intended to provoke crashes on use of uninitialized values) and
production using zeros (deemed more likely to lead to harmless
misbehavior or NULL-pointer dereferences).

Reviewed by: emaste
Obtained from: CheriBSD
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D27131

3 years agoAdd C startup code tests for PIE binaries.
jhb [Tue, 10 Nov 2020 19:09:35 +0000 (19:09 +0000)]
Add C startup code tests for PIE binaries.

- Force dynamic to be a non-PIE binary.

- Add a dynamicpie test which uses a PIE binary.

Reviewed by: andrew
Obtained from: CheriBSD
MFC after: 2 weeks
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D27127

3 years agoFix dso_handle_check for PIE executables.
jhb [Tue, 10 Nov 2020 19:07:30 +0000 (19:07 +0000)]
Fix dso_handle_check for PIE executables.

PIE executables use crtbeginS.o and have a non-NULL dso_handle as a
result.

Reviewed by: andrew, emaste
MFC after: 2 weeks
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D27126

3 years agoRename __JCR_LIST__ to __JCR_END__ in crtend.c.
jhb [Tue, 10 Nov 2020 19:04:54 +0000 (19:04 +0000)]
Rename __JCR_LIST__ to __JCR_END__ in crtend.c.

This is more consistent with the names used for .ctor and .dtor
symbols and better reflects __JCR_END__'s role.

Reviewed by: andrew
Obtained from: CheriBSD
MFC after: 2 weeks
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D27125

3 years agoWhen destroying a UMA zone which has a reserve (set with
jtl [Tue, 10 Nov 2020 18:12:09 +0000 (18:12 +0000)]
When destroying a UMA zone which has a reserve (set with
uma_zone_reserve()), messages like the following appear on the console:
"Freed UMA keg (Test zone) was not empty (0 items). Lost 528 pages of
memory."

When keg_drain_domain() is draining the zone, it tries to keep the number
of items specified in the reservation. However, when we are destroying the
UMA zone, we do not need to keep those items. Therefore, when destroying a
non-secondary and non-cache zone, we should reset the keg reservation to 0
prior to draining the zone.

Reviewed by: markj
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D27129

3 years agoAllow rtprio_thread to operate on threads of any process
mjg [Tue, 10 Nov 2020 18:10:50 +0000 (18:10 +0000)]
Allow rtprio_thread to operate on threads of any process

This in particular unbreaks rtkit.

The limitation was a leftover of previous state, to quote a
comment:

/*
 * Though lwpid is unique, only current process is supported
 * since there is no efficient way to look up a LWP yet.
 */

Long since then a global tid hash was introduced to remedy
the problem.

Permission checks still apply.

Submitted by: greg_unrelenting.technology (Greg V)
Differential Revision: https://reviews.freebsd.org/D27158

3 years agomakeman: Don't require filemon with MK_DIRDEPS_BUILD.
bdrewery [Tue, 10 Nov 2020 18:05:17 +0000 (18:05 +0000)]
makeman: Don't require filemon with MK_DIRDEPS_BUILD.

MFC after: 2 weeks
Reviewed by: sjg, dim (tested earlier version)
Sponsored by: Dell EMC
Differential Revision: https://reviews.freebsd.org/D27134

3 years agozfs: combine zio caches if possible
mjg [Tue, 10 Nov 2020 14:23:46 +0000 (14:23 +0000)]
zfs: combine zio caches if possible

This deduplicates 2 sets of caches using the same sizes.

Memory savings fluctuate a lot, one sample result is buildworld on zfs
saving ~180MB RAM in reduced page count associated with zio caches.

3 years agozfs: g/c unused data_alloc_arena
mjg [Tue, 10 Nov 2020 14:21:23 +0000 (14:21 +0000)]
zfs: g/c unused data_alloc_arena

3 years agoAddress a mandoc warning
0mp [Tue, 10 Nov 2020 14:17:05 +0000 (14:17 +0000)]
Address a mandoc warning

MFC after: 3 days

3 years agoInclude GID type when deleting GIDs from HW table under RoCE in mlx4ib.
hselasky [Tue, 10 Nov 2020 12:58:25 +0000 (12:58 +0000)]
Include GID type when deleting GIDs from HW table under RoCE in mlx4ib.
Refer to the Linux commit mentioned below for a more detailed description.

Linux commit:
a18177925c252da7801149abe217c05b80884798

Requested by: Isilon
MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoDo not document MOTIFLIB in ports(7)
0mp [Tue, 10 Nov 2020 11:32:01 +0000 (11:32 +0000)]
Do not document MOTIFLIB in ports(7)

Perhaps it made sense in 1998 (r32836), but now it feels a bit out of
place.  We tend to avoid documenting non-essential ports variables in
the manual page (we try to document them in the Porter's Handbook instead).

MFC after: 1 week

3 years agoAdd an entry for r351863 (honoring ${name}_env in rc(8) scripts)
0mp [Tue, 10 Nov 2020 10:40:44 +0000 (10:40 +0000)]
Add an entry for r351863 (honoring ${name}_env in rc(8) scripts)

PR: 239692
Requested by: koobs

3 years agoAdd an entry to RELNOTES about renaming ACPI_DMAR to IOMMU
0mp [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
eugen [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
mjg [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
mjg [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
mjg [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
mjg [Tue, 10 Nov 2020 01:13:58 +0000 (01:13 +0000)]
thread: adds newer bits for r367537

The committed patch was an older version.