]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agotcp_bbr(4): Fix a few typos in sysctl descriptions
Gordon Bergling [Sun, 2 Jan 2022 17:03:10 +0000 (18:03 +0100)]
tcp_bbr(4): Fix a few typos in sysctl descriptions

- s/measurment/measurement/

(cherry picked from commit 1b90dfa5d2b01549b51d9829206acac39a432bbb)

2 years agoreadelf: add Go Build ID ELF note support
Ed Maste [Fri, 10 Dec 2021 20:11:45 +0000 (15:11 -0500)]
readelf: add Go Build ID ELF note support

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

(cherry picked from commit ca457394fccfc7d712cd9cc6a66e574767a0a32b)

2 years agoar: deprecate -T option
Ed Maste [Wed, 29 Dec 2021 19:59:06 +0000 (14:59 -0500)]
ar: deprecate -T option

Other ar implementations (GNU, LLVM) use -T to mean thin archive
rather than use only the first fifteen characters of the archive member
name.  We support both -T and -f for this, with -f documented as an
alias of -T.

An exp-run showed that the ports invoking `ar -T` expect thin archives,
not truncated names.  Switch -f to be the documented flag for this
behaviour, and emit a warning when -T is used.

The warning will be changed to an error in the future (in main), once
ports no longer use -T.

PR: 260523 [exp-run]
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

(cherry picked from commit edadbb46065d9ee9559140b2522197fcdba57064)

2 years agoCheck cpu_softc is not NULL before dereferencing
Andrew Turner [Mon, 27 Sep 2021 11:22:15 +0000 (12:22 +0100)]
Check cpu_softc is not NULL before dereferencing

In the acpi_cpu_postattach SYSINIT function cpu_softc may be NULL, e.g.
on arm64 when booting from FDT. Check it is not NULL at the start of
the function so we don't try to dereference a NULL pointer.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 4e50efb1944bffe6ae648c8c81bd0814c18474b9)

2 years agoamdtemp: Revert related part of "Make CPU children" commit.
Alexander Motin [Wed, 1 Dec 2021 18:00:17 +0000 (13:00 -0500)]
amdtemp: Revert related part of "Make CPU children" commit.

While it still looks like previous code worked by coincidence, this
change broke things even more instead of fixing.

Reported by: avg@
MFC after: 1 week

(cherry picked from commit 94a72c5ac4285b2940e5d2c7e53d21c84023defc)

2 years agoacpi_cpu: Fix panic if some CPU devices are disabled.
Alexander Motin [Sat, 25 Sep 2021 20:54:28 +0000 (16:54 -0400)]
acpi_cpu: Fix panic if some CPU devices are disabled.

While there, remove couple unneeded global variables.

(cherry picked from commit 695323ae88c71776e131940ed7dedd25365e932f)

2 years agoMake CPU children explicitly share parent unit numbers.
Alexander Motin [Sat, 25 Sep 2021 03:25:46 +0000 (23:25 -0400)]
Make CPU children explicitly share parent unit numbers.

Before this device unit number match was coincidental and broke if I
disabled some CPU device(s).  Aside of cosmetics, for some drivers
(may be considered broken) it caused talking to wrong CPUs.

(cherry picked from commit d3a8f98acbf51e728411f10c5f179a30b9ca683c)

2 years agoacpi_cpu: Make device unit numbers match OS CPU IDs.
Alexander Motin [Sat, 25 Sep 2021 01:03:02 +0000 (21:03 -0400)]
acpi_cpu: Make device unit numbers match OS CPU IDs.

There are already APIC ID, ACPI ID and OS ID for each CPU.  In perfect
world all of those may match, but at least for SuperMicro server boards
none of them do.  Plus none of them match the CPU devices listing order
by ACPI.  Previous code used the ACPI device listing order to number
cpuX devices.  It looked nice from NewBus perspective, but introduced
4th different set of IDs. Extremely confusing one, since in some places
the device unit numbers were treated as OS CPU IDs (coretemp), but not
in others (sysctl dev.cpu.X.%location).

(cherry picked from commit c8077ccd70cfcbcccb752e89b848f098abcb9309)

2 years agobus: Cleanup device_probe_child()
Alexander Motin [Sat, 25 Sep 2021 00:27:10 +0000 (20:27 -0400)]
bus: Cleanup device_probe_child()

When device driver probe method returns 0, i.e. absolute priority, do
not remove its class from the device just to set it back few lines
later, that may change the device unit number, etc. and after which
we'd better call the probe again.

If during search we found some driver with absolute priority, we do
not need to set device driver and class since we haven't removed them
before.

It should not happen, but if second probe method call failed, remove
the driver and possibly the class from the device as it was when we
started.

Reviewed by: imp, jhb
Differential Revision: https://reviews.freebsd.org/D32125

(cherry picked from commit f73c2bbf811ba77b2fe91b5bc0cbe19e9f7eb6c4)

2 years agobus: Fix LINT / BUS_DEBUG build
Warner Losh [Fri, 24 Sep 2021 20:03:10 +0000 (14:03 -0600)]
bus: Fix LINT / BUS_DEBUG build

Fix 0389e9be63c5e for LINT built. Removed an arg only from code
under BUS_DEBUG w/o rebuilding LINT...

Sponsored by: Netflix
Fixes: 0389e9be63c5e24ecedbb366c5682ddc2ff4de60
(cherry picked from commit 67a9e76da6e69ceee94a3b9c0fd490ed2f781938)

2 years agobus: retire DF_REBID
Warner Losh [Fri, 24 Sep 2021 18:10:18 +0000 (12:10 -0600)]
bus: retire DF_REBID

I did DF_REBID to allow for 'hoover' drivers that would attach to
otherwise unattached devices in the tree. This notion didn't catch on as
it was tricky to make work well and it was easier to just publish a /dev
node of some flavor by the parent device. It's been nothing but dead
weight for a long time.

Reviewed by: mav
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D32056

(cherry picked from commit 0389e9be63c5e24ecedbb366c5682ddc2ff4de60)

2 years agoAllow ddb and dtrace use the DMAP region on arm64
Andrew Turner [Tue, 21 Sep 2021 17:10:57 +0000 (17:10 +0000)]
Allow ddb and dtrace use the DMAP region on arm64

When writing to memory on arm64 we may be trying to be accessing a
read-only page. In this case try to access via the DMAP region to
get a writable location.

While here simplify writing data in DDB and stop trashing the size as
it is passed into the cache handling functions.

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32053

(cherry picked from commit 3d2533f5c29fbf6e63c5e408ba13c2294a7612fd)

2 years agoAdd atomic_testandset_acq_* on arm64
Andrew Turner [Mon, 20 Dec 2021 13:49:59 +0000 (13:49 +0000)]
Add atomic_testandset_acq_* on arm64

We only need to include sys/_atomic_subword.h on arm64 to provide
atomic_testandset_acq_long. Add an implementation in the arm64 atomic.h
based on the existing atomic_testandset macro.

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

(cherry picked from commit 02c16e2174baa756997600a8139f19f218da0a8f)

2 years agoAdd an loader command on arm64 to sync the cache
Andrew Turner [Mon, 20 Dec 2021 13:42:15 +0000 (13:42 +0000)]
Add an loader command on arm64 to sync the cache

On boot we don't need to perform any CPU cache management when the IDC
and DIC fields in the ctr_el0 register are set. Add a command to tell
loader to ignore these fields. This could be useful, for example, if the
hardware is misreporting the values and we are missing a quirk to enable
it.

It is not expected this will be needed, but is only intended as a
workaround to ensure the kernel can still boot.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit c399283c71e310e1573e8d27f9cb9d27a4ea3376)

2 years agoDon't sync the I/D caches when they are coherent
Andrew Turner [Fri, 17 Dec 2021 09:33:57 +0000 (09:33 +0000)]
Don't sync the I/D caches when they are coherent

In the arm64 loader we need to syncronise the I and D caches. On some
newer CPUs the I and D caches are coherent so we don't need to perform
these operations.

While here remove the arguments to cpu_inval_icache as they are unneeded.

Reported by: cperciva
Tested by: cperciva
Sponsored by: Innovate UK

(cherry picked from commit c1381f07f61a66979f1569995f37f2a0413c0413)

2 years agoocs_fc: Add lancer G7 to the supported hardware in the man page.
Ram Kishore Vegesna [Fri, 24 Dec 2021 07:24:27 +0000 (12:54 +0530)]
ocs_fc: Add lancer G7 to the supported hardware in the man page.

Reviewed by: mav
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D33668

(cherry picked from commit f5e24f24c7cc217dbe328c1181b568b893da5dd1)

ocs_fc: Updated man page date.

MFC after: 3 days

(cherry picked from commit 99948907e3cbe58c2e3e27b19c79793db9b21ca0)

2 years agowpa: Import wpa_supplicant/hostapd commit 14ab4a816
Cy Schubert [Thu, 2 Dec 2021 23:00:32 +0000 (15:00 -0800)]
wpa: Import wpa_supplicant/hostapd commit 14ab4a816

This is the November update to vendor/wpa committed upstream 2021-11-26.

(cherry picked from commit 4b72b91a7132df1f77bbae194e1071ac621f1edb)

2 years agontp: Revert "Disable stack gap for ntpd during build."
Cy Schubert [Mon, 16 Aug 2021 14:46:31 +0000 (07:46 -0700)]
ntp: Revert "Disable stack gap for ntpd during build."

This reverts commit af949c590bd8a00a5973b5875d7e0fa6832ea64a because
889b56c8cd84c9a9f2d9e3b019c154d6f14d9021 fixes the underlying problem.

(cherry picked from commit 733a832fb515ef9ebf9d584896962fd28e714d0b)

2 years agontp: Revert "Disable ntpd stack gap. When ASLR with STACK GAP != 0 ntpd suffers SIGSEGV."
Cy Schubert [Mon, 16 Aug 2021 15:05:50 +0000 (08:05 -0700)]
ntp: Revert "Disable ntpd stack gap. When ASLR with STACK GAP != 0 ntpd suffers SIGSEGV."

This reverts commit 55263180628a386ad38b4b6621919220b137f770 because the
underlying problem was fixed by 889b56c8cd84c9a9f2d9e3b019c154d6f14d9021.

(cherry picked from commit fc393054398ea50fb0cee52704e9385afe888b48)

2 years agotests/libalias: Portrange
Lutz Donnerhacke [Sat, 3 Jul 2021 22:28:20 +0000 (00:28 +0200)]
tests/libalias: Portrange

Test ranges of allowed ports for aliasing.
 - Explicit default like ipfw(8) is doing
 - Regular range
 - Exhausting a very small range
 - Recovery

Includes a fix of an utility macro, which was not used before.

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

(cherry picked from commit 2c733b50c5a99cbe4f6eef437e1e3efd720ba306)

2 years agoaw_spi: improve I/O stability
Andriy Gapon [Mon, 20 Dec 2021 10:40:17 +0000 (12:40 +0200)]
aw_spi: improve I/O stability

This driver does not use DMA at the moment, so some care is needed to
prevent TX FIFO underruns and RX FIFO overflows.
Several improvements are done in oder to minimize chances of those.

First, the interrupt handling is moved to a filter to minimize latency.
Second, FIFO trigger thresholds are configured for both FIFOs.
The TX FIFO threshold is set to 3/4-th of its size and the RX FIFO
threshold is set to 1/4-th of its size.
The interrupt conditions are changed from the empty FIFO and full FIFO
for the TX and RX correspondingly to going below and above the thresholds.

While here I renamed AW_SPI_IER_RF_ERQ to AW_SPI_IER_RF_RDY which is
closer to what the documentation uses, RF_RDY_INT_EN in the interrupt
control register and RX_RDY in the interrupt status register.

(cherry picked from commit 08ff54dc5b5de85580044167e1714fb75df8e44f)

2 years agonfs: don't truncate directory cookies to 32-bits in the NFS server
Alan Somers [Mon, 13 Dec 2021 03:57:14 +0000 (20:57 -0700)]
nfs: don't truncate directory cookies to 32-bits in the NFS server

In NFSv2, the directory cookie was 32-bits.  NFSv3 widened it to
64-bits and SVN r22521 widened the corresponding argument in
VOP_READDIR, but FreeBSD's NFS server continued to treat the cookies as
32-bits, and 0-extended to fill the field on the wire.  Nobody ever
noticed, because every in-tree file system generates cookies that fit
comfortably within 32-bits.

Also, have better type safety for txdr_hyper.  Turn it into an inline
function that type-checks its arguments.  Prevents warnings about
shift-count-overflow.

PR: 260375
Reviewed by: rmacklem
Differential Revision: https://reviews.freebsd.org/D33404

(cherry picked from commit 32fbc5d824f51f97220bc5c61a23e0bf3ff2b470)

2 years agofusefs: invalidate the cache during copy_file_range
Alan Somers [Sun, 5 Dec 2021 20:39:10 +0000 (13:39 -0700)]
fusefs: invalidate the cache during copy_file_range

FUSE_COPY_FILE_RANGE instructs the server to write data to a file.
fusefs must invalidate any cached data within the written range.

PR: 260242
Reviewed by: pfg
Differential Revision: https://reviews.freebsd.org/D33280

(cherry picked from commit 41ae9f9e644d1196bebacdb3748670f36b354384)

2 years agofusefs: inline fuse_io_dispatch
Alan Somers [Sun, 5 Dec 2021 21:25:17 +0000 (14:25 -0700)]
fusefs: inline fuse_io_dispatch

This function was always confusing, because it created an H-shaped
callgraph: two functions called in and left via different paths based on
which which called.

(cherry picked from commit dc433e1530af26b0430d66c06c342889e9609590)

2 years agofusefs: correctly handle an inode that changes file types
Alan Somers [Mon, 6 Dec 2021 05:43:17 +0000 (22:43 -0700)]
fusefs: correctly handle an inode that changes file types

Correctly handle the situation where a FUSE server unlinks a file, then
creates a new file of a different type but with the same inode number.
Previously fuse_vnop_lookup in this situation would return EAGAIN.  But
since it didn't call vgone(), the vnode couldn't be reused right away.
Fix this by immediately calling vgone() and reallocating a new vnode.

This problem can occur in three code paths, during VOP_LOOKUP,
VOP_SETATTR, or following FUSE_GETATTR, which usually happens during
VOP_GETATTR but can occur during other vops, too.  Note that the correct
response actually doesn't depend on whether the entry cache has expired.
In fact, during VOP_LOOKUP, we can't even tell.  Either it has expired
already, or else the vnode got reclaimed by vnlru.

Also, correct the error code during the VOP_SETATTR path.

PR: 258022
Reported by: chogata@moosefs.pro
Reviewed by: pfg
Differential Revision: https://reviews.freebsd.org/D33283

(cherry picked from commit 25927e068fcbcac0a5111a881de723bd984b04b3)

2 years agofusefs: better debugging for FUSE_RENAME in the tests
Alan Somers [Fri, 3 Dec 2021 03:26:27 +0000 (20:26 -0700)]
fusefs: better debugging for FUSE_RENAME in the tests

(cherry picked from commit c2d342c509065bee6392624e95b75cf7b3bb9c45)

2 years agolorder: add note that it is no longer required
Ed Maste [Mon, 20 Dec 2021 17:57:34 +0000 (12:57 -0500)]
lorder: add note that it is no longer required

Use of lorder(1) is not required by contemporary linkers.

The GNU coreutils manual[1] has a good description of the use of lorder
and tsort:

    This whole procedure has been obsolete since about 1980, because
    Unix archives now contain a symbol table (traditionally built by
    ranlib, now generally built by ar itself), and the Unix linker uses
    the symbol table to effectively make multiple passes over an archive
    file.

See 0e1e341b486c for some more details.

[1] https://www.gnu.org/software/coreutils/manual/html_node/tsort-background.html

PR: 259254 [exp-run]
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 3e01ee76f2042fe07ad5cf8edeb5065bc0aba320)

2 years agofsutil: forward declare struct fstab
Warner Losh [Thu, 16 Dec 2021 02:38:28 +0000 (19:38 -0700)]
fsutil: forward declare struct fstab

Fix the build by forward declaring struct fstab.

Sponsored by: Netflix

(cherry picked from commit 7090cba410b3fcaa00d75e86eacd636501b1494b)

2 years agoUpdate fsck(8) to ignore failures from a check program for a filesystem
Kirk McKusick [Thu, 16 Dec 2021 00:51:55 +0000 (16:51 -0800)]
Update fsck(8) to ignore failures from a check program for a filesystem
when the fstab(5) entry for the filesystem has the "failok" attribute.

PR:           246201
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D33424

(cherry picked from commit c72372c693b36058b58a525981e833515ce8e441)

2 years agoxen/blkfront: Remove CTLFLAG_NEEDGIANT from sysctl.
Alexander Motin [Sun, 26 Dec 2021 02:24:24 +0000 (21:24 -0500)]
xen/blkfront: Remove CTLFLAG_NEEDGIANT from sysctl.

It only converts bit field into string.  It does not need locking.

MFC after: 1 week

(cherry picked from commit 54daceab555cb56765a8d4e63071ea44cd877f53)

2 years agoamd64 sigtramp: comment-out annotations for registers with DWARF number >= 32
Konstantin Belousov [Sun, 2 Jan 2022 18:39:07 +0000 (20:39 +0200)]
amd64 sigtramp: comment-out annotations for registers with DWARF number >= 32

(cherry picked from commit 642f77be1d10b57cd7635573aa8a3757913778ad)

2 years agoEnforce that vdso does not contain runtime relocations
Konstantin Belousov [Wed, 1 Dec 2021 00:35:26 +0000 (02:35 +0200)]
Enforce that vdso does not contain runtime relocations

(cherry picked from commit d49b75d0d67f86265cfe9b8c83d3749c4a8d3e14)

2 years agoEnforce that vdso does not consume too much from the shared page
Konstantin Belousov [Thu, 18 Nov 2021 01:20:08 +0000 (03:20 +0200)]
Enforce that vdso does not consume too much from the shared page

(cherry picked from commit b0e0b4e7b3795e9beb0cddcfd75261cc9327b5b0)

2 years agoamd64 ia32 vdso: add unwind annotations to the signal trampoline
Konstantin Belousov [Mon, 15 Nov 2021 18:30:48 +0000 (20:30 +0200)]
amd64 ia32 vdso:  add unwind annotations to the signal trampoline

(cherry picked from commit 8a4bd7f818a0e361876ab05d49fd04e28ce05357)

2 years agoamd64 native vdso: add unwind annotations to the signal trampoline
Konstantin Belousov [Mon, 15 Nov 2021 18:29:45 +0000 (20:29 +0200)]
amd64 native vdso: add unwind annotations to the signal trampoline

(cherry picked from commit 5b8918fac6fa9c150f68a0ec0805385ee7029ec3)

2 years agoAdd kern.elf{32,64}.vdso knobs to enable/disable vdso preloading
Konstantin Belousov [Thu, 25 Nov 2021 01:31:27 +0000 (03:31 +0200)]
Add kern.elf{32,64}.vdso knobs to enable/disable vdso preloading

(cherry picked from commit eb029587481e8d6f610eb31d7f50d34b9240f2f2)

2 years agovdso for ia32 on amd64
Konstantin Belousov [Sun, 14 Nov 2021 00:26:55 +0000 (02:26 +0200)]
vdso for ia32 on amd64

(cherry picked from commit 98c8b6252496e874d337d9a7b565d9037609168f)

2 years agortld: load preloaded vdso
Konstantin Belousov [Thu, 11 Nov 2021 18:07:44 +0000 (20:07 +0200)]
rtld: load preloaded vdso

(cherry picked from commit c210ef1347929cb3a0f46cdfdb3d4ad738e3af74)

2 years agoFix assert check for SV_DSO_SIG in exec_sysvec_init_secondary()
Justin Hibbits [Thu, 9 Dec 2021 04:50:10 +0000 (22:50 -0600)]
Fix assert check for SV_DSO_SIG in exec_sysvec_init_secondary()

(cherry picked from commit d2de68811a80bffe20040592dca194238c5a5c86)

2 years agoPass vdso address to userspace
Konstantin Belousov [Thu, 11 Nov 2021 17:29:24 +0000 (19:29 +0200)]
Pass vdso address to userspace

(cherry picked from commit 01c77a436e35d6dc9660ec7bac477946f563c99d)

2 years agoamd64: wrap 64bit sigtramp into vdso
Konstantin Belousov [Fri, 5 Nov 2021 08:07:24 +0000 (10:07 +0200)]
amd64: wrap 64bit sigtramp into vdso

(cherry picked from commit ab4524b3d7fba872a143b03c9346cb04c3670efa)

2 years agoRemove bogus cast from exec_sysvec_init().
Dmitry Chagin [Tue, 20 Jul 2021 06:54:09 +0000 (09:54 +0300)]
Remove bogus cast from exec_sysvec_init().

(cherry picked from commit b39fa4770dd19ff32b2d70622521135dd384c7c1)

2 years agoModify exec_sysvec_init() to allow non-native abi to setup their sysentvecs.
Dmitry Chagin [Tue, 20 Jul 2021 06:53:21 +0000 (09:53 +0300)]
Modify exec_sysvec_init() to allow non-native abi to setup their sysentvecs.

(cherry picked from commit 21629e2a456446bff101813a16f8cba046f44176)

2 years agoamd64 get_mcontext(): third argument to get_fpcontext() is a pointer
Konstantin Belousov [Sat, 1 Jan 2022 03:55:59 +0000 (05:55 +0200)]
amd64 get_mcontext(): third argument to get_fpcontext() is a pointer

(cherry picked from commit 76ef4f6348ccad73317ce2d10ab7a78d8591ba1a)

2 years agoitimers: strip unused bits from struct itimer and struct itimers
Konstantin Belousov [Mon, 27 Dec 2021 18:29:22 +0000 (20:29 +0200)]
itimers: strip unused bits from struct itimer and struct itimers

(cherry picked from commit 23ba59fbfb6ad580c4f185ffea2fa8a32b4d131d)

2 years agoitimers_alloc: no need to initialize its_timers array
Konstantin Belousov [Mon, 27 Dec 2021 18:32:01 +0000 (20:32 +0200)]
itimers_alloc: no need to initialize its_timers array

(cherry picked from commit 3f1570847831e6dbcafc1f416f96404bf66048f2)

2 years agoAvoid emitting popcnt in libclang_rt.fuzzer*.a if unsupported
Dimitry Andric [Thu, 30 Dec 2021 09:53:25 +0000 (10:53 +0100)]
Avoid emitting popcnt in libclang_rt.fuzzer*.a if unsupported

Since popcnt is only supported by CPUTYPE=nehalem and later, ensure that
this instruction is only emitted when appropriate. Otherwise, programs
using the library can abort with SIGILL.

See also: https://github.com/llvm/llvm-project/issues/52893

PR: 258156
Reported by: Eric Rucker <bhtooefr@bhtooefr.org>
MFC after: 3 days

(cherry picked from commit 133180557479cd9676758e6f3f93a9d3e1c6b532)

2 years agolibc: Fix build with -DNS_REREAD_CONF.
Alexander Motin [Wed, 29 Dec 2021 22:00:17 +0000 (17:00 -0500)]
libc: Fix build with -DNS_REREAD_CONF.

MFC after: 3 days

(cherry picked from commit 62ed2d0152dce6da883fef753e0995e6d85e0cf1)

2 years agofd: Initialize more export_fd_buf fields in kern_proc_cwd_out()
Mark Johnston [Thu, 16 Dec 2021 21:53:59 +0000 (16:53 -0500)]
fd: Initialize more export_fd_buf fields in kern_proc_cwd_out()

In particular, we need to initialize efbuf->flags, since
export_vnode_to_sb() loads that field.  This was mostly harmless since
the flag only determines whether the output kinfo_file is packed, and
KERN_PROC_CWD only ever emits a single kinfo_file anyway.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 327060bd7799e5d4376693fba770a17b79e5a38d)

2 years agounix: Increase the default datagram recv buffer size
Mark Johnston [Fri, 17 Dec 2021 15:59:29 +0000 (10:59 -0500)]
unix: Increase the default datagram recv buffer size

syslog(3) was recently change to support larger messages, up to 8KB.
Our syslogd handles this fine, as it adjusts /dev/log's recv buffer to a
large size.  rsyslog, however, uses the system default of 4KB.  This
leads to problems since our syslog(3) retries indefinitely when a send()
returns ENOBUFS, but if the message is large enough this will never
succeed.

Increase the default recv buffer size for datagram sockets to support
8KB syslog messages without requiring the logging daemon to adjust its
buffers.

PR: 260126
Reviewed by: asomers
Sponsored by: The FreeBSD Foundation

(cherry picked from commit d157f2627b238ba38d1cad36f1aa165c42ce91ee)

2 years agoktls: Add a regression test to exercise socket error handling
Mark Johnston [Fri, 17 Dec 2021 16:00:19 +0000 (11:00 -0500)]
ktls: Add a regression test to exercise socket error handling

Prior to commit 916c61a5ed37 ("Fix handling of errors from
pru_send(PRUS_NOTREADY)") this test triggered a kernel panic due to an
mbuf double free.

Reviewed by: jhb
Sponsored by: The FreeBSD Foundation

(cherry picked from commit ee5686c614ba7e11e8586b2e5b02dfc550679e96)

2 years agoiwlwifi: attach to the build
Bjoern A. Zeeb [Mon, 27 Dec 2021 18:46:04 +0000 (18:46 +0000)]
iwlwifi: attach to the build

Add iwlwifi and iwlwififw to the module builds.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 7d4394cbe7072fff75a8fb94e0871c1408213f09)

2 years agoiwlwifi: plug memory modified after free
Bjoern A. Zeeb [Mon, 27 Dec 2021 17:42:51 +0000 (17:42 +0000)]
iwlwifi: plug memory modified after free

In certain situations we saw a memory modified after free.  This was
tracked down to a pointer not NULLed after free and used in a different
code path.  It is unclear how the race happens pending further
investigation but setting the pointer to NULL after free and adding a
check in the 2nd code path handling the case gracefully helps for now.

While here improve another debug messge in sta handling.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 586c8e32330591693c5fca4e089d90340b313f5d)

2 years agoiwlwifi: cherry-pick fixes from upstream iwlwifi-next
Bjoern A. Zeeb [Mon, 27 Dec 2021 17:41:19 +0000 (17:41 +0000)]
iwlwifi: cherry-pick fixes from upstream iwlwifi-next

Cherry-pick f973795a8d19cbf3d03807704eb7c6ff65788d5a (Fix a double free
in iwl_txq_dyn_alloc_dma), db66abeea3aefed481391ecc564fb7b7fb31d742
(synchronize with FW after multicast commands),
d5d8ee526d1401173ad1261c3b6388a4f947e0a3 (remove session protection
upon station removal), and 8e967c137df3b236d2075f9538cb888129425d1a
(avoid clearing a just saved session protection id).

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 8f06a2b550c6288b48996036c325a1999780cb6a)

2 years agoiwlwifi: add man pages
Bjoern A. Zeeb [Mon, 27 Dec 2021 17:40:02 +0000 (17:40 +0000)]
iwlwifi: add man pages

Add and hook up man pages for iwlwifi and iwlwififw and install a copy
of the firmware license to /usr/share/docs/legal so it will always be
shipped with the installed system.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 5a02ae5e8f2d74b7ac20fa2e0cd98c66d934905b)

2 years agoiwlwifi: turn off broadcast filtering for now
Bjoern A. Zeeb [Mon, 27 Dec 2021 17:37:41 +0000 (17:37 +0000)]
iwlwifi: turn off broadcast filtering for now

Turn off broadcast filtering in iwlwifi for now as it gives me
or rather the firmware headaches.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit c6ea5aed79a33ce3482c4e3fa2bf56a9ee495815)

2 years agoiwlwifi: also depend on linuxkpi_wlan
Bjoern A. Zeeb [Mon, 27 Dec 2021 17:36:04 +0000 (17:36 +0000)]
iwlwifi: also depend on linuxkpi_wlan

The 802.11 compat code is split off linuxkpi.ko into linuxkpi_wlan.ko
in case it is built as a module.  Depend on that.
While here adjust our module to a longer version to avoid conflicts.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 81ff67ffbec066bc5014a64e67de0219d943156a)

2 years agoiwlwifi: remove copyright and license from Makefiles
Bjoern A. Zeeb [Mon, 27 Dec 2021 17:34:40 +0000 (17:34 +0000)]
iwlwifi: remove copyright and license from Makefiles

We do not generally protect the Makefiles like this.
Remove the details and go with project style.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit ca8bf0e8d68398b1f1f50dad1432130360b0bbdc)

2 years agoLinuxKPI: add 802.11 compat code
Bjoern A. Zeeb [Sun, 26 Dec 2021 18:52:51 +0000 (18:52 +0000)]
LinuxKPI: add 802.11 compat code

Add 802.11 compat code for mac80211 and to a minimal degree cfg80211.
This allows us to compile and use basic functionality of wireless
drivers such as iwlwifi.

This is a constant work in progress but having it in the tree will
allow others to test and more easy to track changes and avoid having
snapshots no longer applying to branches.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 6b4cac814e32f3b307720d6b880939fb1f21f3ac)

2 years agoLinuxKPI: import beginning of a new version of netdevice.h
Bjoern A. Zeeb [Sun, 26 Dec 2021 18:29:29 +0000 (18:29 +0000)]
LinuxKPI: import beginning of a new version of netdevice.h

Import a netdevice update complementing the last remaining bits of
the old ifnet derived implementation.  Along add a (for now) task
based NAPI implementation.

This is the minimal set of chnages which are needed for the initial
support of wireless drivers.  The NAPI implementation has an option to
still switch to "direct dispatch" as it had been used by these drivers
before not relying on a deferred context along with some printf tracing.
This has been helpful in the last weeks for debugging and will be
cleaned once we have had broader testing and are sure this is fine as-is.
Should we need a more time-sensitive or load-sensitive response
in the future we can always switch to something more sophisticated.

Sponsored by: The FreeBSD Foundation
X-Differential Revision: D33075 (abandoned without feedback a while ago)

(cherry picked from commit d105895844848ddba85d686e03e0d14c03ad4eb4)

2 years agoLinuxKPI: add a work-in-progress skbuff implementation
Bjoern A. Zeeb [Sun, 26 Dec 2021 18:26:26 +0000 (18:26 +0000)]
LinuxKPI: add a work-in-progress skbuff implementation

This is a work-in-progress implementation of sk_buff compat code
used for wireless drivers only currently.
Bring in this version of the code as it has proven to be good enough
to have packets going for a few months.

The current implementation has several drawbacks including the need
for us to copy data between sk_buffs and mbufs.
Do not rely on the internals of this implementation.  They are highly
likely to change as we will improve the integration to FreeBSD mbufs.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 49ed6e979c3b327ae466a559884802d901aa5792)

2 years agonet80211: adjust a printf to toeee80211_note
Bjoern A. Zeeb [Sun, 26 Dec 2021 17:26:58 +0000 (17:26 +0000)]
net80211: adjust a printf to toeee80211_note

Throughout net80211 there are multiple ways to log (debugging)
information.  Start to clenaup one as I kept hitting it to harmonize
the output.  The more we get away from printfs into either wrapper
functions or macros the more likely we can use holistic systematic
tracing in the future.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 2e59c9c7f01e9e8878664f59438d1ed6c27d0e2b)

2 years agonet80211: add debugging information
Bjoern A. Zeeb [Sun, 26 Dec 2021 17:25:57 +0000 (17:25 +0000)]
net80211: add debugging information

Add more STATE / DEBUG probes and enhance the output of one in order
to track state changes triggered by "ack" (or not).
This helped to narrow down causes from drivers or the LinuxKPI 802.11
compat framework which kept us in a scan -> auth -> scan loop.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 04efa18f83d12dca2b69dd4cdb626f92e5ce64f0)

2 years agonet80211: format debug functions as single line
Bjoern A. Zeeb [Sun, 26 Dec 2021 17:24:04 +0000 (17:24 +0000)]
net80211: format debug functions as single line

Making use of the debug output was hard given debug lines were run in
parts through vlog (if_printf) and in (multiple) parts through printf(s).

Like some of the functions alreay have, use a local buffer to format
the string and then use a single if_printf;  in addition given these
functions are debug-only, add an extra printf in case we find our
buffers still to be too small so we can adjust for the future.
We already found that 128 characters are to short for some log messages.
Bump the buffer sizes collectively to 256 characters which also is
the maximum of if_vlog() so getting longer would need further changes
elsewhere.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 04435a1b145b310f8be62dd453e2f0c69d764cca)

2 years agonet80211: fix debug printf
Bjoern A. Zeeb [Thu, 23 Dec 2021 15:21:32 +0000 (15:21 +0000)]
net80211: fix debug printf

We are printing %p in _db_show_sta(), there is no need to prefix it
with 0x again to get a 0x0x...

Spsonsored by: The FreeBSD Foundation

(cherry picked from commit e51b46cefbfaab08f6e5cb402ebecbf1c0cba3c8)

2 years agomodules: increase MAXMODNAME and provide backward compat
Bjoern A. Zeeb [Wed, 17 Nov 2021 19:35:46 +0000 (19:35 +0000)]
modules: increase MAXMODNAME and provide backward compat

With various firmware files used by graphics and wireless drivers
we are exceeding the current 32 character module name (file path
in kldxref) length.
In order to overcome this issue bump it to the maximum path length
for the next version.
To be able to MFC provide backward compat support for another version
of the struct as the offsets for the second half change due to the
array size increase.

MAXMODNAME being defined to MAXPATHLEN needs param.h to be
included first.  With only 7 modules (or LinuxKPI module.h) not
doing that adjust them rather than including param.h in module.h [1].

Reported by: Greg V (greg unrelenting.technology)
Sponsored by: The FreeBSD Foundation
Suggested by: imp [1]
Reviewed by: imp (and others to different level)
Differential Revision: https://reviews.freebsd.org/D32383

(cherry picked from commit df38ada2931f95d07b65b19fcfb4c9845d656ba9)

2 years agoiwlwifi: import Intel's iwlwifi/mvm driver.
Bjoern A. Zeeb [Sun, 28 Nov 2021 18:35:53 +0000 (18:35 +0000)]
iwlwifi: import Intel's iwlwifi/mvm driver.

Over the past few months we published multiple snapshots for this
Linux derived driver and it has become fairly stable in terms of
minimal local changes needed for new updates.

The current version is based on iwlwifi-next update at
cbaa6aeedee5f92dafa5982eceea2a1f98ce4f7d with the addition of
a hand full of files replaced for FreeBSD.

Given the lack of full license texts on non-local files this is
imported under the draft policy for handling SPDX files (D29226). [1]

Do not yet hook this to the build until the remaining compat code
is all in.  Along with the firmware import this will make publishing
the last bits and final testing a lot easier.

Sponsored by:   The FreeBSD Foundation
Approved by:    core (imp) [1]

(cherry picked from commit bfcc09ddd422c95a1a2e4e794b63ee54c4902398)

2 years agoiwlwifi: import firmware for Intel iwlwifi/mvm supported chipsets.
Bjoern A. Zeeb [Sun, 28 Nov 2021 18:34:19 +0000 (18:34 +0000)]
iwlwifi: import firmware for Intel iwlwifi/mvm supported chipsets.

Import the most recent versions of the firmware images for iwlwifi
chipsets supported by the "mvm" sub-driver.
This is based on linux-firmware at f5d519563ac9d2d1f382a817aae5ec5473811ac8.
The license of the firmware matches the previous iwnfw(4) and
iwmfw(4) firmware files and you can find a copy in
sys/contrib/dev/iwlwififw/LICENCE.iwlwifi_firmware .

Add build infrastructure to create the .ko files but do not yet hook
it up to the build until all parts are in the tree.
There is an open issue concerning kldxref that we need to resolve
(D32383).

Sponsored by: The FreeBSD Foundation

(cherry picked from commit f4c129f5fb1669b284d76a838b1e509f97c2d299)

2 years agoLinuxKPI: USB return possible error from suspend/resume
Bjoern A. Zeeb [Wed, 24 Nov 2021 21:28:46 +0000 (21:28 +0000)]
LinuxKPI: USB return possible error from suspend/resume

USB suspend/resume cannot fail so we never returned the error which
resulted in a -Wunused-but-set-variable warning.
Initialize the return variable and return a possible error possibly
triggering a printf upstream to at least have a trace of the problem.
This also fixes the warning.

Suggested by: hselasky
Sponsored by: The FreeBSD Foundation
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D33107

(cherry picked from commit 943df073a348bcb1e701c3677536f913761d4123)

2 years agoLinuxKPI: fix -Wunused-but-set-variable warnings
Bjoern A. Zeeb [Wed, 24 Nov 2021 21:20:52 +0000 (21:20 +0000)]
LinuxKPI: fix -Wunused-but-set-variable warnings

Handle write-only variables by removing the unused return value from void
functions or removing the unused variables entirely.

Sponsored by: The FreeBSD Foundation
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D33107

(cherry picked from commit 7043359ce3c1e56ed55c8b41867a14a418511a05)

2 years agostd.nodebug: turn off net80211 debugging as well
Bjoern A. Zeeb [Wed, 24 Nov 2021 18:03:48 +0000 (18:03 +0000)]
std.nodebug: turn off net80211 debugging as well

Add IEEE80211_DEBUG to turn off some net80211 debbugging for
no-debug builds.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 1c55b0ce1c944c0b1b7657b7efa151cd25a74f5b)

2 years agonet80211: fix -Wunused-but-set-variable warnings
Bjoern A. Zeeb [Wed, 24 Nov 2021 17:36:48 +0000 (17:36 +0000)]
net80211: fix -Wunused-but-set-variable warnings

Put the offending variables under the appropriate #ifdefs
(mostly IEEE80211_DEBUG, in one case IEEE80211_SUPPORT_SUPERG, and
in two cases under __notyet__ to revisit why these had been left
there but not used).

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 05ea7a3e5e748547a0229efa80be0e71eaf84f52)

2 years agonet80211: radiotap add another define
Bjoern A. Zeeb [Thu, 18 Nov 2021 14:57:09 +0000 (14:57 +0000)]
net80211: radiotap add another define

Add a define needed by latest iwlwifi-next.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit f7c526ab3f23e5663cb8477c3dfb41a89de2d4cd)

2 years agolibthr: Use kern.stacktop for thread stack calculation.
Dawid Gorecki [Wed, 13 Oct 2021 19:06:05 +0000 (21:06 +0200)]
libthr: Use kern.stacktop for thread stack calculation.

Use the new kern.stacktop sysctl to retrieve the address of stack top
instead of kern.usrstack. kern.usrstack does not have any knowledge
of the stack gap, so this can cause problems with thread stacks.
Using kern.stacktop sysctl should fix most of those problems.
kern.usrstack is used as a fallback when kern.stacktop cannot be read.

Rename usrstack variables to stacktop to reflect this change.

Fixes problems with firefox and thunderbird not starting with
stack gap enabled.

PR: 239873
Reviewed by: kib
Obtained from: Semihalf
Sponsored by: Stormshield
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D31898

(cherry picked from commit 78df56ccfcb40013a3e6904bd6d39836220c3550)

2 years agokern_exec: Add kern.stacktop sysctl.
Dawid Gorecki [Wed, 13 Oct 2021 19:03:37 +0000 (21:03 +0200)]
kern_exec: Add kern.stacktop sysctl.

With stack gap enabled top of the stack is moved down by a random
amount of bytes. Because of that some multithreaded applications
which use kern.usrstack sysctl to calculate address of stacks for
their threads can fail. Add kern.stacktop sysctl, which can be used
to retrieve address of the stack after stack gap is applied to it.
Returns value identical to kern.usrstack for processes which have
no stack gap.

Reviewed by: kib
Obtained from: Semihalf
Sponsored by: Stormshield
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D31897

(cherry picked from commit a97d697122da2bfb0baae5f0939d118d119dae33)

2 years agosetrlimit: Take stack gap into account.
Dawid Gorecki [Wed, 13 Oct 2021 19:01:08 +0000 (21:01 +0200)]
setrlimit: Take stack gap into account.

Calling setrlimit with stack gap enabled and with low values of stack
resource limit often caused the program to abort immediately after
exiting the syscall. This happened due to the fact that the resource
limit was calculated assuming that the stack started at sv_usrstack,
while with stack gap enabled the stack is moved by a random number
of bytes.

Save information about stack size in struct vmspace and adjust the
rlim_cur value. If the rlim_cur and stack gap is bigger than rlim_max,
then the value is truncated to rlim_max.

PR: 253208
Reviewed by: kib
Obtained from: Semihalf
Sponsored by: Stormshield
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D31516

(cherry picked from commit 889b56c8cd84c9a9f2d9e3b019c154d6f14d9021)

2 years agobsdinstall: zfsboot: Prompt user for zpool name if the pool already exists
Emmanuel Vadot [Wed, 8 Dec 2021 10:37:50 +0000 (11:37 +0100)]
bsdinstall: zfsboot: Prompt user for zpool name if the pool already exists

If one install FreeBSD on multiple disks (say 13 and CURRENT) the first created
pool will always be used.
Prompt the user for a new pool name if we detect that the default or supplied one
already exists.

Reviewed by: imp
MFC after:      2 weeks
Sponsored by:   Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D33331

(cherry picked from commit 9935b0e8ea41804b32576987531be4d31ba705f1)

2 years agobsdinstall: bootconfig: Try to clean old efi boot entries
Emmanuel Vadot [Wed, 8 Dec 2021 09:37:54 +0000 (10:37 +0100)]
bsdinstall: bootconfig: Try to clean old efi boot entries

If one install FreeBSD on the same machine multiple times in a row or
on different harddrive they have a lot of 'FreeBSD' efi boot entries added.
With this patch we now do :
- If there is no 'FreeBSD' entry we add one like before
- If there is one or more entries we ask the user if they want to delete
  them all and add a new one
  - If they say yes we do that
  - If they say no we prompt them an inputbox so they can enter a different
    entry name if they want, it defaults to 'FreeBSD'

Reviewed by: bapt, imp
MFC after: 2 weeks
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D33330

(cherry picked from commit 40c928e7b80a7e2ba3652f7c3dc1d30fe92e5b48)

2 years agonfscl: Handle CB_SEQUENCE not first op correctly
Rick Macklem [Thu, 16 Dec 2021 00:36:40 +0000 (16:36 -0800)]
nfscl: Handle CB_SEQUENCE not first op correctly

The check for "not first operation" in CB_SEQUENCE
was done after the slot, etc. was updated. This patch
moves the check to the beginning of CB_SEQUENCE
processing.

While here, also fix the check for "no CB_SEQUENCE operation first"
by moving the check to the beginning of callback operation parsing,
since the check was in a couple of the other operations, but
not all of them.

PR: 260412

(cherry picked from commit e0861304a7b6b9c410db69be6148a5510c6b2d23)

2 years agorpc: Delete AUTH_NEEDS_TLS(_MUTUAL_HOST) auth_stat values
Rick Macklem [Thu, 23 Dec 2021 22:31:53 +0000 (14:31 -0800)]
rpc: Delete AUTH_NEEDS_TLS(_MUTUAL_HOST) auth_stat values

I thought that these new auth_stat values had been agreed
upon by the IETF NFSv4 working group, but that no longer
is the case.  As such, delete them and use AUTH_TOOWEAK
instead.  Leave the code that uses these new auth_stat
values in the sources #ifdef notnow, in case they are
defined in the future.

(cherry picked from commit 744c2dc7dde4ee1e1efc9630439682ea0dc338db)

2 years agogetfh: clarify that it is a privileged operation
Ed Maste [Thu, 23 Dec 2021 15:24:27 +0000 (10:24 -0500)]
getfh: clarify that it is a privileged operation

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

(cherry picked from commit 5bc2e6e22774f4663c971a4b5b7eaf4cb9a2485e)

2 years agoMFC: Improve readahead in loader
Colin Percival [Sun, 19 Sep 2021 22:24:00 +0000 (15:24 -0700)]
MFC: Improve readahead in loader

style: Fix leading whitespace in bcache.c
loader: Refactor readahead adjustment in bcache
loader bcache: Track unconsumed readahead
loader bcache: Allow readahead up to 256 kB I/Os

Sponsored by: https://www.patreon.com/cperciva

(cherry picked from commit 5a01dea7e8c9640605e5731a9fc7f600c07ace61)
(cherry picked from commit b841148bbbdc967c871e8742a6f0b7b17b2d1d91)
(cherry picked from commit 04b9b7c507c52daf7b2999329a50825db098151f)
(cherry picked from commit 248682a589159619aa5f2019e415a423e849e327)

2 years agoOnly trigger read-ahead if two adjacent blocks have been requested.
Maxim Sobolev [Fri, 20 Aug 2021 19:33:51 +0000 (12:33 -0700)]
Only trigger read-ahead if two adjacent blocks have been requested.

The change makes block caching algorithm to work better for remote
media on low-BW/high-delay links.

This cuts boot time over IP KVMs noticeably, since the initialization
stage reads bunch of small 4th (and now lua) files that are not in
the same cache stripe (usually), thus wasting lot of bandwidth and
increasing latency even further.

The original regression came in 2017 with revision 87ed2b7f5. We've
seen increase of time it takes for the loader to get to the kernel
loading from under a minute to 10-15 minutes in many cases.

Reviewed by: tsoome
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D31623

(cherry picked from commit 0d13f5343fafbf3067ffc33a507ffca0375c4417)

2 years agoEFI loader: Don't free bcache for DEVT_DISK devs
Colin Percival [Thu, 30 Sep 2021 21:48:14 +0000 (14:48 -0700)]
EFI loader: Don't free bcache for DEVT_DISK devs

Booting on an EC2 c5.xlarge instance, this reduces the number of I/Os
performed from 609 to 432, reduces the total number of blocks read
from 61963 to 60797, and reduces the time spent in the loader by 39 ms.

Note that b4cb3fe0e39a allowed the bcache to be retained for most of
the boot process, but relies on mounting filesystems; this commit
allows the bcache to be retained at the start of the boot process,
before the root filesystem has been located.

Sponsored by: https://www.patreon.com/cperciva
Differential Revision: https://reviews.freebsd.org/D32239

(cherry picked from commit ce73f768b76486b1562f207a6fc1cef87065418a)

2 years agoMFC: Add TSLOG to loader sprintf
Colin Percival [Sat, 25 Sep 2021 03:19:38 +0000 (20:19 -0700)]
MFC: Add TSLOG to loader sprintf

loader tslog: Don't use sprintf
loader printf: Profile with TSLOG

Sponsored by: https://www.patreon.com/cperciva

(cherry picked from commit 242923eb848a94d657344c2ff45c4f15433cdf3c)
(cherry picked from commit 0a35c4b3cab563e3ab1bf5b7b49bf26e0bb7cb04)

2 years agoAdd _sleep to TSLOG
Colin Percival [Sun, 5 Sep 2021 19:50:15 +0000 (12:50 -0700)]
Add _sleep to TSLOG

Most of the nvme initialization time in my tests is being spent here
(via pause_sbt).

Sponsored by: https://www.patreon.com/cperciva

(cherry picked from commit bd11e253a9a459c9a7b69ebb1c68f0162eb6119f)

2 years agoloader: Set twiddle globaldiv to 16 by default
Colin Percival [Tue, 28 Sep 2021 18:39:59 +0000 (11:39 -0700)]
loader: Set twiddle globaldiv to 16 by default

Booting FreeBSD on an EC2 c5.xlarge instance, the loader "twiddles"
810 times over the course of 510 ms, a rate of 1.59 kHz. Even accepting
that many systems are slower than this particular VM and will take
longer to boot (especially if using spinning-rust disks), this seems
like an unhelpfully large amount of twiddling when compared to the
~60 Hz frame rate of many displays; printing the twiddles also consumes
roughly 10% of the boot time on the aforementioned VM.

Setting the default globaldiv to 16 dramatically reduces the time spent
printing twiddles to the console while still twiddling at roughly 100
Hz; this should be ample even for systems which take longer to boot and
consequently twiddle slower.

Note that this can adjusted via the twiddle_divisor variable in
loader.conf, but that file is not processed until nearly halfway
through the loader's runtime.

Sponsored by: https://www.patreon.com/cperciva
Differential Revision: https://reviews.freebsd.org/D32163

(cherry picked from commit 7457840230c5a470ee5df8abed6ab59c4d008a45)

2 years agoMFC: arm64 fixes for TSLOG
Colin Percival [Thu, 24 Jun 2021 05:10:26 +0000 (22:10 -0700)]
MFC: arm64 fixes for TSLOG

arm64: Disable early printf if TSLOG
arm64: Instrument initarm with TSLOG
libsa: Add tslog support for arm64

Sponsored by: https://www.patreon.com/cperciva

(cherry picked from commit 0acc529dc35f88836dbcbe75940954c75595b058)
(cherry picked from commit ccadcb8f3343562f22a426e845dba640319d4355)
(cherry picked from commit e6caac717b4fc2b87cf93f67109884e768253e77)

2 years agoMFC loader+userland TSLOG support
Colin Percival [Sun, 30 May 2021 20:17:11 +0000 (20:17 +0000)]
MFC loader+userland TSLOG support

stand/common: Add file_addbuf()
libsa: Add support for timestamp logging (tslog)
stand/common: Add support for timestamp logging (tslog)
i386/loader: Call tslog_init
efi/loader: Call tslog_init (+ bugfix)
stand/common command_boot: Pass tslog to kernel
kern_tslog: Include tslog data from loader
loader: Use tslog to instrument some functions
Add userland boot profiling to TSLOG (+ bugfix)

Sponsored by: https://www.patreon.com/cperciva

(cherry picked from commit 60a978bec9123fcb9c74bd925e06dd3f4faddac6)
(cherry picked from commit e193d3ba337757a27148a38494d3df106b826d1c)
(cherry picked from commit c8dfc327db2373c721a35efe857cf07262fd7dd0)
(cherry picked from commit c4b65e954f0f4754941f5b37436231f611b76d67)
(cherry picked from commit f49381ccb6bc8a5733f1aa505e716eddae299986)
(cherry picked from commit 537a44bf281559d304850b5e28b6f8b8e44fd593)
(cherry picked from commit fe51b5a76de38d20cddc05a4c6cb1103d1a0547e)
(cherry picked from commit 313724bab940c1844fda3d797cf88cd46780e62a)
(cherry picked from commit 46dd801acb2318c8464b185893bb111f09b71138)
(cherry picked from commit 52e125c2bd302982c179ecc920cc9a6e166033d6)
(cherry picked from commit 19e4f2f289fb8d2b14576a65ca9e6f931dbb6a02)

2 years agoEliminate key press requirement "show vmopag" command output.
Stephen J. Kiernan [Fri, 17 Dec 2021 21:39:51 +0000 (16:39 -0500)]
Eliminate key press requirement "show vmopag" command output.

Summary:
One was required to press a key to continue after every 18 lines of
output. This requirement had been in the "show vmopag" command since it
was introduced, which was many years before paging was added to DDB.
With paging, this explict key check is no longer necessary.

Obtained from: Juniper Networks, Inc.
MFC after: 1 week

Test Plan:
Run "show vmopag" from db> prompt and see that it does not need additional
keypresses other than the ones needed for the pager.

Subscribers: imp, #contributor_reviews_base

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

(cherry picked from commit 18048b6e3cb647f2a18e1e51df1cf86a90fc6802)

2 years agovm_reserv: fix zero-boundary error
Doug Moore [Sun, 26 Dec 2021 17:40:27 +0000 (11:40 -0600)]
vm_reserv: fix zero-boundary error

Handle specially the boundary==0 case of vm_reserv_reclaim_config,
by turning off boundary adjustment in that case.

Reviewed by: alc
Tested by: pho, madpilot

(cherry picked from commit 49fd2d51f07fb29af3fd239f83f249c00cd84123)

2 years agoUSB dwc3 controller: add quirk snps,dis_rxdet_inp3_quirk
Bjoern A. Zeeb [Wed, 10 Nov 2021 00:22:20 +0000 (00:22 +0000)]
USB dwc3 controller: add quirk snps,dis_rxdet_inp3_quirk

Add support for the "snps,dis_rxdet_inp3_quirk" quirk needed
at least on SolidRun's HoneyComb.

Reviewed by: manu, mw
Differential Revision: https://reviews.freebsd.org/D32921

(cherry picked from commit 3987e506112a7e8af6f09966792fb8656d630496)

2 years agoUSB: add CYUSB330x to usbdevs
Bjoern A. Zeeb [Fri, 15 Oct 2021 10:46:58 +0000 (10:46 +0000)]
USB: add CYUSB330x to usbdevs

Add the Cypress dual USB3/2 HUB CYUSB330x as found in SolidRun's
HoneyComb to usbdevs.

(cherry picked from commit 1910048eb931bb749c42534a8f252d772c0719de)

2 years agofw_stub: fix -Wunused-but-set-variable for firmware files
Bjoern A. Zeeb [Tue, 30 Nov 2021 14:23:18 +0000 (14:23 +0000)]
fw_stub: fix -Wunused-but-set-variable for firmware files

In case we are only embedding a single firmware image the variable
"parent" gets set but never used.  Add checks for the number of files
for it and only print it out if we are exceeding the single file count.
This fixes -Wunused-but-set-variable warnings for the majority of
firmware files in the tree.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit b394e16ef0b5ad0da5e029bcdd3a01e361724d8d)

2 years agorc: network.subr improve network6_getladdr()
Bjoern A. Zeeb [Mon, 13 Dec 2021 22:10:25 +0000 (22:10 +0000)]
rc: network.subr improve network6_getladdr()

In network6_getladdr() we are iterating over inet6 lines and are not
interested in any others.  So tell ifconfig to limit output to "inet6"
as much as possible.
This is probably a micro-optimisation but was noticed while looking
at other IPv6-related boot-time improvements.

(cherry picked from commit e448ff6f0e8035c3dd5b7bd0872f3f0d91c4e0d0)

2 years agox86: Do not attempt to calibrate the LAPIC timer if no APIC is present
Mark Johnston [Tue, 28 Dec 2021 22:44:57 +0000 (17:44 -0500)]
x86: Do not attempt to calibrate the LAPIC timer if no APIC is present

Reported and tested by: Michael Butler <imb@protected-networks.net>
Reviewed by: jhb, kib
Fixes: 62d09b46ad75 ("x86: Defer LAPIC calibration until after timecounters are available")
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 0ecda8d5ae896b229f13bfe73ffa3a7fc81cc550)

2 years agox86: Perform late TSC calibration before LAPIC timer calibration
Mark Johnston [Mon, 6 Dec 2021 15:42:19 +0000 (10:42 -0500)]
x86: Perform late TSC calibration before LAPIC timer calibration

This ensures that LAPIC calibration is done using the correct tsc_freq
value, i.e., the one associated with the TSC timecounter.  It does mean
though that TSC calibration cannot use sbinuptime() to read the
reference timecounter, as timehands are not yet set up.

Reviewed by: kib, jhb
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 553af8f1ec71d397b5b4fd5876622b9269936e63)

2 years agox86: Defer LAPIC calibration until after timecounters are available
Mark Johnston [Mon, 6 Dec 2021 15:42:10 +0000 (10:42 -0500)]
x86: Defer LAPIC calibration until after timecounters are available

This ensures that we have a good reference timecounter for performing
calibration.

Change lapic_setup to avoid configuring the timer when booting, and move
calibration and initial configuration to a new lapic routine,
lapic_calibrate_timer.  This calibration will be initiated from
cpu_initclocks(), before an eventtimer is selected.

Reviewed by: kib, jhb
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 62d09b46ad7508ae74d462e49234f0a80f91ff69)

2 years agox86: Implement deferred TSC calibration
Mark Johnston [Mon, 15 Nov 2021 20:31:21 +0000 (15:31 -0500)]
x86: Implement deferred TSC calibration

There is no universal way to find the TSC frequency.  Newer Intel CPUs
may report it via CPUID leaves 0x15 and 0x16.  Sometimes it can be
obtained from the PLATFORM_INFO MSR as well, though we never use that.
On older platforms we derive the frequency using a DELAY(1000000) call,
which uses the 8254 PIT.  On some newer platforms the 8254 is apparently
non-functional, leading to bogus calibration results.  On such platforms
the TSC frequency must be available from CPUID.  It is also possible to
disable calibration with a tunable, in which case we try to parse the
brand string if the TSC freq is not available from CPUID.

CPUID 0x15 provides an authoritative TSC frequency value, but even that
is not always available on new Intel platforms.  CPUID 0x16 provides the
specified processor base frequency, which is not the same as the TSC
frequency.  Empirically, it is close enough for early boot, but too far
off for timekeeping: on a Comet Lake NUC, CPUID 0x16 yields 1600MHz but
the TSC frequency is rougly 1608MHz, leading to frequent clock stepping
when NTP is in use.

Thus we have a situation where we cannot calibrate using the PIT and
cannot obtain a precise frequency from CPUID (or MSRs).  This change
seeks to address that by using the CPUID 0x16 value during early boot
and refining the calibration later once ACPI-based timecounters are
available.  TSC frequency detection is thus split into two phases:

Early phase:
- On Intel platforms, query CPUID 0x15 and 0x16 and use that value
  initially if available.
- Otherwise, get an estimate using the PIT, reducing the delay loop to
  100ms from 1s.
- Continue to register the TSC as the CPU ticks provider early, even
  though the frequency may be off.  Otherwise any code executed during
  boot that uses cpu_ticks() (e.g., context switching) gets tripped up
  when the ticks provider changes.

Later phase:
- In SI_SUB_CLOCKS, once the timehands are initialized, load the current
  TSC and timecounter (sbinuptime()) values at the beginning and end of
  a 1s interval and use the timecounter frequency (typically from
  kvmclock, HPET or the ACPI PM timer) to estimate the TSC frequency.
- Update the TSC timecounter, global tsc_freq and CPU ticker with the
  new frequency and finally register the TSC as a timecounter.

Reviewed by: kib, jhb (previous version)
Discussed with: imp, cperciva
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 22875f88799e1684febf79b5049541e0f825aaa1)

2 years agoAdd assembly optimized code for OpenSSL on powerpc, powerpc64 and powerpc64le
Piotr Kubaj [Mon, 22 Nov 2021 02:28:46 +0000 (03:28 +0100)]
Add assembly optimized code for OpenSSL on powerpc, powerpc64 and powerpc64le

Summary:
1. https://github.com/openssl/openssl/commit/34ab13b7d8e3e723adb60be8142e38b7c9cd382a
needs to be merged for ELFv2 support on big-endian.
2. crypto/openssl/crypto/ppccap.c needs to be patched.
Same reason as in https://github.com/openssl/openssl/pull/17082.

Approved by: jkim, jhibbits, alfredo (MFC to stable/13)
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D33076

(cherry picked from commit 3a60869237b8b315fe66497cf5299ec08b688533)