]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agoBump __FreeBSD_version after vget() and HASBUF change
mjg [Sun, 16 Aug 2020 17:56:30 +0000 (17:56 +0000)]
Bump __FreeBSD_version after vget() and HASBUF change

3 years agovfs: mark HASBUF as an internal flag
mjg [Sun, 16 Aug 2020 17:55:20 +0000 (17:55 +0000)]
vfs: mark HASBUF as an internal flag

There is no setter for cn_pnbuf.

3 years agotmpfs: use vget_prep/vget_finish instead of vget + vnode
mjg [Sun, 16 Aug 2020 17:19:23 +0000 (17:19 +0000)]
tmpfs: use vget_prep/vget_finish instead of vget + vnode

3 years agovfs: remove the thread argument from vget
mjg [Sun, 16 Aug 2020 17:18:54 +0000 (17:18 +0000)]
vfs: remove the thread argument from vget

It was already asserted to be curthread.

Semantic patch:

@@

expression arg1, arg2, arg3;

@@

- vget(arg1, arg2, arg3)
+ vget(arg1, arg2)

3 years agoRemove a line which is needed and was added in
tuexen [Sun, 16 Aug 2020 13:31:14 +0000 (13:31 +0000)]
Remove a line which is needed and was added in
https://svnweb.freebsd.org/changeset/base/364268

MFC after: 3 days

3 years agoUnbreak building cp2112(8) as a module outside of kernel build environment.
eugen [Sun, 16 Aug 2020 12:59:43 +0000 (12:59 +0000)]
Unbreak building cp2112(8) as a module outside of kernel build environment.

3 years agoImprove the handling of concurrent send() calls for SCTP sockets,
tuexen [Sun, 16 Aug 2020 11:50:37 +0000 (11:50 +0000)]
Improve the handling of concurrent send() calls for SCTP sockets,
especially when having the explicit EOR mode enabled.

Reported by: Megan2013678@protonmail.com
Reported by: syzbot+bc02585076c3cc977f9b@syzkaller.appspotmail.com
MFC after: 3 days

3 years agoUnbreak nvd(8) build as module outside of kernel build environment.
eugen [Sun, 16 Aug 2020 11:37:28 +0000 (11:37 +0000)]
Unbreak nvd(8) build as module outside of kernel build environment.

3 years agoMerge ^/head r364251 through r364263.
dim [Sat, 15 Aug 2020 22:59:44 +0000 (22:59 +0000)]
Merge ^/head r364251 through r364263.

3 years agoTemporarily disable libunwind's FrameHeaderCache, until there is a
dim [Sat, 15 Aug 2020 22:58:07 +0000 (22:58 +0000)]
Temporarily disable libunwind's FrameHeaderCache, until there is a
resolution for <https://bugs.llvm.org/show_bug.cgi?id=47181>.

The cache implementation depends on dl_iterate_phdr(3) ensuring that its
callbacks are not called simultaneously for multiple threads, but that
is only the case for the dl_iterate_phdr() implementation in rtld.

In a statically linked executable, libc's dl_iterate_phdr() is used,
which does no such locking. If multiple threads then call into the
unwinder at the same time, it is possible to trigger a segfault.

In particular, the statically linked lld which is built during the
cross-tools stage can segfault in this way, because it starts multiple
worker threads that can exit in parallel. Since our pthread_exit(3)
invokes the unwinder, it will therefore call into it in parallel too.

3 years agoUse the sbput() function to write alternate superblocks so that
mckusick [Sat, 15 Aug 2020 21:40:36 +0000 (21:40 +0000)]
Use the sbput() function to write alternate superblocks so that
they get a checkhash.

PR:           246983
Sponsored by: Netflix

3 years agowitness(4): Print stack of prior observed lock order on reversal
cem [Sat, 15 Aug 2020 19:45:50 +0000 (19:45 +0000)]
witness(4): Print stack of prior observed lock order on reversal

The first time Witness observes a lock order between two locks, it records
the caller's stack.  On detected reversal, print out that previous observed
stack.  It is quite possible that the reported "LOR" is the correct
ordering, and the violation was the observed earlier ordering.

Reviewed by: mjg
Differential Revision: https://reviews.freebsd.org/D26070

3 years agopcg-c: Add 'static' to inline function definitions
cem [Sat, 15 Aug 2020 18:46:26 +0000 (18:46 +0000)]
pcg-c: Add 'static' to inline function definitions

Make the inlines static to avoid kernel build failure with Clang 11 on i386.
(The issue was not observed with Clang 10, currently in tree; reproduction
depends on compiler inlining choices.)

The compiler may choose not to inline 'bare' C inlines, and in that case
expects a symbol of the same name will be available.  It does not
automatically define that symbol at use, because of traditional C linking
semantics. (In contrast, C++ does define it, and then deduplicates redundant
definitions at link).  As we do not instantiate the C99 inline ('extern
inline ...;'), the linker errors with "undefined symbol."

Reported by: dim
Tested by: dim
Fixes: r364219

3 years agoCorrect the mask byte order when checking for reserved bits.
qingli [Sat, 15 Aug 2020 16:48:58 +0000 (16:48 +0000)]
Correct the mask byte order when checking for reserved bits.

Reviewed by: gnn
Approved by: gnn
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D26071

3 years agoRISC-V: copy kernelname from the environment
mhorne [Sat, 15 Aug 2020 16:15:34 +0000 (16:15 +0000)]
RISC-V: copy kernelname from the environment

This is allows kern.bootfile to report the correct value.

3 years agoarm64: parse HWCAP values using user_cpu_desc
mhorne [Sat, 15 Aug 2020 15:06:39 +0000 (15:06 +0000)]
arm64: parse HWCAP values using user_cpu_desc

The hard work of parsing fields per-CPU, handling heterogeneous
features, and excluding features from userspace is already done by
update_special_regs. We can build our set of HWCAPs from the result.

This exposed a small bug in update_special_regs, in which the
generated bitmask was not wide enough, and as a result some bits
weren't being exposed in user_cpu_desc. Fix this.

While here, adjust some formatting.

Reviewed by: andrew
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D26069

3 years agoarm64: update instruction set attribute register definitions
mhorne [Sat, 15 Aug 2020 14:57:53 +0000 (14:57 +0000)]
arm64: update instruction set attribute register definitions

This adds definitions for the latest additions to the AA64ISAR[01] ID
registers. This brings these registers in sync with ARMv8.6 initial spec
release.

An future change will parse many of these fields for HWCAP features.

Reviewed by: andrew, manu, markj (all previous versions)
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D26029

3 years agoMerge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
dim [Sat, 15 Aug 2020 12:29:55 +0000 (12:29 +0000)]
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
release/11.x llvmorg-11.0.0-rc1-47-gff47911ddfc.

3 years agoUpdate OptionalObsoleteFiles.inc for added and removed clang 11.0.0
dim [Sat, 15 Aug 2020 12:24:05 +0000 (12:24 +0000)]
Update OptionalObsoleteFiles.inc for added and removed clang 11.0.0
internal headers.

3 years agoMerge ^/head r364082 through r364250.
dim [Sat, 15 Aug 2020 11:49:31 +0000 (11:49 +0000)]
Merge ^/head r364082 through r364250.

3 years agoMake net.inet6.ip6.deembed_scopeid behaviour default & remove sysctl.
melifaro [Sat, 15 Aug 2020 11:37:44 +0000 (11:37 +0000)]
Make net.inet6.ip6.deembed_scopeid behaviour default & remove sysctl.

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

3 years agoEnter epoch earlier. This is needed because we are exiting it also
tuexen [Sat, 15 Aug 2020 11:22:07 +0000 (11:22 +0000)]
Enter epoch earlier. This is needed because we are exiting it also
in error cases.

MFC after: 1 week

3 years ago- Update to Unicode CLDR v35 (Unicode 12.0).
hrs [Sat, 15 Aug 2020 07:19:37 +0000 (07:19 +0000)]
- Update to Unicode CLDR v35 (Unicode 12.0).

- Update tools/tools/locale to add make targets to automatically
  generate locale source files.  With this change, just typing
  "make obj && make -j4" will rebuild them.  Check README for more details.

- Fix issues in ja_JP ctypedef and range specification support
  in utf8-rollup.pl.

- Add a temporary patch for UnicodeData.txt to fix code ranges of
  CJK Ideograph Extension A and Extension B.

- tools/cldr2def.pl:
    Use eucJP for ja_JP ctypedef because eucJP is not compatible with UTF-8.

- tools/convert_map.pl:
    Add a verbose error message.

- tools/utf8-rollup.pl:
    Normalize entries to use Unicode, not UTF-8.

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

3 years agoRemove redeclaration found by gcc build
lwhsu [Sat, 15 Aug 2020 03:26:00 +0000 (03:26 +0000)]
Remove redeclaration found by gcc build

Reviewed by: Jacob Keller <jacob.e.keller@intel.com>
Suggested editing from: Krzysztof Galazka <krzysztof.galazka@intel.com>
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D25954

3 years agoRemove redeclaration found by gcc build
lwhsu [Sat, 15 Aug 2020 03:20:39 +0000 (03:20 +0000)]
Remove redeclaration found by gcc build

Reviewed by: erj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D25953

3 years agokenv: avoid sleepable alloc for integer tunables
jah [Fri, 14 Aug 2020 21:37:38 +0000 (21:37 +0000)]
kenv: avoid sleepable alloc for integer tunables

Avoid performing a potentially-blocking malloc for kenv lookups that will only
perform non-destructive integer conversions on the returned buffer. Instead,
perform the strtoq() in-place with the kenv lock held.

While here, factor the logic around kenv_lock acquire and release into
kenv_acquire() and kenv_release(), and use these functions for some light
cleanup. Collapse getenv_string_buffer() into kern_getenv(), as the former
no longer has any other callers and the only additional task performed by
the latter is a WITNESS check that hasn't been useful since r362231.

PR: 248250
Reported by: gbe
Reviewed by: mjg
Tested by: gbe
Differential Revision: https://reviews.freebsd.org/D26010

3 years agoSimplify dom_<rtattach|rtdetach>.
melifaro [Fri, 14 Aug 2020 21:29:56 +0000 (21:29 +0000)]
Simplify dom_<rtattach|rtdetach>.

Remove unused arguments from dom_rtattach/dom_rtdetach functions and make
  them return/accept 'struct rib_head' instead of 'void **'.
Declare inet/inet6 implementations in the relevant _var.h headers similar
  to domifattach / domifdetach.
Add rib_subscribe_internal() function to accept subscriptions to the rnh
  directly.

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

3 years agovm_pageout: Correct threshold calculation on single-CPU systems
cem [Fri, 14 Aug 2020 18:48:48 +0000 (18:48 +0000)]
vm_pageout: Correct threshold calculation on single-CPU systems

Reported by: Michael Butler
X-MFC-With: r364129

3 years agoRename the pipe_map field of struct pipe.
markj [Fri, 14 Aug 2020 14:50:41 +0000 (14:50 +0000)]
Rename the pipe_map field of struct pipe.

This is to avoid conflicts with a upcoming macro.  pipe_pages is a
more accurate name since the field tracks pages wired into the kernel as
part of a process-to-process copy operation.

Reviewed by: alc, kib
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

3 years agocrunchgen: use pwd -P without env
arichardson [Fri, 14 Aug 2020 09:45:41 +0000 (09:45 +0000)]
crunchgen: use pwd -P without env

The -P flag is required by POSIX so we don't have to care whether pwd is
a shell builtin or not. This also allows removing pwd from the list of
bootstrap tools since all shells we care about for building have a
builtin pwd command. This effectively reverts r364190.

Suggested By: rgrimes, jrtc27

3 years agoBump __FreeBSD_version after r364232
manu [Fri, 14 Aug 2020 08:49:40 +0000 (08:49 +0000)]
Bump __FreeBSD_version after r364232

We now have everything needed for DRM from Linux v5.4, let the
ports tree know that.

3 years agolinuxkpi: Add a few wait_bit functions
manu [Fri, 14 Aug 2020 08:48:17 +0000 (08:48 +0000)]
linuxkpi: Add a few wait_bit functions

The linux function does a lot more than that as multiple waitqueue could be fetch
from a static table based on the hash of the argument but since in DRM it's only used
in one place just add a single variable.
We will probably need to change that in the futur but it's ok with DRM even with current
linux.

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

3 years agoProperly disable LUA_USE_DLOPEN for bootstrap flua
kevans [Fri, 14 Aug 2020 02:40:17 +0000 (02:40 +0000)]
Properly disable LUA_USE_DLOPEN for bootstrap flua

flua does have some specific bits that will include luaconf.h, but the
definition of LUA_USE_DLOPEN for those won't matter. This belongs in liblua
instead.

To expand on my previous commit, which was a little sparse with details,
it's not really safe to allow LUA_USE_DLOPEN with host lib paths being used.
The host system could have an entirely different lua version and this could
cause us to crash and burn.

If we want to revive this later, we need to make sure to define c module
paths inside OBJDIR that are compiled against whatever version we've
bootstrapped.

Pointy hat: kevans

3 years agoflua: don't allow dlopen, et al., for bootstrap flua
kevans [Fri, 14 Aug 2020 02:22:19 +0000 (02:22 +0000)]
flua: don't allow dlopen, et al., for bootstrap flua

There are some logistics issues that need to be sorted out here before we
can actually allow this to work.

3 years agosyslog(3): Send proper NILVALUE if gethostname(3) fails.
bdrewery [Fri, 14 Aug 2020 00:18:18 +0000 (00:18 +0000)]
syslog(3): Send proper NILVALUE if gethostname(3) fails.

RFC5424 defines NILVALUE as '-'. Replace its usage with a macro and
separate out the fields to be more clear. fputs(3) is used in some
places to avoid hiding possible format string problems in a macro.

Reviewed by: cem, vangyzen (earlier version)
Sponsored by: Dell EMC

3 years agoflua: support "require" for binary objects in the base system
emaste [Thu, 13 Aug 2020 23:13:05 +0000 (23:13 +0000)]
flua: support "require" for binary objects in the base system

Export symbols from flua, and enable dlopen.

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

3 years agoAdd test to for FreeBSD-SA-19:20.bsnmp
bdrewery [Thu, 13 Aug 2020 22:42:24 +0000 (22:42 +0000)]
Add test to for FreeBSD-SA-19:20.bsnmp

Submitted by: Darrick Lew <darrick.freebsd at gmail.com>
Reviewed by: cem
Sponsored by: Dell EMC
Differential Revision: https://reviews.freebsd.org/D26037

3 years agolagg: Avoid adding a port to a lagg device being destroyed.
bdrewery [Thu, 13 Aug 2020 22:06:27 +0000 (22:06 +0000)]
lagg: Avoid adding a port to a lagg device being destroyed.

The lagg_clone_destroy() handles detach and waiting for ifconfig callers
to drain already.

This narrows the race for 2 panics that the tests triggered. Both were a
consequence of adding a port to the lagg device after it had already detached
from all of its ports. The link state task would run after lagg_clone_destroy()
free'd the lagg softc.

    kernel:trap_fatal+0xa4
    kernel:trap_pfault+0x61
    kernel:trap+0x316
    kernel:witness_checkorder+0x6d
    kernel:_sx_xlock+0x72
    if_lagg.ko:lagg_port_state+0x3b
    kernel:if_down+0x144
    kernel:if_detach+0x659
    if_tap.ko:tap_destroy+0x46
    kernel:if_clone_destroyif+0x1b7
    kernel:if_clone_destroy+0x8d
    kernel:ifioctl+0x29c
    kernel:kern_ioctl+0x2bd
    kernel:sys_ioctl+0x16d
    kernel:amd64_syscall+0x337

    kernel:trap_fatal+0xa4
    kernel:trap_pfault+0x61
    kernel:trap+0x316
    kernel:witness_checkorder+0x6d
    kernel:_sx_xlock+0x72
    if_lagg.ko:lagg_port_state+0x3b
    kernel:do_link_state_change+0x9b
    kernel:taskqueue_run_locked+0x10b
    kernel:taskqueue_run+0x49
    kernel:ithread_loop+0x19c
    kernel:fork_exit+0x83

PR: 244168
Reviewed by: markj
MFC after: 2 weeks
Sponsored by: Dell EMC
Differential Revision: https://reviews.freebsd.org/D25284

3 years agoAdd prng(9) API
cem [Thu, 13 Aug 2020 20:48:14 +0000 (20:48 +0000)]
Add prng(9) API

Add prng(9) as a replacement for random(9) in the kernel.

There are two major differences from random(9) and random(3):

- General prng(9) APIs (prng32(9), etc) do not guarantee an
  implementation or particular sequence; they should not be used for
  repeatable simulations.

- However, specific named API families are also exposed (for now: PCG),
  and those are expected to be repeatable (when so-guaranteed by the named
  algorithm).

Some minor differences from random(3) and earlier random(9):

- PRNG state for the general prng(9) APIs is per-CPU; this eliminates
  contention on PRNG state in SMP workloads.  Each PCPU generator in an
  SMP system produces a unique sequence.

- Better statistical properties than the Park-Miller ("minstd") PRNG
  (longer period, uniform distribution in all bits, passes
  BigCrush/PractRand analysis).

- Faster than Park-Miller ("minstd") PRNG -- no division is required to
  step PCG-family PRNGs.

For now, random(9) becomes a thin shim around prng32().  Eventually I
would like to mechanically switch consumers over to the explicit API.

Reviewed by: kib, markj (previous version both)
Discussed with: markm
Differential Revision: https://reviews.freebsd.org/D25916

3 years agoFix a typo in the cpp macro defined for PIC.
jhb [Thu, 13 Aug 2020 20:28:35 +0000 (20:28 +0000)]
Fix a typo in the cpp macro defined for PIC.

In practice this isn't used in OpenSSL outside of some sparc-specific
code.

Reviewed by: delphij
Differential Revision: https://reviews.freebsd.org/D26058

3 years agoMove rtzone handling code to net/route_ctl.c
melifaro [Thu, 13 Aug 2020 18:35:29 +0000 (18:35 +0000)]
Move rtzone handling code to net/route_ctl.c

After moving the route control plane code from net/route.c,
 all rtzone users ended up being in net/route_ctl.c.
Move uma(9) rtzone setup/teardown code to net/route_ctl.c as well
 to have everything in a single place.

While here, remove custom initializers from the zone.
It was added originally to avoid setup/teardown of costy per-cpu couters.
With these counters removed, the only remaining job was avoiding rte mutex
 setup/teardown. Mutex setup is relatively cheap. Additionally, this mutex
 will soon be removed. With that in mind, there is no sense in keeping
 custom zone callbacks.

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

3 years agoTCP Cubic: Have Fast Convergence Heuristic work for ECN, and align concave region
rscheff [Thu, 13 Aug 2020 16:45:55 +0000 (16:45 +0000)]
TCP Cubic: Have Fast Convergence Heuristic work for ECN, and align concave region

The Cubic concave region was not aligned nicely for the very first exit from
slow start, where a 50% cwnd reduction is done instead of the normal 30%.

This addresses an issue, where a short line-rate burst could result from that
sudden jump of cwnd.

In addition, the Fast Convergence Heuristic has been expanded to work also
with ECN induced congestion response.

Submitted by: chengc_netapp.com
Reported by: chengc_netapp.com
Reviewed by: tuexen (mentor), rgrimes (mentor)
Approved by: tuexen (mentor), rgrimes (mentor)
MFC after: 3 weeks
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D25976

3 years agoTCP Cubic: After leaving slowstart fix unintended cwnd jump.
rscheff [Thu, 13 Aug 2020 16:38:51 +0000 (16:38 +0000)]
TCP Cubic: After leaving slowstart fix unintended cwnd jump.

Initializing K to zero in D23655 introduced a miscalculation,
where cwnd would suddenly jump to cwnd_max instead of gradually
increasing, after leaving slow-start.

Properly calculating K instead of resetting it to zero resolves
this issue. Also making sure, that cwnd is recalculated at the
earliest opportunity once slow-start is over.

Reported by: chengc_netapp.com
Reviewed by: chengc_netapp.com, tuexen (mentor), rgrimes (mentor)
Approved by: tuexen (mentor), rgrimes (mentor)
MFC after: 3 weeks
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D25746

3 years agoImprove SACK support code for RFC6675 and PRR
rscheff [Thu, 13 Aug 2020 16:30:09 +0000 (16:30 +0000)]
Improve SACK support code for RFC6675 and PRR

Adding proper accounting of sacked_bytes and (per-ACK)
delivered data to the SACK scoreboard. This will
allow more aspects of RFC6675 to be implemented as well
as Proportional Rate Reduction (RFC6937).

Prior to this change, the pipe calculation controlled with
net.inet.tcp.rfc6675_pipe was also susceptible to incorrect
results when more than 3 (or 4) holes in the sequence space
were present, which can no longer all fit into a single
ACK's SACK option.

Reviewed by: kbowling, rgrimes (mentor)
Approved by: rgrimes (mentor, blanket)
MFC after: 3 weeks
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D18624

3 years agoEnable interrupts while handling traps
mhorne [Thu, 13 Aug 2020 14:21:05 +0000 (14:21 +0000)]
Enable interrupts while handling traps

I observed hangs post-r362977 in QEMU with -smp 2, in which one thread
would acquire write access to an rm_lock (sysctllock) and get stuck
waiting in smp_rendezvous_cpus while the other CPU was servicing a trap.
The other thread was waiting for read access to the same lock, thus
causing deadlock.

It's clear that this is just one symptom of a larger problem. The
general expectation of MI kernel code is that interrupts are enabled.
Violating this assumption will at best create some additional latency,
but otherwise might cause locking or other unforeseen issues. All other
architectures do so for some subset of trap values, but this somehow got
missed in the RISC-V port. Enable interrupts now during kernel page
faults and for all user trap types.

The code in exception.S already knows to disable interrupts while
handling the return from exception, so there are no changes required
there.

Reviewed by: jhb, markj
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D26017

3 years agoSmall fixes in locore.S
mhorne [Thu, 13 Aug 2020 14:17:36 +0000 (14:17 +0000)]
Small fixes in locore.S

 - Properly set up the frame pointer
 - Hang if we return from mi_startup
 - Whitespace

Clearing the frame pointer marks the end of the backtrace. This fixes
"bt 0" in ddb, which previously would unwind one frame too far.

Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D26016

3 years agoMake bsd.linker.mk work with the MacOS linker
arichardson [Thu, 13 Aug 2020 14:14:51 +0000 (14:14 +0000)]
Make bsd.linker.mk work with the MacOS linker

This is not strictly required for crossbuilding but having lots of warnings
from bsd.linker.mk in the output was making it hard to see the actual
warning messages.

Reviewed By: imp
Differential Revision: https://reviews.freebsd.org/D14318

3 years agoAdd pwd to the list of tools that are linked to $WORLDTMP/legacy
arichardson [Thu, 13 Aug 2020 14:14:46 +0000 (14:14 +0000)]
Add pwd to the list of tools that are linked to $WORLDTMP/legacy

After r364166 and r364174, crunchgen needs a pwd binary in $PATH instead
of using a hardcoded absolute path. This commit is needed for
BUILD_WITH_STRICT_TMPPATH builds (currently not on by default).

3 years agovfs: add missing pwd_drop on error in namei_setup
mjg [Thu, 13 Aug 2020 10:24:45 +0000 (10:24 +0000)]
vfs: add missing pwd_drop on error in namei_setup

Reported by: pho

3 years agoifconfig(8): plug memory leak after r361790 by me.
eugen [Thu, 13 Aug 2020 06:32:39 +0000 (06:32 +0000)]
ifconfig(8): plug memory leak after r361790 by me.

MFC after: 3 days

3 years agoFill device serial_num and device_id in NVMe XPT.
mav [Thu, 13 Aug 2020 02:32:46 +0000 (02:32 +0000)]
Fill device serial_num and device_id in NVMe XPT.

It allows to report GEOM::lunid for nda(4) same as for nvd(4).  Since
NVMe now allows multiple LUs (namespaces) with multiple paths unique
LU identification is important.  The serial_num field is filled same
as before with the controller serial number, while device_id is based
on namespace GUID and/or EUI64 fields as recommended by "NVM Express:
SCSI Translation Reference" and matching nvd(4) at the end.

MFC after: 1 week

3 years agoflua: initial support for "require" in the base system
emaste [Thu, 13 Aug 2020 00:19:05 +0000 (00:19 +0000)]
flua: initial support for "require" in the base system

Use /usr not /usr/local for base system components.

Use /usr/lib/flua and /usr/share/flua (not lua) for consistency and to
avoid the possibility that other software accidentally finds our base
system modules.

Also drop the version from the path, as flua represents an unspecified
lua version that corresponds to the FreeBSD version it comes with.

LUA_USE_DLOPEN is not yet enabled because some additional changes are
needed wrt symbol visibility.

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

3 years agoCheck that the frame pointer is within the current stack.
jhb [Wed, 12 Aug 2020 20:33:29 +0000 (20:33 +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: mhorne
Obtained from: CheriBSD
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D25996

3 years agoUse uintptr_t instead of uint64_t for pointers in stack frames.
jhb [Wed, 12 Aug 2020 20:29:49 +0000 (20:29 +0000)]
Use uintptr_t instead of uint64_t for pointers in stack frames.

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

3 years agoReport cpi->hba_* for nda(4) because why not.
mav [Wed, 12 Aug 2020 20:05:43 +0000 (20:05 +0000)]
Report cpi->hba_* for nda(4) because why not.

MFC after: 1 week

3 years agoReport proper stripesize for nda(4).
mav [Wed, 12 Aug 2020 19:37:57 +0000 (19:37 +0000)]
Report proper stripesize for nda(4).

Same as for nvd(4) report NPWG if present, otherise NOIOB.

MFC after: 1 week

3 years agoReport attachment for nvd same as reported for nda.
mav [Wed, 12 Aug 2020 19:11:53 +0000 (19:11 +0000)]
Report attachment for nvd same as reported for nda.

MFC after: 1 week

3 years agoCorrect padding length for RISC-V PCPU data.
jhb [Wed, 12 Aug 2020 18:45:36 +0000 (18:45 +0000)]
Correct padding length for RISC-V PCPU data.

There was an additional 7 bytes of compiler-inserted padding at the
end of the structure visible via 'ptype /o' in gdb.

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

3 years agoUse env pwd instead of pwd in crunchgen.c
arichardson [Wed, 12 Aug 2020 17:27:24 +0000 (17:27 +0000)]
Use env pwd instead of pwd in crunchgen.c

In r364166 I changed /bin/pwd to pwd, but pwd can be shell builtin that
may not correctly return a real path. To ensure that all symlinks are
resolved use `env pwd -P` instead (the -P flag is part of POSIX so
should be supported everywhere).

Reported By: rgrimes
Suggested By: jrtc27

3 years agoCorrectly set error in rt_mpath_unlink
mhorne [Wed, 12 Aug 2020 16:43:20 +0000 (16:43 +0000)]
Correctly set error in rt_mpath_unlink

It is possible for rn_delete() to return NULL. If this happens, then set
*perror to ESRCH, as is done in the rest of the function.

Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D25871

3 years agolinprocfs: Fix some inaccuracies in meminfo.
markj [Wed, 12 Aug 2020 16:08:44 +0000 (16:08 +0000)]
linprocfs: Fix some inaccuracies in meminfo.

- Fill out MemFree correctly.  Delete an ancient comment suggesting that
  we don't want to advertise the true quantity of free memory.
- Populate the Buffers field by reading vfs.bufspace.
- The page cache consists of all pages in page queues, not just the
  inactive queue.

PR: 248463
Reported and tested by: danfe
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

3 years agoFix stand/newvers.sh with zsh in sh mode
arichardson [Wed, 12 Aug 2020 15:49:10 +0000 (15:49 +0000)]
Fix stand/newvers.sh with zsh in sh mode

When building on macOS with sh==zsh, newvers.sh was producing an
unterminated string literal due to \\n being turned as a newline. Fix this
by using a here document instead.

Reviewed By: imp
Differential Revision: https://reviews.freebsd.org/D26036

3 years agoFix crunchgen usage of mkstemp()
arichardson [Wed, 12 Aug 2020 15:49:06 +0000 (15:49 +0000)]
Fix crunchgen usage of mkstemp()

On Glibc systems mkstemp can only be used once with the same template
string since it will be modified in-place and no longer contain any 'X' chars.
It is fine to reuse the same file here but we need to be explicit and use
open() instead of mkstemp() on the second use.

While touching this file also avoid a hardcoded /bin/pwd since that may not
work when building on non-FreeBSD systems.

Reviewed By: brooks
Differential Revision: https://reviews.freebsd.org/D25990

3 years agoiflib: netmap: improve rxsync to support IFLIB_HAS_RXCQ
vmaffione [Wed, 12 Aug 2020 14:45:31 +0000 (14:45 +0000)]
iflib: netmap: improve rxsync to support IFLIB_HAS_RXCQ

For drivers with IFLIB_HAS_RXCQ set, there is a separate completion
queue. In this case, the netmap rxsync routine needs to update
rxq->ifr_cq_cidx in the same way it is updated by iflib_rxeof().
This improves the situation for vmx(4) and bnxt(4) drivers, which
use iflib and have the IFLIB_HAS_RXCQ bit set.

PR: 248494
MFC after: 3 weeks

3 years agoiflib: refactor netmap_fl_refill and fix off-by-one issue
vmaffione [Wed, 12 Aug 2020 14:17:38 +0000 (14:17 +0000)]
iflib: refactor netmap_fl_refill and fix off-by-one issue

First, fix the initialization of the fl->ifl_rxd_idxs array,
which was affected by an off-by-one bug.
Once there, refactor the function to use better names for
local variables, optimize the variable assignments, and
merge the bus_dmamap_sync() inner loop with the outer one.

PR: 248494
MFC after: 3 weeks

3 years agohook cp2112.4 to the build
avg [Wed, 12 Aug 2020 11:37:28 +0000 (11:37 +0000)]
hook cp2112.4 to the build

Reported by: 0mp
MFC after: 1 week
X-MFC with: r364144

3 years agohook gpiokeys.4 to the build
avg [Wed, 12 Aug 2020 11:36:09 +0000 (11:36 +0000)]
hook gpiokeys.4 to the build

Reported by: 0mp
MFC after: 3 days
X-MFC with: r363905

3 years agoAdd support for Cortex-A76/Neoverse-N1 to hwpmc
andrew [Wed, 12 Aug 2020 10:17:17 +0000 (10:17 +0000)]
Add support for Cortex-A76/Neoverse-N1 to hwpmc

This adds support for the Cortex-A76 and Neoverse-N1 PMU counters to pmc.

While here add more PMCR_IDCODE values and check the implementers code is
correct before setting the PMU type.

Reviewed by: bz, emaste (looks reasonable to me)
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D25959

3 years agoaw_cir: in the pulse encoding the actual length is one greater than value
avg [Wed, 12 Aug 2020 09:57:28 +0000 (09:57 +0000)]
aw_cir: in the pulse encoding the actual length is one greater than value

While here change type of some variables from long to int, it's sufficient.
Also, add length reporting to a couple of debug printfs.

MFC after: 3 weeks

3 years agoaw_cir: lower activation threshold to support NECx protocol
avg [Wed, 12 Aug 2020 09:56:21 +0000 (09:56 +0000)]
aw_cir: lower activation threshold to support NECx protocol

In NECx the leading mark has length of 8T as opposed to 16T in NEC,
where T is  562.5 us.  So, 4.5 ms.
Our threshold was set to 128 * 42.7 us (derived from the sampling
frequency of 3/128 MHz).  So, ~5.5 ms.

The new threshold is set to AW_IR_L1_MIN.  I think that's a good enough
lower bound for detecting the leading pulse.

Also, calculations of active_delay (which is activation delay) are fixed.
Previously they would be wrong if AW_IR_ACTIVE_T was anything but zero,
because the value was already bit-shifted.

Finally, I am not sure why the activation delay was divided by two when
calculating the initial pulse length.  I have not found anything that
would explain or justify it.  So, I removed that division.

MFC after: 3 weeks

3 years agoaw_cir: minor cleanups
avg [Wed, 12 Aug 2020 09:52:39 +0000 (09:52 +0000)]
aw_cir: minor cleanups

MFC after: 1 week

3 years agoaw_cir: add support for allwinner,sun6i-a31-ir (found, e.g., on h3)
avg [Wed, 12 Aug 2020 09:52:12 +0000 (09:52 +0000)]
aw_cir: add support for allwinner,sun6i-a31-ir (found, e.g., on h3)

MFC after: 1 week

3 years agogpiokeys: add evdev support
avg [Wed, 12 Aug 2020 09:49:25 +0000 (09:49 +0000)]
gpiokeys: add evdev support

Only linux,code is supported as it maps 1:1 to evdev key codes.
No reverse mapping for freebsd,code yet.

Reviewed by: wulf
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D25940

3 years agoadd a manual page for cp2112
avg [Wed, 12 Aug 2020 09:42:05 +0000 (09:42 +0000)]
add a manual page for cp2112

MFC after: 1 week

3 years agocp2112: a number of cleanups and improvements
avg [Wed, 12 Aug 2020 09:07:07 +0000 (09:07 +0000)]
cp2112: a number of cleanups and improvements

- hoist all request / response structures from function level to top level
- replace magic numeric literals with constants
- regroup types, data and functions
- remove setting of the id field in responses as they are completely
  overwritten with data from the device
- centralize setting of the id field as it is always set to the value of
  request type
- fix setting and querying of open-drain vs push-pull configuration of
  an output pin -- it's always in one of those configurations
- detect special pin configurations: a pin in a special configuration is
  neither general purpose input or output
- there is still no support for setting special configurations

MFC after: 2 weeks

3 years agovfs: inline vrefcnt
mjg [Wed, 12 Aug 2020 04:53:20 +0000 (04:53 +0000)]
vfs: inline vrefcnt

3 years agovfs: garbage collect vrefactn
mjg [Wed, 12 Aug 2020 04:53:02 +0000 (04:53 +0000)]
vfs: garbage collect vrefactn

3 years agovfs: reimplement vref on top of vget
mjg [Wed, 12 Aug 2020 04:52:35 +0000 (04:52 +0000)]
vfs: reimplement vref on top of vget

No change in generated assembly.

3 years agoFix a bug introduced by r363001 for the ext_pgs case.
rmacklem [Wed, 12 Aug 2020 04:35:49 +0000 (04:35 +0000)]
Fix a bug introduced by r363001 for the ext_pgs case.

r363001 added support for ext_pgs mbufs to nfsm_uiombuf().
By inspection, I noticed that "mlen" was not set non-zero and, as such, there
would be an iteration of the loop that did nothing.
This patch sets it.
This bug would have no effect on the system, since the ext_pgs mbuf code
is not yet enabled.

3 years agodevfs: Abstract locking assertions
cem [Wed, 12 Aug 2020 00:32:31 +0000 (00:32 +0000)]
devfs: Abstract locking assertions

The conversion was largely mechanical: sed(1) with:

  -e 's|mtx_assert(&devmtx, MA_OWNED)|dev_lock_assert_locked()|g'
  -e 's|mtx_assert(&devmtx, MA_NOTOWNED)|dev_lock_assert_unlocked()|g'

The definitions of these abstractions in fs/devfs/devfs_int.h are the
only non-mechanical change.

No functional change.

3 years agoBack out unrelated change
cem [Wed, 12 Aug 2020 00:21:30 +0000 (00:21 +0000)]
Back out unrelated change

Reported by: kib, markj
X-MFC-With: r364129

3 years agoWhen booting a system with WITHOUT_IPFILTER the following errors
cy [Tue, 11 Aug 2020 23:36:38 +0000 (23:36 +0000)]
When booting a system with WITHOUT_IPFILTER the following errors
are encountered at boot time:

rcorder: requirement `ipfs' in file `/etc/rc.d/netif' has no providers.
rcorder: requirement `ipfilter' in file `/etc/rc.d/netif' has no
providers.
rcorder: requirement `ipfilter' in file `/etc/rc.d/netwait' has no
providers.
rcorder: requirement `ipfilter' in file `/etc/rc.d/net_watchdog' has no
providers.
rcorder: requirement `ipfilter' in file `/etc/rc.d/securelevel' has no
providers.

Listing its own requrements in BEFORE rather than use REQUIRE of
non-optional scripts resolves this issue.

The issue was discovered and patched by glebius at Netflix.

Submitted by: glebius
Reported by: glebius
MFC after: 1 week

3 years agosince kld_deb.py was removed a while back, this script isn't useful
jmg [Tue, 11 Aug 2020 22:33:56 +0000 (22:33 +0000)]
since kld_deb.py was removed a while back, this script isn't useful
anymore...

3 years agotput(1): Several enhancements for the manual page
gbe [Tue, 11 Aug 2020 21:44:43 +0000 (21:44 +0000)]
tput(1): Several enhancements for the manual page

- a couple of descriptions are incomplete
- synopsis doesn't show that all arguments are optional
- missing an ENVIRONMENT section with TERM mentioned

PR: 84670
Submitted by: Gary W. Swearingen <garys at opusnet dot com>
Reviewed by: bcr
Approved by: bcr
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D26009

3 years agosmp.h: Reconcile definition and declaration of smp_ncpus
cem [Tue, 11 Aug 2020 20:42:21 +0000 (20:42 +0000)]
smp.h: Reconcile definition and declaration of smp_ncpus

The variable is defined unconditionally; declare it unconditionally as well.

It is already initialized to the correct value (1) for !SMP builds.

No functional change.

3 years agoAdd support for multithreading the inactive queue pageout within a domain.
cem [Tue, 11 Aug 2020 20:37:45 +0000 (20:37 +0000)]
Add support for multithreading the inactive queue pageout within a domain.

In very high throughput workloads, the inactive scan can become overwhelmed
as you have many cores producing pages and a single core freeing.  Since
Mark's introduction of batched pagequeue operations, we can now run multiple
inactive threads working on independent batches.

To avoid confusing the pid and other control algorithms, I (Jeff) do this in
a mpi-like fan out and collect model that is driven from the primary page
daemon.  It decides whether the shortfall can be overcome with a single
thread and if not dispatches multiple threads and waits for their results.

The heuristic is based on timing the pageout activity and averaging a
pages-per-second variable which is exponentially decayed. This is visible in
sysctl and may be interesting for other purposes.

I (Jeff) have verified that this does indeed double our paging throughput
when used with two threads. With four we tend to run into other contention
problems.  For now I would like to commit this infrastructure with only a
single thread enabled.

The number of worker threads per domain can be controlled with the
'vm.pageout_threads_per_domain' tunable.

Submitted by: jeff (earlier version)
Discussed with: markj
Tested by: pho
Sponsored by: probably Netflix (based on contemporary commits)
Differential Revision: https://reviews.freebsd.org/D21629

3 years agoAllow linking the kernel with a linker that doesn't support -z ifunc-noplt
arichardson [Tue, 11 Aug 2020 16:47:00 +0000 (16:47 +0000)]
Allow linking the kernel with a linker that doesn't support -z ifunc-noplt

This can happen when linking with upstream LLD < 9.0.

Reviewed By: markj
Differential Revision: https://reviews.freebsd.org/D25985

3 years agoFix libdtrace build with zsh as /bin/sh
arichardson [Tue, 11 Aug 2020 16:46:54 +0000 (16:46 +0000)]
Fix libdtrace build with zsh as /bin/sh

When zsh runs in POSIX sh mode it does not support the -e flag to echo.
Use printf instead of echo to avoid the "-e" characters being printed.

Obtained from: CheriBSD
Reviewed By: markj
Differential Revision: https://reviews.freebsd.org/D26026

3 years agoFix -DBUILD_WITH_STRICT_TMPPATH dtrace builds
arichardson [Tue, 11 Aug 2020 16:46:48 +0000 (16:46 +0000)]
Fix -DBUILD_WITH_STRICT_TMPPATH dtrace builds

Some of the scripts used for libdtrace invoke nawk instead of awk
(for example cddl/contrib/opensolaris/lib/libdtrace/common/mknames.sh).
When bootstrapping all tools, we get the nawk -> awk link while building
usr.bin/awk, but when linking/copying the dependencies from the host we
were only adding awk but not nawk.

This was silently generating invalid files when building libdtrace with
BUILD_WITH_STRICT_TMPPATH=1 since those scripts invoke nawk instead of
awk. In addition to adding the missing link this commit also adds
set -e to those scripts to catch errors like this in the future.

Reviewed By: markj, emaste
Differential Revision: https://reviews.freebsd.org/D26025

3 years agoAdd CLANG/LLD/LLD to BROKEN_OPTIONS when building on non-FreeBSD
arichardson [Tue, 11 Aug 2020 16:46:43 +0000 (16:46 +0000)]
Add CLANG/LLD/LLD to BROKEN_OPTIONS when building on non-FreeBSD

These tools require a bootstrap llvm-tblgen/clang-tblgen and that cannot
be built with the current make infrastructure: the config header is not
correct for Linux/macOS and we don't include the CMakeLists.txt in contrib
so we can't generate one that would be correct.

Reviewed By: emaste, imp, dim
Differential Revision: https://reviews.freebsd.org/D14245

3 years agoFix bootstrapping of pwd_mkdb after r364049
arichardson [Tue, 11 Aug 2020 16:46:38 +0000 (16:46 +0000)]
Fix bootstrapping of pwd_mkdb after r364049

I moved the bootstrap pwd.h to a subdirectory in r364049 but forgot to
adjust the #include path.

3 years agoFix bootstrapping ldd after r362152
arichardson [Tue, 11 Aug 2020 16:46:33 +0000 (16:46 +0000)]
Fix bootstrapping ldd after r362152

r362152 started using DF_1_PIE, which is not present in older versions
of sys/elf_common.h. To fix this include the ELF headers as part of -legacy.

3 years agoAllow overriding the tool used for stripping binaries
arichardson [Tue, 11 Aug 2020 16:46:27 +0000 (16:46 +0000)]
Allow overriding the tool used for stripping binaries

Since the make variable STRIP is already used for other purposes, this
uses STRIPBIN (which is also used for the same purpose by install(1).
This allows using LLVM objcopy to strip binaries instead of the in-tree
elftoolchain objcopy. We make use of this in CheriBSD since passing
binaries generated by our toolchain to elftoolchain strip sometimes results
in assertion failures.

This allows working around https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=248516
by specifying STRIPBIN=/path/to/llvm-strip

Obtained from: CheriBSD
Reviewed By: emaste, brooks
Differential Revision: https://reviews.freebsd.org/D25988

3 years agoRemove sys/compat/netbsd.
markj [Tue, 11 Aug 2020 16:40:09 +0000 (16:40 +0000)]
Remove sys/compat/netbsd.

It contained only a header used by ncv(4), which was mainly used on pc98
systems.  Both ncv(4) and pc98 support have long been removed.

3 years agoipfw: make the "frag" keyword accept additional options "mf",
glebius [Tue, 11 Aug 2020 15:46:22 +0000 (15:46 +0000)]
ipfw: make the "frag" keyword accept additional options "mf",
"df", "rf" and "offset".  This allows to match on specific
bits of ip_off field.

For compatibility reasons lack of keyword means "offset".

Reviewed by: ae
Differential Revision: https://reviews.freebsd.org/D26021

3 years agodevfs: rework si_usecount to track opens
mjg [Tue, 11 Aug 2020 14:27:57 +0000 (14:27 +0000)]
devfs: rework si_usecount to track opens

This removes a lot of special casing from the VFS layer.

Reviewed by: kib (previous version)
Tested by: pho (previous version)
Differential Revision: https://reviews.freebsd.org/D25612

3 years agoscript: Minor cleanups.
markj [Tue, 11 Aug 2020 14:19:05 +0000 (14:19 +0000)]
script: Minor cleanups.

- Instead of using isatty() to decide whether to call tcgetattr(), just
  call tcgetattr() directly, since that's all that isatty() does anyway.
- Simplify error handling in termset().  Check for errno != ENOTTY from
  tcgetattr() to handle errors that may be raised while running
  script(1) under a debugger.

PR: 248377
Submitted by: Soumendra Ganguly <soumendraganguly@gmail.com>
MFC after: 1 week

3 years agoUse atomic_clear_rel_long() to implement clear_bit_unlock() in the LinuxKPI
hselasky [Tue, 11 Aug 2020 12:41:40 +0000 (12:41 +0000)]
Use atomic_clear_rel_long() to implement clear_bit_unlock() in the LinuxKPI
after r363842.

Suggested by: alc@
MFC after: 1 week
Sponsored by: Mellanox Technologies

3 years agoNeed to clone the task struct fields related to RCU aswell in the
hselasky [Tue, 11 Aug 2020 12:17:46 +0000 (12:17 +0000)]
Need to clone the task struct fields related to RCU aswell in the
LinuxKPI after r359727. This fixes a minor regression issue. Else the
priority tracking won't work properly when both sleepable and
non-sleepable RCU is in use on the same thread.

Bump the __FreeBSD_version to force recompilation of external kernel
modules.

PR: 242272
MFC after: 1 week
Sponsored by: Mellanox Technologies

3 years agopkgbase: Replace / with | for PKG_WWW
manu [Tue, 11 Aug 2020 10:07:59 +0000 (10:07 +0000)]
pkgbase: Replace / with | for PKG_WWW

PKG_WWW contain / char, replace the delimiter by a '|'.

Reported by: 0mp