]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agoAdd the firmware blob required to use the sdma hardware in the imx6
Ian Lepore [Thu, 26 Nov 2020 01:40:04 +0000 (01:40 +0000)]
Add the firmware blob required to use the sdma hardware in the imx6
processor, and its associated license text (which is similar to a
bsd-3-clause, but with a prohibition against decompiling).  Install a copy
of the license in /usr/share/doc/legal/imx, to comply with the license terms
that requires a copy of the license to be delivered along with the firmware.

Obtained from: https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/imx/sdma/sdma-imx6q.bin https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/LICENSE.sdma_firmware

3 years agoUnobfuscate "KERNLOAD" parameter on amd64. This change lines-up amd64 with the
Maxim Sobolev [Wed, 25 Nov 2020 23:19:01 +0000 (23:19 +0000)]
Unobfuscate "KERNLOAD" parameter on amd64. This change lines-up amd64 with the
i386 and the rest of supported architectures by defining KERNLOAD in the
vmparam.h and getting rid of magic constant in the linker script, which albeit
documented via comment but isn't programmatically accessible at a compile time.

Use KERNLOAD to eliminate another (matching) magic constant 100 lines down
inside unremarkable TU "copy.c" 3 levels deep in the EFI loader tree.

Reviewed by: markj
Approved by: markj
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D27355

3 years agoAdd a manpage for kernel TLS.
John Baldwin [Wed, 25 Nov 2020 23:17:23 +0000 (23:17 +0000)]
Add a manpage for kernel TLS.

This subsumes some of the content from tcp(4) describing the socket
options but also adds additional notes.

Reviewed by: gallatin, hselasky
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D27272

3 years agopipe: follow up cleanup to previous
Mateusz Guzik [Wed, 25 Nov 2020 22:53:21 +0000 (22:53 +0000)]
pipe: follow up cleanup to previous

The commited patch was incomplete.

- add back missing goto retry, noted by jhb
- 'if (error)'  -> 'if (error != 0)'
- consistently do:

if (error != 0)
    break;
continue;

instead of:

if (error != 0)
    break;
else
    continue;

This adds some 'continue' uses which are not needed, but line up with the
rest of pipe_write.

3 years agopipe: drop spurious pipeunlock/pipelock cycle on write
Mateusz Guzik [Wed, 25 Nov 2020 21:41:23 +0000 (21:41 +0000)]
pipe: drop spurious pipeunlock/pipelock cycle on write

3 years agoIPv6: set ifdisabled in the kernel rather than in rc
Bjoern A. Zeeb [Wed, 25 Nov 2020 20:58:01 +0000 (20:58 +0000)]
IPv6: set ifdisabled in the kernel rather than in rc

Enable ND6_IFF_IFDISABLED when the interface is created in the
kernel before return to user space.

This avoids a race when an interface is create by a program which
also calls ifconfig IF inet6 -ifdisabled and races with the
devd -> /etc/pccard_ether -> .. netif start IF -> ifdisabled
calls (the devd/rc framework disabling IPv6 again after the program
had enabled it already).

In case the global net.inet6.ip6.accept_rtadv was turned on,
we also default to enabling IPv6 on the interfaces, rather than
disabling them.

PR: 248172
Reported by: Gert Doering (gert greenie.muc.de)
Reviewed by: glebius (, phk)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D27324

3 years agoExtend the imx6 gpc->gic interrupt controller fixup of fdt data at runtime
Ian Lepore [Wed, 25 Nov 2020 20:05:05 +0000 (20:05 +0000)]
Extend the imx6 gpc->gic interrupt controller fixup of fdt data at runtime
to work with the pmu and tempmon nodes as well as the soc node.  This allows
interrupts to work on the pmu and tempmon devices even though we don't have
a driver for the low-power gpc interrupt controller (which is not a problem
because we also don't have support for entering deep power-down modes where
it gets used).

3 years agoConvert the imx6_snvs RTC driver to access registers via the syscon device.
Ian Lepore [Wed, 25 Nov 2020 19:10:20 +0000 (19:10 +0000)]
Convert the imx6_snvs RTC driver to access registers via the syscon device.
This is required for it to work correctly in the GENERIC kernel.

3 years agoAdd the standard extres pseudo devices to the IMX6 kernel config.
Ian Lepore [Wed, 25 Nov 2020 19:08:22 +0000 (19:08 +0000)]
Add the standard extres pseudo devices to the IMX6 kernel config.

Some imx6 drivers are being converted to use features that weren't available
when they were first written (such as accessing shared device registers via
the syscon pseudo-device), so imx6 custom kernels that reference those
devices will now need this infrastructure in place.

3 years agoA couple small fixes for the imx6_sdma driver...
Ian Lepore [Wed, 25 Nov 2020 18:09:01 +0000 (18:09 +0000)]
A couple small fixes for the imx6_sdma driver...

Attach after interrupt controllers, since the attach function tries to
set up an interrupt handler.

Check for the availability of the required firmware early in the attach
code (before allocating resources).  If the firmware is not available, set
a static var to remember that, so that if the device is re-probed on later
passes it won't repeatedly try to attach and then complain again about
missing firmware.

3 years agoif: Fix non-VIMAGE build
Kristof Provost [Wed, 25 Nov 2020 17:15:24 +0000 (17:15 +0000)]
if: Fix non-VIMAGE build

if_link_ifnet() and if_unlink_ifnet() are needed even when VIMAGE is not
enabled.

MFC after: 2 weeks
Sponsored by: Modirum MDPay

3 years agoffs_softdep.c: get_parent_vp(): Fix bp lock leak when inum inode was already freed.
Konstantin Belousov [Wed, 25 Nov 2020 17:12:21 +0000 (17:12 +0000)]
ffs_softdep.c: get_parent_vp(): Fix bp lock leak when inum inode was already freed.

Reported by: markj, pho
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

3 years agoUse designated initializers for libc pthread stubs' jump table.
Konstantin Belousov [Wed, 25 Nov 2020 17:04:26 +0000 (17:04 +0000)]
Use designated initializers for libc pthread stubs' jump table.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

3 years agolibsysdecode: correctly decode mmap flags
Pawel Biernacki [Wed, 25 Nov 2020 16:30:57 +0000 (16:30 +0000)]
libsysdecode: correctly decode mmap flags

r352913 added decoding of mmap PROT_MAX()'d flags but didn’t account for the
case where different values were specified for PROT_MAX and regular flags.
Fix it.

Submitted by: sigsys_gmail.com
Reported by: sigsys_gmail.com
MFC after: 7 days
Differential Revision: https://reviews.freebsd.org/D27312

3 years agoOnly attach the ti_scm_syscon driver when running on a compatible TI chip.
Ian Lepore [Wed, 25 Nov 2020 15:45:20 +0000 (15:45 +0000)]
Only attach the ti_scm_syscon driver when running on a compatible TI chip.
This prevents attaching on non-TI systems in the GENERIC kernel.

Reviewed by: manu@, mmel@

3 years agoif: Protect V_ifnet in vnet_if_return()
Kristof Provost [Wed, 25 Nov 2020 15:07:22 +0000 (15:07 +0000)]
if: Protect V_ifnet in vnet_if_return()

When we terminate a vnet (i.e. jail) we move interfaces back to their home
vnet. We need to protect our access to the V_ifnet CK_LIST.

We could enter NET_EPOCH, but if_detach_internal() (called from if_vmove())
waits for net epoch callback completion. That's not possible from NET_EPOCH.
Instead, we take the IFNET_WLOCK, build a list of the interfaces that need to
move and, once we've released the lock, move them back to their home vnet.

We cannot hold the IFNET_WLOCK() during if_vmove(), because that results in a
LOR between ifnet_sx, in_multi_sx and iflib ctx lock.

Separate out moving the ifp into or out of V_ifnet, so we can hold the lock as
we do the list manipulation, but do not hold it as we if_vmove().

Reviewed by: melifaro
MFC after: 2 weeks
Sponsored by: Modirum MDPay
Differential Revision: https://reviews.freebsd.org/D27279

3 years agoclang: allow -fstack-clash-protection on FreeBSD
Ed Maste [Wed, 25 Nov 2020 14:26:13 +0000 (14:26 +0000)]
clang: allow -fstack-clash-protection on FreeBSD

-fstack-clash-protection was added in Clang commit e67cbac81211 but was
enabled only on Linux.  It should work fine on FreeBSD as well, so
enable it.

To be discussed and upstreamed with a test.  The OS test should probably
just be removed.

Reviewed by: dim
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27366

3 years agodtb: allwinner: Add pineh64 to the build
Emmanuel Vadot [Wed, 25 Nov 2020 11:21:03 +0000 (11:21 +0000)]
dtb: allwinner: Add pineh64 to the build

3 years agoarm: allwinner: aw_rtc: Add H6 compatible
Emmanuel Vadot [Wed, 25 Nov 2020 11:20:04 +0000 (11:20 +0000)]
arm: allwinner: aw_rtc: Add H6 compatible

3 years agoarm64: allwinner: H6: Fix pll 4x clocks
Emmanuel Vadot [Wed, 25 Nov 2020 11:19:42 +0000 (11:19 +0000)]
arm64: allwinner: H6: Fix pll 4x clocks

The clock configured by the registers are the 4x version not the 1x.

3 years agoif: Remove ifnet_rwlock
Kristof Provost [Wed, 25 Nov 2020 10:56:38 +0000 (10:56 +0000)]
if: Remove ifnet_rwlock

It no longer serves any purpose, as evidenced by the fact that we never take it
without ifnet_sxlock.

Sponsored by: Modirum MDPay
Differential Revision: https://reviews.freebsd.org/D27278

3 years agoDrop superfluous "of" from the systat example.
Benedict Reuschling [Wed, 25 Nov 2020 10:21:29 +0000 (10:21 +0000)]
Drop superfluous "of" from the systat example.

3 years agokern: cpuset: properly rebase when attaching to a jail
Kyle Evans [Wed, 25 Nov 2020 03:14:25 +0000 (03:14 +0000)]
kern: cpuset: properly rebase when attaching to a jail

The current logic is a fine choice for a system administrator modifying
process cpusets or a process creating a new cpuset(2), but not ideal for
processes attaching to a jail.

Currently, when a process attaches to a jail, it does exactly what any other
process does and loses any mask it might have applied in the process of
doing so because cpuset_setproc() is entirely based around the assumption
that non-anonymous cpusets in the process can be replaced with the new
parent set.

This approach slightly improves the jail attach integration by modifying
cpuset_setproc() callers to indicate if they should rebase their cpuset to
the indicated set or not (i.e. cpuset_setproc_update_set).

If we're rebasing and the process currently has a cpuset assigned that is
not the containing jail's root set, then we will now create a new base set
for it hanging off the jail's root with the existing mask applied instead of
using the jail's root set as the new base set.

Note that the common case will be that the process doesn't have a cpuset
within the jail root, but the system root can freely assign a cpuset from
a jail to a process outside of the jail with no restriction. We assume that
that may have happened or that it could happen due to a race when we drop
the proc lock, so we must recheck both within the loop to gather up
sufficient freed cpusets and after the loop.

To recap, here's how it worked before in all cases:

0     4 <-- jail              0      4 <-- jail / process
|                             |
1                 ->          1
|
3 <-- process

Here's how it works now:

0     4 <-- jail             0       4 <-- jail
|                            |       |
1                 ->         1       5 <-- process
|
3 <-- process

or

0     4 <-- jail             0       4 <-- jail / process
|                            |
1 <-- process     ->         1

More importantly, in both cases, the attaching process still retains the
mask it had prior to attaching or the attach fails with EDEADLK if it's
left with no CPUs to run on or the domain policy is incompatible. The
author of this patch considers this almost a security feature, because a MAC
policy could grant PRIV_JAIL_ATTACH to an unprivileged user that's
restricted to some subset of available CPUs the ability to attach to a jail,
which might lift the user's restrictions if they attach to a jail with a
wider mask.

In most cases, it's anticipated that admins will use this to be able to,
for example, `cpuset -c -l 1 jail -c path=/ command=/long/running/cmd`,
and avoid the need for contortions to spawn a command inside a jail with a
more limited cpuset than the jail.

Reviewed by: jamie
MFC after: 1 month (maybe)
Differential Revision: https://reviews.freebsd.org/D27298

3 years agokern: cpuset: rename _cpuset_create() to cpuset_init()
Kyle Evans [Wed, 25 Nov 2020 02:12:24 +0000 (02:12 +0000)]
kern: cpuset: rename _cpuset_create() to cpuset_init()

cpuset_init() is better descriptor for what the function actually does. The
name was previously taken by a sysinit that setup cpuset_zero's mask
from all_cpus, it was removed in r331698 before stable/12 branched.

A comment referencing the removed sysinit has now also been removed, since
the setup previously done was moved into cpuset_thread0().

Suggested by: markj
MFC after: 1 week

3 years agokern: cpuset: allow cpuset_create() to take an allocated *setp
Kyle Evans [Wed, 25 Nov 2020 01:42:32 +0000 (01:42 +0000)]
kern: cpuset: allow cpuset_create() to take an allocated *setp

Currently, it must always allocate a new set to be used for passing to
_cpuset_create, but it doesn't have to. This is purely kern_cpuset.c
internal and it's sparsely used, so just change it to use *setp if it's
not-NULL and modify the two consumers to pass in the address of a NULL
cpuset.

This paves the way for consumers that want the unr allocation without the
possibility of sleeping as long as they've done their due diligence to
ensure that the mask will properly apply atop the supplied parent
(i.e. avoiding the free_unr() in the last failure path).

Reviewed by: jamie, markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D27297

3 years agoRemove uses of CRIOGET in OCF tests after r368005.
John Baldwin [Wed, 25 Nov 2020 01:31:00 +0000 (01:31 +0000)]
Remove uses of CRIOGET in OCF tests after r368005.

Pointy hat to: jhb
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D27367

3 years agoRemove a reference to CRIOGET missed in r368005.
John Baldwin [Wed, 25 Nov 2020 01:09:58 +0000 (01:09 +0000)]
Remove a reference to CRIOGET missed in r368005.

3 years agokern: never restart syscalls calling closefp(), e.g. close(2)
Kyle Evans [Wed, 25 Nov 2020 01:08:57 +0000 (01:08 +0000)]
kern: never restart syscalls calling closefp(), e.g. close(2)

All paths leading into closefp() will either replace or remove the fd from
the filedesc table, and closefp() will call fo_close methods that can and do
currently sleep without regard for the possibility of an ERESTART. This can
be dangerous in multithreaded applications as another thread could have
opened another file in its place that is subsequently operated on upon
restart.

The following are seemingly the only ones that will pass back ERESTART
in-tree:
- sockets (SO_LINGER)
- fusefs
- nfsclient

Reviewed by: jilles, kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D27310

3 years agoRemove the cloned file descriptors for /dev/crypto.
John Baldwin [Wed, 25 Nov 2020 00:10:54 +0000 (00:10 +0000)]
Remove the cloned file descriptors for /dev/crypto.

Crypto file descriptors were added in the original OCF import as a way
to provide per-open data (specifically the list of symmetric
sessions).  However, this gives a bit of a confusing API where one has
to open /dev/crypto and then invoke an ioctl to obtain a second file
descriptor.  This also does not match the API used with /dev/crypto on
other BSDs or with Linux's /dev/crypto driver.

Character devices have gained support for per-open data via cdevpriv
since OCF was imported, so use cdevpriv to simplify the userland API
by permitting ioctls directly on /dev/crypto descriptors.

To provide backwards compatibility, CRIOGET now opens another
/dev/crypto descriptor via kern_openat() rather than dup'ing the
existing file descriptor.  This preserves prior semantics in case
CRIOGET is invoked multiple times on a single file descriptor.

Reviewed by: markj
Relnotes: yes
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D27302

3 years agoPull the check for VM ownership into ppt_find().
John Baldwin [Tue, 24 Nov 2020 23:56:33 +0000 (23:56 +0000)]
Pull the check for VM ownership into ppt_find().

This reduces some code duplication.  One behavior change is that
ppt_assign_device() will now only succeed if the device is unowned.
Previously, a device could be assigned to the same VM multiple times,
but each time it was assigned, the device's state was reset.

Reviewed by: markj, grehan
MFC after: 2 weeks
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D27301

3 years agoHonor the disabled setting for MSI-X interrupts for passthrough devices.
John Baldwin [Tue, 24 Nov 2020 23:18:52 +0000 (23:18 +0000)]
Honor the disabled setting for MSI-X interrupts for passthrough devices.

Add a new ioctl to disable all MSI-X interrupts for a PCI passthrough
device and invoke it if a write to the MSI-X capability registers
disables MSI-X.  This avoids leaving MSI-X interrupts enabled on the
host if a guest device driver has disabled them (e.g. as part of
detaching a guest device driver).

This was found by Chelsio QA when testing that a Linux guest could
switch from MSI-X to MSI interrupts when using the cxgb4vf driver.

While here, explicitly fail requests to enable MSI on a passthrough
device if MSI-X is enabled and vice versa.

Reported by: Sony Arpita Das @ Chelsio
Reviewed by: grehan, markj
MFC after: 2 weeks
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D27212

3 years agoCorrect entries for manpages removed in r359374.
John Baldwin [Tue, 24 Nov 2020 22:52:12 +0000 (22:52 +0000)]
Correct entries for manpages removed in r359374.

Reported by: Yuri Pankov <yuripv@yuripv.dev>
Sponsored by: Chelsio Communications

3 years agoRemove more legacy of parallel SCSI.
Alexander Motin [Tue, 24 Nov 2020 22:43:27 +0000 (22:43 +0000)]
Remove more legacy of parallel SCSI.

3 years agoRemove support for SSLv3 from fetch(3).
Jung-uk Kim [Tue, 24 Nov 2020 22:10:33 +0000 (22:10 +0000)]
Remove support for SSLv3 from fetch(3).

Support for SSLv3 was already removed from OpenSSL (r361392).

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

3 years agoUpdate dirdeps.mk et al to latest
Simon J. Gerraty [Tue, 24 Nov 2020 21:45:38 +0000 (21:45 +0000)]
Update dirdeps.mk et al to latest

Move some local tweaks to local.*.mk

Reviewed by: bdrewery
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D27300

3 years agoPort rtsx(4) driver for Realtek SD card reader from OpenBSD.
Jung-uk Kim [Tue, 24 Nov 2020 21:28:44 +0000 (21:28 +0000)]
Port rtsx(4) driver for Realtek SD card reader from OpenBSD.

This driver provides support for Realtek PCI SD card readers.  It attaches
mmc(4) bus on card insertion and detaches it on card removal.  It has been
tested with RTS5209, RTS5227, RTS5229, RTS522A, RTS525A and RTL8411B.  It
should also work with RTS5249, RTL8402 and RTL8411.

PR: 204521
Submitted by: Henri Hennebert (hlh at restart dot be)
Reviewed by: imp, jkim
Differential Revision: https://reviews.freebsd.org/D26435

3 years agoDo not truncate the last character from serial number.
Jung-uk Kim [Tue, 24 Nov 2020 21:14:36 +0000 (21:14 +0000)]
Do not truncate the last character from serial number.

strlcpy() requires one more byte for the NULL character.

Submitted by: Henri Hennebert (hlh at restart dot be)
MFC after: 3 days

3 years agorelease: Merge the RPI2 and BEAGLEBONE image with the GENERICSD one
Emmanuel Vadot [Tue, 24 Nov 2020 17:53:13 +0000 (17:53 +0000)]
release: Merge the RPI2 and BEAGLEBONE image with the GENERICSD one

Both RPI2 and BEAGLEBONE are still popular and used arm boards.
Both u-boots can coexist as they are named differently and live in the
fat partition.
This leave us with only one image that can be used for both of those
boards and all the other ones supported by FreeBSD provided that you
install the correct u-boot on it.

Reviewed by: imp
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D27283

3 years agoRelease: arm: Remove config for old boards
Emmanuel Vadot [Tue, 24 Nov 2020 17:52:01 +0000 (17:52 +0000)]
Release: arm: Remove config for old boards

All those board are impossible to buy nowadays and could boot using the
GENERICSD image after putting the correct u-boot on them.

Reviewed by: imp
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D27282

3 years agoarm: Remove old amlogic support
Emmanuel Vadot [Tue, 24 Nov 2020 17:51:10 +0000 (17:51 +0000)]
arm: Remove old amlogic support

Remove the port for aml8726.
Kernel config was removed in r346096 and this port was never migrated
to GENERIC.
It is also impossible to obtain such hardware nowadays.

Reviewed by: imp
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D27281

3 years agoarm: Remove old rockchip support
Emmanuel Vadot [Tue, 24 Nov 2020 17:50:22 +0000 (17:50 +0000)]
arm: Remove old rockchip support

Remove the port for rk30xx.
Kernel config was removed in r346096 and this port was never migrated
to GENERIC.
It is also impossible to obtain such hardware nowadays and this code
don't provide anything beside booting.

Reviewed by: imp
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D27280

3 years agoUpdate RQSFLAG_* definitions.
Alexander Motin [Tue, 24 Nov 2020 17:37:12 +0000 (17:37 +0000)]
Update RQSFLAG_* definitions.

3 years agopf tests: provoke tag hashing panic
Kristof Provost [Tue, 24 Nov 2020 17:32:49 +0000 (17:32 +0000)]
pf tests: provoke tag hashing panic

Attempt to provoke the panic fixed in r367987.

MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D27350

3 years agoata(4): Release the ioport resource if device initialization fails
Mark Johnston [Tue, 24 Nov 2020 17:13:08 +0000 (17:13 +0000)]
ata(4): Release the ioport resource if device initialization fails

PR: 251346
Submitted by: janm@transactionware.com
MFC after: 1 week

3 years agoping(8): Improve parameter validation
Mark Johnston [Tue, 24 Nov 2020 17:12:40 +0000 (17:12 +0000)]
ping(8): Improve parameter validation

- Use strtonum(3) to simplify bounds checking of numeric parameters.
- Fix bounds checking when filling out packet data in "sweep" mode.

PR: 239974, 239977, 239978
Reported by: Neeraj <neerajpal09@gmail.com>
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D25622

3 years agopf: Make tag hashing more robust
Mark Johnston [Tue, 24 Nov 2020 16:18:47 +0000 (16:18 +0000)]
pf: Make tag hashing more robust

tagname2tag() hashes the tag name before truncating it to 63 characters.
tag_unref() removes the tag from the name hash by computing the hash
over the truncated name.  Ensure that both operations compute the same
hash for a given tag.

The larger issue is a lack of string validation in pf(4) ioctl handlers.
This is intended to be fixed with some future work, but an extra safety
belt in tagname2hashindex() is worthwhile regardless.

Reported by: syzbot+a0988828aafb00de7d68@syzkaller.appspotmail.com
Reviewed by: kp
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27346

3 years agoRemove concept of mbox_sleep_ok.
Alexander Motin [Tue, 24 Nov 2020 15:32:25 +0000 (15:32 +0000)]
Remove concept of mbox_sleep_ok.

It was broken by design and unused for years due to conflicts between
different threads, fighting for the same set of mailbox registers, not
designed for multiple requests at a time.  So either request has to be
synchronous and spin under the lock, or it should be sent asynchronously
through the queues as Mailbox Command IOCB or some other way.

This removes any OS specifics from the wait code, so it can be inlined.

3 years agoRemove unneeded locking around xpt_bus_[de]register().
Alexander Motin [Tue, 24 Nov 2020 14:05:52 +0000 (14:05 +0000)]
Remove unneeded locking around xpt_bus_[de]register().

MFC after: 2 weeks

3 years agoarm64: Check if we have a map before checking the flags
Emmanuel Vadot [Tue, 24 Nov 2020 14:05:35 +0000 (14:05 +0000)]
arm64: Check if we have a map before checking the flags

This fixes amdgpu on arm64 where linuxkpi is calling id_mapped
and we call might_bounce without a map.

3 years agoRemove erradic assert after SVN r367149 in mlx5en(4).
Hans Petter Selasky [Tue, 24 Nov 2020 13:07:59 +0000 (13:07 +0000)]
Remove erradic assert after SVN r367149 in mlx5en(4).

The ratelimit tags may be shared, especially for unlimited TLS
traffic, and then the refcount is allowed to be greater than one
when freeing the send tag.

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

3 years agoFix a typo in a comment.
Cy Schubert [Tue, 24 Nov 2020 06:42:32 +0000 (06:42 +0000)]
Fix a typo in a comment.

MFC after: 3 days

3 years agoImplement request queue overflow protection.
Alexander Motin [Tue, 24 Nov 2020 04:16:49 +0000 (04:16 +0000)]
Implement request queue overflow protection.

Before this change in case of request queue overflow driver just froze the
device queue for 100ms to retry after.  It was pretty bad for performance.
This change introduces SIM queue freezing when free space on the request
queue drops below 255 entries (worst case of maximum I/O size S/G list),
checking for a chance to release it on I/O completion.  If the queue still
get overflowed somehow, the old mechanism is still in place, just with
delay reduced to 10ms.

With the earlier queue length increase overflows should not happen often,
but it is still easily reachable on synthetic tests.

3 years agolocks: push lock_delay_arg_init calls down
Mateusz Guzik [Tue, 24 Nov 2020 03:49:37 +0000 (03:49 +0000)]
locks: push lock_delay_arg_init calls down

Minor cleanup to skip doing them when recursing on locks and so that
they can act on found lock value if need be.

3 years agosx: drop spurious volatile keyword
Mateusz Guzik [Tue, 24 Nov 2020 03:48:44 +0000 (03:48 +0000)]
sx: drop spurious volatile keyword

3 years agoping6: update usage text after r365547
Alan Somers [Tue, 24 Nov 2020 02:51:45 +0000 (02:51 +0000)]
ping6: update usage text after r365547

MFC after: 2 weeks

3 years agoPrefer Em to Ar for emphasis
Warner Losh [Mon, 23 Nov 2020 18:37:19 +0000 (18:37 +0000)]
Prefer Em to Ar for emphasis

Em is better than Ar if all we want to do is underline the text.

Submitted by: yuripv@

3 years agodtrace: stop using eventhandlers for the part compiled into the kernel
Mateusz Guzik [Mon, 23 Nov 2020 18:27:21 +0000 (18:27 +0000)]
dtrace: stop using eventhandlers for the part compiled into the kernel

Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D27311

3 years agothread: stash domain id to work around vtophys problems on ppc64
Mateusz Guzik [Mon, 23 Nov 2020 18:26:47 +0000 (18:26 +0000)]
thread: stash domain id to work around vtophys problems on ppc64

Adding to zombie list can be perfomed by idle threads, which on ppc64 leads to
panics as it requires a sleepable lock.

Reported by: alfredo
Reviewed by: kib, markj
Fixes: r367842 ("thread: numa-aware zombie reaping")
Differential Revision: https://reviews.freebsd.org/D27288

3 years agoLinuxolator: Replace use of eventhandlers by sysent hooks.
Konstantin Belousov [Mon, 23 Nov 2020 18:18:16 +0000 (18:18 +0000)]
Linuxolator: Replace use of eventhandlers by sysent hooks.

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D27309

3 years agoProvide ABI modules hooks for process exec/exit and thread exit.
Konstantin Belousov [Mon, 23 Nov 2020 17:29:25 +0000 (17:29 +0000)]
Provide ABI modules hooks for process exec/exit and thread exit.

Exec and exit are same as corresponding eventhandler hooks.

Thread exit hook is called somewhat earlier, while thread is still
owned by the process and enough context is available.  Note that the
process lock is owned when the hook is called.

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D27309

3 years agobin/setfacl: Little refactoring, no functional change.
Gleb Popov [Mon, 23 Nov 2020 17:00:06 +0000 (17:00 +0000)]
bin/setfacl: Little refactoring, no functional change.

The acl_from_stat function accepts a stat_t * argument, but only uses its
st_mode field. There is no reason to pass the whole struct, so make it accept
a mode_t and rename the function to acl_from_mode.
Linux has non-standard acl_from_mode function in its libacl, so naming the
function this way may help discovering it during porting efforts.

Reviewed by: tsoome, markj
Approved by: markj
Differential Revision: https://reviews.freebsd.org/D27292

3 years agoReplace paths in ctladm(8) examples with something sensible.
Edward Tomasz Napierala [Mon, 23 Nov 2020 14:30:27 +0000 (14:30 +0000)]
Replace paths in ctladm(8) examples with something sensible.

PR: 251181
Reviewed by: 0mp, rm, ygy
MFC after: 2 weeks
Sponsored by: EPSRC
Differential Revision: https://reviews.freebsd.org/D27249

3 years agoEnsure that the buffer is in nvme_single_map() mapped to single segment.
Michal Meloun [Mon, 23 Nov 2020 14:30:22 +0000 (14:30 +0000)]
Ensure that the buffer is in nvme_single_map() mapped to single segment.
Not a functional change.

MFC after: 1 week

3 years agoAssorted tweaks to hier(7): punctuation, some .Xr's, clarify wording.
Edward Tomasz Napierala [Mon, 23 Nov 2020 14:26:59 +0000 (14:26 +0000)]
Assorted tweaks to hier(7): punctuation, some .Xr's, clarify wording.

Reviewed by: 0mp, bcr, imp
MFC after: 2 weeks
Sponsored by: EPSRC
Differential Revision: https://reviews.freebsd.org/D27248

3 years agoMake sbp(4) use xpt_alloc_ccb/xpt_free_ccb instead of malloc/free.
Edward Tomasz Napierala [Mon, 23 Nov 2020 13:05:11 +0000 (13:05 +0000)]
Make sbp(4) use xpt_alloc_ccb/xpt_free_ccb instead of malloc/free.

Reviewed by: imp, mav
MFC after: 2 weeks
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D26843

3 years agoMake tws(4) use xpt_alloc_ccb()/xpt_free_ccb() instead of malloc/free.
Edward Tomasz Napierala [Mon, 23 Nov 2020 13:02:23 +0000 (13:02 +0000)]
Make tws(4) use xpt_alloc_ccb()/xpt_free_ccb() instead of malloc/free.

Reviewed by: imp
MFC after: 2 weeks
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D26841

3 years agoDon't check return from xpt_alloc_ccb() for being NULL; since it's not
Edward Tomasz Napierala [Mon, 23 Nov 2020 12:59:56 +0000 (12:59 +0000)]
Don't check return from xpt_alloc_ccb() for being NULL; since it's not
the _nowait wariant, it cannot fail.

Suggested by: mav
MFC after: 2 weeks
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.

3 years agoMake hptmv(4) use xpt_alloc_ccb/xpt_free_ccb instead of malloc/free.
Edward Tomasz Napierala [Mon, 23 Nov 2020 12:57:24 +0000 (12:57 +0000)]
Make hptmv(4) use xpt_alloc_ccb/xpt_free_ccb instead of malloc/free.

Reviewed by: imp, mav
MFC after: 2 weeks
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D26842

3 years agosmartpqi: don't bzero the new ccb; xpt_alloc_ccb_nowait() already does that.
Edward Tomasz Napierala [Mon, 23 Nov 2020 12:54:19 +0000 (12:54 +0000)]
smartpqi: don't bzero the new ccb; xpt_alloc_ccb_nowait() already does that.

Reviewed by: imp
MFC after: 2 weeks
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D26838

3 years agoarcmsr(4): don't bzero newly allocated ccb; xpt_alloc_ccb() already does that.
Edward Tomasz Napierala [Mon, 23 Nov 2020 12:50:38 +0000 (12:50 +0000)]
arcmsr(4): don't bzero newly allocated ccb; xpt_alloc_ccb() already does that.

Reviewed by: delphij, imp, ching2048@areca.com.tw
Tested by: ching2048@areca.com.tw
MFC after: 2 weeks
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D26840

3 years agoRemove the 'wantparent' variable, unused since r145004.
Edward Tomasz Napierala [Mon, 23 Nov 2020 12:47:23 +0000 (12:47 +0000)]
Remove the 'wantparent' variable, unused since r145004.

Reviewed by: kib
MFC after: 2 weeks
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D27193

3 years agoFix two occurences of a typo in a comment introduced in r367530.
Michael Tuexen [Mon, 23 Nov 2020 10:13:56 +0000 (10:13 +0000)]
Fix two occurences of a typo in a comment introduced in r367530.

Reported by: lstewart@
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D27148

3 years agoarcconfig: add callsign again
Eitan Adler [Mon, 23 Nov 2020 04:39:29 +0000 (04:39 +0000)]
arcconfig: add callsign again

Problem

When using git-svn or other non-pure-svn tooling the original subversion
URL is not present. This causes arcanist/phabricator to be unable to
determine which repository is being modified.

Solution

Restore callsign to .arcconfig to enable exact repository matching even
with git-svn.

Reported By: jhb

3 years agocpuset_setproc: use the appropriate parent for new anonymous sets
Kyle Evans [Mon, 23 Nov 2020 02:49:53 +0000 (02:49 +0000)]
cpuset_setproc: use the appropriate parent for new anonymous sets

As far as I can tell, this has been the case since initially committed in
2008.  cpuset_setproc is the executor of cpuset reassignment; note this
excerpt from the description:

* 1) Set is non-null.  This reparents all anonymous sets to the provided
*    set and replaces all non-anonymous td_cpusets with the provided set.

However, reviewing cpuset_setproc_setthread() for some jail related work
unearthed the error: if tdset was not anonymous, we were replacing it with
`set`. If it was anonymous, then we'd rebase it onto `set` (i.e. copy the
thread's mask over and AND it with `set`) but give the new anonymous set
the original tdset as the parent (i.e. the base of the set we're supposed to
be leaving behind).

The primary visible consequences were that:

1.) cpuset_getid() following such assignment returns the wrong result, the
    setid that we left behind rather than the one we joined.
2.) When a process attached to the jail, the base set of any anonymous
    threads was a set outside of the jail.

This was initially bundled in D27298, but it's a minor fix that's fairly
easy to verify the correctness of.

A test is included in D27307 ("badparent"), which demonstrates the issue
with, effectively:

osetid = cpuset_getid()
newsetid = cpuset()
cpuset_setaffinity(thread)
cpuset_setid(osetid)
cpuset_getid(thread) -> observe that it matches newsetid instead of osetid.

MFC after: 1 week

3 years agofreebsd32: take the _umtx_op struct definitions back
Kyle Evans [Mon, 23 Nov 2020 00:58:14 +0000 (00:58 +0000)]
freebsd32: take the _umtx_op struct definitions back

Providing these in freebsd32.h facilitates local testing/measuring of the
structs rather than forcing one to locally recreate them. Sanity checking
offsets/sizes remains in kern_umtx.c where these are typically used.

3 years agokern: dup: do not assume oldfde is valid
Kyle Evans [Mon, 23 Nov 2020 00:33:06 +0000 (00:33 +0000)]
kern: dup: do not assume oldfde is valid

oldfde may be invalidated if the table has grown due to the operation that
we're performing, either via fdalloc() or a direct fdgrowtable_exp().

This was technically OK before rS367927 because the old table remained valid
until the filedesc became unused, but now it may be freed immediately if
it's an unshared table in a single-threaded process, so it is no longer a
good assumption to make.

This fixes dup/dup2 invocations that grow the file table; in the initial
report, it manifested as a kernel panic in devel/gmake's configure script.

Reported by: Guy Yur <guyyur gmail com>
Reviewed by: rew
Differential Revision: https://reviews.freebsd.org/D27319

3 years agoRefactor rib iterator functions.
Alexander V. Chernikov [Sun, 22 Nov 2020 20:21:10 +0000 (20:21 +0000)]
Refactor rib iterator functions.

* Make rib_walk() order of arguments consistent with the rest of RIB api
* Add rib_walk_ext() allowing to exec callback before/after iteration.
* Rename rt_foreach_fib_walk_del -> rib_foreach_table_walk_del
* Rename rt_forach_fib_walk -> rib_foreach_table_walk
* Move rib_foreach_table_walk{_del} to route/route_helpers.c
* Slightly refactor rib_foreach_table_walk{_del} to make the implementation
 consistent and prepare for upcoming iterator optimizations.

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

3 years agoif_dwc: Correctly configure the DMA engine based on the fdt properties
Emmanuel Vadot [Sun, 22 Nov 2020 20:16:46 +0000 (20:16 +0000)]
if_dwc: Correctly configure the DMA engine based on the fdt properties

Do not hardcode what we setup for the DMA engine configuration but
lookup the fdt properties and configuring accordingly.
Use a default value of 8 for the burst dma length for both TX and
RX, this is what we used for TX before.

3 years agorelease: rpi3: Copy the bcm2710 variant of the rpi2
Emmanuel Vadot [Sun, 22 Nov 2020 18:42:08 +0000 (18:42 +0000)]
release: rpi3: Copy the bcm2710 variant of the rpi2

This is the dtb intented to be used for booting RPI2 v1.2 in aarch64.

3 years agoFix debug build after 367926.
Alexander Motin [Sun, 22 Nov 2020 16:13:09 +0000 (16:13 +0000)]
Fix debug build after 367926.

3 years agonetmap: bridge: improve readability
Vincenzo Maffione [Sun, 22 Nov 2020 13:39:21 +0000 (13:39 +0000)]
netmap: bridge: improve readability

Multiple cosmetic changes, plus a fix to a verbose print
(indicating wrong net->host/host->net direction).

MFC after: 3 days

3 years agonetmap: valectl: switch to libnetmap
Vincenzo Maffione [Sun, 22 Nov 2020 10:02:56 +0000 (10:02 +0000)]
netmap: valectl: switch to libnetmap

Use the newer libnetmap (included in base) rather than the older
nm_open()/nm_close() defined in netmap_user.h

MFC after:      3 days

3 years agonetmap: nmreplay: switch to libnetmap
Vincenzo Maffione [Sun, 22 Nov 2020 09:38:01 +0000 (09:38 +0000)]
netmap: nmreplay: switch to libnetmap

Use the newer libnetmap (included in base) rather than the older
nm_open()/nm_close() defined in netmap_user.h

MFC after:      3 days

3 years agonetmap: lb: switch to libnetmap
Vincenzo Maffione [Sun, 22 Nov 2020 09:28:50 +0000 (09:28 +0000)]
netmap: lb: switch to libnetmap

Use the newer libnetmap (included in base) rather than the older
nm_open()/nm_close() defined in netmap_user.h

MFC after: 3 days

3 years agonetmap: pkt-gen: switch to libnetmap
Vincenzo Maffione [Sun, 22 Nov 2020 09:20:08 +0000 (09:20 +0000)]
netmap: pkt-gen: switch to libnetmap

Use the newer libnetmap (included in base) rather than the older
nm_open()/nm_close() defined in netmap_user.h

3 years agonetmap: bridge: switch to libnetmap
Vincenzo Maffione [Sun, 22 Nov 2020 09:10:12 +0000 (09:10 +0000)]
netmap: bridge: switch to libnetmap

Use the newer libnetmap (included in base) rather than the older
nm_open()/nm_close() defined in netmap_user.h

3 years ago[2/2] _umtx_op: introduce 32-bit/i386 flags for operations
Kyle Evans [Sun, 22 Nov 2020 05:47:45 +0000 (05:47 +0000)]
[2/2] _umtx_op: introduce 32-bit/i386 flags for operations

This patch takes advantage of the consolidation that happened to provide two
flags that can be used with the native _umtx_op(2): UMTX_OP___32BIT and
UMTX_OP__I386.

UMTX_OP__32BIT iindicates that we are being provided with 32-bit structures.
Note that this flag alone indicates a 64bit time_t, since this is the
majority case.

UMTX_OP__I386 has been provided so that we can emulate i386 as well,
regardless of whether the host is amd64 or not.

Both imply a different set of copyops in sysumtx_op. freebsd32__umtx_op
simply ignores the flags, since it's already doing a 32-bit operation and
it's unlikely we'll be running an emulator under compat32. Future work
could consider it, but the author sees little benefit.

This will be used by qemu-bsd-user to pass on all _umtx_op calls to the
native interface as long as the host/target endianness matches, effectively
eliminating most if not all of the remaining unresolved deadlocks for most.

This version changed a fair amount from what was under review, mostly in
response to refactoring of the prereq reorganization and battle-testing
it with qemu-bsd-user.  The main changes are as follows:

1.) The i386 flag got renamed to omit '32BIT' since this is redundant.
2.) The flags are now properly handled on 32-bit platforms to emulate other
    32-bit platforms.
3.) Robust list handling was fixed, and the 32-bit functionality that was
    previously gated by COMPAT_FREEBSD32 is now unconditional.
4.) Robust list handling was also improved, including the error reported
    when a process has already registered 32-bit ABI lists and also
    detecting if native robust lists have already been registered. Both
    scenarios now return EBUSY rather than EINVAL, because the input is
    technically valid but we're too busy with another ABI's lists.

libsysdecode/kdump/truss support will go into review soon-ish, along with
the associated manpage update.

Reviewed by: kib (earlier version)
MFC after: 3 weeks

3 years agoFix build after 367926.
Alexander Motin [Sun, 22 Nov 2020 05:42:52 +0000 (05:42 +0000)]
Fix build after 367926.

Option ISP_TARGET_MODE is evil.

3 years ago_umtx_op: move compat32 definitions back in
Kyle Evans [Sun, 22 Nov 2020 05:34:51 +0000 (05:34 +0000)]
_umtx_op: move compat32 definitions back in

These are reasonably compact, and a future commit will blur the compat32
lines by supporting 32-bit operations with the native _umtx_op.

3 years agofd: free old file descriptor tables when not shared
Robert Wing [Sun, 22 Nov 2020 05:00:28 +0000 (05:00 +0000)]
fd: free old file descriptor tables when not shared

During the life of a process, new file descriptor tables may be allocated. When
a new table is allocated, the old table is placed in a free list and held onto
until all processes referencing them exit.

When a new file descriptor table is allocated, the old file descriptor table
can be freed when the current process has a single-thread and the file
descriptor table is not being shared with any other processes.

Reviewed by:    kevans
Approved by:    kevans (mentor)
Differential Revision:  https://reviews.freebsd.org/D18617

3 years agoMake handlers and atpds overflows unlikely.
Alexander Motin [Sun, 22 Nov 2020 04:29:55 +0000 (04:29 +0000)]
Make handlers and atpds overflows unlikely.

 - Allocate 256 handlers more than payload commands for management purposes.
 - Increase maximum number of handlers from 8K to 16K by tuning the format.
 - Just to be safe limit the number of payload commands to 16K - 256.
 - Limit number of target exchanges in mixed mode to the number of atpds.
 - If we still somehow get out of atpds -- return BUSY, since we really are.

3 years agoDo not parent all busdma tags to the payload tag.
Alexander Motin [Sun, 22 Nov 2020 04:10:13 +0000 (04:10 +0000)]
Do not parent all busdma tags to the payload tag.

There is not much to inherit any more, may create more problems than solve.
Instead parent them all directly to upstream.

While there, add missed payload tag and tune scratch tag destructions.

3 years agoRemove remnants of execthrottle and maxalloc parameters.
Alexander Motin [Sun, 22 Nov 2020 02:51:30 +0000 (02:51 +0000)]
Remove remnants of execthrottle and maxalloc parameters.

The first was obsolete since 26xx, not used on 25xx and not needed on 24xx.
The second seems never worked on 24xx and up.

3 years agoStop using eventhandlers for itimers subsystem exec and exit hooks.
Konstantin Belousov [Sat, 21 Nov 2020 21:43:36 +0000 (21:43 +0000)]
Stop using eventhandlers for itimers subsystem exec and exit hooks.

While there, do some minor cleanup for kclocks.  They are only
registered from kern_time.c, make registration function static.
Remove event hooks, they are not used by both registered kclocks.
Add some consts.

Perhaps we can stop registering kclocks at all and statically
initialize them.

Reviewed by: mjg
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D27305

3 years agoImprove number reading by rounding up to a next unit earlier for memory display.
Michael Reifenberger [Sat, 21 Nov 2020 19:14:11 +0000 (19:14 +0000)]
Improve number reading by rounding up to a next unit earlier for memory display.

Submitted by: ota@j.email.ne.jp
Differential Revision: https://reviews.freebsd.org/D26503

3 years agonetmap: bridge, pkt-gen: fix man page typo
Vincenzo Maffione [Sat, 21 Nov 2020 18:47:13 +0000 (18:47 +0000)]
netmap: bridge, pkt-gen: fix man page typo

Reported by: ian
MFC after: 3 days

3 years agonetmap: bridge: update man page with more information
Vincenzo Maffione [Sat, 21 Nov 2020 18:20:21 +0000 (18:20 +0000)]
netmap: bridge: update man page with more information

Update the man page to describe how it is necessary to
enable promiscuous mode and/or disable offloads.

3 years agoRemove unused prototype.
Konstantin Belousov [Sat, 21 Nov 2020 10:58:19 +0000 (10:58 +0000)]
Remove unused prototype.

Missed part of r367918.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

3 years agoStop using eventhandler to invoke umtx_exec hook.
Konstantin Belousov [Sat, 21 Nov 2020 10:32:40 +0000 (10:32 +0000)]
Stop using eventhandler to invoke umtx_exec hook.

There is no point in dynamic registration, umtx hook is there always.

Reviewed by: mjg
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D27303

3 years agocxgbe(4): Catch up with in-flight netmap rx before destroying queues.
Navdeep Parhar [Sat, 21 Nov 2020 03:27:32 +0000 (03:27 +0000)]
cxgbe(4): Catch up with in-flight netmap rx before destroying queues.

The netmap application using the driver is responsible for replenishing
the receive freelists and they may be totally depleted when the
application exits.  Packets in flight, if any, might block the pipeline
in case there aren't enough buffers left in the freelist.  Avoid this by
filling up the freelists with a driver allocated buffer.

MFC after: 1 week
Sponsored by: Chelsio Communications