]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agomulti-boot for openstack/qcow images
imp [Mon, 27 Jan 2020 22:40:03 +0000 (22:40 +0000)]
multi-boot for openstack/qcow images

Make stock FreeBSD more useful for people wishing to use them. The
QEMU folks suggested this change. It adds a serial console which
allows them to interact with FreeBSD from the earliest moments. This
allows them to configure FreeBSD via the serial port to set it up for
CI use.

Reviewed by: kevans@
Sponsored by: Netflix, Inc
Differential Revision: https://reviews.freebsd.org/D22786

4 years agoMake mqueue objects work across a fork again.
imp [Mon, 27 Jan 2020 22:36:54 +0000 (22:36 +0000)]
Make mqueue objects work across a fork again.

In r110908 (2003) alfred added DFLAG_PASSABLE to tag those types of FD
that can be passed via unix pipes, but mqueuefs didn't exist
yet. Later, in r152825 (2005) davidxu neglected to include
DFLAG_PASSABLE since people don't normally pass these things via unix
sockets (it's a FreeBSD implementation detail that it's a file
descriptor, nobody noticed). Then r223866 (2011) by jonathan used the
new flag in fdcopy, which fork uses. Due to that, mqueuefs actually
broke mqueue objects being propagated by fork. No mention of mqueuefs
was made in r223866, so I think it was an unintended consequence.

Fix this by tagging mqueuefs as passable as well. They were prior to
alfred's change (and it's clear there's no intent in his change to
change this behavior), and POSIX requires this to be the case as well.

PR: 243103
Reviewed by: kib@, jiles@
Differential Revision: https://reviews.freebsd.org/D23038

4 years agoNo need to have an extra layer of indirection here. Call the sdhci_cam_requiest
imp [Mon, 27 Jan 2020 22:20:02 +0000 (22:20 +0000)]
No need to have an extra layer of indirection here. Call the sdhci_cam_requiest
routine directly when handling a MMIO request.

4 years agoCreate a convenince wrapper to fill in a CAM_PATH_INQ request for MMC sims. Pass
imp [Mon, 27 Jan 2020 22:19:55 +0000 (22:19 +0000)]
Create a convenince wrapper to fill in a CAM_PATH_INQ request for MMC sims. Pass
in the parameters needed for the different sims, but it's almost all identical.

4 years agoCorrect the use of RB_AUGMENT in the RB_TREE macros so that is invoked
dougm [Mon, 27 Jan 2020 15:09:13 +0000 (15:09 +0000)]
Correct the use of RB_AUGMENT in the RB_TREE macros so that is invoked
at the root of every subtree that changes in an insert or delete, and
only once, and ordered from the bottom of the tree to the top.  For
intel_gas.c, the only user of RB_AUGMENT I can find, change the
augmenting routine so that it does not climb from entry to tree root
on every call, and remove a 'tree correcting' function that can be
supplanted by proper tree augmentation.

Reviewed by: kib
Tested by: pho
Differential Revision: https://reviews.freebsd.org/D23189

4 years agoFix aggregating geoms for BIO_SPEEDUP.
kib [Mon, 27 Jan 2020 13:15:16 +0000 (13:15 +0000)]
Fix aggregating geoms for BIO_SPEEDUP.

If the bio was split into several bios going down, completion computes
bio_completed of the original bio as sum of the bio_completes of the
splits.  For BIO_SETUP, bio_length means something different than the
length. it is the requested speedup amount, and is duplicated into the
splits, which is in fact reasonable, since we cannot know how the
previous activity was distributed among subordinate geoms.  Obviously,
the sum of n bio_length is greater than bio_length for n > 1, which
triggers assert that bio_length >= bio_completed for e.g. geom_stripe
and geom_raid3.

Fix this by reassigning bio_completed from bio_length for completed
BIO_SPEEDED, I do not think it really mattters what we return in
bio_completed.

Reported and tested by: pho
Reviewed by: imp
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D23380

4 years agoBuild hard-float lib32 for mips64hf/mips64elhf
arichardson [Mon, 27 Jan 2020 12:02:47 +0000 (12:02 +0000)]
Build hard-float lib32 for mips64hf/mips64elhf

This should fix linker errors when building with clang+lld.
After this change the lib32 compat libraries are now buildt with
-mhard-float instead of -msoft-float

Reviewed By: brooks, jhb
Differential Revision: https://reviews.freebsd.org/D23229

4 years agoAllow bootstrapping makefs on older FreeBSD hosts and Linux/macOS
arichardson [Mon, 27 Jan 2020 12:02:41 +0000 (12:02 +0000)]
Allow bootstrapping makefs on older FreeBSD hosts and Linux/macOS

In order to do so we need to install the msdosfs headers to the bootstrap
sysroot and avoid includes of kernel headers that may not exist on every
host (e.g. sys/lockmgr.h). This change should allow bootstrapping of makefs
on FreeBSD 11+ as well as Linux and macOS.

We also have to avoid using the IO_SYNC macro since that may not be
available. In makefs it is only used to switch between calling
bwrite() and bdwrite() which both call the same function. Therefore we
can simply always call bwrite().

For our CheriBSD builds we always bootstrap makefs by setting
LOCAL_XTOOL_DIRS='lib/libnetbsd usr.sbin/makefs' and use the makefs binary
from the build tree to create a bootable disk image.

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

4 years agohwpstate(4): Log a debug line when throttled
cem [Mon, 27 Jan 2020 06:04:32 +0000 (06:04 +0000)]
hwpstate(4): Log a debug line when throttled

If we're going to throttle user requested P-states, we should at least produce
a debug log line indicating the surprising behavior.

PR: inspired by 234733

4 years agoEnter net epoch in msk_tick.
kan [Mon, 27 Jan 2020 00:14:51 +0000 (00:14 +0000)]
Enter net epoch in msk_tick.

One more instance of if_input being called outside of
interrupt, by means of msk_handle_events.

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

4 years agonetmap_mem_unmap: fix NULL pointer dereference
vmaffione [Sun, 26 Jan 2020 21:34:46 +0000 (21:34 +0000)]
netmap_mem_unmap: fix NULL pointer dereference

MFC after: 3 days

4 years agoFix a crash in the NFSv4 server.
rmacklem [Sun, 26 Jan 2020 17:59:05 +0000 (17:59 +0000)]
Fix a crash in the NFSv4 server.

The PR reported a crash that occurred when a file was removed while
client(s) were actively doing lock operations on it.
Since nfsvno_getvp() will return NULL when the file does not exist,
the bug was obvious and easy to fix via this patch. It is a little
surprising that this wasn't found sooner, but I guess the above
case rarely occurs.

Tested by: iron.udjin@gmail.com
PR: 242768
Reported by: iron.udjin@gmail.com
MFC after: 2 weeks

4 years agoRevert accidental change from r357146.
jhb [Sun, 26 Jan 2020 14:23:27 +0000 (14:23 +0000)]
Revert accidental change from r357146.

4 years agoFix some misleading indentation warnings reported by recent clang.
jhb [Sun, 26 Jan 2020 14:20:57 +0000 (14:20 +0000)]
Fix some misleading indentation warnings reported by recent clang.

These should not be any functional change.  While the change in
emul10kx-pcm.c looks like a real bug fix (as opposed to inconsistent
whitespace), the extra statements were not harmful.

Reviewed by: kib
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D23363

4 years agoCompile hack.c with normal CFLAGS + -shared -nostdlib.
jhb [Sun, 26 Jan 2020 14:19:08 +0000 (14:19 +0000)]
Compile hack.c with normal CFLAGS + -shared -nostdlib.

Originally, hack.c was compiled into a shard object with just -shared
-nostdlib.  This assumed that ${CC} did not require any additional
flags for ABIs, cross-building, etc.

When kern.post.mk was created in r89509 by reducing duplication in
kernel Makefile.<arch> files, the -shared flag was moved into a
HACK_EXTRA_FLAGS variable so that sparc64 could override it with
-Wl,-shared.  The sparc64 hack was removed in r111650, but
HACK_EXTRA_FLAGS was left in place.  Over time, we have started
support toolchains that require flags to support alternate ABIs on
MIPS and PowerPC and started (ab)using HACK_EXTRA_FLAGS to set only
those flags.

I need to fix risc-v to pass -mno-relax to the hack.c build for lld in
llvm 10, and the patches to support cross-build from non-FreeBSD hosts
need to include -target for clang in CFLAGS for hack.c.  Rather than
adding more hacks into HACK_EXTRA_FLAGS, just use the full set of
CFLAGS with hack.c.

Reviewed by: kib, arichardson
MFC after: 1 month
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D23362

4 years agoFix NOINET6 build after r357038.
melifaro [Sun, 26 Jan 2020 11:54:21 +0000 (11:54 +0000)]
Fix NOINET6 build after r357038.

Reported by: AN <andy at neu.net>

4 years agoStyle changes, mostly usage of braces around single line statements -
pjd [Sun, 26 Jan 2020 11:13:34 +0000 (11:13 +0000)]
Style changes, mostly usage of braces around single line statements -
it is safer and allowed for some time now by style(9).

Sponsored by: Fudo Security

4 years agoImplement tests for the newly added -o flag.
pjd [Sun, 26 Jan 2020 11:03:45 +0000 (11:03 +0000)]
Implement tests for the newly added -o flag.

Sponsored by: Fudo Security

4 years agoImplement -o flag which tells pwait(1) to exit if any of the given processes
pjd [Sun, 26 Jan 2020 11:02:51 +0000 (11:02 +0000)]
Implement -o flag which tells pwait(1) to exit if any of the given processes
has terminated.

Sponsored by: Fudo Security

4 years agoDon't setup a timeout if we are exiting.
pjd [Sun, 26 Jan 2020 10:54:16 +0000 (10:54 +0000)]
Don't setup a timeout if we are exiting.

Sponsored by: Fudo Security

4 years agoCheck for duplicated PID without using additional variable.
pjd [Sun, 26 Jan 2020 10:51:57 +0000 (10:51 +0000)]
Check for duplicated PID without using additional variable.

Sponsored by: Fudo Security

4 years ago- Be consistent with using sysexits(3) codes.
pjd [Sun, 26 Jan 2020 10:49:24 +0000 (10:49 +0000)]
- Be consistent with using sysexits(3) codes.
- Turn fprintf()+exit() into errx().

Sponsored by: Fudo Security

4 years agoTemporarily skip flakey test case sys.kern.ptrace_test.ptrace__procdesc_reparent_wait...
lwhsu [Sun, 26 Jan 2020 07:24:49 +0000 (07:24 +0000)]
Temporarily skip flakey test case sys.kern.ptrace_test.ptrace__procdesc_reparent_wait_child

PR: 243605
Sponsored by: The FreeBSD Foundation

4 years agovfs: do an unlocked check before iterating the lazy list
mjg [Sun, 26 Jan 2020 07:06:18 +0000 (07:06 +0000)]
vfs: do an unlocked check before iterating the lazy list

For most filesystems it is expected to be empty most of the time.

4 years agovfs: remove vop loop from vop_sigdefer
mjg [Sun, 26 Jan 2020 07:05:06 +0000 (07:05 +0000)]
vfs: remove vop loop from vop_sigdefer

All ops are guaranteed to be present since r357131.

4 years agovfs: stop null checking routines in vop wrappers
mjg [Sun, 26 Jan 2020 00:41:38 +0000 (00:41 +0000)]
vfs: stop null checking routines in vop wrappers

Calls to vop_bypass pass the same argument, but type casted to something else.
Thus by replacing NULL routines with vop_bypass we avoid a runtime check.

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

4 years agovfs: fix freevnodes count update race against preemption
mjg [Sun, 26 Jan 2020 00:40:27 +0000 (00:40 +0000)]
vfs: fix freevnodes count update race against preemption

vdbatch_process leaves the critical section too early, openign a time
window where another thread can get scheduled and modify vd->freevnodes.
Once it the preempted thread gets back it overrides the value with 0.

Just move critical_exit to the end of the function.

4 years agoufs: add vgone calls for unconstructed vnodes in the error path
mjg [Sun, 26 Jan 2020 00:38:06 +0000 (00:38 +0000)]
ufs: add vgone calls for unconstructed vnodes in the error path

This mostly eliminates the requirement that vput never unlocks the vnode
before calling VOP_INACTIVE. Note it may still be present for other
filesystems.

See r356126 for an example bug.

Note vput stopped doing early unlock in r357070 thus this change does
not affect correctness as it is.

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

4 years agovfs: predict vn_lock failure as unlikely in vget
mjg [Sun, 26 Jan 2020 00:34:57 +0000 (00:34 +0000)]
vfs: predict vn_lock failure as unlikely in vget

4 years agoSpecify PACKAGE to install tests files
lwhsu [Sat, 25 Jan 2020 23:22:08 +0000 (23:22 +0000)]
Specify PACKAGE to install tests files

MFC after: 3 weeks
MFC with: r356984
Sponsored by: The FreeBSD Foundation

4 years agoImport libxo-1.4.0:
phil [Sat, 25 Jan 2020 21:16:45 +0000 (21:16 +0000)]
Import libxo-1.4.0:

    - Two changes to encoder options:
        encoder options may use plus or colon, but only one
        encoder names can be specified as "@name"
        This results in the syntax:

        df --libxo @csv:no-header:leafs=name.available-blocks /

    - If xo_set_program is called before xo_parse_args, honor the requested value
    - add xo_errorn* function; repair newline-adding-on-xo_error bug
    - test programs now use fixed name, since linux libtool prefixs "lt-"
    - Fix "horse butt" comment in source code
    - update test cases

PR: 242686

4 years agoSending CWR after an RTO is according to RFC 3168 generally required
tuexen [Sat, 25 Jan 2020 13:45:10 +0000 (13:45 +0000)]
Sending CWR after an RTO is according to RFC 3168 generally required
and not only for the DCTCP congestion control.

Submitted by: Richard Scheffenegger
Reviewed by: rgrimes, tuexen@, Cheng Cui
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D23119

4 years agoDon't set the ECT codepoint on retransmitted packets during SACK loss
tuexen [Sat, 25 Jan 2020 13:34:29 +0000 (13:34 +0000)]
Don't set the ECT codepoint on retransmitted packets during SACK loss
recovery. This is required by RFC 3168.

Submitted by: Richard Scheffenegger
Reviewed by: rgrimes@, tuexen@, Cheng Cui
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D23118

4 years agoAs a TCP client only enable ECN when the corresponding sysctl variable
tuexen [Sat, 25 Jan 2020 13:11:14 +0000 (13:11 +0000)]
As a TCP client only enable ECN when the corresponding sysctl variable
indicates that ECN should be negotiated for the client side.

Submitted by: Richard Scheffenegger
Reviewed by: rgrimes@, tuexen@
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D23228

4 years agotests: Routing tests overwrote net tests
kp [Sat, 25 Jan 2020 10:51:51 +0000 (10:51 +0000)]
tests: Routing tests overwrote net tests

The routing subdirectory installed into the same directory as the test tests,
which caused them to overwrite the net Kyuafile. As a result these tests were
not executed.

X-MFC-With: r356146

4 years agoImplement cycle-detecting garbage collector for AF_UNIX sockets
jah [Sat, 25 Jan 2020 08:57:26 +0000 (08:57 +0000)]
Implement cycle-detecting garbage collector for AF_UNIX sockets

The existing AF_UNIX socket garbage collector destroys any socket
which may potentially be in a cycle, as indicated by its file reference
count being equal to its enqueue count. However, this can produce false
positives for in-flight sockets which aren't part of a cycle but are
part of one or more SCM_RIGHTS mssages and which have been closed
on the sending side. If the garbage collector happens to run at
exactly the wrong time, destruction of these sockets will render them
unusable on the receiving side, such that no previously-written data
may be read.

This change rewrites the garbage collector to precisely detect cycles:

1. The existing check of msgcount==f_count is still used to determine
   whether the socket is potentially in a cycle.
2. The socket is now placed on a local "dead list", which is used to
   reduce iteration time (and therefore contention on the global
   unp_link_rwlock).
3. The first pass through the dead list removes each potentially-dead
   socket's outgoing references from the graph of potentially-dead
   sockets, using a gc-specific copy of the original reference count.
4. The second series of passes through the dead list removes from the
   list any socket whose remaining gc refcount is non-zero, as this
   indicates the socket is actually accessible outside of any possible
   cycle.  Iteration is repeated until no further sockets are removed
   from the dead list.
5. Sockets remaining in the dead list are destroyed as before.

PR: 227285
Submitted by: jan.kokemueller@gmail.com (prior version)
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D23142

4 years agolua: add modules.loaded hook
kevans [Sat, 25 Jan 2020 03:52:16 +0000 (03:52 +0000)]
lua: add modules.loaded hook

This may be used for the local module to hook in and load any additional
modules that it wants, since it can't modify the modules table internal to
config. We may consider adding API to do so at a later time, but I suspect
it will be more complicated to use with little return.

status is captured but ignored for the purpose of loading the hook. status
will be false if *any* module failed to load, but we typically don't let
that halt the boot so there's no reason to let it halt hooks. Some vendors
or setups may have expected fails that would be actively thwarted by
checking it.

We may, at a later date, consider adding an API for letting non-config
modules check which modules have successfully (or not) loaded in case an
unexpected failure *should* halt whatever they are doing.

MFC after: 3 days

4 years agoloader.lua: re-arrange to load local.lua *after* config loading
kevans [Sat, 25 Jan 2020 03:02:45 +0000 (03:02 +0000)]
loader.lua: re-arrange to load local.lua *after* config loading

The major problem with the current ordering is that loader.conf may contain
all of the magic we need to actually setup the console, so loading local.lua
prior to that can make it excessively difficult and annoying to debug
(whoops, sorry Ravi & Warner).

The new ordering has some implications, but I suspect they are a non-issue.
The first is that it's no longer possible for the local module to inject any
logic prior to loading config -- I suspect no one has relied on this. The
second implication is that the config.loaded hook is now useless, as the
local module will always be included after that hook would have fired.

For config.loaded, I will opt to leave it in, just in case we add an early
point for local lua to get injected or in case one wants to schedule some
deferred logic in a custom loader.lua. The overhead of having it if no hooks
will be invoked is relatively minimal.

Diagnosed by: imp
Reported by: imp, rpokala (most likely)
MFC after: 3 days

4 years agoEnter the network epoch in RX processing taskqueue.
glebius [Sat, 25 Jan 2020 00:06:18 +0000 (00:06 +0000)]
Enter the network epoch in RX processing taskqueue.

4 years agoDon't delay the ACK for a TCP segment with the CWR flag set.
tuexen [Fri, 24 Jan 2020 22:50:23 +0000 (22:50 +0000)]
Don't delay the ACK for a TCP segment with the CWR flag set.
This allows the data sender to increase the CWND faster.

Submitted by: Richard Scheffenegger
Reviewed by: rgrimes@, tuexen@, Cheng Cui
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D22670

4 years agoThe server side of TCP fast open relies on the delayed ACK timer to allow
tuexen [Fri, 24 Jan 2020 22:37:53 +0000 (22:37 +0000)]
The server side of TCP fast open relies on the delayed ACK timer to allow
including user data in the SYN-ACK. When DSACK support was added in
r347382, an immediate ACK was sent even for the received SYN with
user data. This patch fixes that and allows again to send user data with
the SYN-ACK.

Reported by: Jeremy Harris
Reviewed by: Richard Scheffenegger, rrs@
MFC after: 1 week
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D23212

4 years agoEnter the network epoch when rack_output() is called in setsockopt(2).
glebius [Fri, 24 Jan 2020 21:56:10 +0000 (21:56 +0000)]
Enter the network epoch when rack_output() is called in setsockopt(2).

4 years agoEnter the network epoch in USB WiFi drivers when processing input
glebius [Fri, 24 Jan 2020 21:04:33 +0000 (21:04 +0000)]
Enter the network epoch in USB WiFi drivers when processing input
mbuf queues.

Submitted by: Idwer Vollering <vidwer gmail.com>

4 years agoAdd support for RFC 6598/Carrier Grade NAT subnets. to libalias and ipfw.
melifaro [Fri, 24 Jan 2020 20:35:41 +0000 (20:35 +0000)]
Add support for RFC 6598/Carrier Grade NAT subnets. to libalias and ipfw.

In libalias, a new flag PKT_ALIAS_UNREGISTERED_RFC6598 is added.
 This is like PKT_ALIAS_UNREGISTERED_ONLY, but also is RFC 6598 aware.
Also, we add a new NAT option to ipfw called unreg_cgn, which is like
 unreg_only, but also is RFC 6598-aware.  The reason for the new
 flags/options is to avoid breaking existing networks, especially those
 which rely on RFC 6598 as an external address.

Submitted by: Neel Chauhan <neel AT neelc DOT org>
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D22877

4 years agoHandle a race of collapse with a retrying fault.
kib [Fri, 24 Jan 2020 19:42:53 +0000 (19:42 +0000)]
Handle a race of collapse with a retrying fault.

Both vm_object_scan_all_shadowed() and vm_object_collapse_scan() might
observe an invalid page left in the default backing object by the
fault handler that retried.  Check for the condition and refuse to collapse.

Reported and tested by: pho
Reviewed by: jeff
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D23331

4 years agore(4) uses taskqueue to process input packets. Enter network epoch
glebius [Fri, 24 Jan 2020 17:24:02 +0000 (17:24 +0000)]
re(4) uses taskqueue to process input packets.  Enter network epoch
in there.

4 years agoath(4) processing input packets in taskqueue. Enter network epoch
glebius [Fri, 24 Jan 2020 17:11:54 +0000 (17:11 +0000)]
ath(4) processing input packets in taskqueue.  Enter network epoch
before calling ieee80211_input_mimo().

4 years agoInclude the PCI stack to the riscv GENERIC kernel.
br [Fri, 24 Jan 2020 17:10:21 +0000 (17:10 +0000)]
Include the PCI stack to the riscv GENERIC kernel.

It will be used by an upcoming PCI root complex driver.

Sponsored by: DARPA, AFRL

4 years agoEnable NEW_PCIB on riscv.
br [Fri, 24 Jan 2020 16:50:51 +0000 (16:50 +0000)]
Enable NEW_PCIB on riscv.

Sponsored by: DARPA, AFRL

4 years agoo Move the software context struct to a header file.
br [Fri, 24 Jan 2020 16:43:49 +0000 (16:43 +0000)]
o Move the software context struct to a header file.
o Make the pci_host_generic_acpi_attach() globally visible.
o Declare a new driver class.

These will be used by a new PCI root complex driver.

Sponsored by: DARPA, AFRL

4 years agocaroot: use bsd.obj.mk, not bsd.prog.mk
kevans [Fri, 24 Jan 2020 16:43:02 +0000 (16:43 +0000)]
caroot: use bsd.obj.mk, not bsd.prog.mk

This directory stages certdata into .OBJDIR and processes it, but does not
actually build a prog-shaped object; bsd.obj.mk provides the minimal support
that we actually need, an .OBJDIR and descent into subdirs. This is
admittedly the nittiest of nits.

4 years agoMove the ECAM macroses to the header file.
br [Fri, 24 Jan 2020 16:08:06 +0000 (16:08 +0000)]
Move the ECAM macroses to the header file.

These will be used by other PCI root complex drivers.

Sponsored by: DARPA, AFRL

4 years agoRevert r357050.
markj [Fri, 24 Jan 2020 14:58:02 +0000 (14:58 +0000)]
Revert r357050.

It seems to have introduced a couple of regressions.

Reported by: cy, pho

4 years agoTag NLS aliases with pkgbase package
emaste [Fri, 24 Jan 2020 14:41:51 +0000 (14:41 +0000)]
Tag NLS aliases with pkgbase package

POSIX and en_US.US_ASCII are aliases (symlinks) to the C locale.  They were
not previously tagged with a pkgbase pacakge.  Add the tag so that they are
handled correctly on pkgbase-installed/updated systems.

[This is r356990 reapplied with a corrected commit message.]

Discussed with: manu

4 years agorevert r356990 to reapply with correct commit message
emaste [Fri, 24 Jan 2020 14:40:37 +0000 (14:40 +0000)]
revert r356990 to reapply with correct commit message

Requested by: rgrimes

4 years agoImplement mmget_not_zero() in the LinuxKPI.
hselasky [Fri, 24 Jan 2020 13:05:53 +0000 (13:05 +0000)]
Implement mmget_not_zero() in the LinuxKPI.

Submitted by: Austin Shafer <ashafer@badland.io>
MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agoMake linux(4) handle MAP_32BIT.
trasz [Fri, 24 Jan 2020 12:08:23 +0000 (12:08 +0000)]
Make linux(4) handle MAP_32BIT.

This unbreaks Mono (mono-devel-4.6.2.7+dfsg-1ubuntu1 from Ubuntu Bionic);
previously would crash on "amd64_is_imm32" assert.

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

4 years agoAdd kern_unmount() and use in Linuxulator. No functional changes.
trasz [Fri, 24 Jan 2020 11:57:55 +0000 (11:57 +0000)]
Add kern_unmount() and use in Linuxulator.  No functional changes.

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

4 years agoFix a few spacing issues to make the page more readable.
n_hibma [Fri, 24 Jan 2020 11:22:33 +0000 (11:22 +0000)]
Fix a few spacing issues to make the page more readable.

4 years agoMost uses of vm_map_clip_start follow a call to vm_map_lookup. Define
dougm [Fri, 24 Jan 2020 07:48:11 +0000 (07:48 +0000)]
Most uses of vm_map_clip_start follow a call to vm_map_lookup. Define
an inline function vm_map_lookup_clip_start that invokes them both and
use it in places that invoke both. Drop a couple of local variables
made unnecessary by this function.

Reviewed by: markj
Tested by: pho
Differential Revision: https://reviews.freebsd.org/D22987

4 years agovfs: allow v_usecount to transition 0->1 without the interlock
mjg [Fri, 24 Jan 2020 07:47:44 +0000 (07:47 +0000)]
vfs: allow v_usecount to transition 0->1 without the interlock

There is nothing to do but to bump the count even during said transition.
There are 2 places which can do it:
- vget only does this after locking the vnode, meaning there is no change in
  contract versus inactive or reclamantion
- vref only ever did it with the interlock held which did not protect against
  either (that is, it would always succeed)

VCHR vnodes retain special casing due to the need to maintain dev use count.

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

4 years agovfs: stop handling VI_OWEINACT in vget
mjg [Fri, 24 Jan 2020 07:45:59 +0000 (07:45 +0000)]
vfs: stop handling VI_OWEINACT in vget

vget is almost always called with LK_SHARED, meaning the flag (if present) is
almost guaranteed to get cleared. Stop handling it in the first place and
instead let the thread which wanted to do inactive handle the bumepd usecount.

Reviewed by: jeff
Tested by: pho
Differential Revision: https://reviews.freebsd.org/D23184

4 years agovfs: stop unlocking the vnode upfront in vput
mjg [Fri, 24 Jan 2020 07:44:25 +0000 (07:44 +0000)]
vfs: stop unlocking the vnode upfront in vput

Doing so runs into races with filesystems which make half-constructed vnodes
visible to other users, while depending on the chain vput -> vinactive ->
vrecycle to be executed without dropping the vnode lock.

Impediments for making this work got cleared up (notably vop_unlock_post now
does not do anything and lockmgr stops touching the lock after the final
write). Stacked filesystems keep vhold/vdrop across unlock, which arguably can
now be eliminated.

Reviewed by: jeff
Differential Revision: https://reviews.freebsd.org/D23344

4 years agolockmgr: don't touch the lock past unlock
mjg [Fri, 24 Jan 2020 07:42:57 +0000 (07:42 +0000)]
lockmgr: don't touch the lock past unlock

This evens it up with other locking primitives.

Note lock profiling still touches the lock, which again is in line with the
rest.

Reviewed by: jeff
Differential Revision: https://reviews.freebsd.org/D23343

4 years ago[ntp] Don't compile in the ssl routines into libevent if MK_OPENSSL is no
adrian [Fri, 24 Jan 2020 06:24:40 +0000 (06:24 +0000)]
[ntp] Don't compile in the ssl routines into libevent if MK_OPENSSL is no

Most of ntpd still handles MK_OPENSSL ok, but the libevent import brought
in the SSL bufferevent routines without checking MK_OPENSSL.

This doesn't completely fix WITHOUT_CRYPTO=YES building, but hey, it's one
less broken thing.

4 years agoDrop "All Rights Reserved" from all libbe/bectl files
kevans [Fri, 24 Jan 2020 02:18:09 +0000 (02:18 +0000)]
Drop "All Rights Reserved" from all libbe/bectl files

I sent out an e-mail on 2020/01/21 with a plan to do this to Kyle, Rob, and
Wes; all parties have responded in the affirmative that it's OK to drop it
from these files.

4 years agorandom(3): Abstract routines into _r versions on explicit state
cem [Fri, 24 Jan 2020 01:39:29 +0000 (01:39 +0000)]
random(3): Abstract routines into _r versions on explicit state

The existing APIs simply pass the implicit global state to the _r variants.

No functional change.

Note that these routines are not exported from libc and are not intended to be
exported.  If someone wished to export them from libc (which I would
discourage), they should first be modified to match the inconsistent parameter
type / order of the glibc public interfaces of the same names.

I know Ravi will ask, so: the eventual goal of this series is to replace
rand(3) with the implementation from random(3) (D23290).  However, I'd like to
wait a bit longer on that one to see if more feedback emerges.

Reviewed by: kevans, markm
Differential Revision: https://reviews.freebsd.org/D23289

4 years agorandom(3): Abstract state into a single context object
cem [Fri, 24 Jan 2020 01:32:16 +0000 (01:32 +0000)]
random(3): Abstract state into a single context object

No functional change.

Reviewed by: kevans, markm
Differential Revision: https://reviews.freebsd.org/D23288

4 years agocpufreq(4): Fix missing MODULE_DEPEND on hwpstate_intel
cem [Thu, 23 Jan 2020 23:52:57 +0000 (23:52 +0000)]
cpufreq(4): Fix missing MODULE_DEPEND on hwpstate_intel

DRIVER_MODULE does not actually define a MODULE_VERSION, which is required
to satisfy a MODULE_DEPENDency.  Declare one explicitly in
hwpstate_intel(4).

Reported by: flo
X-MFC-With: r357002

4 years agoCorrect the return types of fueword*().
jhb [Thu, 23 Jan 2020 23:36:58 +0000 (23:36 +0000)]
Correct the return types of fueword*().

MFC after: 1 week
Sponsored by: DARPA

4 years agopf: Apply kif flags to new group members
kp [Thu, 23 Jan 2020 22:13:41 +0000 (22:13 +0000)]
pf: Apply kif flags to new group members

If we have a 'set skip on <ifgroup>' rule this flag it set on the group
kif, but must also be set on all members. pfctl does this when the rules
are set, but if groups are added afterwards we must also apply the flags
to the new member. If not, new group members will not be skipped until
the rules are reloaded.

Reported by: dvl@
Reviewed by: glebius@
Differential Revision: https://reviews.freebsd.org/D23254

4 years agoadd MIPS-specific PT header ELF definitions
emaste [Thu, 23 Jan 2020 17:38:17 +0000 (17:38 +0000)]
add MIPS-specific PT header ELF definitions

Submitted by: David Carlier
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D19428

4 years agosparc64: Busy the TSB page before freeing it in pmap_release().
markj [Thu, 23 Jan 2020 17:18:58 +0000 (17:18 +0000)]
sparc64: Busy the TSB page before freeing it in pmap_release().

This is now required by vm_page_free().

PR: 243534
Reported and tested by: Michael Reim <kraileth@elderlinux.org>

4 years agoFix r356919.
kib [Thu, 23 Jan 2020 17:08:33 +0000 (17:08 +0000)]
Fix r356919.

Instead of waiting for pc_curthread which is overwritten by
init_secondary_tail(), wait for non-NULL pc_curpcb, to be set by the
first context switch.
Assert that pc_curpcb is not set too early.

Reported and tested by: rlibby
Reviewed by: markj, rlibby
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D23330

4 years agong_nat: Pass IPv6 packets through.
markj [Thu, 23 Jan 2020 16:45:48 +0000 (16:45 +0000)]
ng_nat: Pass IPv6 packets through.

ng_nat implements NAT for IPv4 traffic only.  When connected to an
ng_ether node it erroneously handled IPv6 packets as well.

This change is not sufficient: ng_nat does not do any validation of IP
packets in this mode, even though they have not yet passed through
ip_input().

PR: 243096
Reported by: Robert James Hernandez <rob@sarcasticadmin.com>
Reviewed by: julian
Differential Revision: https://reviews.freebsd.org/D23080

4 years agovm_map_submap(): Avoid unnecessary clipping.
markj [Thu, 23 Jan 2020 16:45:10 +0000 (16:45 +0000)]
vm_map_submap(): Avoid unnecessary clipping.

A submap can only be created from an entry spanning the entire request
range.  In particular, if vm_map_lookup_entry() returns false or the
returned entry contains "end".

Since the only use of submaps in FreeBSD is for the static pipe and
execve argument KVA maps, this has no functional effect.

Github PR: https://github.com/freebsd/freebsd/pull/420
Submitted by: Wuyang Chung <wuyang.chung1@gmail.com> (original)
Reviewed by: dougm, kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D23299

4 years agoWith MSI interrupts bge(4) just schedules taskqueue. Enter the network
glebius [Thu, 23 Jan 2020 16:36:58 +0000 (16:36 +0000)]
With MSI interrupts bge(4) just schedules taskqueue.  Enter the network
epoch in the taskqueue handler.

Reported by: kib

4 years agoSet td_oncpu before dropping the thread lock during a switch.
markj [Thu, 23 Jan 2020 16:24:51 +0000 (16:24 +0000)]
Set td_oncpu before dropping the thread lock during a switch.

After r355784 we no longer hold a thread's thread lock when switching it
out.  Preserve the previous synchronization protocol for td_oncpu by
setting it together with td_state, before dropping the thread lock
during a switch.

Reported and tested by: pho
Reviewed by: kib
Discussed with: jeff
Differential Revision: https://reviews.freebsd.org/D23270

4 years agoPrint missing ID_AA64PFR{0,1}_EL1 register fields.
markj [Thu, 23 Jan 2020 16:10:38 +0000 (16:10 +0000)]
Print missing ID_AA64PFR{0,1}_EL1 register fields.

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

4 years agoarm64: Don't enable interrupts in init_secondary().
markj [Thu, 23 Jan 2020 16:07:27 +0000 (16:07 +0000)]
arm64: Don't enable interrupts in init_secondary().

Doing so can cause deadlocks or panics during boot, if an interrupt
handler accesses uninitialized per-CPU scheduler structures.  This seems
to occur frequently when running under QEMU or AWS.  The idle threads
are set up to release a spinlock section and enable interrupts in
fork_exit(), so there is no need to enable interrupts earlier.

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

4 years agoTag /usr/tests/local symlink with package=tests
emaste [Thu, 23 Jan 2020 15:59:30 +0000 (15:59 +0000)]
Tag /usr/tests/local symlink with package=tests

As with the rest of /usr/tests, so that it is handled correctly on
pkgbase-installed/updated systems.

Sponsored by: The FreeBSD Foundation

4 years agoApply r355819 to sparc64 - fix assertion failure after r355784
emaste [Thu, 23 Jan 2020 14:11:02 +0000 (14:11 +0000)]
Apply r355819 to sparc64 - fix assertion failure after r355784

From r355819:
Repeat the spinlock_enter/exit pattern from amd64 on other architectures
to fix an assert violation introduced in r355784.  Without this
spinlock_exit() may see owepreempt and switch before reducing the
spinlock count.  amd64 had been optimized to do a single critical
enter/exit regardless of the number of spinlocks which avoided the
problem and this optimization had not been applied elsewhere.

This is completely untested - I have no obsolete Sparc hardware - but
someone did try testing recent changes on sparc64 (PR 243534).

PR: 243534

4 years agoFix kernel-tags target.
nyan [Thu, 23 Jan 2020 13:56:12 +0000 (13:56 +0000)]
Fix kernel-tags target.
  - A depend-file is broken up into .depend.*.o files. [1]
  - Fix an assembly file support.

PR: 241746
Submitted by: leres [1]
MFC after: 1 week

4 years agovmxnet3: add support for RSS kernel option
avg [Thu, 23 Jan 2020 11:05:03 +0000 (11:05 +0000)]
vmxnet3: add support for RSS kernel option

We observe at least one problem: if a UDP socket is connect(2)-ed, then a
received packet that matches the connection cannot be matched to the
corresponding PCB because of an incorrect flow ID.  That was oberved for DNS
requests from the libc resolver.  We got this problem because FreeBSD
r343291 enabled code that can set rsstype of received packets to values
other than M_HASHTYPE_OPAQUE_HASH.  Earlier that code was under 'ifdef
notyet'.

The essence of this change is to use the system-wide RSS key instead of
some historic hardcoded key when the software RSS is enabled and it is
configured to use Toeplitz algorithm (the default).
In all other cases, the driver reports the opaque hash type for received
packets while still using Toeplitz algorithm with the internal key.

PR: 242890
Reviewed by: pkelsey
Sponsored by: Panzura
Differential Revision: https://reviews.freebsd.org/D23147

4 years agoFix build of stand/usb .
hselasky [Thu, 23 Jan 2020 10:40:34 +0000 (10:40 +0000)]
Fix build of stand/usb .

MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agovirtio_scsi: use max target ID plus one as the initiator ID
avg [Thu, 23 Jan 2020 10:13:56 +0000 (10:13 +0000)]
virtio_scsi: use max target ID plus one as the initiator ID

This bus does not really have a concept of the initiator ID, so use
a guaranteed dummy one that won't conflict with any real target.

This change fixes a problem with virtio_scsi on GCE where disks get
sequential target IDs starting from one.  If there are seven or more
disks, then a disk with the target ID of seven would not be discovered
by FreeBSD as that ID was reserved as the initiator ID -- see
scsi_scan_bus().

Discussed with: bryanv
MFC after: 2 weeks
Sponsored by: Panzura

4 years agoBring indentation back to normal after r357038.
melifaro [Thu, 23 Jan 2020 09:46:45 +0000 (09:46 +0000)]
Bring indentation back to normal after r357038.
No functional changes.

MFC after: 3 weeks

4 years agoFix epoch-related panic in ipdivert, ensuring in_broadcast() is called
melifaro [Thu, 23 Jan 2020 09:14:28 +0000 (09:14 +0000)]
Fix epoch-related panic in ipdivert, ensuring in_broadcast() is called
 within epoch.

Simplify gigantic div_output() by splitting it into 3 functions,
 handling preliminary setup, remote "ip[6]_output" case and
 local "netisr" case. Leave original indenting in most parts to ease
 diff comparison.  Indentation will be fixed by a followup commit.

Reported by: Nick Hibma <nick at van-laarhoven.org>
Reviewed by: glebius
Differential Revision: https://reviews.freebsd.org/D23317

4 years ago(fault 9/9) Move zero fill into a dedicated function to make the object lock
jeff [Thu, 23 Jan 2020 05:23:37 +0000 (05:23 +0000)]
(fault 9/9) Move zero fill into a dedicated function to make the object lock
state more clear.

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

4 years ago(fault 8/9) Restructure some code to reduce duplication and simplify flow
jeff [Thu, 23 Jan 2020 05:22:02 +0000 (05:22 +0000)]
(fault 8/9) Restructure some code to reduce duplication and simplify flow
control.

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

4 years ago(fault 7/9) Move fault population and allocation into a dedicated function
jeff [Thu, 23 Jan 2020 05:19:39 +0000 (05:19 +0000)]
(fault 7/9) Move fault population and allocation into a dedicated function

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

4 years ago(fault 6/9) Move getpages and associated logic into a dedicated function.
jeff [Thu, 23 Jan 2020 05:18:00 +0000 (05:18 +0000)]
(fault 6/9) Move getpages and associated logic into a dedicated function.

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

4 years ago(fault 5/9) Move the backing_object traversal into a dedicated function.
jeff [Thu, 23 Jan 2020 05:14:41 +0000 (05:14 +0000)]
(fault 5/9)  Move the backing_object traversal into a dedicated function.

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

4 years ago(fault 4/9) Move copy-on-write into a dedicated function.
jeff [Thu, 23 Jan 2020 05:11:01 +0000 (05:11 +0000)]
(fault 4/9) Move copy-on-write into a dedicated function.

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

4 years ago(fault 3/9) Move map relookup into a dedicated function.
jeff [Thu, 23 Jan 2020 05:07:01 +0000 (05:07 +0000)]
(fault 3/9) Move map relookup into a dedicated function.

Add a new VM return code KERN_RESTART which means, deallocate and restart in
fault.

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

4 years ago(fault 2/9) Move map lookup into a dedicated function.
jeff [Thu, 23 Jan 2020 05:05:39 +0000 (05:05 +0000)]
(fault 2/9) Move map lookup into a dedicated function.

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

4 years ago(fault 1/9) Move a handful of stack variables into the faultstate.
jeff [Thu, 23 Jan 2020 05:03:34 +0000 (05:03 +0000)]
(fault 1/9) Move a handful of stack variables into the faultstate.

This additionally fixes a potential bug/pessimization where we could fail to
reload the original fault_type on restart.

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

4 years agouma: fix zone domain overlaying pcpu cache with disabled cpus
rlibby [Thu, 23 Jan 2020 04:56:38 +0000 (04:56 +0000)]
uma: fix zone domain overlaying pcpu cache with disabled cpus

UMA zone structures have two arrays at the end which are sized according
to the machine: an array of CPU count length, and an array of NUMA
domain count length.  The CPU counting was wrong in the case where some
CPUs are disabled (when mp_ncpus != mp_maxid + 1), and this caused the
second array to be overlaid with the first.

Reported by: olivier
Reviewed by: jeff, markj
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D23318

4 years agouma: report leaks more accurately
rlibby [Thu, 23 Jan 2020 04:56:34 +0000 (04:56 +0000)]
uma: report leaks more accurately

Previously UMA had some false negatives in the leak report at keg
destruction time, where it only reported leaks if there were free items
in the slab layer (rather than allocated items), which notably would not
be true for single-item slabs (large items).  Now, report a leak if
there are any allocated pages, and calculate and report the number of
allocated items rather than free items.

Reviewed by: jeff, markj
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D23275

4 years agoConsistently use busy and vm_page_valid() rather than touching page bits
jeff [Thu, 23 Jan 2020 04:54:49 +0000 (04:54 +0000)]
Consistently use busy and vm_page_valid() rather than touching page bits
directly.  This improves API compliance, asserts, etc.

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