freebsd.git
4 years agoAdd a couple of definitions for NFSv4.2 and update macros to use them.
rmacklem [Fri, 6 Dec 2019 23:51:11 +0000 (23:51 +0000)]
Add a couple of definitions for NFSv4.2 and update macros to use them.

This patch adds code to macros to clear attribute bits not supported
by NFSv4.2. For now, these bits are never set anyhow, but this prepares
the code for the addition of NFSv4.2 support in a future commit.

There will be a series of these preliminary commits that will prepare for
a major commit of the NFSv4.2 client/server changes currently found in
subversion under projects/nfsv42/sys.

4 years agoFix an inverted condition introduced in r353539.
markj [Fri, 6 Dec 2019 23:49:37 +0000 (23:49 +0000)]
Fix an inverted condition introduced in r353539.

This would have most likely resulted in read errors causing page leaks.

Submitted by: jeff

4 years agoFix tail -f in capability mode.
markj [Fri, 6 Dec 2019 23:39:38 +0000 (23:39 +0000)]
Fix tail -f in capability mode.

We were not adding CAP_EVENT to input file capabilities, so kevent()
always failed with ENOTCAPABLE.  tail implements a fallback mode to
poll the file in this case, so the failure was not apparent.

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

4 years agoFix fault_type handling in vm_map_lookup().
markj [Fri, 6 Dec 2019 23:39:08 +0000 (23:39 +0000)]
Fix fault_type handling in vm_map_lookup().

Suppose that the map entry is wired, so that we later assign
fault_type = entry->protection.  Suppose further that we jump back to
RetryLookup.  Then fault_type will no longer contain the original
fault protection mask, but instead that of the wired entry.

Submitted by: Wuyang Chung <wuyang.chung1@gmail.com>
Reviewed by: kib
MFC after: 3 days
Github PR: https://github.com/freebsd/freebsd/pull/419
Differential Revision: https://reviews.freebsd.org/D22683

4 years agomakesyscalls.lua: improve config processing
kevans [Fri, 6 Dec 2019 22:45:36 +0000 (22:45 +0000)]
makesyscalls.lua: improve config processing

The current version will strip out #include directives appearing inside strings, which is clearly wrong. Improve the processing entirely in the following ways:

- Strip only whole-line comments on every single iteration
- Abort if we see a malformed line that doesn't match the key=value format
- For quoted (backtick or double quote) strings, we'll advance to the end of
  the key=value pair and make sure there's not extra stuff left over
- For unquoted key=value pairs, we'll strip any trailing comments and verify
  there's no internal whitespace

This has revealed the caveat that key/value pairs can't even include escaped quotes (and haven't been able to). I don't know if this is actually problematic, as we're usually looking at cases like "#include <foo>" or raw identifiers.The current version will strip out #include directives appearing inside strings, which is clearly wrong. Improve the processing entirely in the following ways:

Reviewed and noticed by: brooks
Differential Revision: https://reviews.freebsd.org/D22698

4 years agoImplement bus_rescan for gpiobus(4). This allows on-the-fly reconfiguration
ian [Fri, 6 Dec 2019 22:32:06 +0000 (22:32 +0000)]
Implement bus_rescan for gpiobus(4).  This allows on-the-fly reconfiguration
of gpio devices by using kenv to add hints for a new device and then do
'devctl rescan gpiobus4' to make the new device(s) attach.

It's not particularly easy to detect whether the 'at' hint has been deleted
for a child device that's currently attached, so this doesn't handle that.
But the user can use devctl commands to manually detach an existing device.

4 years agoRemove the extra epoch tracker change sneaked into r355449 and was not part
bz [Fri, 6 Dec 2019 22:20:26 +0000 (22:20 +0000)]
Remove the extra epoch tracker change sneaked into r355449 and was not part
of the originally reviewed or described change.

Pointyhat to:   bz
Reported by:    glebius

4 years agotrackers always know what qpair they are on
imp [Fri, 6 Dec 2019 22:12:39 +0000 (22:12 +0000)]
trackers always know what qpair they are on

Don't needlessly pass around qpair pointers when the tracker knows what
qpair it's on.  This will simplify code and make it easier to split
submission and completion queues in the future.

Signed-off-by: John Meneghini <johnm@netapp.com>
4 years agoRemove ifdefs for FreeBSD 6, 7, 8 and 9. Assume we're past that.
imp [Fri, 6 Dec 2019 21:50:24 +0000 (21:50 +0000)]
Remove ifdefs for FreeBSD 6, 7, 8 and 9. Assume we're past that.

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

4 years agoAdd a GPIO based MDIO bit-banging bus driver.
loos [Fri, 6 Dec 2019 20:21:07 +0000 (20:21 +0000)]
Add a GPIO based MDIO bit-banging bus driver.

Uses two GPIO pins as MDC (clock) and MDIO (bidirectional I/O), relies
on mii_bitbang.

Tested on SG-3200 where the PHY for one of the ports is wired independently
of the SoC MDIO bus.

Sponsored by: Rubicon Communications, LLC (Netgate)

4 years agoFix the ARM64 build, include the necessary <sys/mutex.h> header.
loos [Fri, 6 Dec 2019 20:05:08 +0000 (20:05 +0000)]
Fix the ARM64 build, include the necessary <sys/mutex.h> header.

While here, call device_delete_children() to detach and dealloc all the
existent children and handle the child's detach errors properly.

Reported by: jenkins, hselasky, ian
Sponsored by: Rubicon Communications, LLC (Netgate)

4 years agolibbe: fix build against sysutils/openzfs, part 1
kevans [Fri, 6 Dec 2019 19:33:39 +0000 (19:33 +0000)]
libbe: fix build against sysutils/openzfs, part 1

This is the half of the changes required that work as-is with both in-tree
ZFS and the new hotness, sysutils/openzfs.  Highlights are less dependency
on header pollution (from somewhere) and using 'mnttab' instead of
'extmnttab'.   In the in-tree ZFS, the latter is a #define for the former,
but in the port extmnttab is actually a distinct struct that's a super-set
of mnttab.  We really want mnttab here anyways, so just use it.

4 years agoRemove SPARE_USRSPACE.
jhb [Fri, 6 Dec 2019 19:20:45 +0000 (19:20 +0000)]
Remove SPARE_USRSPACE.

This constant was used to reserve space at the top of the stack to
hold translated system call arguments for non-default ABIs (the
"stackgap").  However, none of the compatibility ABIs have used the
stackgap in many years and the last use of SPARE_USRSPACE was removed
in r355373.

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

4 years agoMake devstat_end_transaction_bio() count BIO_ORDERED.
mav [Fri, 6 Dec 2019 18:39:05 +0000 (18:39 +0000)]
Make devstat_end_transaction_bio() count BIO_ORDERED.

MFC after: 2 weeks

4 years agoUpdate comment.
bz [Fri, 6 Dec 2019 16:53:42 +0000 (16:53 +0000)]
Update comment.

Update the comment related to SIIT and v4mapped addresses being rejected
by us when coming from the wire given we have supported IPv6-only kernels
for a few years now.
See also draft-itojun-v6ops-v4mapped-harmful.

Suggested by: melifaro
MFC after: 2 weeks

4 years agoRemove some branching from GEOM_DISK hot path.
mav [Fri, 6 Dec 2019 16:48:36 +0000 (16:48 +0000)]
Remove some branching from GEOM_DISK hot path.

pp->private just can not be NULL in those places.

In g_disk_start() and g_disk_ioctl() both dp != NULL and !dp->d_destroyed
should always be true if disk_gone() and disk_destroy() are used properly,
since GEOM does not send requests to errored providers.  If the protocol is
not followed, then no amount of additional checks here give real safety.

In g_disk_access() though the checks are useful, since GEOM blocks only
new opens for errored providers, but allows closes.  It should not happen
if disk_gone() and disk_destroy() are used properly, but may otherwise.

To improve cases when disk_gone() is not used, call it from disk_destroy().
It does not give full guaranties, but it errors the provider and makes
GEOM block unwanted requests at least after some race.

MFC after: 2 weeks

4 years agoip6_input: remove redundant v4mapped check
bz [Fri, 6 Dec 2019 16:42:58 +0000 (16:42 +0000)]
ip6_input: remove redundant v4mapped check

In ip6_input() we apply the same v4mapped address check twice. The only
case which skipps the first one is M_FASTFWD_OURS which should have passed
the check on the firstinput pass and passed the firewall.
Remove the 2nd redundant check.

Reviewed by: kp, melifaro
MFC after: 2 weeks
Sponsored by: Netflix (originally)
Differential Revision: https://reviews.freebsd.org/D22462

4 years agocarp: replace caddr_t with char *
bz [Fri, 6 Dec 2019 16:35:48 +0000 (16:35 +0000)]
carp: replace caddr_t with char *

Change the remaining caddr_t usages to char * following the removal
of the KAME macros

No functional change.

Requested by: glebius
Reviewed by: glebius
MFC after: 2 weeks
Sponsored by: Netflix (originally)
Differential Revision: https://reviews.freebsd.org/D22399

4 years agoImprove EPOCH_TRACE
bz [Fri, 6 Dec 2019 16:34:04 +0000 (16:34 +0000)]
Improve EPOCH_TRACE

Two changes to EPOCH_TRACE:
(1) add a sysctl to surpress the backtrace from epoch_trace_report().
    Sometimes the log line for the recursion is enough and the
    backtrace massively spams the console.
(2) In order to be able to go without the backtrace do not only
    print where the previous occurance happened, but also where
    the current one happens.  That way we have file:line information
    for both and can look at them without the need for getting line
    numbers from backtrace and a debugging tool.

Reviewed by: glebius
Sponsored by: Netflix (originally)
Differential Revision: https://reviews.freebsd.org/D22641

4 years agoFix compilation issue with mlx5core and sparc64 (gcc48):
hselasky [Fri, 6 Dec 2019 16:20:22 +0000 (16:20 +0000)]
Fix compilation issue with mlx5core and sparc64 (gcc48):

sys/dev/mlx5/mlx5_en/mlx5_en_tx.c:335: error: requested alignment is not a constant

MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agoImplement hardware TLS via send tags for mlx5en(4), which is supported by
hselasky [Fri, 6 Dec 2019 15:36:32 +0000 (15:36 +0000)]
Implement hardware TLS via send tags for mlx5en(4), which is supported by
ConnectX-6 DX.

Currently TLS v1.2 and v1.3 with AES 128/256 crypto over TCP/IP (v4
and v6) is supported.

A per PCI device UMA zone is used to manage the memory of the send
tags.  To optimize performance some crypto contexts may be cached by
the UMA zone, until the UMA zone finishes the memory of the given send
tag.

An asynchronous task is used manage setup of the send tags towards the
firmware. Most importantly setting the AES 128/256 bit pre-shared keys
for the crypto context.

Updating the state of the AES crypto engine and encrypting data, is
all done in the fast path. Each send tag tracks the TCP sequence
number in order to detect non-contiguous blocks of data, which may
require a dump of prior unencrypted data, to restore the crypto state
prior to wire transmission.

Statistics counters have been added to count the amount of TLS data
transmitted in total, and the amount of TLS data which has been dumped
prior to transmission. When non-contiguous TCP sequence numbers are
detected, the software needs to dump the beginning of the current TLS
record up until the point of retransmission. All TLS counters utilize
the counter(9) API.

In order to enable hardware TLS offload the following sysctls must be set:
kern.ipc.mb_use_ext_pgs=1
kern.ipc.tls.ifnet.permitted=1
kern.ipc.tls.enable=1

Sponsored by: Mellanox Technologies

4 years agoAdd the SPI driver for the Marvell Armada 37x0 SoC.
loos [Fri, 6 Dec 2019 12:55:39 +0000 (12:55 +0000)]
Add the SPI driver for the Marvell Armada 37x0 SoC.

Interrupt based driver, implements SPI mode and clock configuration.

Tested on espressobin and SG-3200.

Sponsored by: Rubicon Communications, LLC (Netgate)

4 years agoloader.efi: print ImageBase so we know where we are
tsoome [Fri, 6 Dec 2019 09:50:29 +0000 (09:50 +0000)]
loader.efi: print ImageBase so we know where we are

Output a bit of debugging aid.

4 years agoDeclare the global kernel symbols created by ldscript.arm in arm's machdep.h,
ian [Fri, 6 Dec 2019 03:48:35 +0000 (03:48 +0000)]
Declare the global kernel symbols created by ldscript.arm in arm's machdep.h,
and remove a couple scattered local declarations.

Most of these aren't referenced in C code (there are some references in
asm code), and they also aren't documented anywhere.  This helps a bit
with the latter.

4 years agoBlock ioctls for dying GEOM_DEV instances.
mav [Fri, 6 Dec 2019 03:46:38 +0000 (03:46 +0000)]
Block ioctls for dying GEOM_DEV instances.

For normal I/Os consumer and provider statuses are checked by g_io_check().
But ioctl calls often do not go through it, being dispatched directly. This
change makes their semantics more alike, protecting lower levels.

MFC after: 2 weeks

4 years agoMake GEOM_DEV code slightly more compact.
mav [Fri, 6 Dec 2019 03:18:37 +0000 (03:18 +0000)]
Make GEOM_DEV code slightly more compact.

Should be no functional change.

MFC after: 2 weeks

4 years agoMove the mds, irbs, and ssb mitigation knobs into machdep.mitigations.
scottl [Fri, 6 Dec 2019 02:43:05 +0000 (02:43 +0000)]
Move the mds, irbs, and ssb mitigation knobs into machdep.mitigations.
They're in both the old and new places in HEAD for the moment for
discussion and transition.  The old locations will be garbage collected
in 4 weeks.  MFCs to 12 an 11 will keep the old and new for transition
purposes.

Reviewed by: kib
MFC after: 4 weeks
Sponsored by: Intel
Differential Revision: https://reviews.freebsd.org/D22590

4 years agoAdd some definitions for NFSv4.2 which will be used by subsequent commits.
rmacklem [Fri, 6 Dec 2019 01:53:02 +0000 (01:53 +0000)]
Add some definitions for NFSv4.2 which will be used by subsequent commits.

This is a preliminary commit of NFSv4.2 definitions that will be used by
subsequent commits which adds NFSv4.2 support to the NFS client and server.

There will be a series of these preliminary commits that will prepare for
a major commit of the NFSv4.2 client/server changes currently found in
subversion under projects/nfsv42/sys.

4 years agogmultipath: add ATF tests
asomers [Fri, 6 Dec 2019 00:12:14 +0000 (00:12 +0000)]
gmultipath: add ATF tests

Add ATF tests for most gmultipath operations. Add some dtrace probes too,
primarily for configuration changes that happen in response to provider
errors.

PR: 178473
MFC after: 2 weeks
Sponsored by: Axcient
Differential Revision: https://reviews.freebsd.org/D22235

4 years agoses: sanitize illegal strings in SES element descriptors
asomers [Fri, 6 Dec 2019 00:06:05 +0000 (00:06 +0000)]
ses: sanitize illegal strings in SES element descriptors

The SES4r3 standard requires that element descriptors may only contain ASCII
characters in the range 0x20 to 0x7e.  Some SuperMicro expanders violate
that rule.  This patch adds a sanity check to ses(4).  Descriptors in
violation will be replaced by "<invalid>".

This patch fixes "sesutil --libxo xml" on such systems.  Previously it would
generate non-well-formed XML output.

PR: 241929
Reviewed by: allanjude
MFC after: 2 weeks
Sponsored by: Axcient

4 years agoAdd support for new sound HDA hardware
scottl [Thu, 5 Dec 2019 19:39:51 +0000 (19:39 +0000)]
Add support for new sound HDA hardware

Sponsored by: Intel

4 years agoAdd a new "riscv-relaxations" linker feature.
jhb [Thu, 5 Dec 2019 19:37:30 +0000 (19:37 +0000)]
Add a new "riscv-relaxations" linker feature.

When the linker doesn't have this feature, add -mno-relax to CFLAGS
on RISC-V.

Define the feature for ld.bfd, but not lld.  If lld gains relaxation
support in a newer version, we can enable it for those versions of lld
in bsd.linker.mk.

Reviewed by: mhorne
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D22659

4 years agoOn a context switch, handle the possibility that the old thread was
alc [Thu, 5 Dec 2019 19:25:49 +0000 (19:25 +0000)]
On a context switch, handle the possibility that the old thread was
preempted after an "ic" or "tlbi" instruction but before it performed a
"dsb" instruction.  The "ic" and "tlbi" instructions have unusual
synchronization requirements.  If the old thread migrates to a new
processor, its completion of a "dsb" instruction on that new processor does
not guarantee that the "ic" or "tlbi" instructions performed on the old
processor have completed.

This issue is not restricted to the kernel.  Since locore.S sets the UCI bit
in SCTLR, user-space programs can perform "ic ivau" instructions (as well as
some forms of the "dc" instruction).

Reviewed by: andrew, kib, markj, mmel
X-MFC with: r355145
Differential Revision: https://reviews.freebsd.org/D22622

4 years agoUse a void * argument to callout handlers instead of timeout_t casts.
jhb [Thu, 5 Dec 2019 18:47:29 +0000 (18:47 +0000)]
Use a void * argument to callout handlers instead of timeout_t casts.

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

4 years agoRemove useless NULL check
kp [Thu, 5 Dec 2019 16:50:54 +0000 (16:50 +0000)]
Remove useless NULL check

Coverity points out that we've already dereferenced m by the time we check, so
there's no reason to keep the check. Moreover, it's safe to pass NULL to
m_freem() anyway.

CID: 1019092

4 years agorelease: chase ports r519089 (rpi-firmware update)
kevans [Thu, 5 Dec 2019 16:17:56 +0000 (16:17 +0000)]
release: chase ports r519089 (rpi-firmware update)

The recent rpi-firmware update renamed "0" to "zero" in the RPi0 DTB
filename

It also included the components needed to boot the RPi4, so install those
now -- interested parties can install sysutils/u-boot-rpi4 and copy
config_rpi4.txt to config.txt on the FAT partition in order to boot the
board. Do note that we currently don't support ethernet/usb/pci.

Reviewed by: manu
MFC after: 3 days

4 years agoUPDATING: Add long-belated note about certs in base
kevans [Thu, 5 Dec 2019 15:32:33 +0000 (15:32 +0000)]
UPDATING: Add long-belated note about certs in base

While the interaction between this and the ETCSYMLINK option of
security/ca_root_nss isn't necessarily fatal, one should be aware and
attempt to understand the ramifications of mixing the two.

ports-secteam will be contacted to discuss the default option for branches
where certs are being included in base.

4 years agomlx5: Do not poke hardware for statistic after teardown is started.
kib [Thu, 5 Dec 2019 15:21:13 +0000 (15:21 +0000)]
mlx5: Do not poke hardware for statistic after teardown is started.

Sponsored by: Mellanox Technologies
MFC after: 1 week

4 years agoAdd basic support for TCP/IP based hardware TLS offload to mlx5core.
hselasky [Thu, 5 Dec 2019 15:16:19 +0000 (15:16 +0000)]
Add basic support for TCP/IP based hardware TLS offload to mlx5core.

The hardware offload is primarily targeted for TLS v1.2 and v1.3,
using AES 128/256 bit pre-shared keys. This patch adds all the needed
hardware structures, capabilites and firmware commands.

Sponsored by: Mellanox Technologies

4 years agoRemove duplicate g_debugflags declaration.
mav [Thu, 5 Dec 2019 15:07:32 +0000 (15:07 +0000)]
Remove duplicate g_debugflags declaration.

While there, define G_F_FOOTSHOOTING instead of numeric constants.

MFC after: 13 days
X-MFX-with: r355412

4 years agosx: check for SX_LOCK_SHARED | SX_LOCK_WRITE_SPINNER when exclusive-locking
mjg [Thu, 5 Dec 2019 13:43:44 +0000 (13:43 +0000)]
sx: check for SX_LOCK_SHARED | SX_LOCK_WRITE_SPINNER when exclusive-locking

First, this removes a spurious difference compared to rw locks.
More importantly though this avoids a trip through sleepq code if the lock
happens to be caught in this state.

4 years agonullfs: locklessly check for entries in null_hashget
mjg [Thu, 5 Dec 2019 13:41:22 +0000 (13:41 +0000)]
nullfs: locklessly check for entries in null_hashget

During random sampling over poudriere -j 104 over 10% of calls returned NULL.

4 years agovfs: remove 'active' variable from _vdrop
mjg [Thu, 5 Dec 2019 13:40:10 +0000 (13:40 +0000)]
vfs: remove 'active' variable from _vdrop

No functional changes.

4 years agoUpdate ELF Tool Chain to upstream r3769
emaste [Thu, 5 Dec 2019 13:20:15 +0000 (13:20 +0000)]
Update ELF Tool Chain to upstream r3769

This contains many small bugfixes and documentation improvements.

Sponsored by: The FreeBSD Foundation

4 years agoWrap g_trace() into a macro to avoid unneeded calls.
mav [Thu, 5 Dec 2019 04:52:19 +0000 (04:52 +0000)]
Wrap g_trace() into a macro to avoid unneeded calls.

In most cases with debug disabled this function does nothing, but argument
passing and the call still cost measurable time due to cache misses, etc.

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

4 years agoFix a trivial typo and add a missing word.
ian [Thu, 5 Dec 2019 04:18:22 +0000 (04:18 +0000)]
Fix a trivial typo and add a missing word.

4 years agoSwitch GEOM_DEV from make_dev_p() to make_dev_s().
mav [Thu, 5 Dec 2019 04:03:08 +0000 (04:03 +0000)]
Switch GEOM_DEV from make_dev_p() to make_dev_s().

It closes the race condition and so allows to remove few NULL checks.

Also while there, use dev->si_drv1 in addition to cp->private to store
softc pointer.  For calls coming from the dev side it gives reliable cache
hit instead of often miss before.

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

4 years agoFix the build, use the correct include path.
loos [Thu, 5 Dec 2019 02:01:47 +0000 (02:01 +0000)]
Fix the build, use the correct include path.

Pointy hat to: loos

4 years agoAdd the I2C driver for the Armada 37x0.
loos [Thu, 5 Dec 2019 00:56:03 +0000 (00:56 +0000)]
Add the I2C driver for the Armada 37x0.

This controller is a bit tricky as the STOP condition must be indicated in
the last tranferred byte, some devices will not like the repeated start
behavior of this controller.  A proper fix to this issue is in the works.

This driver works in polling mode, can be used early in the boot (required
in some cases).

Tested on espressobin/SG-1100 and the SG-3200.

Obtained from: pfSense
Sponsored by: Rubicon Communications, LLC (Netgate)

4 years agoStop using per-mount tmpfs zones.
kib [Thu, 5 Dec 2019 00:03:17 +0000 (00:03 +0000)]
Stop using per-mount tmpfs zones.

Requested and reviewed by: jeff
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D22643

4 years agoAdd some definitions for NFSv4.2 which will be used by subsequent commits.
rmacklem [Wed, 4 Dec 2019 23:24:40 +0000 (23:24 +0000)]
Add some definitions for NFSv4.2 which will be used by subsequent commits.

This is a preliminary commit of NFSv4.2 definitions that will be used by
subsequent commits which adds NFSv4.2 support to the NFS client and server.

There will be a series of these preliminary commits that will prepare for
a major commit of the NFSv4.2 client/server changes currently found in
subversion under projects/nfsv42/sys.

4 years agoFix regression from r354484. Don't leak pcb lock if cr_canseeinpcb()
glebius [Wed, 4 Dec 2019 22:41:52 +0000 (22:41 +0000)]
Fix regression from r354484.  Don't leak pcb lock if cr_canseeinpcb()
returns non-zero.

PR: 242415

4 years agoMark some more hot global variables with __read_mostly.
mav [Wed, 4 Dec 2019 21:26:03 +0000 (21:26 +0000)]
Mark some more hot global variables with __read_mostly.

MFC after: 1 week

4 years agoUse "far" calls and branches so that lld uses valid relocations.
jhb [Wed, 4 Dec 2019 21:01:13 +0000 (21:01 +0000)]
Use "far" calls and branches so that lld uses valid relocations.

Conditional branch and jump instructions do not always call via PLT
stubs and thus will not honor LD_PRELOAD, etc.  lld warns about using
non-preemptible relocations for preemptible or unknown symbols whereas
bfd does not (at least for RISC-V).

Reviewed by: br, James Clarke
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D22658

4 years agoUse a single 'ld' to read the jmpbuf magic values instead of 'la; ld'.
jhb [Wed, 4 Dec 2019 20:50:49 +0000 (20:50 +0000)]
Use a single 'ld' to read the jmpbuf magic values instead of 'la; ld'.

This saves an instruction in each case as well as an extra memory
indirection via the GOT for PIC code.

Reviewed by: br, James Clarke
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D22656

4 years agoDefine __SOFT_FP__ for riscv64sf to avoid infinite recursion.
jhb [Wed, 4 Dec 2019 20:18:12 +0000 (20:18 +0000)]
Define __SOFT_FP__ for riscv64sf to avoid infinite recursion.

Submitted by: James Clarke <jrtc27@jrtc27.com>
Reviewed by: imp
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D22660

4 years agobistring: avoid gcc -Wsign-compare
rlibby [Wed, 4 Dec 2019 20:15:17 +0000 (20:15 +0000)]
bistring: avoid gcc -Wsign-compare

Appease gcc after after r355377, which broke gcc builds.

Reviewed by: dougm
MFC with: r355377
Differential Revision: https://reviews.freebsd.org/D22682

4 years agoFix an off-by-one error in vm_map_pmap_enter().
markj [Wed, 4 Dec 2019 19:46:48 +0000 (19:46 +0000)]
Fix an off-by-one error in vm_map_pmap_enter().

If the starting pindex is equal to object->size, there is nothing to do.
This was harmless since the rest of vm_map_pmap_enter() has no effect
when psize == 0.

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

4 years agoFix the signature for zone_import and zone_release
andrew [Wed, 4 Dec 2019 18:40:05 +0000 (18:40 +0000)]
Fix the signature for zone_import and zone_release

These are cast to uma_import and uma_release functions. Use the signature
for these in the zone functions.

This was found with an experimental Kernel CFI. It will complain if the
signature is different than what a function pointer expects. The
simplest way to fix these is to correct the signature.

Reviewed by: rlibby
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D22671

4 years agoMerge commit 241cbf201 from llvm git (by Nemanja Ivanovic):
dim [Wed, 4 Dec 2019 18:38:50 +0000 (18:38 +0000)]
Merge commit 241cbf201 from llvm git (by Nemanja Ivanovic):

  [PowerPC] Fix crash in peephole optimization

  When converting reg+reg shifts to reg+imm rotates, we neglect to
  consider the CodeGenOnly versions of the 32-bit shift mnemonics. This
  means we produce a rotate with missing operands which causes a crash.

  Committing this fix without review since it is non-controversial that
  the list of mnemonics to consider should include the 64-bit aliases
  for the exact mnemonics.

  Fixes PR44183.

This should fix "Assertion failed: (idx < size()), function operator[],
file /usr/src/contrib/llvm/include/llvm/ADT/SmallVector.h, line 153"
when building the graphics/mesa-dri port for the PowerPC64 ELFv2 ABI.

Reported by: Alfredo Dal'Ava Júnior <alfredo.junior@eldorado.org.br>
MFC after:      1 month
X-MFC-With:     r353358

4 years agombuf zones: take out the trash
rlibby [Wed, 4 Dec 2019 18:21:29 +0000 (18:21 +0000)]
mbuf zones: take out the trash

The mbuf zones were explicitly specifying the uma trash procedures on
zcreate, conditionally on INVARIANTS, because that used to be necessary
in order to get use-after-free checking for uma zones with non-empty
constructors or destructors.  After r355137 uma automatically invokes
the trash constructor and destructor as long as no init and fini are
specified.  This now allows the mbuf zones to pass their constructors
and destructors without needing to add on the uma trash procedures
conditionally.

Reviewed by: cem, jhb, markj
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D22583

4 years agoRegularize my copyright notice
imp [Wed, 4 Dec 2019 16:56:11 +0000 (16:56 +0000)]
Regularize my copyright notice

o Remove All Rights Reserved from my notices
o imp@FreeBSD.org everywhere
o regularize punctiation, eliminate date ranges
o Make sure that it's clear that I don't claim All Rights reserved by listing
  All Rights Reserved on same line as other copyright holders (but not
  me). Other such holders are also listed last where it's clear.

4 years agoFix accidentally changed copyright year.
imp [Wed, 4 Dec 2019 16:55:55 +0000 (16:55 +0000)]
Fix accidentally changed copyright year.

Noticed by: bapt@

4 years agoloader: clean up efipart filter expressions
tsoome [Wed, 4 Dec 2019 16:41:00 +0000 (16:41 +0000)]
loader: clean up efipart filter expressions

Small cleanup based on illumos review.

4 years agoChase r352304. The default rlimit memlock is no memory locking.
cy [Wed, 4 Dec 2019 15:04:06 +0000 (15:04 +0000)]
Chase r352304. The default rlimit memlock is no memory locking.

Reported by: egypcio@
MFC after: 3 days

4 years agoFix arm64 build after r355373
lwhsu [Wed, 4 Dec 2019 08:21:54 +0000 (08:21 +0000)]
Fix arm64 build after r355373

Sponsored by: The FreeBSD Foundation

4 years agoRemove "All rights reserved" phrase from copyright notes.
se [Wed, 4 Dec 2019 08:03:33 +0000 (08:03 +0000)]
Remove "All rights reserved" phrase from copyright notes.

With the ratification of the Berne Convention in 2000, it became obsolete.

I have removed that phrase and the "(c)" only from files without copyright
claims by other parties. There are 2 files (pci.c, pci_private.h) that are
also claimed by Michael Smith <msmith@freebsd.org> and by BSDi, which have
therefore not been included in this commit.

When all member nations of the Buenos Aires Convention adopted the Berne
Convention, the phrase "All rights reserved" became unnecessary to assert
copyright. Remove it from files under my copyright.

There are 2 files (pci.c, pci_private.h) that) that do also bear msmith's
and BSDi's copyright. I have left them unchanged for now, since I do not
know whether they (or the legal successor in case of BSDi) would agree.

4 years agoUse full path to sysctl(8) since /sbin is not in PATH.
bdrewery [Wed, 4 Dec 2019 04:01:53 +0000 (04:01 +0000)]
Use full path to sysctl(8) since /sbin is not in PATH.

X-MFC-With: r355379
MFC after: 2 weeks

4 years agopowerpc/booke: Fix some formatting errors in debug printfs
jhibbits [Wed, 4 Dec 2019 03:51:30 +0000 (03:51 +0000)]
powerpc/booke: Fix some formatting errors in debug printfs

Use the right formats for the types given (vm_offset_t and vm_size_t are
both uint32_t on 32-bit platforms, and uint64_t on 64-bit platforms, and
match size_t in size, so we can use the size_t format as we do in other
similar code).

These were found by clang.

4 years agoRun make in parallel.
bdrewery [Wed, 4 Dec 2019 03:44:50 +0000 (03:44 +0000)]
Run make in parallel.

This is mostly targetting the 'installconfig' phase of 'distribution'
which does a full tree walk.

MFC after:  2 weeks

4 years agopowerpc/booke: Fix 32-bit Book-E SMP AP bringup
jhibbits [Wed, 4 Dec 2019 03:41:55 +0000 (03:41 +0000)]
powerpc/booke: Fix 32-bit Book-E SMP AP bringup

r354266 changed the type of bp_kernload to vm_paddr_t in platform_mpc85xx.c,
but not the variable itself in locore.S.  This caused the AP to not come up,
due to overwriting the following variable (bp_virtaddr).  Also, properly
load bp_kernload into MAS3 and MAS7.  Prior to r354266, we required loading
into the low 4GB, but now we can load from anywhere in memory that ubldr can
access.

4 years agoChange the implementation of bit_ffc_area_at so that, in the worst
dougm [Wed, 4 Dec 2019 03:36:54 +0000 (03:36 +0000)]
Change the implementation of bit_ffc_area_at so that, in the worst
case, the number of operations spent on each b-bit word is
proportional to lg b rather than b.

For one word, shrink all regions of 0-bits by size-1 bit positions in
no more than O(lg(min(b,size))) operations. In what remains, the first
0-bit is either the start of an area of sufficient size contained
within the original word, or the start of an area that could spill
over into the next word, and prove to be of sufficient size once the
start of that word is examined.

Change bit_ffs_area_at similarly.

Reviewed by: erj, jacob.e.keller_intel.com
MFC with: r354977
Differential Revision: https://reviews.freebsd.org/D22523

4 years agocaroot update to latest tip: one (1) addition, none (0) removed
kevans [Wed, 4 Dec 2019 02:59:50 +0000 (02:59 +0000)]
caroot update to latest tip: one (1) addition, none (0) removed

Added:
- Entrust Root Certification Authority - G4

4 years agox86: Add missed break to TAA status sysctl
cem [Wed, 4 Dec 2019 02:42:22 +0000 (02:42 +0000)]
x86: Add missed break to TAA status sysctl

Just a typo that Coverity identified.

Coverity also identified an unused store in the same functional area (x86 TAA
stuff), but this commit does not address that issue (CID 1408334).

Reported by: Coverity
CID: 1408328, 1408332

4 years agoPass 0 to __builtin_frame_address() to appease modern GCC.
jhb [Tue, 3 Dec 2019 23:20:19 +0000 (23:20 +0000)]
Pass 0 to __builtin_frame_address() to appease modern GCC.

Modern versions of GCC warn about passing non-zero values to
__builtin_frame_address().  Passing 1 is a cosmetic change to remove
the db_trace_self() frame from the printed stack trace.

Reported by: marius, imp
Differential Revision: https://reviews.freebsd.org/D22600

4 years agoUse uintptr_t instead of register_t * for the stack base.
jhb [Tue, 3 Dec 2019 23:17:54 +0000 (23:17 +0000)]
Use uintptr_t instead of register_t * for the stack base.

- Use ustringp for the location of the argv and environment strings
  and allow destp to travel further down the stack for the stackgap
  and auxv regions.
- Update the Linux copyout_strings variants to move destp down the
  stack as was done for the native ABIs in r263349.
- Stop allocating a space for a stack gap in the Linux ABIs.  This
  used to hold translated system call arguments, but hasn't been used
  since r159992.

Reviewed by: kib
Tested on: md64 (amd64, i386, linux64), i386 (i386, linux)
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D22501

4 years agoCurrently the breadn_flags() and getblkx() interfaces are passed
mckusick [Tue, 3 Dec 2019 23:07:09 +0000 (23:07 +0000)]
Currently the breadn_flags() and getblkx() interfaces are passed
the vnode, logical block number, and size of data block that is
being requested. They then use the VOP_BMAP function to calculate
the mapping from logical block number to physical block number from
which to access the data. This change expands the interface to also
pass the physical block number in cases where the VOP_MAP function
may no longer work, for example when a file is being truncated.

No functional change.

Reviewed by:  kib
Tested by:    Peter Holm
Sponsored by: Netflix

4 years agocpufreq_dt: Do not fetch again hw.ncpu
manu [Tue, 3 Dec 2019 22:26:55 +0000 (22:26 +0000)]
cpufreq_dt: Do not fetch again hw.ncpu

MD code already set the global variable mp_ncpus according to
the tunable hw.ncpu so use the global variable directly.

Reported by: ian

4 years agocpufreq_dt: Do not attach the device if the cpu isn't present
manu [Tue, 3 Dec 2019 22:08:54 +0000 (22:08 +0000)]
cpufreq_dt: Do not attach the device if the cpu isn't present

If we boot with hw.ncpu=X (available on arm and arm64 at least) we
shouldn't attach the cpufreq driver as cf_set_method will try to get
the cpuid and it doesn't exists.
This solves cpufreq panicing on RockChip RK3399 when booting with
hw.ncpu=4

MFC after: 1 week

4 years agoRemove "all rights reserved" from copyright for the file that Jared McNeill
manu [Tue, 3 Dec 2019 21:05:33 +0000 (21:05 +0000)]
Remove "all rights reserved" from copyright for the file that Jared McNeill
own. He gave me permission to do this.

4 years agoRemove "all rights reserved" from copyright for the file I own.
manu [Tue, 3 Dec 2019 21:00:45 +0000 (21:00 +0000)]
Remove "all rights reserved" from copyright for the file I own.
Some of the files have both me and Jared McNeill and he gave me
permission to remove it from his files too.

4 years agoarm64: rockchip: rl3399: Remove the ability to put the PLL in normal mode at boot
manu [Tue, 3 Dec 2019 19:18:32 +0000 (19:18 +0000)]
arm64: rockchip: rl3399: Remove the ability to put the PLL in normal mode at boot

RK3399 PLLs have three modes :
 - Normal, where they behave normally and their freq is calculated based on
   the registers values.
 - Slow, where the PLL freq is 24Mhz (well, the external oscillator).
 - Deep Slow, used for suspend where the freq is 32Khz.

We used to put every CPU related PLL in normal mode but it can cause problem
if the firmware didn't setup the clocks register correctly.
And even if it did but left the pll in slow or deep slow mode that might be
because the PMIC suppling voltage for the CPU haven't been configured yet
and we cannot do that at this point.
So remove the ability to set PLLs to normal mode at boot to avoid any problems.

4 years agolualoader: correct a typo from r354247
kevans [Tue, 3 Dec 2019 18:44:19 +0000 (18:44 +0000)]
lualoader: correct a typo from r354247

r354247 converted try_include to lfs + dofile with the loader.lua_path added
just before. Fortunately, there was a hardcoded /boot/lua fallback in case
loader.lua_path wasn't being set yet- I typo'd it as loader.lua_paths.

Fix the typo.

X-MFC-With: r354247
MFC after: 3 days

4 years agoloader: ReadKeyStrokeEx may return partial keystrokes
tsoome [Tue, 3 Dec 2019 18:36:39 +0000 (18:36 +0000)]
loader: ReadKeyStrokeEx may return partial keystrokes

In some systems we can receive no scancode nor unicodechar values.

PR: 240760
Reported by: Ariel Millennium Thornton
MFC after: 1 week

4 years agobitset: avoid pessimized code when bitset size is not constant
rlibby [Tue, 3 Dec 2019 17:43:57 +0000 (17:43 +0000)]
bitset: avoid pessimized code when bitset size is not constant

We have a couple optimizations for when the bitset is known to be just
one word.  But with dynamically sized bitsets, it was actually more work
to determine the size than just to do the necessary computation.  Now,
only use the optimization when the size is known to be constant.

Reviewed by: markj
Discussed with: jeff
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D22639

4 years agomips busdma: bzero map on alloc
rlibby [Tue, 3 Dec 2019 17:43:52 +0000 (17:43 +0000)]
mips busdma: bzero map on alloc

Maps from the mips busdma dmamap_zone were not completely initialized.
In particular, pagesneeded and pagesreserved were not initialized.  This
could cause a crash.

Remove some dead fields from mips struct bus_dmamap while here.

Reported by: brooks
Reviewed by: ian
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D22638

4 years agoctau.c: convert from KOI8-R to UTF-8 encoding
emaste [Tue, 3 Dec 2019 16:52:03 +0000 (16:52 +0000)]
ctau.c: convert from KOI8-R to UTF-8 encoding

AFAICT this is the last source file (excluding contrib) that was not
ASCII or UTF-8.

4 years agoscterm-sc.c: convert source file to UTF-8 encoding
emaste [Tue, 3 Dec 2019 16:45:53 +0000 (16:45 +0000)]
scterm-sc.c: convert source file to UTF-8 encoding

Most source files are already ASCII or UTF-8 but this one was not previously
converted.

4 years agoRegularize copyright notices for me.
imp [Tue, 3 Dec 2019 15:48:28 +0000 (15:48 +0000)]
Regularize copyright notices for me.

Remove stray All Rights Reserved and other non-license stuff. Make sure all
copyrights have year.

4 years agoMake icmp6_reflect() static.
bz [Tue, 3 Dec 2019 14:46:38 +0000 (14:46 +0000)]
Make icmp6_reflect() static.

icmp6_reflect() is not used anywhere outside icmp6.c, no reason to
export it.

Sponsored by: Netflix

4 years agodevstat_selectdevs: resize dev_select only after copying data out of it
avg [Tue, 3 Dec 2019 09:48:43 +0000 (09:48 +0000)]
devstat_selectdevs: resize dev_select only after copying data out of it

The resizing could be a downsizing so some data would be lost and we
could attempt to read past the end of the new memory allocation.

MFC after: 2 weeks
Sponsored by: Panzura

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