]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agoImport DTS files for riscv from Linux 5.4
manu [Tue, 3 Dec 2019 09:12:53 +0000 (09:12 +0000)]
Import DTS files for riscv from Linux 5.4

Requested by:  mhorne

4 years agoRevert r355188 as it shouldn't have created the risc-v directory at
manu [Tue, 3 Dec 2019 09:06:37 +0000 (09:06 +0000)]
Revert r355188 as it shouldn't have created the risc-v directory at
the top level.

Reported by: rpokala

4 years agoUse refcount from "in_joingroup_locked()" when joining multicast
hselasky [Tue, 3 Dec 2019 08:46:59 +0000 (08:46 +0000)]
Use refcount from "in_joingroup_locked()" when joining multicast
groups. Do not acquire additional references. This makes the IPv4 IGMP
code in line with the IPv6 MLD code.

Background:
The IPv4 multicast code puts an extra reference on the in_multi struct
when joining groups.  This becomes visible when using daemons like
igmpproxy from ports, that multicast entries do not disappear from the
output of ifmcstat(8) when multicast streams are disconnected.

This fixes a regression issue after r349762.

While at it factor the ip_mfilter_insert() and ip6_mfilter_insert() calls
to avoid repeated "is_new" check.

Differential Revision: https://reviews.freebsd.org/D22595
Tested by: Guido van Rooij <guido@gvr.org>
Reviewed by: rgrimes (network)
MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agoExplicitly exit() instead of return in main().
delphij [Tue, 3 Dec 2019 07:03:25 +0000 (07:03 +0000)]
Explicitly exit() instead of return in main().

MFC after: 2 weeks

4 years agonewfs_msdos: -A is incompatible with -r, not -o.
delphij [Tue, 3 Dec 2019 07:01:28 +0000 (07:01 +0000)]
newfs_msdos: -A is incompatible with -r, not -o.

PR: 242314
Submitted by: Guy Yur <guyyur gmail com>
MFC after: 2 weeks

4 years agosyscons.c: clang-format pass to reduce style inconsistencies
kevans [Tue, 3 Dec 2019 02:30:52 +0000 (02:30 +0000)]
syscons.c: clang-format pass to reduce style inconsistencies

This was purely automatically massaged... some parts are still imperfect,
but this is close enough to make it more readable/easy to work on.
Unfortunately the vt/syscons/kdb situation slightly complicates changes to
tty locking, so some work will need to be done to remediate that.

4 years agoUse a precise bit count for the slab free items in UMA. This significantly
jeff [Mon, 2 Dec 2019 22:44:34 +0000 (22:44 +0000)]
Use a precise bit count for the slab free items in UMA.  This significantly
shrinks embedded slab structures.

Reviewed by: markj, rlibby (prior version)
Differential Revision: https://reviews.freebsd.org/D22584

4 years agoFix a few places that free a page from an object without busy held. This is
jeff [Mon, 2 Dec 2019 22:42:05 +0000 (22:42 +0000)]
Fix a few places that free a page from an object without busy held.  This is
tightening constraints on busy as a precursor to lockless page lookup and
should largely be a NOP for these cases.

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

4 years agoFix the last few cases that grab without busy or valid. The grab functions must
jeff [Mon, 2 Dec 2019 22:38:25 +0000 (22:38 +0000)]
Fix the last few cases that grab without busy or valid.  The grab functions must
return the page in some held state for consistency elsewhere.

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

4 years agoInitialize the idle thread's lock sooner so it's not evaluated on every fork
jeff [Mon, 2 Dec 2019 22:35:45 +0000 (22:35 +0000)]
Initialize the idle thread's lock sooner so it's not evaluated on every fork
exit and we can rely on it elsewhere.

Reviewed by: mav, kib, jhb, markj
Differential Revision: https://reviews.freebsd.org/D22624

4 years agoDon't run sched_preempt() inside of an extra critical section. This disables
jeff [Mon, 2 Dec 2019 22:34:19 +0000 (22:34 +0000)]
Don't run sched_preempt() inside of an extra critical section.  This disables
the sched_preempt() switch optimization and causes the sched lock to be dropped
and immediately reacquired.

Reviewed by: jhb, kib, mav, markj (with changes)
Differential Revision: https://reviews.freebsd.org/D22623

4 years agoBump __FreeBSD_version after r355304.
trasz [Mon, 2 Dec 2019 21:09:57 +0000 (21:09 +0000)]
Bump __FreeBSD_version after r355304.

The net/tcprtt port depends on this.

Sponsored by: Klara, Inc, Netflix

4 years agoloader.efi: fix cd boot for cisco C220M3
tsoome [Mon, 2 Dec 2019 21:08:59 +0000 (21:08 +0000)]
loader.efi: fix cd boot for cisco C220M3

Reported by: Chris Ross
MFC after: 1w

4 years agoExpand stats(3) man page to add a caveat regarding HZ.
trasz [Mon, 2 Dec 2019 21:03:09 +0000 (21:03 +0000)]
Expand stats(3) man page to add a caveat regarding HZ.

Suggested by: thj
Sponsored by: Klara Inc, Netflix

4 years agoMake use of the stats(3) framework in the TCP stack.
trasz [Mon, 2 Dec 2019 20:58:04 +0000 (20:58 +0000)]
Make use of the stats(3) framework in the TCP stack.

This makes it possible to retrieve per-connection statistical
information such as the receive window size, RTT, or goodput,
using a newly added TCP_STATS getsockopt(3) option, and extract
them using the stats_voistat_fetch(3) API.

See the net/tcprtt port for an example consumer of this API.

Compared to the existing TCP_INFO system, the main differences
are that this mechanism is easy to extend without breaking ABI,
and provides statistical information instead of raw "snapshots"
of values at a given point in time.  stats(3) is more generic
and can be used in both userland and the kernel.

Reviewed by: thj
Tested by: thj
Obtained from: Netflix
Relnotes: yes
Sponsored by: Klara Inc, Netflix
Differential Revision: https://reviews.freebsd.org/D20655

4 years agobhyve: uniform printf format string newlines
vmaffione [Mon, 2 Dec 2019 20:51:46 +0000 (20:51 +0000)]
bhyve: uniform printf format string newlines

Some of the printf statements only use LF to get a newline. However, a CR character is also required for the serial console to print debug logs in a nice way.
Fix those code locations that only use LF, by adding a CR character.

Reviewed by: markj, aleksandr.fedorov@itglobal.com
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D22552

4 years agoFix a typo (upto --> up to) and reword to improve word flow.
cy [Mon, 2 Dec 2019 20:39:40 +0000 (20:39 +0000)]
Fix a typo (upto --> up to) and reword to improve word flow.

MFC after: 3 days

4 years agoFix a hang introduced in r351599.
ken [Mon, 2 Dec 2019 19:57:39 +0000 (19:57 +0000)]
Fix a hang introduced in r351599.

My changes in 351599 (kindly committed by avg) made the cd(4) media check
asynchronous to avoid a sleep while holding a mutex.

There was a difficult to reproduce bug with those changes that caused a
hang on boot on some single processor machines/VMs.  Leandro Lupori
managed to reproduce the bug, diagnose it, and supplied a patch!  Here is
his analysis, from the PR:

======
I was able to reproduce the problem described in comment#14.

Actually, I wasn't trying to reproduce it, I just started seeing it a few
weeks ago, in CURRENT.

I can reproduce it consistently, by using QEMU to run a PowerPC64 VM with a
single core/thread (-smp 1).

It happens only when there is no media in the emulated CD-ROM, a device
that QEMU adds by default, unless -nodefaults is specified in command line.

I've debugged it and this is what I've found:

1- After the CD probe is successful, GEOM will try to open the device,
which will end up calling cdcheckmedia(), that sets CD state to
CD_STATE_MEDIA_PREVENT.
2- Next, scsi_prevent() is executed and succeeds, the CD_FLAG_DISC_LOCKED
flag is set and CD state moves to CD_STATE_MEDIA_SIZE.
3- Next, scsi_read_capacity() is executed and fails, state is set to
CD_STATE_MEDIA_ALLOW, cdmediaprobedone() is called and wakes up
cdcheckmedia().
4- Then, when cdstart() is invoked to process CD_STATE_MEDIA_ALLOW, it
first checks if CD_FLAG_DISC_LOCKED is set, and if so skips directly to
CD_STATE_MEDIA_SIZE state. This will repeat the steps of bullet 3, entering
an infinite MEDIA_SIZE command loop.

When there is a least another core/thread, the GEOM thread that performed
the initial cdopen() will get scheduled again, closing the CD device, that
will call cdprevent(PR_ALLOW) that clears the CD_FLAG_DISC_LOCKED flag and
breaks the loop.

So, apparently, the problem is CD_STATE_MEDIA_ALLOW being skipped when
CD_FLAG_DISC_LOCKED is set. If I understand correctly, in this case, the
state should be advanced to CD_STATE_MEDIA size only when the current state
is CD_STATE_MEDIA_PREVENT.
=====

PR: kern/219857
Submitted by: Leandro Lupori <leandro.lupori@gmail.com>
MFC after: 1 week

4 years agoDo not initialize the flags field in struct gpiobus_pin from the flags in
ian [Mon, 2 Dec 2019 19:57:20 +0000 (19:57 +0000)]
Do not initialize the flags field in struct gpiobus_pin from the flags in
struct gpio_pin.  It turns out these two sets of flags are completely
unrelated to each other.

Also, update the comment for GPIO_ACTIVE_LOW to reflect the fact that it
does get set, somewhat unobviously, by code that parses FDT data.  The bits
from the FDT cell containing flags are just copied to gpiobus_pin.flags, so
there's never any obvious reference to the symbol GPIO_ACTIVE_LOW being
stored into the flags field.

4 years agoRemove "all rights reserved" from copyright after getting a response from
ian [Mon, 2 Dec 2019 16:15:18 +0000 (16:15 +0000)]
Remove "all rights reserved" from copyright after getting a response from
Luiz that he also was not intentionally asserting that right, it was already
there when he added his name.

4 years agolibzpool: use CFLAGS.lz4.c to build lz4.o and lz4.pico
tsoome [Mon, 2 Dec 2019 15:37:06 +0000 (15:37 +0000)]
libzpool: use CFLAGS.lz4.c to build lz4.o and lz4.pico

Clean up this Makefile a bit.

4 years agorevert r354714 "Boot arm64 kernel using booti command from U-boot."
jhibbits [Mon, 2 Dec 2019 15:07:06 +0000 (15:07 +0000)]
revert r354714 "Boot arm64 kernel using booti command from U-boot."

After discussing with mmel@, it was clear this is insufficient to address
all the needs.  mmel@ will commit his original patch, from
https://reviews.freebsd.org/D13861, and the additions needed from r354714
will be made afterward.

Requested by: mmel
Sponsored by: Juniper Networks, Inc.

4 years agomlx5: Do not try to enable fwdumps if scan space did not responded.
kib [Mon, 2 Dec 2019 14:22:55 +0000 (14:22 +0000)]
mlx5: Do not try to enable fwdumps if scan space did not responded.

Sponsored by: Mellanox Technologies
MFC after: 1 week

4 years agomlx5: Downgrade assert about misbehaving hardware to error message.
kib [Mon, 2 Dec 2019 14:21:40 +0000 (14:21 +0000)]
mlx5: Downgrade assert about misbehaving hardware to error message.

Sponsored by: Mellanox Technologies
MFC after: 1 week

4 years agoFix spurious error from sysrc
dteske [Mon, 2 Dec 2019 05:24:16 +0000 (05:24 +0000)]
Fix spurious error from sysrc

When using sysrc to modify a file, the file should be created silently.
However, with the introduction of SVN r335280, an error of "No such file
or directory" would appear despite everything else working as-expected.

The nature of this spurious error is that SVN r335280 did not check if
the file exists first, before trying to fixup the line-endings in the
file just prior to modification.

PR: bin/240875
Reported by: Jose Luis Duran
MFC after: 3 days

4 years agoFix leading whitespace (spaces->tabs) in comments; no functional change.
ian [Mon, 2 Dec 2019 00:00:26 +0000 (00:00 +0000)]
Fix leading whitespace (spaces->tabs) in comments; no functional change.

4 years agoRewrite gpioiic(4) to use the gpio_pin_* API, and to conform to the modern
ian [Sun, 1 Dec 2019 23:05:20 +0000 (23:05 +0000)]
Rewrite gpioiic(4) to use the gpio_pin_* API, and to conform to the modern
FDT bindings document for gpio-i2c devices.

Using the gpio_pin_* functions to acquire/release/manipulate gpio pins
removes the constraint that both gpio pins must belong to the same gpio
controller/bank, and that the gpioiic instance must be a child of gpiobus.
Removing those constraints allows the driver to be fully compatible with
the modern dts bindings for a gpio bitbanged i2c bus.

For hinted attachment, the two gpio pins still must be on the same gpiobus,
and the device instance must be a child of that bus.  This preserves
compatibility for existing installations that have use gpioiic(4) with hints.

4 years agopowerpc: Add 'show frame <addr>' to show an arbitrary trap frame
jhibbits [Sun, 1 Dec 2019 21:29:34 +0000 (21:29 +0000)]
powerpc: Add 'show frame <addr>' to show an arbitrary trap frame

This lets us print, for example, the user's trap frame when a panic occurs.
The frame address is given in the backtrace at the trap point, which can
then be passed to 'show frame'.  This is useful for debugging as it can show
inputs that lead to a panic or fault.  It can also be used to print trap
frames from other CPUs that get stuck.

i386 already has a similar command, but no others do.

4 years agoMove most of the gpio_pin_* functions from ofw_gpiobus.c to gpiobus.c so
ian [Sun, 1 Dec 2019 21:27:09 +0000 (21:27 +0000)]
Move most of the gpio_pin_* functions from ofw_gpiobus.c to gpiobus.c so
that they can be used by drivers on non-FDT-configured systems.  Only the
functions related to acquiring pins by parsing FDT data remain in
ofw_gpiobus.  Also, add two new functions for acquiring gpio pins based on
child device_t and index, or on the bus device_t and pin number.  And
finally, defer reserving pins for gpiobus children until they acquire the
pin, rather than reserving them as soon as the child is added (before it's
even known whether the child will attach).

This will allow drivers configured with hints (or any other mechanism) to
use the same code as drivers configured via FDT data.  Until now, a hinted
driver and an FDT driver had to be two completely different sets of code,
because hinted drivers could only use gpiobus calls to manipulate pins,
while fdt-configured drivers could not use that API (due to not always being
children of the bus that owns the pins) and had to use the newer
gpio_pin_xxxx() functions.  Now drivers can be written in the more
traditional form, where most of the code is shared and only the resource
acquisition code at attachment time changes.

4 years agoMove all ECN related flags from the flags to the flags2 field.
tuexen [Sun, 1 Dec 2019 21:01:33 +0000 (21:01 +0000)]
Move all ECN related flags from the flags to the flags2 field.
This allows adding more ECN related flags in the future.
No functional change intended.

Submitted by: Richard Scheffenegger
Reviewed by: rrs@, tuexen@
Differential Revision: https://reviews.freebsd.org/D22497

4 years agoMake the TF_* flags easier readable by humans by adding leading zeroes
tuexen [Sun, 1 Dec 2019 20:45:48 +0000 (20:45 +0000)]
Make the TF_* flags easier readable by humans by adding leading zeroes
to make them aligned.

Submitted by: Richard Scheffenegger
Reviewed by: rgrimes@, rrs@, tuexen@
Differential Revision: https://reviews.freebsd.org/D22428

4 years agoRemove more needless <sys/tty.h> includes
kevans [Sun, 1 Dec 2019 20:43:37 +0000 (20:43 +0000)]
Remove more needless <sys/tty.h> includes

As part of my journey to make it easy to determine what's relying on tty
bits, remove a couple more. Some of these just outright didn't need it,
while others did rely on <sys/tty.h> pollution for mutex headers.

4 years agoStore the bottom of the shadow chain in OBJ_ANON object->handle member.
kib [Sun, 1 Dec 2019 20:43:04 +0000 (20:43 +0000)]
Store the bottom of the shadow chain in OBJ_ANON object->handle member.

The handle value is stable for all shadow objects in the inheritance
chain.  This allows to avoid descending the shadow chain to get to the
bottom of it in vm_map_entry_set_vnode_text(), and eliminate
corresponding object relocking which appeared to be contending.

Change vm_object_allocate_anon() and vm_object_shadow() to handle more
of the cred/charge initialization for the new shadow object, in
addition to set up the handle.

Reported by: jeff
Reviewed by: alc (previous version), jeff (previous version)
Tested by: pho
Sponsored by: The FreeBSD Foundation
Differrential revision: https://reviews.freebsd.org/D22541

4 years agoThis is an initial step in implementing the new congestion window
tuexen [Sun, 1 Dec 2019 20:35:41 +0000 (20:35 +0000)]
This is an initial step in implementing the new congestion window
validation as specified in RFC 7661.

Submitted by: Richard Scheffenegger
Reviewed by: rrs@, tuexen@
Differential Revision: https://reviews.freebsd.org/D21798

4 years agoAdd a description for the TCP sysctl variable rfc6675_pipe.
tuexen [Sun, 1 Dec 2019 19:20:28 +0000 (19:20 +0000)]
Add a description for the TCP sysctl variable rfc6675_pipe.
It was introduced by r290122, but no documentation was provided.
This is taken from https://reviews.freebsd.org/D21798, since it
is not related to the feature added there.

Submitted by: Richard Scheffenegger
MFC after: 1 week

4 years agoMake the IPTOS value available to all substate handlers. This will allow
tuexen [Sun, 1 Dec 2019 18:47:53 +0000 (18:47 +0000)]
Make the IPTOS value available to all substate handlers. This will allow
to add support for L4S or SCE, which require processing of the IP TOS
field.

Submitted by: Richard Scheffenegger
Reviewed by: rgrimes@, rrs@, tuexen@
Differential Revision: https://reviews.freebsd.org/D22426

4 years agoIn order for the TCP Handshake to support ECN++, and further ECN-related
tuexen [Sun, 1 Dec 2019 18:05:02 +0000 (18:05 +0000)]
In order for the TCP Handshake to support ECN++, and further ECN-related
improvements, the ECN bits need to be exposed to the TCP SYNcache.
This change is a minimal modification to the function headers, without any
functional change intended.

Submitted by: Richard Scheffenegger
Reviewed by: rgrimes@, rrs@, tuexen@
Differential Revision: https://reviews.freebsd.org/D22436

4 years agoWhen changing the MTU of an SCTP path, not only cancel all ongoing
tuexen [Sun, 1 Dec 2019 17:35:36 +0000 (17:35 +0000)]
When changing the MTU of an SCTP path, not only cancel all ongoing
RTT measurements, but also scheldule new ones for the future.

Submitted by: Julius Flohr
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D22547

4 years agoUpdate the hostcache also for PTB messages received for SCTP/IPv6.
tuexen [Sun, 1 Dec 2019 16:14:44 +0000 (16:14 +0000)]
Update the hostcache also for PTB messages received for SCTP/IPv6.
The corresponding code for SCTP/IPv4 was introduced in
https://svnweb.freebsd.org/base?view=revision&revision=317597

Submitted by: Julius Flohr
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D22605

4 years agoSimplify code with strlcpy/strlcat.
delphij [Sun, 1 Dec 2019 08:04:22 +0000 (08:04 +0000)]
Simplify code with strlcpy/strlcat.

MFC after: 2 weeks

4 years agobhyve amd: amdvi_dump_cmds() log the command for which the command completion failed...
anish [Sun, 1 Dec 2019 04:00:08 +0000 (04:00 +0000)]
bhyve amd: amdvi_dump_cmds() log the command for which the command completion failed.  Completion is checked in poll mode although it can be done using interrupts.
No need to log all the commands in command ring but only the last one for which completion failed.

Reported by: np@freebsd.org
Reviewed by: np, markj
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D22566

4 years agousb: remove some extraneous tty.h includes
kevans [Sun, 1 Dec 2019 03:56:18 +0000 (03:56 +0000)]
usb: remove some extraneous tty.h includes

4 years agolockmgr: remove more remnants of adaptive spinning
mjg [Sun, 1 Dec 2019 00:35:08 +0000 (00:35 +0000)]
lockmgr: remove more remnants of adaptive spinning

Sponsored by: The FreeBSD Foundation

4 years agotmpfs: use proper macros for permission values in tmpfs_access
mjg [Sun, 1 Dec 2019 00:34:49 +0000 (00:34 +0000)]
tmpfs: use proper macros for permission values in tmpfs_access

While here group them in one var to prevent overy long lines. Perhaps a
general macro of the same sort should be introduced.

Requested by: kib

4 years agoFix m_pullup() problem after removing PULLDOWN_TESTs and KAME EXT_*macros.
bz [Sun, 1 Dec 2019 00:22:04 +0000 (00:22 +0000)]
Fix m_pullup() problem after removing PULLDOWN_TESTs and KAME EXT_*macros.

r354748-354750 replaced the KAME macros with m_pulldown() calls.
Contrary to the rest of the network stack m_len checks before m_pulldown()
were not put in placed (see r354748).
Put these m_len checks in place for now (to go along with the style of the
network stack since the initial commits).  These are not put in for
performance but to avoid an error scenario (even though it also will help
performance at the moment as it avoid allocating an extra mbuf; not because
of the unconditional function call).

The observed error case went like this:
(1) an mbuf with M_EXT arrives and we call m_pullup() unconditionally on it.
(2) m_pullup() will call m_get() unless the requested length is larger than
MHLEN (in which case it'll m_freem() the perfectly fine mbuf) and migrate the
requested length of data and pkthdr into the new mbuf.
(3) If m_get() succeeds, a further m_pullup() call going over MHLEN will fail.
This was observed with failing auto-configuration as an RA packet of
200 bytes exceeded MHLEN and the m_pullup() called from nd6_ra_input()
dropped the mbuf.
(Re-)adding the m_len checks before m_pullup() calls avoids this problems
with mbufs using external storage for now.

MFC after: 3 weeks
Sponsored by: Netflix

4 years agotty: implement TIOCNOTTY
kevans [Sat, 30 Nov 2019 20:10:50 +0000 (20:10 +0000)]
tty: implement TIOCNOTTY

Generally, it's preferred that an application fork/setsid if it doesn't want
to keep its controlling TTY, but it could be that a debugger is trying to
steal it instead -- so it would hook in, drop the controlling TTY, then do
some magic to set things up again. In this case, TIOCNOTTY is quite handy
and still respected by at least OpenBSD, NetBSD, and Linux as far as I can
tell.

I've dropped the note about obsoletion, as I intend to support TIOCNOTTY as
long as it doesn't impose a major burden.

Reviewed by: bcr (manpages), kib
Differential Revision: https://reviews.freebsd.org/D22572

4 years agoReduce disk write load in /usr/libexec/save-entropy.
delphij [Sat, 30 Nov 2019 20:06:53 +0000 (20:06 +0000)]
Reduce disk write load in /usr/libexec/save-entropy.

Before this commit, the save-entropy script rotates entropy files
like logs. This involves creating a new file that holds the entropy
and renaming of all existing entropy files. However, the entropy
data do not really need to be kept in a particular order, and
replacing the oldest file is sufficient.

This commit replaces the rotation with a scan in the
[1..entropy_save_num] space that finds the first empty slot, or
the slot of the oldest file, and writes entropy into that slot.

This also fixes an issue that prevents save-entropy from saving
any entropy when there is one non-regular file in any slot as a
side effect.

Based on an earlier patch from peterj@.

PR: 134225
Reported by: peterj
Reviewed by: csprng (cem, markm)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D22612

4 years agosmp: cast the read in quiesce_all_critical through void *
mjg [Sat, 30 Nov 2019 19:33:02 +0000 (19:33 +0000)]
smp: cast the read in quiesce_all_critical through void *

Fixes compilation on some 32-bit arm platforms.

Sponsored by: The FreeBSD Foundation

4 years agoAdd an OFWBUS_PNP_INFO() macro for devices that hang directly off the root
ian [Sat, 30 Nov 2019 19:16:44 +0000 (19:16 +0000)]
Add an OFWBUS_PNP_INFO() macro for devices that hang directly off the root
ofwbus.  Also, apply some style(9) whitespace fixing to the
SIMPLEBUS_PNP_INFO() macro (no functional change).

4 years agoldconfig: fetch hw.machine_arch only once
mjg [Sat, 30 Nov 2019 17:30:01 +0000 (17:30 +0000)]
ldconfig: fetch hw.machine_arch only once

This happens to be of significance with poudriere which runs the script a lot
when installing packages.

4 years agolockprof: use IPI-injecetd fences to fix hangs on stat dump and reset
mjg [Sat, 30 Nov 2019 17:24:42 +0000 (17:24 +0000)]
lockprof: use IPI-injecetd fences to fix hangs on stat dump and reset

The previously used quiesce_all_cpus walks all CPUs and waits until curthread
can run on them. Even on contemporary machines this becomes a significant
problem under load when it can literally take minutes for the operation to
complete. With the patch the stall is normally less than 1 second.

Reviewed by: kib, jeff (previous version)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21740

4 years agoAdd a way to inject fences using IPIs
mjg [Sat, 30 Nov 2019 17:22:10 +0000 (17:22 +0000)]
Add a way to inject fences using IPIs

A variant of this facility was already used by rmlocks where IPIs would
enforce ordering.

This allows to elide fences where they are rarely needed and the cost of
IPI (should it be necessary) is cheaper.

Reviewed by: kib, jeff (previous version)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21740

4 years agodevfs: introduce a per-dev lock to protect ->si_devsw
mjg [Sat, 30 Nov 2019 16:46:19 +0000 (16:46 +0000)]
devfs: introduce a per-dev lock to protect ->si_devsw

This allows bumping threadcount without taking the global devmtx lock.

In particular this eliminates contention on said lock while using bhyve
with multiple vms.

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

4 years agotmpfs: add fast path to tmpfs_access for common case lookup
mjg [Sat, 30 Nov 2019 16:41:47 +0000 (16:41 +0000)]
tmpfs: add fast path to tmpfs_access for common case lookup

VEXEC consists of vast majority of all calls and almost all targets have
at least 0111.

4 years agovfs: swap placement between v_type and v_tag
mjg [Sat, 30 Nov 2019 16:40:16 +0000 (16:40 +0000)]
vfs: swap placement between v_type and v_tag

The former is frequently accessed (e.g., in vfs_cache_lookup) and shares the
cacheline with v_usecount, avoidably adding to cache misses during concurrent
lookup. The latter is almost unused and probably can get garbage-collected.

The struct does not change in size despite enum vs char * discrepancy.
On 64-bit archs there used to be 4 bytes padding after v_type giving 480 bytes
in total.

4 years agoCapitalize some user-visible output messages in
bcr [Sat, 30 Nov 2019 14:17:45 +0000 (14:17 +0000)]
Capitalize some user-visible output messages in
the bectl utility.

No functional changes.

Approved by:     imp@
MFC after:     7 days
Differential Revision: https://reviews.freebsd.org/D22330

4 years agoloader.efi: efipart needs better support detecting nested partitions
tsoome [Sat, 30 Nov 2019 09:11:28 +0000 (09:11 +0000)]
loader.efi: efipart needs better support detecting nested partitions

Just as disks can have nested partitions, the same happens with cd devices,
so we need to detect device paths and make sure we will not mix the handles.

To address this:

we fetch handle array and create linked list of block devices.
we walk the list and detect parent devices and set children pd_parent.
for {fd, cd, hd}, we walk device list and pick up our devices and store to
corresponding list. We make sure we store parent device first.

For sorting we use 3 steps: We check for floppy, we check for cd and then
everything else must be hd.

In general, it seems the floppy devices have no parent.
CD can have both parents and children (multiple boot entries, partitions
from the hybrid disk image).

Tested by: cross+freebsd@distal.com on Cisco UCS systems, C200 series (C220M5, C240M4).
Also on MBP with UEFI 1.10

Reported by: Chriss Ross
MFC after: 1w
Differential Revision: https://reviews.freebsd.org/D22553

4 years agoUse strlcat().
delphij [Sat, 30 Nov 2019 05:57:54 +0000 (05:57 +0000)]
Use strlcat().

MFC after: 2 weeks

4 years agoCorrect date and time of George Harrison's death.
grog [Fri, 29 Nov 2019 23:04:45 +0000 (23:04 +0000)]
Correct date and time of George Harrison's death.
  Source: https://www.beatlesbible.com/2001/11/29/george-harrison-dies/

4 years agoRestore swap space accounting for non-anonymous swap objects. This was
jeff [Fri, 29 Nov 2019 19:57:49 +0000 (19:57 +0000)]
Restore swap space accounting for non-anonymous swap objects.  This was
broken in r355082.  Reduce some locking in nearby related object type
checks.

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

4 years agoAvoid acquiring the object lock if color is already set. It can not be
jeff [Fri, 29 Nov 2019 19:49:20 +0000 (19:49 +0000)]
Avoid acquiring the object lock if color is already set.  It can not be
unset until the object is recycled so this check is stable.  Now that we
can acquire the ref without a lock it is not necessary to group these
operations and we can avoid it entirely in many cases.

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

4 years agoFix a perf regression from r355122. We can use a shared lock to drop the
jeff [Fri, 29 Nov 2019 19:47:40 +0000 (19:47 +0000)]
Fix a perf regression from r355122.  We can use a shared lock to drop the
last ref on vnodes.

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

4 years agoIgnore "gpio-hog" nodes when instantiating ofw_gpiobus children. Also,
ian [Fri, 29 Nov 2019 18:05:54 +0000 (18:05 +0000)]
Ignore "gpio-hog" nodes when instantiating ofw_gpiobus children.  Also,
in ofw_gpiobus_probe() return BUS_PROBE_DEFAULT rather than 0; we are not
the only possible driver to handle this device, we're just slightly better
than the base gpiobus (which probes at BUS_PROBE_GENERIC).

In the time since this code was first written, the gpio controller bindings
aquired the concept of a "hog" node which could be used to preset one or
more gpio pins as input or output at a specified level.  This change doesn't
fully implement the hogging concept, it just filters out hog nodes when
instantiating child devices by scanning for child nodes in the fdt data.

The whole concept of having child nodes under the controller node is not
supported by the standard bindings, and appears to be a freebsd extension,
probably left over from the days when we had no support for cross-tree
phandle references in the fdt data.

4 years agoUse the VM_MEMATTR macros to describe the MAIR offsets.
andrew [Fri, 29 Nov 2019 16:14:32 +0000 (16:14 +0000)]
Use the VM_MEMATTR macros to describe the MAIR offsets.

Remove the duplicate macros that defined a subset of the VM_MEMATTR values.
While here use VM_MEMATTR macros when filling in the MAIR register.

Reviewed by: alc, markj
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D22241

4 years agotty_rel_gone: add locking assertion
kevans [Fri, 29 Nov 2019 14:46:13 +0000 (14:46 +0000)]
tty_rel_gone: add locking assertion

We already assert the lock is held later during tty_rel_free(), but it is
arguably good form to clarify locking expectations here as well at the
top-level that other drivers use.

4 years agoAdd a VN_OPEN_INVFS flag.
kib [Fri, 29 Nov 2019 14:02:32 +0000 (14:02 +0000)]
Add a VN_OPEN_INVFS flag.

vn_open_cred() assumes that it is called from the top-level of a VFS
syscall.  Writers must call bwillwrite() before locking any VFS
resource to wait for cleanup of dirty buffers.

ZFS getextattr() and setextattr() VOPs do call vn_open_cred(), which
results in wait for unrelated buffers while owning ZFS vnode lock (and
ZFS does not use buffer cache).  VN_OPEN_INVFS allows caller to skip
bwillwrite.

Note that ZFS is still incorrect there, because it starts write on an
mp and locks a vnode while holding another vnode lock.

Reported by: Willem Jan Withagen <wjw@digiware.nl>
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

4 years agoIn nfs_lock(), recheck vp->v_data after lock before accessing it.
kib [Fri, 29 Nov 2019 13:55:56 +0000 (13:55 +0000)]
In nfs_lock(), recheck vp->v_data after lock before accessing it.

We might race with reclaim, and then this is no longer a nfs vnode, in
which case we do not need to handle deferred vnode_pager_setsize()
either.

Reported by: rk@ronald.org
PR:  242184
Sponsored by: The FreeBSD Foundation
MFC after: 3 days

4 years ago[PPC] Remove extra \0 char inserted on vty by QEMU
luporl [Fri, 29 Nov 2019 11:34:11 +0000 (11:34 +0000)]
[PPC] Remove extra \0 char inserted on vty by QEMU

Since version 2.11.0, QEMU became bug-compatible with
PowerVM's vty implementation, by inserting a \0 after
every \r going to the guest. Guests are expected to
workaround this issue by removing every \0 immediately
following a \r.

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

4 years agokern.mk: -Wno-error=stringop-overflow for gcc due to false positives
rlibby [Fri, 29 Nov 2019 06:25:07 +0000 (06:25 +0000)]
kern.mk: -Wno-error=stringop-overflow for gcc due to false positives

Demote gcc's Wstringop-overflow to Wno-error due to false positives.
E.g. the riscv64 build with gcc 8.3.0 has been failing with this warning
since r355062 [1].  A bug has been filed with gcc [2].  The warning was
first introduced in gcc 7.1 [3]. Hopefully we can avoiding suppressing
the warning in future gcc versions.

[1] https://ci.freebsd.org/job/FreeBSD-head-riscv64-build/16691/
[2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92718
[3] https://gcc.gnu.org/wiki/WarningHistory

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

4 years agoktls_session zone: don't need to specify uma trash
rlibby [Fri, 29 Nov 2019 06:25:03 +0000 (06:25 +0000)]
ktls_session zone: don't need to specify uma trash

The use of the uma trash procedures is automatic, there's no need to
pass them explicitly here.

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

4 years agotty_pts: don't rely on tty header pollution for sys/mutex.h
kevans [Fri, 29 Nov 2019 03:56:01 +0000 (03:56 +0000)]
tty_pts: don't rely on tty header pollution for sys/mutex.h

tty_pts.c relies on sys/tty.h for sys/mutex.h. Include it directly instead
of relying on this pollution to ease the diff for anyone that wants to try
converting the tty lock to anything other than a mutex.

4 years agosnp: don't reference tp->t_mtx directly
kevans [Fri, 29 Nov 2019 03:51:01 +0000 (03:51 +0000)]
snp: don't reference tp->t_mtx directly

This is the only part of snp(4) that pokes around in struct tty directly;
replace it with the tty_getlock accessor to avoid struct tty internals.

4 years agoFix braino in previous bugfix r300174
cem [Fri, 29 Nov 2019 03:31:47 +0000 (03:31 +0000)]
Fix braino in previous bugfix r300174

The previous revision missed the exact same error in a copy paste block
of the same code in another function.  Fix the identical case, too.

A DHCP client identifier is simply the hardware type (one byte)
concatenated with the hardware address (some variable number of bytes,
but at most 16).  Limit the size of the temporary buffer to match and
the rest of the calculations shake out correctly.

PR: 238022
Reported by: Young <yangx92 AT hotmail.com>
Submitted by: Young <yangx92 AT hotmail.com>
MFC after: I don't plan to but you should feel free
Security: yes

4 years agoHandle large mallocs by going directly to kmem. Taking a detour through
jeff [Fri, 29 Nov 2019 03:14:10 +0000 (03:14 +0000)]
Handle large mallocs by going directly to kmem.  Taking a detour through
UMA does not provide any additional value.

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D22563

4 years agoFunctions that call vm_map_splay_merge sometimes set data fields
dougm [Fri, 29 Nov 2019 02:06:45 +0000 (02:06 +0000)]
Functions that call vm_map_splay_merge sometimes set data fields
(e.g. root->left = NULL) to affect the behavior of that function. This
change stops that data manipulation, and instead calls a pair of
functions, one for the left direction and the other for the right,
with the function called depending whether or not we currently null
the root child in that direction to control the behavior of
vm_map_splay_merge.

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

4 years agoFix two races while handling nfsuserd daemon start/stop.
rmacklem [Thu, 28 Nov 2019 23:34:23 +0000 (23:34 +0000)]
Fix two races while handling nfsuserd daemon start/stop.

A crash was reported where the nr_client field was NULL during an upcall
to the nfsuserd daemon. Since nr_client == NULL only occurs when the
nfsuserd daemon is being shut down, it appeared to be caused by a race
between doing an upcall and the daemon shutting down.
By inspection two races were identified:
1 - The nfsrv_nfsuserd variable is used to indicate whether or not the
    daemon is running. However it did not handle the intermediate phase
    where the daemon is starting or stopping.

    This was fixed by making nfsrv_nfsuserd tri-state and having the
    functions that are called during start/stop to obey the intermediate
    state.

2 - nfsrv_nfsuserd was checked to see that the daemon was running at
    the beginning of an upcall, but nothing prevented the daemon from
    being shut down while an upcall was still in progress.
    This race probably caused the crash.

    The patch fixes this by adding a count of upcalls in progress and
    having the shut down function delay until this count goes to zero
    before getting rid of nr_client and related data used by an upcall.

Tested by: avg (Panzura QA)
Reported by: avg
Reviewed by: avg
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D22377

4 years agoImplement the ofw_bus_get_node method in the imx_gpio driver so that
ian [Thu, 28 Nov 2019 21:50:34 +0000 (21:50 +0000)]
Implement the ofw_bus_get_node method in the imx_gpio driver so that
ofw_gpiobus can find its fdt metadata and instantiate child devices.

4 years agoClarify name of Pau Casals (it's Catalonian)
grog [Thu, 28 Nov 2019 21:22:04 +0000 (21:22 +0000)]
Clarify name of Pau Casals (it's Catalonian)
Get correct birthday (from Wikipedia).

4 years agoarm64: rockchip: rk3328: Add TSADC clocks
manu [Thu, 28 Nov 2019 20:46:24 +0000 (20:46 +0000)]
arm64: rockchip: rk3328: Add TSADC clocks

Add the clocks so we can use the rk_tsadc driver to monitor
the cpu temperature.

4 years agoarm64: rockchip: tsadc: Do not free the sysctl context is it wasn't created
manu [Thu, 28 Nov 2019 20:17:03 +0000 (20:17 +0000)]
arm64: rockchip: tsadc: Do not free the sysctl context is it wasn't created

MFC after: 3 weeks
X-MFC-With: r355173

4 years agoImport riscv DTS files
manu [Thu, 28 Nov 2019 19:38:57 +0000 (19:38 +0000)]
Import riscv DTS files

Requested by: mhorne

4 years agoImport DTS files from Linux 5.4
manu [Thu, 28 Nov 2019 19:30:41 +0000 (19:30 +0000)]
Import DTS files from Linux 5.4

MFC after: 2 months

4 years agoImport devicetree files from Linux 5.4
manu [Thu, 28 Nov 2019 19:05:03 +0000 (19:05 +0000)]
Import devicetree files from Linux 5.4

4 years agoFix use-after-free in case of L2ARC prefetch failure.
mav [Thu, 28 Nov 2019 18:28:35 +0000 (18:28 +0000)]
Fix use-after-free in case of L2ARC prefetch failure.

In case L2ARC read failed, l2arc_read_done() creates _different_ ZIO
to read data from the original storage device.  Unfortunately pointer
to the failed ZIO remains in hdr->b_l1hdr.b_acb->acb_zio_head, and if
some other read try to bump the ZIO priority, it will crash.

The problem is reproducible by corrupting L2ARC content and reading
some data with prefetch if l2arc_noprefetch tunable is changed to 0.
With the default setting the issue is probably not reproducible now.

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

4 years agoAdd driver for temperature sensors found in RK32898, RK3328 and RK3399 SoC's.
mmel [Thu, 28 Nov 2019 17:01:31 +0000 (17:01 +0000)]
Add driver for temperature sensors found in RK32898, RK3328 and RK3399 SoC's.

MFC after: 3 weeks
Reviewed by: manu
Differential Revision:  https://reviews.freebsd.org/D22442

4 years agoReally ignore the SCTP association identifier on 1-to-1 style sockets
tuexen [Thu, 28 Nov 2019 12:50:25 +0000 (12:50 +0000)]
Really ignore the SCTP association identifier on 1-to-1 style sockets
as requiresd by the socket API specification.
Thanks to Inaki Baz Castillo, who found this bug running the userland
stack with valgrind and reported the issue in
https://github.com/sctplab/usrsctp/issues/408

MFC after: 1 week

4 years agoFix DEBUG_REDZONE build after r355169
jeff [Thu, 28 Nov 2019 08:56:14 +0000 (08:56 +0000)]
Fix DEBUG_REDZONE build after r355169

4 years agoFactor out check for mounted root file system.
hselasky [Thu, 28 Nov 2019 08:47:36 +0000 (08:47 +0000)]
Factor out check for mounted root file system.

Differential Revision: https://reviews.freebsd.org/D22571
PR: 241639
MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agoGarbage collect the mostly unused us_keg field. Use appropriately named
jeff [Thu, 28 Nov 2019 07:49:25 +0000 (07:49 +0000)]
Garbage collect the mostly unused us_keg field.  Use appropriately named
union members in vm_page.h to store the zone and slab.  Remove some nearby
dead code.

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D22564

4 years agoAlso turn of teken for RB_MULTIPLE
imp [Thu, 28 Nov 2019 05:40:15 +0000 (05:40 +0000)]
Also turn of teken for RB_MULTIPLE

RB_MULTIPLE without RB_SERIAL set is valid, and means 'Video first, then serial'
to the kernel (so kernel messages go to both, but /etc/rc uses video console
(this should be fixed, btw, but another day)). Check for RB_MULTIPLE as well as
RB_SERIAL where we want to to serial things. This means we'll use the old code
for emulation in these situations, which is likely best since we're outputing to
both and the old code is ligher weight allowing both to keep up w/o weird
scrolling things.

4 years agoRemove comment. We're just going to the next node here.
imp [Thu, 28 Nov 2019 05:40:10 +0000 (05:40 +0000)]
Remove comment. We're just going to the next node here.

4 years agouma: move sysctl vm.uma defn out from under INVARIANTS
rlibby [Thu, 28 Nov 2019 04:15:16 +0000 (04:15 +0000)]
uma: move sysctl vm.uma defn out from under INVARIANTS

Fix non-INVARIANTS builds after r355149.

Reported by: Michael Butler <imb@protected-networks.net>
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D22588

4 years agoMake DMAR allow Intel NTB device to access its own BAR0.
mav [Thu, 28 Nov 2019 02:40:12 +0000 (02:40 +0000)]
Make DMAR allow Intel NTB device to access its own BAR0.

I have no good explanation why it happens, but I found that in B2B mode
at least Xeon v4 NTB leaks accesses to its configuration memory at BAR0
originated from the link side to its host side.  DMAR predictably blocks
those, making access to remote scratchpad registers in B2B mode impossible.

This change creates identity mapping in DMAR covering the BAR0 addresses,
making the NTB work fine with DMAR enabled.  It seems like allowing single
4KB range at 32KB offset may be enough, but I don't see a reason to be so
specific.

MFC after: 1 week
Sponsored by: iXsystems, Inc.

4 years agoRemove the trm(4) driver
scottl [Thu, 28 Nov 2019 02:32:17 +0000 (02:32 +0000)]
Remove the trm(4) driver

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

4 years agoMake the code slightly more compact.
mav [Thu, 28 Nov 2019 02:28:12 +0000 (02:28 +0000)]
Make the code slightly more compact.

There should be no functional change.

MFC after: 1 week

4 years agoChange r355157 to make svc_rpc_gss_lifetime_max a static.
rmacklem [Thu, 28 Nov 2019 02:18:51 +0000 (02:18 +0000)]
Change r355157 to make svc_rpc_gss_lifetime_max a static.

MFC after: 2 weeks

4 years agoAdd a cap on credential lifetime for Kerberized NFS.
rmacklem [Thu, 28 Nov 2019 02:05:31 +0000 (02:05 +0000)]
Add a cap on credential lifetime for Kerberized NFS.

The kernel RPCSEC_GSS code sets the credential (called a client) lifetime
to the lifetime of the Kerberos ticket, which is typically several hours.
As such, when a user's credentials change such as being added to a new group,
it can take several hours for this change to be recognized by the NFS server.
This patch adds a sysctl called kern.rpc.gss.lifetime_max which can be set
by a sysadmin to put a cap on the time to expire for the credentials, so that
a sysadmin can reduce the timeout.
It also fixes a bug, where time_uptime is added twice when GSS_C_INDEFINITE
is returned for a lifetime. This has no effect in practice, sine Kerberos
never does this.

Tested by: pen@lysator.liu.se
PR: 242132
Submitted by: pen@lysator.liu.se
MFC after: 2 weeks

4 years agoInclude fin, the packet information structure (fr_info_t), in the
cy [Thu, 28 Nov 2019 00:46:33 +0000 (00:46 +0000)]
Include fin, the packet information structure (fr_info_t), in the
l4sums DTrace probe, making more information available for the diagnosis
of IPv6 checksum errors.

MFC after: 3 days

4 years agoauditd(8): fix long-standing uninitialized memory use bug
cem [Thu, 28 Nov 2019 00:46:03 +0000 (00:46 +0000)]
auditd(8): fix long-standing uninitialized memory use bug

The bogus use could lead to an infinite loop depending on how fast the
audit_warn script to execute.

By fixing read(2) interruptibility, d060887 (r335899) revealed another bug
in auditd_wait_for_events.  When read is interrupted by SIGCHLD,
auditd_reap_children will always return with errno set to ECHILD.  But
auditd_wait_for_events checks errno after that point, expecting it to be
unchanged since read.  As a result, it calls auditd_handle_trigger with bogus
stack garbage.  The result is the error message "Got unknown trigger 48."  Fix
by simply ignoring errno at that point; there's only one value it could've
possibly had, thanks to the check up above.

The best part is we've had a fix for this for like 18 months and just never
merged it.  Merge it now.

PR: 234209
Reported by: Marie Helene Kvello-Aune <freebsd AT mhka.no> (2018-12)
Submitted by: asomers (2018-07)
Reviewed by: me (in OpenBSM)
Obtained from: OpenBSM
X-MFC-With: r335899
Security: ¯\_(ツ)_/¯
Differential Revision: https://github.com/openbsm/openbsm/pull/45

4 years agoAs part of creating a snapshot, set fs->fs_fmod to 0 in the snapshot image
chs [Thu, 28 Nov 2019 00:37:43 +0000 (00:37 +0000)]
As part of creating a snapshot, set fs->fs_fmod to 0 in the snapshot image
because nothing ever changes this field for read-only mounts and we want
to verify that it is still 0 when we unmount.

Reviewed by: mckusick
Approved by: mckusick (mentor)
Sponsored by: Netflix