]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agobsdiff: fix off-by-one error
Mitchell Horne [Mon, 16 Nov 2020 18:41:49 +0000 (18:41 +0000)]
bsdiff: fix off-by-one error

The program reads oldsize bytes from oldfile, and proceeds to initialize
a suffix array of oldsize elements using divsufsort(). As per the
function's API [1], array indices 0 through n-1 are initialized.

Later, search() is called, but with index bounds [0, n]. Depending on
the contents of the malloc'd buffer, accessing this uninitialized index
at the end of can result in a segmentation fault. Fix this by passing
oldsize-1 to search(), limiting the search bounds to [0, n-1].

This bug is a result of r303285, which introduced divsufsort() as an
alternate suffix sorting function to the existing qsufsort(). It seems
that qsufsort() did initialize the final empty element, meaning it could
be safely accessed. This difference in the implementations was missed at
the time.

[1] https://github.com/y-256/libdivsufsort

Discussed with: cperciva
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D26911

3 years agomalloc: make malloc_large closer to standalone
Mateusz Guzik [Mon, 16 Nov 2020 17:56:58 +0000 (17:56 +0000)]
malloc: make malloc_large closer to standalone

This moves entire large alloc handling out of all consumers, apart from
deciding to go there.

This is a step towards creating a fast path.

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

3 years agoAdd missing includes of src.opts.mk
Brooks Davis [Mon, 16 Nov 2020 17:20:35 +0000 (17:20 +0000)]
Add missing includes of src.opts.mk

Without this "SUBDIR.${MK_TESTS}=tests" would always expand to
"SUBDIR.=tests" resulting in the tests not being built.

Sponsored by: DARPA

3 years agoFix a bug in assertion: entry flags also includes IOMMU_MAP_ENTRY_UNMAPPED.
Ruslan Bukin [Mon, 16 Nov 2020 15:37:09 +0000 (15:37 +0000)]
Fix a bug in assertion: entry flags also includes IOMMU_MAP_ENTRY_UNMAPPED.
The entry->flags field is initialized in iommu_gas_init_domain().

Reviewed by: kib
Sponsored by: Innovate DSbD
Differential Revision: https://reviews.freebsd.org/D27235

3 years agoAdd device_t member to struct iommu.
Ruslan Bukin [Mon, 16 Nov 2020 15:29:52 +0000 (15:29 +0000)]
Add device_t member to struct iommu.

This is needed on arm64 for the interface between iommu framework
and iommu controller drivers.

Reviewed by: kib
Sponsored by: Innovate DSbD
Differential Revision: https://reviews.freebsd.org/D27229

3 years agoimx7gpc: Remove unused functions
Emmanuel Vadot [Mon, 16 Nov 2020 11:54:38 +0000 (11:54 +0000)]
imx7gpc: Remove unused functions

3 years agodwmmc: dwmmc_switch_vccq is only used in MMCCAM kernel
Emmanuel Vadot [Mon, 16 Nov 2020 11:53:36 +0000 (11:53 +0000)]
dwmmc: dwmmc_switch_vccq is only used in MMCCAM kernel

Silence the build for non MMCCAM kernel

3 years agoRevert "When building on Ubuntu bootstrap bmake with bash as the default shell"
Alex Richardson [Mon, 16 Nov 2020 11:38:51 +0000 (11:38 +0000)]
Revert "When building on Ubuntu bootstrap bmake with bash as the default shell"

This reverts r365950 since the latest bmake update includes fixes for the test
failures that prompted the change.

3 years agoMake mlx5_cmd_exec_cb() a safe API in mlx5core.
Hans Petter Selasky [Mon, 16 Nov 2020 10:15:03 +0000 (10:15 +0000)]
Make mlx5_cmd_exec_cb() a safe API in mlx5core.

APIs that have deferred callbacks should have some kind of cleanup
function that callers can use to fence the callbacks. Otherwise things
like module unloading can lead to dangling function pointers, or worse.

The IB MR code is the only place that calls this function and had a
really poor attempt at creating this fence. Provide a good version in
the core code as future patches will add more places that need this
fence.

Linux commit:
e355477ed9e4f401e3931043df97325d38552d54

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

3 years agoReport EQE data upon CQ completion in mlx5core.
Hans Petter Selasky [Mon, 16 Nov 2020 10:10:53 +0000 (10:10 +0000)]
Report EQE data upon CQ completion in mlx5core.

Report EQE data upon CQ completion to let upper layers use this data.

Linux commit:
4e0e2ea1886afe8c001971ff767f6670312a9b04

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

3 years agoEnhance the mlx5_core_create_cq() function in mlx5core.
Hans Petter Selasky [Mon, 16 Nov 2020 10:06:10 +0000 (10:06 +0000)]
Enhance the mlx5_core_create_cq() function in mlx5core.

Enhance mlx5_core_create_cq() to get the command out buffer from the
callers to let them use the output.

Linux commit:
38164b771947be9baf06e78ffdfb650f8f3e908e

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

3 years agoUse mlx5core to create/destroy all Dynamically Connected Targets, DCTs.
Hans Petter Selasky [Mon, 16 Nov 2020 10:03:18 +0000 (10:03 +0000)]
Use mlx5core to create/destroy all Dynamically Connected Targets, DCTs.

To prevent a hardware memory leak when a DEVX DCT object is destroyed
without calling drain DCT before, (e.g. under cleanup flow), need to
manage its creation and destruction via mlx5 core.

Linux commit:
c5ae1954c47d3fd8815bd5a592aba18702c93f33

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

3 years agoFix error handling order in create_kernel_qp in mlx5ib.
Hans Petter Selasky [Mon, 16 Nov 2020 10:00:21 +0000 (10:00 +0000)]
Fix error handling order in create_kernel_qp in mlx5ib.

Make sure order of cleanup is exactly the opposite of initialization.

Linux commit:
f4044dac63e952ac1137b6df02b233d37696e2f5

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

3 years agoselect: call seltdfini on process and thread exit
Mateusz Guzik [Mon, 16 Nov 2020 03:12:21 +0000 (03:12 +0000)]
select: call seltdfini on process and thread exit

Since thread_zone is marked NOFREE the thread_fini callback is never
executed, meaning memory allocated by seltdinit is never released.

Adding the call to thread_dtor is not sufficient as exiting processes
cache the main thread.

3 years agoselect: replace reference counting with memory barriers in selfd
Mateusz Guzik [Mon, 16 Nov 2020 03:09:18 +0000 (03:09 +0000)]
select: replace reference counting with memory barriers in selfd

Refcounting was added to combat a race between selfdfree and doselwakup,
but it adds avoidable overhead.

selfdfree detects it can free the object by ->sf_si == NULL, thus we can
ensure that the condition only holds after all accesses are completed.

3 years agoEnsure make delete-old does not unlink the llvm-cxxfilt and its manpage,
Dimitry Andric [Sun, 15 Nov 2020 22:49:28 +0000 (22:49 +0000)]
Ensure make delete-old does not unlink the llvm-cxxfilt and its manpage,
after r367304 and r367324, when WITH_LLVM_CXXFILT is enabled.

Noticed by: "Herbert J. Skuhra" <herbert@gojira.at>
MFC after: 3 days
X-MFC-With: r367304

3 years agoRevert the whole getlocalbase() set of changes while a different design is
Scott Long [Sun, 15 Nov 2020 20:24:59 +0000 (20:24 +0000)]
Revert the whole getlocalbase() set of changes while a different design is
hashed out.

3 years agozfsboot: add prototype for main()
Toomas Soome [Sun, 15 Nov 2020 14:04:27 +0000 (14:04 +0000)]
zfsboot: add prototype for main()

Some compilers are complaining about missing prototype.

PR: 251150
Reported by: markiyan.kushnir@gmail.com

3 years agoFix regression in AHCI controller settings.
Peter Grehan [Sun, 15 Nov 2020 12:59:24 +0000 (12:59 +0000)]
Fix regression in AHCI controller settings.

When the AHCI code was reworked to use FreeBSD struct
definitions, the valid element was mis-transcribed resulting
in the UMDA capability being hidden. This prevented Illumos
from using AHCI disk/cdrom drives.

Fix by using definitions that match the code pre-rework.

PR: 250924
Submitted by: Rolf Stalder
Reported by: Rolf Stalder
MFC after: 3 days

3 years agoFix the previous revision, it suffered from an incomplete change to the
Scott Long [Sun, 15 Nov 2020 07:50:29 +0000 (07:50 +0000)]
Fix the previous revision, it suffered from an incomplete change to the
getlocalbase API.  Also don't erroneously subtract the lenth from the
buffer a second time.

3 years agoBecause getlocalbase() returns -1 on error, it needs to use a signed type
Scott Long [Sun, 15 Nov 2020 07:48:52 +0000 (07:48 +0000)]
Because getlocalbase() returns -1 on error, it needs to use a signed type
internally.  Do that, and make sure that conversations between signed and
unsigned don't overflow

3 years agosched: fix an incorrect comparison in sched_lend_user_prio_cond
Mateusz Guzik [Sun, 15 Nov 2020 01:54:44 +0000 (01:54 +0000)]
sched: fix an incorrect comparison in sched_lend_user_prio_cond

Compare with sched_lend_user_prio.

3 years agocred: annotate credbatch_process argument as unused
Mateusz Guzik [Sat, 14 Nov 2020 19:56:11 +0000 (19:56 +0000)]
cred: annotate credbatch_process argument as unused

Fixes libprocstat compilation as zfs defines _KERNEL.

3 years agozfs: disable periodic arc updates
Mateusz Guzik [Sat, 14 Nov 2020 19:23:07 +0000 (19:23 +0000)]
zfs: disable periodic arc updates

They are only there to provide less innacurate statistics for debuggers.
However, this is quite heavy-weight and instead it would be better to
teach debuggers how to obtain the necessary information.

3 years agothread: batch credential freeing
Mateusz Guzik [Sat, 14 Nov 2020 19:22:02 +0000 (19:22 +0000)]
thread: batch credential freeing

3 years agothread: batch resource limit free calls
Mateusz Guzik [Sat, 14 Nov 2020 19:21:46 +0000 (19:21 +0000)]
thread: batch resource limit free calls

3 years agothread: rework tid batch to use helpers
Mateusz Guzik [Sat, 14 Nov 2020 19:20:58 +0000 (19:20 +0000)]
thread: rework tid batch to use helpers

3 years agocred: reorder cr_audit to be closer to the lock
Mateusz Guzik [Sat, 14 Nov 2020 19:20:37 +0000 (19:20 +0000)]
cred: reorder cr_audit to be closer to the lock

This makes cr_uid avoid sharing.

3 years agothread: pad tid lock
Mateusz Guzik [Sat, 14 Nov 2020 19:19:27 +0000 (19:19 +0000)]
thread: pad tid lock

On a kernel with other changes this bumps 104-way thread creation/destruction
from 0.96 mln ops/s to 1.1 mln ops/s.

3 years agoChange the default locale to C.UTF-8
Baptiste Daroussin [Sat, 14 Nov 2020 19:16:39 +0000 (19:16 +0000)]
Change the default locale to C.UTF-8

The C.UTF-8 locales is the same as the actual C locale except it does support
the unicode character set. But the collation etc are still the same as the C
locale one.

Reviewed by: many
Approved by: many
Differential Revision: https://reviews.freebsd.org/D26973

3 years agoFix a problem with r367686 related to the use of ssize_t. Not sure how this
Scott Long [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
Kyle Evans [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
Scott Long [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
Scott Long [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.
Jonathan T. Looney [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.
Jonathan T. Looney [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
Mateusz Piotrowski [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
Toomas Soome [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.
Vladimir Kondratyev [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().
Konstantin Belousov [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.
Konstantin Belousov [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
Konstantin Belousov [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.
Konstantin Belousov [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.
Konstantin Belousov [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.
Rick Macklem [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.
Rick Macklem [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.
Alexander Motin [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.
Rick Macklem [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 Davis [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
Jung-uk Kim [Fri, 13 Nov 2020 22:45:26 +0000 (22:45 +0000)]
MFV: r367652

Merge ACPICA 20201113.

3 years agoImport ACPICA 20201113.
Jung-uk Kim [Fri, 13 Nov 2020 21:41:15 +0000 (21:41 +0000)]
Import ACPICA 20201113.

3 years agobhyve: update smbiostbl.c to bump the version and release date
Rebecca Cran [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
Mateusz Guzik [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
Ed Maste [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
Ed Maste [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 Chadd [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
Ed Maste [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
Ed Maste [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.
Brandon Bergren [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.
Brandon Bergren [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
Mark Johnston [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
Mateusz Piotrowski [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
Mateusz Piotrowski [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)
Mateusz Piotrowski [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
Alex Richardson [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@
George V. Neville-Neil [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.
Konstantin Belousov [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().
Konstantin Belousov [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.
Alexander Motin [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 Chadd [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
George V. Neville-Neil [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
Mateusz Guzik [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
Mateusz Guzik [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.
Alexander Motin [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.
Navdeep Parhar [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):
Dimitry Andric [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.
Hans Petter Selasky [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
Mateusz Piotrowski [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
Mateusz Piotrowski [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
Mateusz Piotrowski [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
Mark Johnston [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
Emmanuel Vadot [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
Hans Petter Selasky [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
Hans Petter Selasky [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
Konstantin Belousov [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.
Konstantin Belousov [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.
Konstantin Belousov [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.
Konstantin Belousov [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().
Konstantin Belousov [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.
Navdeep Parhar [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.
Konstantin Belousov [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.
Konstantin Belousov [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
Mateusz Guzik [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
Kyle Evans [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.
Alexander Motin [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
Mateusz Guzik [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
Mateusz Guzik [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
Mark Johnston [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
Mark Johnston [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.
Andrey V. Elsukov [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