]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agoMerge commit 28de0fb48 from llvm git (by Luís Marques):
dim [Wed, 9 Dec 2020 18:37:43 +0000 (18:37 +0000)]
Merge commit 28de0fb48 from llvm git (by Luís Marques):

  [RISCV] Set __GCC_HAVE_SYNC_COMPARE_AND_SWAP_x defines

  The RISCV target did not set the GCC atomic compare and swap defines,
  unlike other targets. This broke builds for things like glib on
  RISCV.

  Patch by Kristof Provost (kprovost)

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

This should fix building glib20 on RISC-V and unblock a number of
dependent ports.

Requested by: kp
MFC after: 3 days

3 years agonetgraph: macfilter: small fixes
kevans [Wed, 9 Dec 2020 15:28:56 +0000 (15:28 +0000)]
netgraph: macfilter: small fixes

Two issues:
- The DEBUG macro defined is in direct conflict with the DEBUG kernel
  option, which broke the -LINT build[0]
- Building with NG_MACFILTER_DEBUG did not compile on LP64 systems due to
  using %d for sizeof().

Reported by: Jenkins[0]

3 years agoPlug a race between fd table teardown and several loops
markj [Wed, 9 Dec 2020 14:05:08 +0000 (14:05 +0000)]
Plug a race between fd table teardown and several loops

To export information from fd tables we have several loops which do
this:

FILDESC_SLOCK(fdp);
for (i = 0; fdp->fd_refcount > 0 && i <= lastfile; i++)
<export info for fd i>;
FILDESC_SUNLOCK(fdp);

Before r367777, fdescfree() acquired the fd table exclusive lock between
decrementing fdp->fd_refcount and freeing table entries.  This
serialized with the loop above, so the file at descriptor i would remain
valid until the lock is dropped.  Now there is no serialization, so the
loops may race with teardown of file descriptor tables.

Acquire the exclusive fdtable lock after releasing the final table
reference to provide a barrier synchronizing with these loops.

Reported by: pho
Reviewed by: kib (previous version), mjg
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27513

3 years agoUse refcount_load(9) to load fd table reference counts
markj [Wed, 9 Dec 2020 14:04:54 +0000 (14:04 +0000)]
Use refcount_load(9) to load fd table reference counts

No functional change intended.

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

3 years agogrep: replace the internal queue with a ring buffer
kevans [Wed, 9 Dec 2020 05:27:45 +0000 (05:27 +0000)]
grep: replace the internal queue with a ring buffer

We know up front how many items we can have in the queue (-B/Bflag), so
pay the cost of those particular allocations early on.

The reduced queue maintenance overhead seemed to yield about an ~8%
improvement for my earlier `grep -C8 -r closefrom .` test.

MFC after: 2 weeks

3 years agogrep: tests: stop expecting a failure of gnuext w/ bsdgrep
kevans [Wed, 9 Dec 2020 05:12:04 +0000 (05:12 +0000)]
grep: tests: stop expecting a failure of gnuext w/ bsdgrep

libregex now supports these and we no longer offer to not link against
libregex.

3 years agokdump/truss: decode new _umtx_op flags
kevans [Wed, 9 Dec 2020 03:24:09 +0000 (03:24 +0000)]
kdump/truss: decode new _umtx_op flags

In both cases, print the flag bits first followed by the command.

Output now looks something like this:

(ktrace)
_umtx_op(0x8605f7008,0xf<UMTX_OP_WAIT_UINT_PRIVATE>,0,0,0)
_umtx_op(0x9fffdce8,0x80000003<UMTX_OP__32BIT|UMTX_OP_WAKE>,0x1,0,0)

(truss)
_umtx_op(0x7fffffffda50,UMTX_OP_WAKE,0x1,0x0,0x0) = 0 (0x0)
_umtx_op(0x9fffdd08,UMTX_OP__32BIT|UMTX_OP_WAKE,0x1,0x0,0x0) = 0 (0x0)

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D27325

3 years agolibsysdecode: decode _UMTX_OP flags
kevans [Wed, 9 Dec 2020 03:22:44 +0000 (03:22 +0000)]
libsysdecode: decode _UMTX_OP flags

Assume that UMTX_OP with a double underbar following is a flag, while any
underbar+alphanumeric combination immeiately following is an op.

This was a part of D27325.

Reviewed by: kib

3 years ago_umtx_op(2): document recent addition of 32bit compat flags
kevans [Wed, 9 Dec 2020 03:20:51 +0000 (03:20 +0000)]
_umtx_op(2): document recent addition of 32bit compat flags

This was part of D27325.

Reviewed by: kib

3 years agoMFV r368464:
cy [Wed, 9 Dec 2020 02:59:24 +0000 (02:59 +0000)]
MFV r368464:

Update unbound from 1.12.0 to 1.13.0

MFC after: 1 week
Security: CVE-2020-28935

3 years agoCopy arm64 make-memstick.sh and mkisoimages.sh to the riscv
gjb [Wed, 9 Dec 2020 02:21:25 +0000 (02:21 +0000)]
Copy arm64 make-memstick.sh and mkisoimages.sh to the riscv
directory to allow properly building *.iso and *.img files.

Sponsored by: Rubicon Communications, LLC (netgate.com)

3 years agodev/mfi: Make a seemingly bogus conditional unconditional
jhibbits [Wed, 9 Dec 2020 02:07:01 +0000 (02:07 +0000)]
dev/mfi: Make a seemingly bogus conditional unconditional

Summary:
r358689 attempted to fix a clang warning/error by inferring the intent
of the condition "(cdb[0] != 0x28 || cdb[0] != 0x2A)".  Unfortunately, it looks
like this broke things.  Instead, fix this by making this path unconditional,
effectively reverting to the previous state.

PR: kern/251483
Reviewed By: ambrisko
MFC after: 2 days
Differential Revision: https://reviews.freebsd.org/D27515

3 years agoMerge OpenSSL 1.1.1i.
jkim [Wed, 9 Dec 2020 02:05:14 +0000 (02:05 +0000)]
Merge OpenSSL 1.1.1i.

3 years agoFixup r368446 with KERN_TLS.
glebius [Tue, 8 Dec 2020 23:54:09 +0000 (23:54 +0000)]
Fixup r368446 with KERN_TLS.

3 years agofts_read: Handle error from a NULL return better.
bdrewery [Tue, 8 Dec 2020 23:38:26 +0000 (23:38 +0000)]
fts_read: Handle error from a NULL return better.

This is addressing cases such as fts_read(3) encountering an [EIO]
from fchdir(2) when FTS_NOCHDIR is not set.  That would otherwise be
seen as a successful traversal in some of these cases while silently
discarding expected work.

As noted in r264201, fts_read() does not set errno to 0 on a successful
EOF so it needs to be set before calling it.  Otherwise we might see
a random error from one of the iterations.

gzip is ignoring most errors and could be improved separately.

Reviewed by: vangyzen
Sponsored by: Dell EMC
Differential Revision: https://reviews.freebsd.org/D27184

3 years agoVendor import of Unbound 1.13.0.
cy [Tue, 8 Dec 2020 21:23:03 +0000 (21:23 +0000)]
Vendor import of Unbound 1.13.0.

Security: CVE-2020-28935

3 years agocpuset_set{affinity,domain}: do not allow empty masks
kevans [Tue, 8 Dec 2020 18:47:22 +0000 (18:47 +0000)]
cpuset_set{affinity,domain}: do not allow empty masks

cpuset_modify() would not currently catch this, because it only checks that
the new mask is a subset of the root set and circumvents the EDEADLK check
in cpuset_testupdate().

This change both directly validates the mask coming in since we can
trivially detect an empty mask, and it updates cpuset_testupdate to catch
stuff like this going forward by always ensuring we don't end up with an
empty mask.

The check_mask argument has been renamed because the 'check' verbiage does
not imply to me that it's actually doing a different operation. We're either
augmenting the existing mask, or we are replacing it entirely.

Reported by: syzbot+4e3b1009de98d2fabcda@syzkaller.appspotmail.com
Discussed with: andrew
Reviewed by: andrew, markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D27511

3 years agokern: cpuset: resolve race between cpuset_lookup/cpuset_rel
kevans [Tue, 8 Dec 2020 18:45:47 +0000 (18:45 +0000)]
kern: cpuset: resolve race between cpuset_lookup/cpuset_rel

The race plays out like so between threads A and B:

1. A ref's cpuset 10
2. B does a lookup of cpuset 10, grabs the cpuset lock and searches
   cpuset_ids
3. A rel's cpuset 10 and observes the last ref, waits on the cpuset lock
   while B is still searching and not yet ref'd
4. B ref's cpuset 10 and drops the cpuset lock
5. A proceeds to free the cpuset out from underneath B

Resolve the race by only releasing the last reference under the cpuset lock.
Thread A now picks up the spinlock and observes that the cpuset has been
revived, returning immediately for B to deal with later.

Reported by: syzbot+92dff413e201164c796b@syzkaller.appspotmail.com
Reviewed by: markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D27498

3 years agokern: cpuset: plug a unr leak
kevans [Tue, 8 Dec 2020 18:44:06 +0000 (18:44 +0000)]
kern: cpuset: plug a unr leak

cpuset_rel_defer() is supposed to be functionally equivalent to
cpuset_rel() but with anything that might sleep deferred until
cpuset_rel_complete -- this setup is used specifically for cpuset_setproc.

Add in the missing unr free to match cpuset_rel. This fixes a leak that
was observed when I wrote a small userland application to try and debug
another issue, which effectively did:

cpuset(&newid);
cpuset(&scratch);

newid gets leaked when scratch is created; it's off the list, so there's
no mechanism for anything else to relinquish it. A more realistic reproducer
would likely be a process that inherits some cpuset that it's the only ref
for, but it creates a new one to modify. Alternatively, administratively
reassigning a process' cpuset that it's the last ref for will have the same
effect.

Discovered through D27498.

MFC after: 1 week

3 years agoarm64: fix struct l_sigaction_t layout
mhorne [Tue, 8 Dec 2020 18:24:33 +0000 (18:24 +0000)]
arm64: fix struct l_sigaction_t layout

The definition was copied from amd64, but the layout of the struct
differs slightly between these platforms. This fixes spurious
`unsupported sigaction flag 0xXXXXXXXX` messages when executing some
Linux binaries on arm64.

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

3 years agoCheck that the frame pointer is within the current stack.
jhb [Tue, 8 Dec 2020 18:00:58 +0000 (18:00 +0000)]
Check that the frame pointer is within the current stack.

This same check is used on other architectures.  Previously this would
permit a stack frame to unwind into any arbitrary kernel address
(including unmapped addresses).

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

3 years agoStack unwinding robustness fixes for RISC-V.
jhb [Tue, 8 Dec 2020 17:57:18 +0000 (17:57 +0000)]
Stack unwinding robustness fixes for RISC-V.

- Push the kstack_contains check down into unwind_frame() so that it
  is honored by DDB and DTrace.

- Check that the trapframe for an exception frame is contained in the
  traced thread's kernel stack for DDB traces.

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

3 years agoMissed adding netgraph to mtree in r368443:
n_hibma [Tue, 8 Dec 2020 17:44:34 +0000 (17:44 +0000)]
Missed adding netgraph to mtree in r368443:

New Netgraph module ng_macfilter:

Macfilter to route packets through different hooks based on sender MAC address.

Based on ng_macfilter written by Pekka Nikander

Sponsered by Retina b.v.

Reviewed by:    afedorov
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D27268

3 years agoFix indenting for netmap.
n_hibma [Tue, 8 Dec 2020 17:42:32 +0000 (17:42 +0000)]
Fix indenting for netmap.

3 years ago[ath] also remove the magic size value here for the transmit antenna statistics.
adrian [Tue, 8 Dec 2020 17:28:42 +0000 (17:28 +0000)]
[ath] also remove the magic size value here for the transmit antenna statistics.

3 years ago[ath] Don't use hard-coded values in the sanity check.
adrian [Tue, 8 Dec 2020 17:27:24 +0000 (17:27 +0000)]
[ath] Don't use hard-coded values in the sanity check.

Don't use hard-coded values in the phy error and receive antenna
checks.

3 years ago[ath] replace the hard-coded magic values in if_athioctl.h with constant defines
adrian [Tue, 8 Dec 2020 17:25:59 +0000 (17:25 +0000)]
[ath] replace the hard-coded magic values in if_athioctl.h with constant defines

Replace some hard-coded magic values in the ioctl stats struct with
#defines.  I'm going to follow up with some more sanity checking in
the receive path that also use these values so we don't do bad
things if the hardware is (more) confused.

3 years agoThe list of ports in configuration path shall be protected by locks,
glebius [Tue, 8 Dec 2020 16:46:00 +0000 (16:46 +0000)]
The list of ports in configuration path shall be protected by locks,
epoch shall be used only for fast path.  Thus use LAGG_XLOCK() in
lagg_[un]register_vlan.  This fixes sleeping in epoch panic.

PR: 240609

3 years agoOpenSSL: address CVE-2020-1971
emaste [Tue, 8 Dec 2020 16:43:35 +0000 (16:43 +0000)]
OpenSSL: address CVE-2020-1971

OpenSSL commit 3db2c9f3:
Complain if we are attempting to encode with an invalid ASN.1 template

OpenSSL commit 43a7033:
Check that multi-strings/CHOICE types don't use implicit tagging

OpenSSL commit f960d812:
Correctly compare EdiPartyName in GENERAL_NAME_cmp()

Obtained from: OpenSSL 3db2c9f343a7033f960d812
Security: CVE-2020-1971

3 years agoConvert LAGG_RLOCK() to NET_EPOCH_ENTER(). No functional changes.
glebius [Tue, 8 Dec 2020 16:36:46 +0000 (16:36 +0000)]
Convert LAGG_RLOCK() to NET_EPOCH_ENTER(). No functional changes.

3 years agoUse a macro to find the offset of kern_ttbr0
andrew [Tue, 8 Dec 2020 15:51:05 +0000 (15:51 +0000)]
Use a macro to find the offset of kern_ttbr0

Rather than hard coding the offset of kern_ttbr0 within arm64_bootparams
use a macro like the other fields.

Sponsored by: Innovate UK

3 years agoFree the arm64 bootparams memory after initarm
andrew [Tue, 8 Dec 2020 15:41:18 +0000 (15:41 +0000)]
Free the arm64 bootparams memory after initarm

This is only needed in initarm, we can return this memory to the stack
used by mi_startup.

Sponsored by: Innivate UK

3 years agoNew Netgraph module ng_macfilter:
n_hibma [Tue, 8 Dec 2020 15:09:42 +0000 (15:09 +0000)]
New Netgraph module ng_macfilter:

Macfilter to route packets through different hooks based on sender MAC address.

Based on ng_macfilter written by Pekka Nikander

Sponsered by Retina b.v.

Reviewed by: afedorov
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D27268

3 years agoregen src.conf.5 after r368441, WITHOUT_GDB default
emaste [Tue, 8 Dec 2020 15:00:07 +0000 (15:00 +0000)]
regen src.conf.5 after r368441, WITHOUT_GDB default

3 years agoDefault to WITHOUT_GDB (GDB 6.1.1) for FreeBSD 13
emaste [Tue, 8 Dec 2020 14:56:15 +0000 (14:56 +0000)]
Default to WITHOUT_GDB (GDB 6.1.1) for FreeBSD 13

As discussed on -current, -stable, -toolchain, and with jhb@ and imp@,
disable the obsolete in-tree GDB 6.1.1 by default.  This was kept only
to provide kgdb for the crashinfo tool, but is long-obsolete, does not
support all architectures that FreeBSD does, and held back other work
(such as forcing the use of DWARF2 for kernel debug).

Crashinfo will use kgdb from the gdb package or devel/gdb port, and will
privde a message referencing those if no kgdb is found.

Relnotes: Yes
Sponsored by: The FreeBSD Foundation

3 years agosrc.conf(5): regen after r368439 (WITH_BSD_GREP default)
kevans [Tue, 8 Dec 2020 14:05:54 +0000 (14:05 +0000)]
src.conf(5): regen after r368439 (WITH_BSD_GREP default)

3 years agosrc.opts.mk: switch to bsdgrep as /usr/bin/grep
kevans [Tue, 8 Dec 2020 14:05:25 +0000 (14:05 +0000)]
src.opts.mk: switch to bsdgrep as /usr/bin/grep

This has been years in the making, and we all knew it was bound to happen
some day. Switch to the BSDL grep implementation now that it's been a
little more thoroughly tested and theoretically supports all of the
extensions that gnugrep in base had with our libregex(3).

Folks shouldn't really notice much from this update; bsdgrep is slower than
gnugrep, but this is currently the price to pay for fewer bugs. Those
dissatisfied with the speed of grep and in need of a faster implementation
should check out what textproc/ripgrep and textproc/the_silver_searcher
can do for them.

I have some WIP to make bsdgrep faster, but do not consider it a blocker
when compared to the pros of switching now (aforementioned bugs, licensing).

PR: 228798 (exp-run)
PR: 128645, 156704, 166842, 166862, 180937, 193835, 201650
PR: 232565, 242308, 246000, 251081, 191086, 194397
Relnotes: yes, please

3 years agoextattr_get_file(20: bump .Dd
ngie [Tue, 8 Dec 2020 04:18:16 +0000 (04:18 +0000)]
extattr_get_file(20: bump .Dd

This is being done for the formatting and context changes. While the net content
hasn't been changed, the content/context changes were sufficient to warrant the
date bump.

MFC after: 1 week
MFC with: r368431, r368433, r368434, r368435
Sponsored by: DellEMC Isilon

3 years agoextattr_get_file(2): clarify RETURN VALUES
ngie [Tue, 8 Dec 2020 04:16:05 +0000 (04:16 +0000)]
extattr_get_file(2): clarify RETURN VALUES

While some of the syscalls' behavior were documented and implied in the
RETURN VALUES section by earlier, e.g., the DESCRIPTION sections, as having
behavior of the other calls (`*_fd` vs `*_file` vs `*_link`), there was a lot
of implied return value behavior in the section prior to this change.

Explicitly document the syscall behavior per the current implementation in
sys/kern/vfs_extattr.c so others can better develop based on its explicit
documented behavior instead of having to digest the context of the manpage to
understand the appropriate behavior.

MFC after: 1 week
MFC with: r368431, r368433, r368434
Sponsored by: DellEMC Isilon

3 years agoextattr_get_file(2): fix more formatting
ngie [Tue, 8 Dec 2020 04:05:19 +0000 (04:05 +0000)]
extattr_get_file(2): fix more formatting

- Remove an unnecessary trailing comma separating a two-item clause.
- Sort more function calls alphabetically (in the same vein as r368433).

MFC after: 1 week
Sponsored by: DellEMC Isilon

3 years agoextattr_get_file(2): sort syscalls alphabetically
ngie [Tue, 8 Dec 2020 04:01:03 +0000 (04:01 +0000)]
extattr_get_file(2): sort syscalls alphabetically

Although some sections of the manpage sort the syscalls alphabetically, many
core areas of the manpage do not. Sort the syscalls so it is easier to pick out
functional changes and to improve manpage readability.

This formatting change is also being done to make future functional changes
easier to spot.

MFC after: 1 week
Sponsored by: DellEMC Isilon

3 years agolio_listio(2): fix manlint error
ngie [Tue, 8 Dec 2020 03:48:05 +0000 (03:48 +0000)]
lio_listio(2): fix manlint error

The date with .Dd prior to this change isn't canonically spelled out: it
should have been "December", not "Dec".

MFC after: 1 week
Sponsored by: DellEMC Isilon

3 years agoextattr_get_fd(2): fix manlint errors
ngie [Tue, 8 Dec 2020 03:43:00 +0000 (03:43 +0000)]
extattr_get_fd(2): fix manlint errors

- The CAVEATS section was misspelled as "CAVEAT".
- The CAVEATS section should come before the "BUGS" section and after
  other existing sections by convention.

MFC after: 1 week
Reported by: make manlint
Sponsored by: DellEMC Isilon

3 years agoIn ext2fs, BA_CLRBUF is used in ext2_balloc() not UFS_BALLOC().
mckusick [Tue, 8 Dec 2020 00:49:31 +0000 (00:49 +0000)]
In ext2fs, BA_CLRBUF is used in ext2_balloc() not UFS_BALLOC().

Noted by:     kib
MFC after:    3 days
Sponsored by: Netflix

3 years agorelease: don't checksum images if there are none
mhorne [Tue, 8 Dec 2020 00:48:50 +0000 (00:48 +0000)]
release: don't checksum images if there are none

For platforms that don't have any of the memstick, cdrom, or dvdrom
release images (i.e. riscv64), the release-install target will trip up
when invoking md5(1) on the non-existent image files. Skipping this
allows the install to complete successfully.

3 years agoRISC-V release confs
mhorne [Tue, 8 Dec 2020 00:42:03 +0000 (00:42 +0000)]
RISC-V release confs

Add two release flavors for RISC-V. First, the traditional "big-iron"
images, capable of generating distribution sets and VM images. Installer
images won't be built yet, but can be trivially enabled in the future
with the addition of riscv/make-memstick.sh.

Second, a GENERICSD embedded image. I've opted for this instead of
board-specific SD card images as it allows users to just dd the u-boot
they want. The RISC-V hardware ecosystem is still young, so a
configuration for e.g. the new PolarFire SoC Icicle Kit would likely see
very few users.

Reviewed by: gjb
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D27045

3 years agoriscv: allow building virtual machine images
mhorne [Tue, 8 Dec 2020 00:37:11 +0000 (00:37 +0000)]
riscv: allow building virtual machine images

RISC-V has the same booting requirements as arm64 (loader.efi, no legacy
boot options), so generated images for both architectures have the same
partition layout.

Reviewed by: gjb
Differential Revision: https://reviews.freebsd.org/D27044

3 years agorelease.sh: add support for RISC-V embedded builds
mhorne [Tue, 8 Dec 2020 00:35:13 +0000 (00:35 +0000)]
release.sh: add support for RISC-V embedded builds

Since the few existing RISC-V hardware platforms are single board
computers, we can piggyback off of arm/arm64's embedded build support
for generating SD card images.

I don't see a pressing need to change the naming in this file at this
time.

Reviewed by: gjb, manu
Differential Revision: https://reviews.freebsd.org/D27043

3 years agoBump __FreeBSD_version for removal of crypto fd's in r368005.
jhb [Mon, 7 Dec 2020 18:58:08 +0000 (18:58 +0000)]
Bump __FreeBSD_version for removal of crypto fd's in r368005.

Requested by: swills
Sponsored by: Chelsio Communications

3 years agoEnsure the boot CPU is CPU 0 on arm64
andrew [Mon, 7 Dec 2020 17:54:49 +0000 (17:54 +0000)]
Ensure the boot CPU is CPU 0 on arm64

We assume the boot CPU is always CPU 0 on arm64. To allow for this reserve
cpuid 0 for the boot CPU in the ACPI and FDT cases but otherwise start the
CPU as normal. We then check for the boot CPU in start_cpu and return as if
it was started.

While here extract the FDT CPU init code into a new function to simplify
cpu_mp_start and return FALSE from start_cpu when the CPU fails to start.

Reviewed by: mmel
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D27497

3 years agoProperly define the bool type in the BSD kernel shim.
hselasky [Mon, 7 Dec 2020 16:08:31 +0000 (16:08 +0000)]
Properly define the bool type in the BSD kernel shim.

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

3 years agoarm: Let the GDB stub write to SP, LR and GP registers
markj [Mon, 7 Dec 2020 15:09:28 +0000 (15:09 +0000)]
arm: Let the GDB stub write to SP, LR and GP registers

This can be handy if gdb's stack unwinder fails, for example because of
a bug in kgdb's trap frame unwinder.

PR: 251463
Submitted by: Dmitry Salychev <dsl@mcusim.org>
MFC after: 1 week

3 years agoAdd missing refcount.9 MLINKS
markj [Mon, 7 Dec 2020 14:53:34 +0000 (14:53 +0000)]
Add missing refcount.9 MLINKS

3 years agoiflib: Avoid leaking the freelist bitmaps upon driver detach
markj [Mon, 7 Dec 2020 14:53:14 +0000 (14:53 +0000)]
iflib: Avoid leaking the freelist bitmaps upon driver detach

Submitted by: Sai Rajesh Tallamraju <stallamr@netapp.com>
MFC after: 2 weeks
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D27342

3 years agoiflib: Detach tasks upon device registration failure
markj [Mon, 7 Dec 2020 14:52:57 +0000 (14:52 +0000)]
iflib: Detach tasks upon device registration failure

In some error paths we would fail to detach from the iflib taskqueue
groups.  Also move the detach code into its own subroutine instead of
duplicating it.

Submitted by: Sai Rajesh Tallamraju <stallamr@netapp.com>
MFC after: 2 weeks
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D27342

3 years agoloader: xdr_array is missing count
tsoome [Mon, 7 Dec 2020 11:25:18 +0000 (11:25 +0000)]
loader: xdr_array is missing count

The integer arrays are encoded in nvlist as counted array <count, i0, i1...>,
loader xdr_array() is missing the count. This will affect the pool import when
there are hole devices in pool.

Also fix the new data add and print functions.

3 years agoFix compilation after r368397.
hselasky [Mon, 7 Dec 2020 11:18:51 +0000 (11:18 +0000)]
Fix compilation after r368397.

MFC after: 3 days
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoAdd missing busdma prototypes for load and unload and implement dummy sync
hselasky [Mon, 7 Dec 2020 10:51:19 +0000 (10:51 +0000)]
Add missing busdma prototypes for load and unload and implement dummy sync
function for kernel bootloader shim code.

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

3 years agoTidy up code a bit. Add missing section comments.
hselasky [Mon, 7 Dec 2020 10:21:01 +0000 (10:21 +0000)]
Tidy up code a bit. Add missing section comments.
No functional change.

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

3 years agoPrefer using the MIN() function macro over the min() inline function
hselasky [Mon, 7 Dec 2020 09:48:06 +0000 (09:48 +0000)]
Prefer using the MIN() function macro over the min() inline function
in the LinuxKPI. Linux defines min() to be a macro, while in FreeBSD
min() is a static inline function clamping its arguments to
"unsigned int".

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

3 years agoAllow sys/refcount.h to be used by standalone builds.
hselasky [Mon, 7 Dec 2020 09:21:06 +0000 (09:21 +0000)]
Allow sys/refcount.h to be used by standalone builds.
No functional change.

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

3 years agoFix the source directory when installing the results. The install
hrs [Mon, 7 Dec 2020 04:45:29 +0000 (04:45 +0000)]
Fix the source directory when installing the results.  The install
target did not install them actually.

Spotted by: Thomas Munro, bapt, yuripv

3 years agouma: Make uma_zone_set_maxcache() work better with small limits
markj [Sun, 6 Dec 2020 22:45:50 +0000 (22:45 +0000)]
uma: Make uma_zone_set_maxcache() work better with small limits

The old implementation chose the largest bucket zone such that if the
per-CPU caches are fully populated, the total number of items cached is
no larger than the specified limit.  If no such zone existed, UMA would
not do any caching.

We can now use uz_bucket_size_max to set a precise limit on the number
of items in a zone's bucket, so the total size of per-CPU caches can be
bounded more easily.  Implement a new policy in uma_zone_set_maxcache():
choose a bucket size such that up to half of the limit can be cached in
per-CPU caches, with the rest going to the full bucket cache.  This
fixes a problem with the kstack_cache zone: the limit of 4 * mp_ncpus
items meant that the zone would not do any caching, defeating the whole
purpose of the zone.  That's because the smallest bucket size holds up
to 2 items and we may cache up to 3 full buckets per CPU, and
2 * 3 * mp_ncpus > 4 * mp_ncpus.

Reported by: mjg
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27168

3 years agouma: Enforce the use of uz_bucket_size_max in the free path
markj [Sun, 6 Dec 2020 22:45:39 +0000 (22:45 +0000)]
uma: Enforce the use of uz_bucket_size_max in the free path

uz_bucket_size_max is the maximum permitted bucket size.  When filling a
new bucket to satisfy uma_zalloc(), the bucket is populated with at most
uz_bucket_size_max items.  The maximum number of entries in the bucket
may be larger.  When freeing items, however, we will fill per-CPPU
buckets up to their maximum number of entries, potentially exceeding
uz_bucket_size_max.  This makes it difficult to precisely limit the
number of items that may be cached in a zone.  For example, if one wants
to limit buckets to 1 entry for a particular zone, that's not possible
since the smallest bucket holds up to 2 entries.

Try to solve the problem by using uz_bucket_size_max to limit the number
of entries in a bucket.  Note that the ub_entries field is initialized
upon every bucket allocation.  Most zones are not affected since they do
not impose any specific limit on the maximum bucket size.

While here, remove the UMA_ZONE_MINBUCKET flag.  It was unused and we
now have uma_zone_set_maxcache() to control the zone's cache size more
precisely.

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

3 years agouma: Use atomic load for uz_sleepers
markj [Sun, 6 Dec 2020 22:45:22 +0000 (22:45 +0000)]
uma: Use atomic load for uz_sleepers

This field is updated locklessly.

Sponsored by: The FreeBSD Foundation

3 years agoAdd deprecation notice to mn(4)
emaste [Sun, 6 Dec 2020 21:34:04 +0000 (21:34 +0000)]
Add deprecation notice to mn(4)

Sync serial (T1/E1) interfaces are largely irrelevant today and phk
confirms this driver is unnecessary in review D23928.

This leaves ce(4) and cp(4) in the tree.  They're likely not relevant
either, but glebius contacted the manufacturer and those devices are
still available for purchase.  At glebius' suggestion leave them in
the tree as long as they do not impose a maintenace burden.

Approved by: phk
MFC after: 3 days
Sponsored by: The FreeBSD Foundation

3 years agoDocument the BA_CLRBUF flag used in ufs and ext2fs filesystems.
mckusick [Sun, 6 Dec 2020 20:50:21 +0000 (20:50 +0000)]
Document the BA_CLRBUF flag used in ufs and ext2fs filesystems.

Suggested by: kib
MFC after:    3 days
Sponsored by: Netflix

3 years agovfs: add cleanup on error missed in r368375
mjg [Sun, 6 Dec 2020 19:24:38 +0000 (19:24 +0000)]
vfs: add cleanup on error missed in r368375

Noted by: jrtc27

3 years agoWhen dropping packets (RRQ or WRQ) for debugging, report the send
tuexen [Sun, 6 Dec 2020 18:43:12 +0000 (18:43 +0000)]
When dropping packets (RRQ or WRQ) for debugging, report the send
operation as successful. Reporting a failure stops the transfer
instead of using timeouts.

MFC after: 1 week

3 years agoufs: handle two more cases of possible VNON vnode returned from VFS_VGET().
kib [Sun, 6 Dec 2020 18:09:14 +0000 (18:09 +0000)]
ufs: handle two more cases of possible VNON vnode returned from VFS_VGET().

Reported by: kevans
Reviewed by: mckusick, mjg
Tested by: pho
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D27457

3 years agobsdgrep: don't link against libregex for bootstrap
kevans [Sun, 6 Dec 2020 17:45:42 +0000 (17:45 +0000)]
bsdgrep: don't link against libregex for bootstrap

r368355 removed the GNU_GREP_COMPAT knob (off by default) and forgot that
bsdgrep may be built/used for bootstrap on some systems.

All base uses should strive to use only POSIX-compliant expressions anyways
and we haven't had libregex by default here up to this point, so just don't
do that if we're bootstrapping.

Note that the resulting binary has the wrong `grep -V` information as it
falsely claims to be GNU compatible, but it is only for bootstrap.

Reported by: GitHub cross-builds via yuripv

3 years agoif_em.ko: fix module build outside of kernel build environment
eugen [Sun, 6 Dec 2020 17:44:28 +0000 (17:44 +0000)]
if_em.ko: fix module build outside of kernel build environment

MFC after: 3 days

3 years agoupdate wcwidth data from utf8proc
yuripv [Sun, 6 Dec 2020 16:44:41 +0000 (16:44 +0000)]
update wcwidth data from utf8proc

Character width data being out of date is a constant source
of weird rendering issues and wasted time trying to diagnose
those, e.g. as reported by Jeremy Chadwick:

https://gitlab.com/muttmua/mutt/-/issues/67

Sadly, there is no real ("standard") wcwidth data source, so
this tries to rectify the problem using the utf8proc one (through
its C API) which would hopefully benefeat both FreeBSD and
utf8proc through bug reports (if any).

Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D27259

3 years agobectl: simplify the tail end of the jail cmd
kevans [Sun, 6 Dec 2020 15:58:50 +0000 (15:58 +0000)]
bectl: simplify the tail end of the jail cmd

This has already confused me once (and I'm pretty sure I wrote it), so let's
clarify: unjailing after the command has completed will only happen if we're
interactive and -U has not been specified.

This just folds two conditionals together to make it obvious how -b/-U
interact with each other.

MFC after: 3 days

3 years agoUpgrade to version 3.2.3
se [Sun, 6 Dec 2020 11:49:21 +0000 (11:49 +0000)]
Upgrade to version 3.2.3

3 years agoMove V4L feature declarations and DTrace provider definitions from
tijl [Sun, 6 Dec 2020 10:58:55 +0000 (10:58 +0000)]
Move V4L feature declarations and DTrace provider definitions from
linux_common.c to linux_util.c so they become available on i386.

linux_common.c defines the linux_common kernel module but this module does
not exist on i386 and linux_common.c is not included in the linux module.
linux_util.c is included in the linux_common module on amd64 and the linux
module on i386.

Remove linux_common.c from files.i386 again.  It was added recently in
r367433 when the DTrace provider definitions were moved.

The V4L feature declarations were moved to linux_common in r283423.

3 years agovfs: factor buffer allocation/copyin out of namei
mjg [Sun, 6 Dec 2020 04:59:24 +0000 (04:59 +0000)]
vfs: factor buffer allocation/copyin out of namei

3 years agoatkbd(4): Just use nitems() for quirk enumeration
cem [Sat, 5 Dec 2020 22:04:30 +0000 (22:04 +0000)]
atkbd(4): Just use nitems() for quirk enumeration

Reviewed by: imp, wulf
X-MFC-With: r368365
Differential Revision: https://reviews.freebsd.org/D27489

3 years agoRemove remaning definition of GFB_<foo> options.
mmel [Sat, 5 Dec 2020 19:44:00 +0000 (19:44 +0000)]
Remove remaning definition of GFB_<foo> options.
They are not used in source files.
This fixes build of some arm boards after r368159.

Reported by: mjg

3 years agoFix i386 linux module after r367395.
tijl [Sat, 5 Dec 2020 14:53:24 +0000 (14:53 +0000)]
Fix i386 linux module after r367395.

In r367395 parts of machine dependent linux_dummy.c were moved to a new
machine independent file sys/compat/linux/linux_dummy.c and the existing
linux_dummy.c was renamed to linux_dummy_machdep.c.

Add linux_dummy_machdep.c to the linux module for i386.
Rename sys/amd64/linux32/linux_dummy.c for consistency.
Add the new linux_dummy.c to the linux module for i386.

3 years agolibc: regex: partial revert of r368358
kevans [Sat, 5 Dec 2020 14:38:46 +0000 (14:38 +0000)]
libc: regex: partial revert of r368358

Part of the libregex functionality leaked into the tests it shares with
the standard regex(3). Introduce a P flag to set the REG_POSIX cflag to
indicate that libc regex should effectively do nothing while libregex should
specifically run it in non-extended mode.

This unbreaks the libc/regex test run.

Reported by: Jenkins

3 years agoSimplify startup of secondary cores and store MPIDR register to pcpu.
mmel [Sat, 5 Dec 2020 14:06:01 +0000 (14:06 +0000)]
Simplify startup of secondary cores and store MPIDR register to pcpu.

 - record MPIDR for all started cores in pcpu, they will be used as link
   between physical locality of given core, ID in external description
   (FDT or ACPI) and cupid.
 - because of above, cpuid can (and should) be freely assigned, only boot
   CPU  must have cpuid 0. Simplify startup code according this.

Please note that pure cpuid is not sufficient instrument to hold any
information about core or cluster topology, nor to determistically iterate
over subpart of cores in CPU (iterate over all cores in single cluster for
example). Situation is more complicated by fact that PSCI can reject start
of core without reporting error (because power budget for example), or by
fact that is possible that we booted on non-first core in cluster (thus with
cpuid 0 assigned to random core).

Given cores topology should be exhibited to other parts of system
(for example to scheduler for big.little or multicluster systems) by using
smp_topo interface.

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

3 years agoAdd basic support for Freescale LX2160A SoC.
mmel [Sat, 5 Dec 2020 12:08:37 +0000 (12:08 +0000)]
Add basic support for Freescale LX2160A SoC.
All peripherals but the network processor are supported.

3 years agoepoch(9): Fix a few mandoc related issues
gbe [Sat, 5 Dec 2020 11:18:37 +0000 (11:18 +0000)]
epoch(9): Fix a few mandoc related issues

- sections out of conventional order: Sh EXAMPLES
- sections out of conventional order: Sh SEE ALSO
- skipping end of block that is not open: El

3 years agoConnect DTB files based on LX2160A SoC to build.
mmel [Sat, 5 Dec 2020 11:17:54 +0000 (11:17 +0000)]
Connect DTB files based on LX2160A SoC to build.
Mainly LX2K Honeycomb and ClearFog-CX boards.

3 years agoig4(4): Add PCI IDs for Intel Tiger Lake
wulf [Sat, 5 Dec 2020 10:57:15 +0000 (10:57 +0000)]
ig4(4): Add PCI IDs for Intel Tiger Lake

Submitted by: Neel Chauhan <neel AT neelc DOT org>
Differential Revision: https://reviews.freebsd.org/D27483

3 years agoatkbd(4): Change quirk table end-of-list marker to NULL vendor/maker/product
wulf [Sat, 5 Dec 2020 10:55:14 +0000 (10:55 +0000)]
atkbd(4): Change quirk table end-of-list marker to NULL vendor/maker/product

This fixes regression introduced in r367349 which effectively resulted in
truncation of quirk table.

PR: 250711
Submitted by: grembo
Reported by: Matthias Apitz <guru@unixarea.de>
X-MFC with: r367349

3 years agoDesignWare PCIe driver: Don't call bus_generic_attach() twice.
mmel [Sat, 5 Dec 2020 10:55:09 +0000 (10:55 +0000)]
DesignWare PCIe driver: Don't call bus_generic_attach() twice.
bus_generic_attach() should be called from the attach function of the real
implementation, not from the common init function.

MFC after: 1 week

3 years agoConnect RK3288 to GENERIC kernel.
mmel [Sat, 5 Dec 2020 10:10:25 +0000 (10:10 +0000)]
Connect RK3288 to GENERIC kernel.

3 years agoAlso build DTB files for Asus Tinker board (RK3288 based).
mmel [Sat, 5 Dec 2020 10:00:39 +0000 (10:00 +0000)]
Also build DTB files for Asus Tinker board (RK3288 based).

3 years agovfs: keep bad ops on vnode reclaim
mjg [Sat, 5 Dec 2020 05:56:23 +0000 (05:56 +0000)]
vfs: keep bad ops on vnode reclaim

They were only modified to accomodate a redundant assertion.

This runs into problems as lockless lookup can still try to use the vnode
and crash instead of getting an error.

The bug was only present in kernels with INVARIANTS.

Reported by: kevans

3 years agolibc: regex: retire internal EMPTBR ("Empty branch present")
kevans [Sat, 5 Dec 2020 03:18:48 +0000 (03:18 +0000)]
libc: regex: retire internal EMPTBR ("Empty branch present")

It was realized just a little too late that this was a hack that belonged in
individual regex(3)-using applications. It was surrounded in NOTYET and not
implemented in the engine, so remove it.

3 years agolibregex: implement \b and \B (word boundary, not word boundary)
kevans [Sat, 5 Dec 2020 03:16:05 +0000 (03:16 +0000)]
libregex: implement \b and \B (word boundary, not word boundary)

This is the last of the needed GNU expressions before we can unleash bsdgrep
by default. \b is effectively an agnostic equivalent of \< and \>, while
\B will match every space that isn't making a transition from
nonchar -> char or char -> nonchar.

3 years agolibregex: implement \` and \' (begin-of-subj, end-of-subj)
kevans [Sat, 5 Dec 2020 03:13:47 +0000 (03:13 +0000)]
libregex: implement \` and \' (begin-of-subj, end-of-subj)

These are GNU extensions, generally equivalent to ^ and $ except that the
new syntax will not match beginning of line after the first in a multi-line
expression or the end of line before absolute last in a multi-line
expression.

3 years agolibc: regex: factor out ISBOW/ISEOW macros
kevans [Sat, 5 Dec 2020 02:23:11 +0000 (02:23 +0000)]
libc: regex: factor out ISBOW/ISEOW macros

These will be reused for \b (word boundary, which matches both sides).

No functional change.

3 years agoRetire GNU_GREP_COMPAT knob
kevans [Sat, 5 Dec 2020 02:21:58 +0000 (02:21 +0000)]
Retire GNU_GREP_COMPAT knob

This was introduced and then disabled by default primarily to avoid dealing
with bugs in libgnuregex. rS363823 switched to using libregex for it, so
let's just rip the option out now so we can make sure we're getting tested
with libregex via bsdgrep.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D27476

3 years agoAdd CFI start/end proc directives to arm64, i386, and ppc
cem [Sat, 5 Dec 2020 00:33:28 +0000 (00:33 +0000)]
Add CFI start/end proc directives to arm64, i386, and ppc

Follow-up to r353959 and r368070: do the same for other architectures.

arm32 already seems to use its own .fnstart/.fnend directives, which
appear to be ARM-specific variants of the same thing.  Likewise, MIPS
uses .frame directives.

Reviewed by: arichardson
Differential Revision: https://reviews.freebsd.org/D27387

3 years agoExpose nonstandard IPv6 kernel definitions to standalone builds.
hselasky [Fri, 4 Dec 2020 21:51:47 +0000 (21:51 +0000)]
Expose nonstandard IPv6 kernel definitions to standalone builds.
No functional change.

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

3 years agonvme: Remove a wmb() that's not necessary.
imp [Fri, 4 Dec 2020 21:34:48 +0000 (21:34 +0000)]
nvme: Remove a wmb() that's not necessary.

bus_dmamap_sync() ensures that memory that's prepared for PREWRITE can
be DMA'd immediately after it returns. The details differ, but this
mirrors atomic thread release semantics, at least for the buffers
synced.

For non-x86 platforms, bus_dmamap_sync() has the right syncing and
fences. So in the past, wmb() had been omitted for them.

For x86 platforms, the memory ordering is already strong enough to
ensure DMA to the device sees the current contents. As such, we don't
need the wmb() here. It translates to an sfence which is only needed
for writes to regions that have the write combining attribute set or
when some exotic opcodes are used. The nvme driver does neither of
these. Since bus_dmamap_sync() includes atomic_thread_fence_rel, we
can be assured any optimizer won't reorder the bus_dmamap_sync and the
bus_space_write operations. The wmb() was a vestiage of the pre-busdma
version initially committed to the tree.

Reviewed by: kib@, gallatin@, chuck@, mav@
Differential Revision: https://reviews.freebsd.org/D27448

3 years agobusdma: Annotate bus_dmamap_sync() with fence
imp [Fri, 4 Dec 2020 21:34:04 +0000 (21:34 +0000)]
busdma: Annotate bus_dmamap_sync() with fence

Add an explicit thread fence release before returning from
bus_dmamap_sync. This should be a no-op in practice, but makes
explicit that all ordinary stores will be completed before subsequent
reads/writes to ordinary device memory. On x86, normal memory ordering
is strong enough to generally guarantee this. The fence keeps the
optimizer (likely LTO) from reordering other calls around this.
The other architectures already have calls, as appropriate, that
are equivalent.

Note: On x86, there is one exception to this rule. If you've mapped
memory as write combining, then you will need to add a sfence or
similar. Normally, though, busdma doesn't operate on such memory, and
drivers that do already cope appropriately.

Reviewed by: kib@, gallatin@, chuck@, mav@
Differential Revision: https://reviews.freebsd.org/D27448