]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agocxgbe(4): Stop but don't free netmap queues when netmap is switched off.
Navdeep Parhar [Thu, 3 Dec 2020 08:30:29 +0000 (08:30 +0000)]
cxgbe(4): Stop but don't free netmap queues when netmap is switched off.

It is common for freelists to be starving when a netmap application
stops.  Mailbox commands to free queues can hang in such a situation.
Avoid that by not freeing the queues when netmap is switched off.
Instead, use an alternate method to stop the queues without releasing
the context ids.  If netmap is enabled again later then the same queue
is reinitialized for use.  Move alloc_nm_rxq and txq to t4_netmap.c
while here.

MFC after: 1 week
Sponsored by: Chelsio Communications

3 years agoRemove trailing whitespace.
Cy Schubert [Thu, 3 Dec 2020 05:49:59 +0000 (05:49 +0000)]
Remove trailing whitespace.

MFC after: 1 week

3 years agoAdd support for hw.physmem tunable for ARM/ARM64/RISC-V platforms
Oleksandr Tymoshenko [Thu, 3 Dec 2020 05:39:27 +0000 (05:39 +0000)]
Add support for hw.physmem tunable for ARM/ARM64/RISC-V platforms

hw.physmem tunable allows to limit number of physical memory available to the
system. It's handled in machdep files for x86 and PowerPC. This patch adds
required logic to the consolidated physmem management interface that is used by
ARM, ARM64, and RISC-V.

Submitted by: Klara, Inc.
Reviewed by: mhorne
Sponsored by: Ampere Computing
Differential Revision: https://reviews.freebsd.org/D27152

3 years ago[PowerPC64LE] Fix LE VSX/fpr interop
Brandon Bergren [Thu, 3 Dec 2020 01:39:59 +0000 (01:39 +0000)]
[PowerPC64LE] Fix LE VSX/fpr interop

In the PCB struct, we need to match the VSX register file layout
correctly, as the VSRs shadow the FPRs.

In LE, we need to have a dword of padding before the fprs so they end up
on the correct side, as the struct may be manipulated by either the FP
routines or the VSX routines.

Additionally, when saving and restoring fprs, we need to explicitly target
the fpr union member so it gets offset correctly on LE.

Fixes weirdness with FP registers in VSX-using programs (A FPR that was
saved by the FP routines but restored by the VSX routines was becoming 0
due to being loaded to the wrong side of the VSR.)

Original patch by jhibbits.

Reviewed by: jhibbits
Differential Revision: https://reviews.freebsd.org/D27431

3 years agoFix r368197: suppress error printing for the "check" command.
Gleb Smirnoff [Wed, 2 Dec 2020 21:53:28 +0000 (21:53 +0000)]
Fix r368197: suppress error printing for the "check" command.

Reviewed by: kevans

3 years agouart: allow UART_DEV_DBGPORT for fdt consoles
Mitchell Horne [Wed, 2 Dec 2020 21:01:52 +0000 (21:01 +0000)]
uart: allow UART_DEV_DBGPORT for fdt consoles

Allow fdt devices to be used as debug ports for gdb(4).

A debug console can be specified with the "freebsd,debug-path" property
in the device tree's /chosen node, or using the environment variable
hw.fdt.dbgport.

The device should be specified by its name in the device tree, for
example hw.fdt.dbgport="serial2".

PR: 251053
Submitted by: Dmitry Salychev <dsl@mcusim.org>
Submitted by:   stevek (original patch, D5986)
Reviewed by: andrew, mhorne
Differential Revision: https://reviews.freebsd.org/D27422

3 years agocxgbe(4): Revert r367917.
Navdeep Parhar [Wed, 2 Dec 2020 20:54:03 +0000 (20:54 +0000)]
cxgbe(4): Revert r367917.

r367917 fixed the backpressure on the netmap rxq being stopped but that
doesn't help if some other netmap rxq is starved (because it is stopping
too although the driver doesn't know this yet) and blocks the pipeline.
An alternate fix that works in all cases will be checked in instead.

Sponsored by: Chelsio Communications

3 years agocrashinfo: Add references to the gdb port/package
Ed Maste [Wed, 2 Dec 2020 19:58:50 +0000 (19:58 +0000)]
crashinfo: Add references to the gdb port/package

We intend to remove the obsolete GDB 6.1.1 from FreeBSD before FreeBSD 13.

Reviewed by jhb
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27447

3 years agoem: fix a null de-reference in em_free_pci_resources
Mitchell Horne [Wed, 2 Dec 2020 17:37:32 +0000 (17:37 +0000)]
em: fix a null de-reference in em_free_pci_resources

A failure in iflib_device_register() can result in
em_free_pci_resources() being called after receive queues have already
been freed. In particular, a failure to allocate IRQ resources will goto
fail_queues, where IFDI_QUEUES_FREE() will be called via
iflib_tx_structures_free(), preceding the call to IFDI_DETACH().

Cope with this by checking adapter->rx_queues before dereferencing it.
A similar check is present in ixgbe(4) and ixl(4).

MFC after: 1 week
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D27260

3 years agoaddr2line: rework check_range conditions
Ed Maste [Wed, 2 Dec 2020 17:22:29 +0000 (17:22 +0000)]
addr2line: rework check_range conditions

Simplify logic and reduce indentation for DW_AT_low_pc case.

Reviewed by: Tiger Gao, markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27426

3 years agoNVME: Multiple busdma related fixes.
Michal Meloun [Wed, 2 Dec 2020 16:54:24 +0000 (16:54 +0000)]
NVME: Multiple busdma related fixes.
- in nvme_qpair_process_completions() do dma sync before completion buffer
  is used.
- in nvme_qpair_submit_tracker(), don't do explicit wmb() also for arm
  and arm64. Bus_dmamap_sync() on these architectures is sufficient to ensure
  that all CPU stores are visible to external (including DMA) observers.
- Allocate completion buffer as BUS_DMA_COHERENT. On not-DMA coherent systems,
  buffers continuously owned (and accessed) by DMA must be allocated with this
  flag. Note that BUS_DMA_COHERENT flag is no-op on DMA coherent systems
  (or coherent buses in mixed systems).

MFC after: 4 weeks
Reviewed by: mav, imp
Differential Revision: https://reviews.freebsd.org/D27446

3 years agortsold: Fix bugs reported by Coverity
Mark Johnston [Wed, 2 Dec 2020 16:46:45 +0000 (16:46 +0000)]
rtsold: Fix bugs reported by Coverity

- Avoid leaking a socket if llflags_get() fails.
- Avoid leaking a file handle if rtsold_init_dumpfile() fails.
- Tighten the check in if_nametosdl() which determines whether we failed
  to find the specified interface.
- Fix errno handling in an error path in rtsock_open().

MFC after: 1 week

3 years agopf tests: Test case for bug #251414
Kristof Provost [Wed, 2 Dec 2020 16:33:23 +0000 (16:33 +0000)]
pf tests: Test case for bug #251414

Changing a table from not having counters to having counters (or vice versa)
may trigger panics.

PR: 251414
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D27441

3 years agopf: Fix table entry counter toggling
Mark Johnston [Wed, 2 Dec 2020 16:01:43 +0000 (16:01 +0000)]
pf: Fix table entry counter toggling

When updating a table, pf will keep existing table entry structures
corresponding to addresses that are in both of the old and new tables.
However, the update may also enable or disable per-entry counters which
are allocated separately.  Thus when toggling PFR_TFLAG_COUNTERS, the
entries may be missing counters or may have unused counters allocated.

Fix the problem by modifying pfr_ina_commit() to transfer counters
from or to entries in the shadow table.

PR: 251414
Reported by: sigsys@gmail.com
Reviewed by: kp
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27440

3 years agonvme: Fix typo in definition
Chuck Tuffli [Wed, 2 Dec 2020 15:59:08 +0000 (15:59 +0000)]
nvme: Fix typo in definition

Change occurrences of "selt test" to "self tests in the NVMe header
file.

Reviewed by: imp, mav
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D27439

3 years agovt/fonts: fix typo
Toomas Soome [Wed, 2 Dec 2020 09:42:02 +0000 (09:42 +0000)]
vt/fonts: fix typo

add missing 'is'.

Reported by: bcr

3 years agoFix r368153. Wrong branch of #ifdef __ARMEB__ was deleted.
Michal Meloun [Wed, 2 Dec 2020 08:14:56 +0000 (08:14 +0000)]
Fix r368153. Wrong branch of #ifdef __ARMEB__ was deleted.

3 years agoAIO tests: update expected failure messages after r368265
Alan Somers [Wed, 2 Dec 2020 00:53:03 +0000 (00:53 +0000)]
AIO tests: update expected failure messages after r368265

PR: 220398, 251515
MFC after: 1 week
MFC-With: r368265

3 years agoselect: make sure there are no wakeup attempts after selfdfree returns
Mateusz Guzik [Wed, 2 Dec 2020 00:48:15 +0000 (00:48 +0000)]
select: make sure there are no wakeup attempts after selfdfree returns

Prior to the patch returning selfdfree could still be racing against doselwakeup
which set sf_si = NULL and now locks stp to wake up the other thread.

A sufficiently unlucky pair can end up going all the way down to freeing
select-related structures before the lock/wakeup/unlock finishes.

This started manifesting itself as crashes since select data started getting
freed in r367714.

3 years agoFix syntax
Konstantin Belousov [Tue, 1 Dec 2020 23:51:48 +0000 (23:51 +0000)]
Fix syntax

3 years agoImprove man page for AmazonEFS mounts.
Rick Macklem [Tue, 1 Dec 2020 23:33:10 +0000 (23:33 +0000)]
Improve man page for AmazonEFS mounts.

PR#250770 was actually just a misunderstanding of what
NFS mount options are needed for AmazonEFS mounts.
This patch attempts to clarify the manpage to clarify this.

This is a content change.

PR: 250770
Reviewed by: bcr
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D27430

3 years agoadd documentation that the rules need to be reloaded, and how to do it...
John-Mark Gurney [Tue, 1 Dec 2020 23:25:21 +0000 (23:25 +0000)]
add documentation that the rules need to be reloaded, and how to do it...

MFC after: 1 week

3 years agoficl: make dump a bit friendlier
Toomas Soome [Tue, 1 Dec 2020 23:07:05 +0000 (23:07 +0000)]
ficl: make dump a bit friendlier

would be nice to have dump to output hex and ascii.

3 years agolio_listio(2): send signal even if number of jobs is zero.
Konstantin Belousov [Tue, 1 Dec 2020 22:53:33 +0000 (22:53 +0000)]
lio_listio(2): send signal even if number of jobs is zero.

Right now, if lio registered zero jobs, syscall frees lio job
structure, cleaning up queued ksi.  As result, the realtime signal is
dequeued and never delivered.

Fix it by allowing sendsig() to copy ksi when job count is zero.

PR: 220398
Reported and reviewed by: asomers
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D27421

3 years agovfs_aio.c: style.
Konstantin Belousov [Tue, 1 Dec 2020 22:46:51 +0000 (22:46 +0000)]
vfs_aio.c: style.

Mostly re-wrap conditions to split after binary ops.

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

3 years agoFix syntax
Konstantin Belousov [Tue, 1 Dec 2020 22:44:23 +0000 (22:44 +0000)]
Fix syntax

3 years agovfs_aio.c: correct comment.
Konstantin Belousov [Tue, 1 Dec 2020 22:30:32 +0000 (22:30 +0000)]
vfs_aio.c: correct comment.

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

3 years agoficl: instead of pad, emit can use local variable
Toomas Soome [Tue, 1 Dec 2020 22:28:02 +0000 (22:28 +0000)]
ficl: instead of pad, emit can use local variable

Pad in forth is used as "scratchpad" and internal implementations
should not use it. Ficl does not really follow this rule and this can fire back.
emit has no need to use pad, we can use local variable instead.

3 years agortld: bump r_debug.r_version to 1 from current 0.
Konstantin Belousov [Tue, 1 Dec 2020 22:28:01 +0000 (22:28 +0000)]
rtld: bump r_debug.r_version to 1 from current 0.

Add r_ldbase.

Requested and reviewed by: emaste
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D27429

3 years ago[arm64] Parse ACPI _PXM property on ARM64 platform
Oleksandr Tymoshenko [Tue, 1 Dec 2020 20:27:06 +0000 (20:27 +0000)]
[arm64] Parse ACPI _PXM property on ARM64 platform

Enable devices' NUMA proximity infromation parsing on ARM64 systems

Sponsored by: Ampere Computing
Submitted by: Klara, Inc.

3 years ago[arm64] Bump MAXMEMDOM value to 8 to match amd64
Oleksandr Tymoshenko [Tue, 1 Dec 2020 20:10:55 +0000 (20:10 +0000)]
[arm64] Bump MAXMEMDOM value to 8 to match amd64

On some of the server-grade ARM64 machines the number of NUMA domains is higher
than 2. When booting GENERIC kernel on such machines the SRAT parser fails
leaving the system with a single domain. To make GENERIC kernel usable on those
server, match the parameter value with the one for amd64 arch.

Reviewed by: allanjude
Differential Revision: https://reviews.freebsd.org/D27368
Sponsored by: Ampere Computing
Submitted by: Klara, Inc.

3 years agortsold: Fix multiple buffer overflows
Mark Johnston [Tue, 1 Dec 2020 19:34:44 +0000 (19:34 +0000)]
rtsold: Fix multiple buffer overflows

Approved by: so
Security: CVE-2020-25577
MFC after: now

3 years agoFix a couple of typos.
John Baldwin [Tue, 1 Dec 2020 18:57:37 +0000 (18:57 +0000)]
Fix a couple of typos.

Submitted by: rmacklem

3 years agoUSB umass: add quirk to not probe
Bjoern A. Zeeb [Tue, 1 Dec 2020 18:24:06 +0000 (18:24 +0000)]
USB umass: add quirk to not probe

Some USB WLAN devices have "on-board" storage showing up as umass
and making the root mount wait for a very long time.
The WLAN drivers know how to deal with that an issue an eject
command later when attaching themselves.
Introduce a quirk to not probe these devices as umass and avoid
hangs and confusion altogether.

Reviewed by: hselasky, imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D27434

3 years agoUse uintptr_t instead of uint64_t for pointers in stack frames.
John Baldwin [Tue, 1 Dec 2020 18:22:34 +0000 (18:22 +0000)]
Use uintptr_t instead of uint64_t for pointers in stack frames.

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

3 years agoUse uintptr_t for pointers in stack frames.
John Baldwin [Tue, 1 Dec 2020 18:08:22 +0000 (18:08 +0000)]
Use uintptr_t for pointers in stack frames.

This catches up to the changes made to struct unwind_state in r364180.

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

3 years agoMake stack_save*() more robust on MIPS.
John Baldwin [Tue, 1 Dec 2020 17:17:22 +0000 (17:17 +0000)]
Make stack_save*() more robust on MIPS.

- Validate any stack addresses read from against td_kstack before
  reading.  If an unwind operation would attempt to read outside the
  bounds of td_kstack, abort the unwind instead.

- For stack_save_td(), don't use the PC and SP from the current
  thread, instead read the PC and SP from pcb_context[].

- For stack_save(), use the current PC and SP of the current thread,
  not the values from pcb_regs (the horribly named td_frame of the
  outermost trapframe).  The result was that stack_trace() never
  logged _any_ kernel frames but only the frame from the saved
  userspace registers on entry from the kernel.

- Inline the one use of stack_register_fetch().

- Add a VALID_PC() helper macro and simplify types to remove
  excessive casts in stack_capture().

- Fix stack_capture() to work on compilers written in this century.
  Don't treat function epilogues as function prologues by skipping
  additions to SP when searching for a function start.

- Add some comments to stack_capture() and fix some style bugs.

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

3 years agoAdd a kstack_contains() helper function.
John Baldwin [Tue, 1 Dec 2020 17:04:46 +0000 (17:04 +0000)]
Add a kstack_contains() helper function.

This is useful for stack unwinders which need to avoid out-of-bounds
reads of a kernel stack which can trigger kernel faults.

Reviewed by: kib, markj
Obtained from: CheriBSD
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D27356

3 years agopf tests: Re-enable panicing tests
Kristof Provost [Tue, 1 Dec 2020 16:44:36 +0000 (16:44 +0000)]
pf tests: Re-enable panicing tests

We've fixed the vnet/epair cleanup race, so it is now safe to re-enable these
tests.

MFC after: 2 weeks
Sponsored by: Modirum MDPay

3 years agonet: Revert vnet/epair cleanup race mitigation
Kristof Provost [Tue, 1 Dec 2020 16:34:43 +0000 (16:34 +0000)]
net: Revert vnet/epair cleanup race mitigation

Revert the mitigation code for the vnet/epair cleanup race (done in r365457).
r368237 introduced a more reliable fix.

MFC after: 2 weeks
Sponsored by: Modirum MDPay

3 years agoif: Fix panic when destroying vnet and epair simultaneously
Kristof Provost [Tue, 1 Dec 2020 16:23:59 +0000 (16:23 +0000)]
if: Fix panic when destroying vnet and epair simultaneously

When destroying a vnet and an epair (with one end in the vnet) we often
panicked. This was the result of the destruction of the epair, which destroys
both ends simultaneously, happening while vnet_if_return() was moving the
struct ifnet to its home vnet. This can result in a freed ifnet being re-added
to the home vnet V_ifnet list. That in turn panics the next time the ifnet is
used.

Prevent this race by ensuring that vnet_if_return() cannot run at the same time
as if_detach() or epair_clone_destroy().

PR: 238870, 234985, 244703, 250870
MFC after: 2 weeks
Sponsored by: Modirum MDPay
Differential Revision: https://reviews.freebsd.org/D27378

3 years agovmem: Revert r364744
Mark Johnston [Tue, 1 Dec 2020 16:06:31 +0000 (16:06 +0000)]
vmem: Revert r364744

A pair of bugs are believed to have caused the hangs described in the
commit log message for r364744:

1. uma_reclaim() could trigger reclamation of the reserve of boundary
   tags used to avoid deadlock.  This was fixed by r366840.
2. The loop in vmem_xalloc() would in some cases try to allocate more
   boundary tags than the expected upper bound of BT_MAXALLOC.  The
   reserve is sized based on the value BT_MAXMALLOC, so this behaviour
   could deplete the reserve without guaranteeing a successful
   allocation, resulting in a hang.  This was fixed by r366838.

PR: 248008
Tested by: rmacklem

3 years agoMFV r368207:
Martin Matuska [Tue, 1 Dec 2020 15:53:12 +0000 (15:53 +0000)]
MFV r368207:
Update libarchive to 3.5.0

Relevant vendor changes:
  Issue #1258: add archive_read_support_filter_by_code()
  PR #1347: mtree digest reader support
  Issue #1381: skip hardlinks pointing to itself on extraction
  PR #1387: fix writing of cpio archives with hardlinks without file type
  PR #1388: fix rdev field in cpio format for device nodes
  PR #1389: completed support for UTF-8 encoding conversion
  PR #1405: more formats in archive_read_support_format_by_code()
  PR #1408: fix uninitialized size in rar5_read_data
  PR #1409: system extended attribute support
  PR #1435: support for decompression of symbolic links in zipx archives
  Issue #1456: memory leak after unsuccessful archive_write_open_filename

MFC after: 1 week

3 years agoUpdate vendor/libarchive/dist to git 833821f55b1807cac22a63a58b759a7802df2fb7
Martin Matuska [Tue, 1 Dec 2020 10:36:46 +0000 (10:36 +0000)]
Update vendor/libarchive/dist to git 833821f55b1807cac22a63a58b759a7802df2fb7

Libarchive 3.5.0

Relevant vendor changes:
  Issue #1258: add archive_read_support_filter_by_code()
  PR #1347: mtree digest reader support
  Issue #1381: skip hardlinks pointing to itself on extraction
  PR #1387: fix writing of cpio archives with hardlinks without file type
  PR #1388: fix rdev field in cpio format for device nodes
  PR #1389: completed support for UTF-8 encoding conversion
  PR #1405: more formats in archive_read_support_format_by_code()
  PR #1408: fix uninitialized size in rar5_read_data
  PR #1409: system extended attribute support
  PR #1435: support for decompression of symbolic links in zipx archives
  Issue #1456: memory leak after unsuccessful archive_write_open_filename

3 years agoRemove duplicated SV_ASLR from the elf flags.
Michal Meloun [Tue, 1 Dec 2020 09:18:18 +0000 (09:18 +0000)]
Remove duplicated SV_ASLR from the elf flags.

Reported by: lattera

3 years agoAlways use the __unused attribute even for potentially unused parameters.
Michal Meloun [Tue, 1 Dec 2020 08:52:13 +0000 (08:52 +0000)]
Always use the __unused attribute even for potentially unused parameters.

Requested by: ian, imp
MFC with: r368167

3 years agoefibootmgr: fix an incorrect error handling check
Mitchell Horne [Mon, 30 Nov 2020 22:16:11 +0000 (22:16 +0000)]
efibootmgr: fix an incorrect error handling check

efivar_device_path_to_unix_path() returns standard error codes on
failure and zero on success. Checking for a return value less than zero
means that the actual failure cases won't be handled. This could
manifest as a segfault during the subsequent call to printf().

Reviewed by: imp
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D27424

3 years agoMove inner loop logic out of sysctl_sysctl_next_ls().
Alexander V. Chernikov [Mon, 30 Nov 2020 21:59:52 +0000 (21:59 +0000)]
Move inner loop logic out of sysctl_sysctl_next_ls().

Refactor sysctl_sysctl_next_ls():
* Move huge inner loop out of sysctl_sysctl_next_ls() into a separate
 non-recursive function, returning the next step to be taken.
* Update resulting node oid parts only on successful lookup
* Make sysctl_sysctl_next_ls() return boolean success/failure instead of errno,
 slightly simplifying logic

Reviewed by: freqlabs
Differential Revision: https://reviews.freebsd.org/D27029

3 years agoRenumber NHR_* flags after NHR_IFAIF removal in r368127.
Alexander V. Chernikov [Mon, 30 Nov 2020 21:42:55 +0000 (21:42 +0000)]
Renumber NHR_* flags after NHR_IFAIF removal in r368127.

Suggested by: rpokala

3 years agoPrint at least something when failing.
Gleb Smirnoff [Mon, 30 Nov 2020 21:05:31 +0000 (21:05 +0000)]
Print at least something when failing.

3 years agowireguard: fix zfs_ copy pasta in module init macro
Matt Macy [Mon, 30 Nov 2020 20:58:42 +0000 (20:58 +0000)]
wireguard: fix zfs_ copy pasta in module init macro

Reported by: Jessica Clarke

3 years agoRemove (dead) GPL copyright code from wireguard sources
Matt Macy [Mon, 30 Nov 2020 20:54:44 +0000 (20:54 +0000)]
Remove (dead) GPL copyright code from wireguard sources

3 years agoqat: Initialize the crypto device ID to -1 instead of 0
Mark Johnston [Mon, 30 Nov 2020 20:53:45 +0000 (20:53 +0000)]
qat: Initialize the crypto device ID to -1 instead of 0

Otherwise qat_detach() may attempt to deregister an unrelated crypto
driver if an error occurs in qat_attach() before crypto_get_driverid()
is called, since 0 is a valid driver ID.

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

3 years agoqat: Fix firmware module autoloading
Mark Johnston [Mon, 30 Nov 2020 20:53:25 +0000 (20:53 +0000)]
qat: Fix firmware module autoloading

If firmware_get() fails to find a loaded firmware image, it searches for
candidate KLDs to load.  It will search for a KLD containing a module
with the same name as the requested image, and failing that, will load a
KLD with the same basename as the requested image.

The module name given by fw_stub.awk is simply "<mangled KLD name>_fw".

QAT firmware modules contain two images, neither of which match either
of the names used during lookup, so automatic loading of firmware images
after mountroot does not work.  Work around this by using the same
string for the first image name and for the KLD basename.

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

3 years agoAdd a few missed entries to ObsoleteFiles.inc:
Dimitry Andric [Mon, 30 Nov 2020 19:18:50 +0000 (19:18 +0000)]
Add a few missed entries to ObsoleteFiles.inc:

* libzfs.so was bumped from 3 to 4 in r364746
* libcap_random.so.1 was removed in r350307, but its .so symlink was not

3 years agoffs: do not read full direct blocks if they are going to be overwritten.
Konstantin Belousov [Mon, 30 Nov 2020 17:03:26 +0000 (17:03 +0000)]
ffs: do not read full direct blocks if they are going to be overwritten.

BA_CLRBUF specifies that existing context of the block will be
completely overwritten by caller, so there is no reason to spend io
fetching existing data.  We do the same for indirect blocks.

Reported by: tmunro
Reviewed by: mckusick, tmunro
Tested by: pho, tmunro
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D27353

3 years agoEnsure that threading library is initialized in pthread_mutex_init().
Konstantin Belousov [Mon, 30 Nov 2020 17:00:36 +0000 (17:00 +0000)]
Ensure that threading library is initialized in pthread_mutex_init().

We need at least thr_malloc ready.  The situation is possible e.g. in case
of libthr being listed in DT_NEEDED before some of its consumers.

Reported and tested by: lev
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

3 years agouma: Avoid allocating buckets with the cross-domain lock held
Mark Johnston [Mon, 30 Nov 2020 16:18:33 +0000 (16:18 +0000)]
uma: Avoid allocating buckets with the cross-domain lock held

Allocation of a bucket can trigger a cross-domain free in the bucket
zone, e.g., if the per-CPU alloc bucket is empty, we free it and get
migrated to a remote domain.  This can lead to deadlocks since a bucket
zone may allocate buckets from itself or a pair of bucket zones could be
allocating from each other.

Fix the problem by dropping the cross-domain lock before allocating a
new bucket and handling refill races.  Use a list of empty buckets to
ensure that we can make forward progress.

Reported by: imp, mjg (witness(9) warnings)
Discussed with: jeff
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27341

3 years agoFix compilation on head and while here:
Olivier Cochard [Mon, 30 Nov 2020 15:04:35 +0000 (15:04 +0000)]
Fix compilation on head and while here:
- remove unwanted whitespaces
- remove useless function ifphys()
- fix the Makefile to install it into /usr/bin

PR: 250133
Reviewed by: glebius, maxim
Approved by: glebius
Differential Revision: https://reviews.freebsd.org/D27155

3 years agoUnbreak r368167 in userland. Decorate unused arguments.
Michal Meloun [Mon, 30 Nov 2020 14:51:48 +0000 (14:51 +0000)]
Unbreak r368167 in userland. Decorate unused arguments.

Reported by: kp, tuexen, jenkins, and many others
MFC with: r368167

3 years agommccam: Convert some printf to CAM_DEBUG
Emmanuel Vadot [Mon, 30 Nov 2020 14:49:13 +0000 (14:49 +0000)]
mmccam: Convert some printf to CAM_DEBUG

This not not useful if you are not debuging mmccam

3 years agoarm: allwinner: aw_mmc: Add a sysctl for debuging
Emmanuel Vadot [Mon, 30 Nov 2020 14:48:50 +0000 (14:48 +0000)]
arm: allwinner: aw_mmc: Add a sysctl for debuging

Add a new hw.aw_mmc.debug sysctl to help debugging the driver.
Bit 0 will debug card changes (removal, insertion, power up/down)
Bit 1 will debug ios changes
Bit 2 will debug interrupts received
Bit 3 will debug commands sent

3 years agovt: if loader did pass the font via metadata, use it
Toomas Soome [Mon, 30 Nov 2020 11:45:47 +0000 (11:45 +0000)]
vt: if loader did pass the font via metadata, use it

The built in 8x16 font may be way too small with large framebuffer
resolutions, to improve readability, use loader provied font.

3 years agoUse function macro for sema_init() in the LinuxKPI to limit macro expansion scope.
Hans Petter Selasky [Mon, 30 Nov 2020 09:47:53 +0000 (09:47 +0000)]
Use function macro for sema_init() in the LinuxKPI to limit macro expansion scope.

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

3 years agofix vmbus_fb_mmio_res after r368168
Toomas Soome [Mon, 30 Nov 2020 08:31:41 +0000 (08:31 +0000)]
fix vmbus_fb_mmio_res after r368168

mixed efifb versus vbefb struct use did slip in by mistake.

3 years agoAdd VT driver for VBE framebuffer device
Toomas Soome [Mon, 30 Nov 2020 08:22:40 +0000 (08:22 +0000)]
Add VT driver for VBE framebuffer device

Implement vt_vbefb to support Vesa Bios Extensions (VBE) framebuffer with VT.
vt_vbefb is built based on vt_efifb and is assuming similar data for
initialization, use MODINFOMD_VBE_FB to identify the structure vbe_fb
in kernel metadata.

struct vbe_fb, is populated by boot loader, and is passed to kernel via
metadata payload.

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

3 years agoNVME: Don't try to swap data on little endian machines.
Michal Meloun [Mon, 30 Nov 2020 07:01:12 +0000 (07:01 +0000)]
NVME: Don't try to swap data on little endian machines.
These swapping functions violate BUSDMA contract - we cannot write
to armed (by bus_dmamap_sync(PRE_..)) buffers. Remove them at least
from little endian machines until a better solution will be developed.

Reviewed by: imp
MFC after: 3 weeks

3 years agoRemove RADIX_MPATH config option.
Alexander V. Chernikov [Sun, 29 Nov 2020 19:43:33 +0000 (19:43 +0000)]
Remove RADIX_MPATH config option.

ROUTE_MPATH is the new config option controlling new multipath routing
 implementation. Remove the last pieces of RADIX_MPATH-related code and
 the config option.

Reviewed by: glebius
Differential Revision: https://reviews.freebsd.org/D27244

3 years agoImport kernel WireGuard support
Matt Macy [Sun, 29 Nov 2020 19:38:03 +0000 (19:38 +0000)]
Import kernel WireGuard support

Data path largely shared with the OpenBSD implementation by
Matt Dunwoodie <ncon@nconroy.net>

Reviewed by: grehan@freebsd.org
MFC after: 1 month
Sponsored by: Rubicon LLC, (Netgate)
Differential Revision: https://reviews.freebsd.org/D26137

3 years agoReduce MAXPHYS back to 128KB on 32bit architectures.
Konstantin Belousov [Sun, 29 Nov 2020 19:06:32 +0000 (19:06 +0000)]
Reduce MAXPHYS back to 128KB on 32bit architectures.

Some of them have limited KVA, like arm, which prevents startup from
allocating needed number of large pbufs.  Other, for instance i386,
are dis-balanced enough after 4/4 that blind bump is probably harmful
because it allows for much more in-flight io than other tunables are
ready for.

Requested by: mmel
Reviewed by: emaste, mmel
Sponsored by: The FreeBSD Foundation

3 years agoStore MPIDR register in pcpu.
Michal Meloun [Sun, 29 Nov 2020 18:59:01 +0000 (18:59 +0000)]
Store MPIDR register in pcpu.

MPIDR represents physical locality of given core and it should be used as
the only viable/robust connection between cpuid (which have zero relation to
cores topology) and external description (for example  in FDT).  It can be
used for determining which interrupt is associated to given per-CPU PMU
or by scheduler for determining big/little core or cluster topology.

MFC after: 3 weeks

3 years agoiconv(1): Add EXAMPLE
Fernando Apesteguía [Sun, 29 Nov 2020 18:22:14 +0000 (18:22 +0000)]
iconv(1): Add EXAMPLE

Just a small example to show simple usage.

Approved by: manpages (0mp@)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D27385

3 years agoRemove unused options.
Michal Meloun [Sun, 29 Nov 2020 17:42:32 +0000 (17:42 +0000)]
Remove unused options.

Marvell files and their related SOC_MV_<foo> options should be cleaned up
in another pass.

3 years ago_ARM_ARCH_5E is always defined, we not support older CPUs.
Michal Meloun [Sun, 29 Nov 2020 16:44:22 +0000 (16:44 +0000)]
_ARM_ARCH_5E is always defined, we not support older CPUs.

3 years agosecurity(7): fix copy/paste error and correct aslr oids
Yuri Pankov [Sun, 29 Nov 2020 16:29:40 +0000 (16:29 +0000)]
security(7): fix copy/paste error and correct aslr oids

Submitted by: Mina Galić <me_igalic.co>
Differential Revision: https://reviews.freebsd.org/D27408

3 years agoOnly set the PCI bus end when we are reducing it
Andrew Turner [Sun, 29 Nov 2020 16:22:33 +0000 (16:22 +0000)]
Only set the PCI bus end when we are reducing it

We read the bus end value from the _CRS method. On some systems we need
to further limit it based on the MCFG table.

Support this by setting a default value, then update it if needed in the
_CRS table, and finally reduce it if it is past the end of the MCFG tabel.
This will allow for both systems that use either method to encode this
value.

This partially reverts r347929, removing the error printf.

Reviewed by: philip
Tested by: philip, Andrey Fesenko <f0andrey_gmail.com>
MFC after: 2 weeks
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D27274

3 years agoRemove orphaned configs.
Michal Meloun [Sun, 29 Nov 2020 15:39:54 +0000 (15:39 +0000)]
Remove orphaned configs.

3 years agoRemove remaining fragments of code for older already ceased ARM versions.
Michal Meloun [Sun, 29 Nov 2020 15:24:00 +0000 (15:24 +0000)]
Remove remaining fragments of code for older already ceased ARM versions.

3 years agoRemove remaining support of big endian byte order.
Michal Meloun [Sun, 29 Nov 2020 15:04:39 +0000 (15:04 +0000)]
Remove remaining support of big endian byte order.
Big endian support was ceased by removing ARMv4 sub architecture.

3 years agoIntroduce rib_walk_ext_internal() to allow iteration with rnh pointer.
Alexander V. Chernikov [Sun, 29 Nov 2020 13:54:49 +0000 (13:54 +0000)]
Introduce rib_walk_ext_internal() to allow iteration with rnh pointer.

This solves the case when rib is not yet attached/detached to/from the
 system rib array.

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

3 years agoAdd nhop_ref_any() to unify referencing nhop or nexthop group.
Alexander V. Chernikov [Sun, 29 Nov 2020 13:52:06 +0000 (13:52 +0000)]
Add nhop_ref_any() to unify referencing nhop or nexthop group.

It allows code within routing subsystem to transparently reference nexthops
 and nexthop groups, similar to nhop_free_any(), abstracting ROUTE_MPATH
 details.

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

3 years agohastd(8) assumes it has no extra file descriptors opened
Eugene Grosbein [Sun, 29 Nov 2020 13:45:53 +0000 (13:45 +0000)]
hastd(8) assumes it has no extra file descriptors opened
and aborts otherwise, so call closefrom() early.

PR: 227461
MFC after: 2 weeks

3 years agoRefactor fib4/fib6 functions.
Alexander V. Chernikov [Sun, 29 Nov 2020 13:41:49 +0000 (13:41 +0000)]
Refactor fib4/fib6 functions.

No functional changes.

* Make lookup path of fib<4|6>_lookup_debugnet() separate functions
 (fib<46>_lookup_rt()). These will be used in the control plane code
 requiring unlocked radix operations and actual prefix pointer.
* Make lookup part of fib<4|6>_check_urpf() separate functions.
 This change simplifies the switch to alternative lookup implementations,
 which helps algorithmic lookups introduction.
* While here, use static initializers for IPv4/IPv6 keys

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

3 years agoAdd tracking for rib/nhops/nhgrp objects and provide cumulative number accessors.
Alexander V. Chernikov [Sun, 29 Nov 2020 13:27:24 +0000 (13:27 +0000)]
Add tracking for rib/nhops/nhgrp objects and provide cumulative number accessors.

The resulting KPI can be used by routing table consumers to estimate the required
 scale for route table export.

* Add tracking for rib routes
* Add accessors for number of nexthops/nexthop objects
* Simplify rib_unsubscribe: store rnh we're attached to instead of requiring it up
 again on destruction. This helps in the cases when rnh is not linked yet/already unlinked.

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

3 years agobhyve: limit max GPA to VM_MAXUSER_ADDRESS_LA48.
Konstantin Belousov [Sun, 29 Nov 2020 10:32:38 +0000 (10:32 +0000)]
bhyve: limit max GPA to VM_MAXUSER_ADDRESS_LA48.

We use 4-level EPT pages, correct the upper bound.

Reviewed by: grehan
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D27402

3 years agobio aio: Destroy ephemeral mapping before unwiring page.
Konstantin Belousov [Sun, 29 Nov 2020 10:30:56 +0000 (10:30 +0000)]
bio aio: Destroy ephemeral mapping before unwiring page.

Apparently some architectures, like ppc in its hashed page tables
variants, account mappings by pmap_qenter() in the response from
pmap_is_page_mapped().

While there, eliminate useless userp variable.

Noted and reviewed by: alc (previous version)
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D27409

3 years agoRemove the pre-ARMv6 and pre-INTRNG code.
Michal Meloun [Sun, 29 Nov 2020 08:40:12 +0000 (08:40 +0000)]
Remove the pre-ARMv6 and pre-INTRNG code.
ARM has required ARMV6+ and INTRNg for some time now, so remove
always false #ifdefs and unconditionally do always true #ifdefs.

3 years agohwpstate_intel: don't unconditionally print the error message
Yuri Pankov [Sun, 29 Nov 2020 01:43:04 +0000 (01:43 +0000)]
hwpstate_intel: don't unconditionally print the error message

Actually check the wrmsr_safe() return value when setting autonomous
HWP for package.

PR: 245582
Differential Revision: https://reviews.freebsd.org/D24744

3 years agoRemove alignment requirements for KVA buffer mapping.
Alexander Motin [Sun, 29 Nov 2020 01:30:17 +0000 (01:30 +0000)]
Remove alignment requirements for KVA buffer mapping.

After r368124 pbuf_zone has extra page to handle this particular case.

3 years agoRemove aligment requirements for passthrough buffer.
Alexander Motin [Sun, 29 Nov 2020 00:57:19 +0000 (00:57 +0000)]
Remove aligment requirements for passthrough buffer.

After r368124 vmapbuf() should happily map misaligned maxphys-sized buffers
thanks to extra page added to pbuf_zone.

3 years agoRemove alignment requirements for KVA buffer mapping.
Alexander Motin [Sun, 29 Nov 2020 00:49:14 +0000 (00:49 +0000)]
Remove alignment requirements for KVA buffer mapping.

After r368124 vmapbuf() should happily map misaligned maxphys-sized buffers
thanks to extra page added to pbuf_zone.

3 years agoMark inline functions static.
Alexander Motin [Sun, 29 Nov 2020 00:35:13 +0000 (00:35 +0000)]
Mark inline functions static.

3 years agoIncrease nvme(4) maximum transfer size from 1MB to 2MB.
Alexander Motin [Sun, 29 Nov 2020 00:20:31 +0000 (00:20 +0000)]
Increase nvme(4) maximum transfer size from 1MB to 2MB.

With 4KB page size the 2MB is the maximum we can address with one page PRP.
Going further would require chaining, that would add some more complexity.

On the other side, to reduce memory consumption, allocate the PRP memory
respecting maximum transfer size reported in the controller identify data.
Many of NVMe devices support much smaller values, starting from 128KB.
To do that we have to change the initialization sequence to pull the data
earlier, before setting up the I/O queue pairs.  The admin queue pair is
still allocated for full MIN(maxphys, 2MB) size, but it is not a big deal,
since there is only one such queue with only 16 trackers.

Reviewed by: imp
MFC after: 2 weeks
Sponsored by: iXsystems, Inc.

3 years agoping: allow building without INET support
Alan Somers [Sat, 28 Nov 2020 23:24:19 +0000 (23:24 +0000)]
ping: allow building without INET support

Building without INET6 support was already possible. Now it's possible to
build ping with only INET6, or even with neither INET nor INET6.

Reported by: bz
Reviewed by: bz
MFC-With: 368045
Differential Revision: https://reviews.freebsd.org/D27394

3 years agoAdd watchdog(9) driver for the Fintek F81803 SuperIO chip
Poul-Henning Kamp [Sat, 28 Nov 2020 22:34:33 +0000 (22:34 +0000)]
Add watchdog(9) driver for the Fintek F81803 SuperIO chip

3 years agoAdd nhgrp_get_idx() as a counterpart for nhop_get_idx().
Alexander V. Chernikov [Sat, 28 Nov 2020 15:46:40 +0000 (15:46 +0000)]
Add nhgrp_get_idx() as a counterpart for nhop_get_idx().

It allows the routing-related code to reference nexthop groups by index
 instead of storing a pointer.

3 years agoCleanup nexthops request flags:
Alexander V. Chernikov [Sat, 28 Nov 2020 15:11:59 +0000 (15:11 +0000)]
Cleanup nexthops request flags:
* remove NHR_IFAIF as it was used by previous version of nexthop KPI
* update NHR_REF description

3 years agoRemove now unused armv4 and not-INTRNG files.
Michal Meloun [Sat, 28 Nov 2020 15:00:08 +0000 (15:00 +0000)]
Remove now unused armv4 and not-INTRNG files.

3 years agolibc: Add pthread_attr_get_np(3) stub, reporting ESRCH.
Konstantin Belousov [Sat, 28 Nov 2020 12:19:20 +0000 (12:19 +0000)]
libc: Add pthread_attr_get_np(3) stub, reporting ESRCH.

This seems to be required by recent clang asan.
I do not see other way than put the symbol under FBSD_1.0 version.

PR: 251112
Reported by: Andrew Stitcher <astitcher@apache.org>
Reviewed by: emaste
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D27389

3 years agoMake MAXPHYS tunable. Bump MAXPHYS to 1M.
Konstantin Belousov [Sat, 28 Nov 2020 12:12:51 +0000 (12:12 +0000)]
Make MAXPHYS tunable.  Bump MAXPHYS to 1M.

Replace MAXPHYS by runtime variable maxphys. It is initialized from
MAXPHYS by default, but can be also adjusted with the tunable kern.maxphys.

Make b_pages[] array in struct buf flexible.  Size b_pages[] for buffer
cache buffers exactly to atop(maxbcachebuf) (currently it is sized to
atop(MAXPHYS)), and b_pages[] for pbufs is sized to atop(maxphys) + 1.
The +1 for pbufs allow several pbuf consumers, among them vmapbuf(),
to use unaligned buffers still sized to maxphys, esp. when such
buffers come from userspace (*).  Overall, we save significant amount
of otherwise wasted memory in b_pages[] for buffer cache buffers,
while bumping MAXPHYS to desired high value.

Eliminate all direct uses of the MAXPHYS constant in kernel and driver
sources, except a place which initialize maxphys.  Some random (and
arguably weird) uses of MAXPHYS, e.g. in linuxolator, are converted
straight.  Some drivers, which use MAXPHYS to size embeded structures,
get private MAXPHYS-like constant; their convertion is out of scope
for this work.

Changes to cam/, dev/ahci, dev/ata, dev/mpr, dev/mpt, dev/mvs,
dev/siis, where either submitted by, or based on changes by mav.

Suggested by: mav (*)
Reviewed by: imp, mav, imp, mckusick, scottl (intermediate versions)
Tested by: pho
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D27225