]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
5 years agoMFC r347271:
Hans Petter Selasky [Thu, 16 May 2019 16:00:00 +0000 (16:00 +0000)]
MFC r347271:
Implement PCAM, MCAM access register commands in mlx5core.

Introduced registers will expose capabilities of new registers and
features related to port/management.
Driver will query MCAM and PCAM in order to avoid failing on old
firmwares with lack of support.

Linux commit:
c835ad64683bd3e2d1b31ed2cb1ff4366932edb1

Submitted by: slavash@
Sponsored by: Mellanox Technologies

5 years agoMFC r347270:
Hans Petter Selasky [Thu, 16 May 2019 15:59:23 +0000 (15:59 +0000)]
MFC r347270:
Expose PCAM, MCAM registers infrastructure in mlx5core.

PCAM: Ports capabilities mask register.
MCAM: Management capabilities mask register.

PCAM and MCAM registers will provide information regarding firmware
support for different features, in order to avoid cases where new driver
combined with old firmware results in syndromes (for ex. PCIe counters
before this patchset).

Linux commit:
cfdcbceaeffc669b70d904d80a2df9c86c232566

Submitted by: slavash@
Sponsored by: Mellanox Technologies

5 years agoMFC r347269:
Hans Petter Selasky [Thu, 16 May 2019 15:58:37 +0000 (15:58 +0000)]
MFC r347269:
Add sysctl(8) to control fast unload support in mlx5core.

Sponsored by: Mellanox Technologies

5 years agoMFC r347268:
Hans Petter Selasky [Thu, 16 May 2019 15:57:59 +0000 (15:57 +0000)]
MFC r347268:
Add Fast teardown support to mlx5core.

Today mlx5 devices support two teardown modes:
1- Regular teardown
2- Force teardown

This change introduces the enhanced version of the "Force teardown" that
allows SW to perform teardown in a faster way without the need to reclaim
all the pages.

Fast teardown provides the following advantages:
1- Fix a FW race condition that could cause command timeout
2- Avoid moving to polling mode
3- Close the vport to prevent PCI ACK to be sent without been
   scattered to memory

Linux commit:
fcd29ad17c6ff885dfae58f557e9323941e63ba2

Sponsored by: Mellanox Technologies

5 years agoMFC r347267:
Hans Petter Selasky [Thu, 16 May 2019 15:57:14 +0000 (15:57 +0000)]
MFC r347267:
Make sure the running variable is properly set for ratelimited SQs in mlx5en(4).

Else the SQs won't be properly released when closing rate-limited connections
leading to wrong state transitions on the SQ.

Sponsored by: Mellanox Technologies

5 years agoMFC r347266:
Hans Petter Selasky [Thu, 16 May 2019 15:56:30 +0000 (15:56 +0000)]
MFC r347266:
Implement get and set nic state as global functions in mlx5core.

Sponsored by: Mellanox Technologies

5 years agoMFC r347265:
Hans Petter Selasky [Thu, 16 May 2019 15:55:54 +0000 (15:55 +0000)]
MFC r347265:
Ticks are integer type in FreeBSD.

Sponsored by: Mellanox Technologies

5 years agoMFC r347264:
Hans Petter Selasky [Thu, 16 May 2019 15:55:08 +0000 (15:55 +0000)]
MFC r347264:
Configure firmware to use RX hash format in mini CQE in mlx5en(4).

When using CQE zipping, one can choose between RX hash and Checksum.
This will indicate the parameter on which a zipping session should be
stopped.

While porting the Linux code, Checksum was chosen. However, the value
of Checksum is not being used anywhere.
For the FreeBSD driver, we prefer to use the RX hash format which will
guarantee the RX hash value for all the mini CQEs.
While at it, make sure to initialize the Checksum value in the
decompressed CQE.

Submitted by: slavash@
Sponsored by: Mellanox Technologies

5 years agoMFC r347263:
Hans Petter Selasky [Thu, 16 May 2019 15:53:48 +0000 (15:53 +0000)]
MFC r347263:
Disable CQE zipping by default in mlx5en(4).

After doing performance measurements, it seems like CQE zipping doesn't
have any significant benefit.
Moreover, we know that this feature is disabled by default on other
operating systems (Linux for example).

Submitted by: slavash@
Sponsored by: Mellanox Technologies

5 years agoMFC r347262:
Hans Petter Selasky [Thu, 16 May 2019 15:53:12 +0000 (15:53 +0000)]
MFC r347262:
Split mlx5e_update_stats_work() in mlx5en(4).

Split the function into the mlx5e_update_stats_locked() core and make
mlx5e_update_stats_work() call the _locked helper, similar to many other
places in the kernel. This improves the code structure, making the
locking clean.

Submitted by: kib@
Sponsored by: Mellanox Technologies

5 years agoMFC r347261:
Hans Petter Selasky [Thu, 16 May 2019 15:52:18 +0000 (15:52 +0000)]
MFC r347261:
Implement fast close of RX channel in mlx5en(4).

Instead of waiting for all jobs to be cancelled, simply close the completion
queue to prevent more completion events and let mlx5e_destroy_rq() cleanup
the remaining mbufs.

Sponsored by: Mellanox Technologies

5 years agoMFC r347260 and r347326:
Hans Petter Selasky [Thu, 16 May 2019 15:51:28 +0000 (15:51 +0000)]
MFC r347260 and r347326:
Correct number of elements for priority to traffic class mappings in mlx5en(4).

The number of priorities is always 8, while the number of traffic classes
supported can vary. While at it convert the sysctl node into an array.

Sponsored by: Mellanox Technologies

5 years agoMFC r347259:
Hans Petter Selasky [Thu, 16 May 2019 15:50:11 +0000 (15:50 +0000)]
MFC r347259:
Remove unused module parameter in mlx5ib.

Sponsored by: Mellanox Technologies

5 years agoMFC r347258:
Hans Petter Selasky [Thu, 16 May 2019 15:49:35 +0000 (15:49 +0000)]
MFC r347258:
Make sure to error out when arming the CQ fails in mlx4ib and mlx5ib.

Sponsored by: Mellanox Technologies

5 years agoMFC r347257:
Hans Petter Selasky [Thu, 16 May 2019 15:48:56 +0000 (15:48 +0000)]
MFC r347257:
Make sure to error out when arming the CQ fails in ibcore.

Sponsored by: Mellanox Technologies

5 years agoMFC r347256:
Hans Petter Selasky [Thu, 16 May 2019 15:48:19 +0000 (15:48 +0000)]
MFC r347256:
Destroy port stats debug context in correct order in mlx5en(4).
Destroy children nodes before parent nodes.

Sponsored by: Mellanox Technologies

5 years agoMFC r347255:
Hans Petter Selasky [Thu, 16 May 2019 15:47:33 +0000 (15:47 +0000)]
MFC r347255:
Fix tx_jumbo_packets counter in mlx5en(4).

Instead of reading Ethernet RFC 2819 pXtoYoctets counters from
hardware which counts RX octets, count tx_stat_pXtoYoctets from
Ethernet extended counters which counts TX octets.

TX jumbo counters should be accumulated only after the PPCNT
counters were fetched from hardware with their latest value.

Submitted by: slavash@
Sponsored by: Mellanox Technologies

5 years agoMFC r347254:
Hans Petter Selasky [Thu, 16 May 2019 15:46:50 +0000 (15:46 +0000)]
MFC r347254:
Update Ethernet extended counters in mlx5en(4).

Expose all Ethernet extended counters those counters via debug_stats
sysctl:
dev.mce.X.debug_stats

Submitted by: slavash@
Sponsored by: Mellanox Technologies

5 years agoMFC r347253:
Hans Petter Selasky [Thu, 16 May 2019 15:46:04 +0000 (15:46 +0000)]
MFC r347253:
Protect from infinite sw-reset loop in mlx5core.

Avoid an infinite software firmware reset loop that may be caused by a
hardware bug by limiting the maximum number of resets.
The counter between resets is reset by request for reset, and not by a
successful reset.
The interval between two resets can be configured via sysctl:
hw.mlx5.sw_reset_timeout
which is global to all mlx5 devices in the system.

Submitted by: slavash@
Sponsored by: Mellanox Technologies

5 years agoMFC r347252:
Hans Petter Selasky [Thu, 16 May 2019 15:45:10 +0000 (15:45 +0000)]
MFC r347252:
Disable all MSIX interrupts before shutdown in mlx5.

Make sure the interrupt handlers don't race with the fast unload one
code in the shutdown handler.

Sponsored by: Mellanox Technologies

5 years agoMFC r347251:
Hans Petter Selasky [Thu, 16 May 2019 15:44:27 +0000 (15:44 +0000)]
MFC r347251:
Import Linux code to implement mlx5_ib_disassociate_ucontext() in mlx5ib.

Submitted by: kib@
Sponsored by: Mellanox Technologies

5 years agoMFC r347250:
Hans Petter Selasky [Thu, 16 May 2019 15:43:34 +0000 (15:43 +0000)]
MFC r347250:
Add temperature warning event to log in mlx5core.

Temperature warning event is sent by FW to indicate high temperature
as detected by one of the sensors on the board.
Add handling of this event by writing the numbers of the alert sensors
to the kernel log.

Linux commit:
1865ea9adbfaf341c5cd5d8f7d384f19948b2fe9

Submitted by: slavash@
Sponsored by: Mellanox Technologies

5 years agoMFC r347249:
Hans Petter Selasky [Thu, 16 May 2019 15:42:47 +0000 (15:42 +0000)]
MFC r347249:
Correctly define the interface state bits in mlx5en(4).

While at it remove unused interface state bits. This also fixes and issue
during shutdown:

There is an issue where the firmware fails during mlx5_load_one,
the health_care timer detects the issue and schedules a health_care call.
Then the mlx5_load_one detects the issue, cleans up and quits. Then
the health_care starts and calls mlx5_unload_one to clean up the resources
that no longer exist and causes kernel panic.

The root cause is that the bit MLX5_INTERFACE_STATE_DOWN is not set
after mlx5_load_one fails. The solution is removing the bit
MLX5_INTERFACE_STATE_DOWN and quit mlx5_unload_one if the
bit MLX5_INTERFACE_STATE_UP is not set. The bit MLX5_INTERFACE_STATE_DOWN
is redundant and we can use MLX5_INTERFACE_STATE_UP instead.

Linux commit:
10a8d00707082955b177164d4b4e758ffcbd4017
b3cb5388499c5e219324bfe7da2e46cbad82bfcf

Sponsored by: Mellanox Technologies

5 years agoMFC r347248:
Hans Petter Selasky [Thu, 16 May 2019 15:42:00 +0000 (15:42 +0000)]
MFC r347248:
Enable FPGA and FPGA QP errors for EQ and call the handler in mlx5core.

Submitted by: kib@
Sponsored by: Mellanox Technologies

5 years agoMFC r347247:
Hans Petter Selasky [Thu, 16 May 2019 15:41:04 +0000 (15:41 +0000)]
MFC r347247:
Add MLX5_FPGA_RELOAD IOCTL(2) to mlx5fpga.

Submitted by: kib@
Sponsored by: Mellanox Technologies

5 years agoMFC r347246:
Hans Petter Selasky [Thu, 16 May 2019 15:40:22 +0000 (15:40 +0000)]
MFC r347246:
Add support for Dynamic Interrupt Moderation, DIM, in mlx5en(4).

Add support for DIM based on Linux,
with some minor adaptions specific to FreeBSD.

Linux commit
f97c3dc3c0e8d23a5c4357d182afeef4c67f5c33

Sponsored by: Mellanox Technologies

5 years agoMFC r347190:
Hans Petter Selasky [Thu, 16 May 2019 15:39:07 +0000 (15:39 +0000)]
MFC r347190:
Use PCIV_INVALID in pci_channel_offline() in the LinuxKPI.

Build tested drm-current-kmod prior to commit.

Submitted by: slavash@
Sponsored by: Mellanox Technologies

5 years agoMFC r347188:
Hans Petter Selasky [Thu, 16 May 2019 15:37:49 +0000 (15:37 +0000)]
MFC r347188:
Disabling a PCI device should only disable busmaster in the LinuxKPI.

As Linux comment for this function point:
Signal to the system that the PCI device is not in use by the system
anymore. This only involves disabling PCI bus-mastering, if active.

Build tested drm-current-kmod prior to commit.

Submitted by: slavash@
Sponsored by: Mellanox Technologies

5 years agoMFC r347187:
Hans Petter Selasky [Thu, 16 May 2019 15:36:56 +0000 (15:36 +0000)]
MFC r347187:
Implement print_hex_dump_debug() function macro in the LinuxKPI.

Build tested drm-current-kmod prior to commit.

Submitted by: slavash@
Sponsored by: Mellanox Technologies

5 years agoMFC r347185:
Hans Petter Selasky [Thu, 16 May 2019 15:35:50 +0000 (15:35 +0000)]
MFC r347185:
Allow controlling pr_debug at runtime in the LinuxKPI.

Turning on pr_debug at compile time make it non-optional at runtime.
This often means that the amount of the debugging is unbearable.
Allow developer to turn on pr_debug output only when needed.

Build tested drm-current-kmod prior to commit.

Submitted by: kib@
Sponsored by: Mellanox Technologies

5 years agoMFC r346968, r346973
Ian Lepore [Thu, 16 May 2019 15:30:35 +0000 (15:30 +0000)]
MFC r346968, r346973

r346968:
Update the manpage text to show the output generated by the first-stage
bootloader these days (x86 instead of i386).

r346973:
Add a paragraph that mentions gptboot having an interactive mode, and
direct the user to the boot(8) manpage, which provides the details on that.

5 years agoMFC r343985, r344133, r345273 (by bde):
Konstantin Belousov [Thu, 16 May 2019 14:39:48 +0000 (14:39 +0000)]
MFC r343985, r344133, r345273 (by bde):
Prevent overflow for usertime/systime in caclru1().

PR: 76972

5 years agoMFC r347016:
Dmitry Chagin [Thu, 16 May 2019 10:41:29 +0000 (10:41 +0000)]
MFC r347016:

Remove unneeded includes.

5 years agoMFC r346647:
Oleksandr Tymoshenko [Wed, 15 May 2019 21:52:43 +0000 (21:52 +0000)]
MFC r346647:

[acpi_ibm] Add support for newer Thinkpad models

Add support for newer Thinkpad models with id LEN0268. Was tested on
Thinkpad T480 and ThinkPad X1 Yoga 2nd gen.

PR: 229120
Submitted by: Ali Abdallah <aliovx@gmail.com>

5 years agoMFC r345550:
Oleksandr Tymoshenko [Wed, 15 May 2019 18:56:42 +0000 (18:56 +0000)]
MFC r345550:

Change default value of kern.bootfile to reflect reality

In most cases kernel.bootfile is populated from the information
provided by loader(8). There are certain scenarios when loader
is not available, for instance when kernel is loaded by u-boot
or some other BootROM directly. In this case the default value
"/kernel" points to invalid location and breaks some functinality,
like using installkernel on self-hosted system or dtrace's CTF
lookup. This can be fixed by setting the value manually but the
default that reflects correct location is better than default that
points to invalid one.

Current default was set around FreeBSD 1, when "/kernel" was the
actual path. Transition to /boot/kernel/kernel happened circa FreeBSD 3.

PR: 221550
Reviewed by: ian, imp
Differential Revision: https://reviews.freebsd.org/D18902

5 years agoMFC r347422:
Ian Lepore [Wed, 15 May 2019 17:50:17 +0000 (17:50 +0000)]
MFC r347422:

Allow dcons(4) to be unloaded when loaded as a module.

When the module is unloaded, the tty devices are destroyed.  That requires
implementing the tsw_free callback to avoid a panic.  This driver requires
no particular cleanup to be done from the callback, but the module itself
must remain in memory until the deferred tsw_free callbacks are invoked.
These changes implement that by incrementing a reference count variable in
the detach routine, and decrementing it in the tsw_free callback.  The
MOD_UNLOAD event handler doesn't return until the count drops to zero.

PR: 237758

5 years agoMFC r347368:
Konstantin Belousov [Wed, 15 May 2019 08:15:44 +0000 (08:15 +0000)]
MFC r347368:
x86: Put other CPUs into tight loop when updating Intel microcode from
loaded OS.

5 years agoMFC r347075:
Enji Cooper [Wed, 15 May 2019 07:51:35 +0000 (07:51 +0000)]
MFC r347075:

Fix `clang -Wcast-qual` issues

Remove unnecessary `char*` casting for arguments passed to `cget*(3)`, and
deconst `_PATH_PRINTCAP` before passing it to `cget*` via the `printcapdb`
variable.

This unblocks ^/projects/runtime-coverage-v2 from building cleanly on
universe13a.freebsd.org. I suspect the issue was introduced through some
changes to `bsd.*.mk` inclusion on the branch, which I will continue to
investigate/isolate.

Tested with: clang 8 (arm64)

5 years agoMFC r347240: Fix dataset name comparison in zfs_compare().
Alexander Motin [Wed, 15 May 2019 01:38:34 +0000 (01:38 +0000)]
MFC r347240: Fix dataset name comparison in zfs_compare().

The code never returned match comparing two datasets (not snapshots).
As result, uu_avl_find(), called from zfs_callback(), never succeeded,
allowing to add same dataset into the list multiple times, for example:

        # zfs get name pers pers pers@z pers@z
        NAME    PROPERTY  VALUE   SOURCE
        pers    name      pers    -
        pers    name      pers    -
        pers@z  name      pers@z  -

With the patch:

        # zfs get name pers pers pers@z pers@z
        NAME    PROPERTY  VALUE   SOURCE
        pers    name      pers    -
        pers@z  name      pers@z  -

5 years agoMFC r347148:
Konstantin Belousov [Tue, 14 May 2019 21:11:15 +0000 (21:11 +0000)]
MFC r347148:
imgact_elf: do not relock the text vnode if possible.

5 years agoMFC r346120:
Edward Tomasz Napierala [Tue, 14 May 2019 20:41:24 +0000 (20:41 +0000)]
MFC r346120:

Use shared vnode locks for the ELF interpreter.

Sponsored by: DARPA, AFRL

5 years agoMFC r346076:
Edward Tomasz Napierala [Tue, 14 May 2019 20:31:06 +0000 (20:31 +0000)]
MFC r346076:

Improve vnode lock assertions.

Sponsored by: DARPA, AFRL

5 years agoMFC r346053:
Edward Tomasz Napierala [Tue, 14 May 2019 20:29:12 +0000 (20:29 +0000)]
MFC r346053:

Factor out section loading into a separate function.

Sponsored by: DARPA, AFRL

5 years agoMFC r346030:
Edward Tomasz Napierala [Tue, 14 May 2019 20:27:45 +0000 (20:27 +0000)]
MFC r346030:

Refactor ELF interpreter loading into a separate function.

Sponsored by: DARPA, AFRL

5 years agoMFC r345661:
Edward Tomasz Napierala [Tue, 14 May 2019 20:26:05 +0000 (20:26 +0000)]
MFC r345661:

Factor out retrieving the interpreter path from the main ELF
loader routine.

MFC r345734 by kib:

Fix branding after r345661.

In particular, elf32 FreeBSD binaries were not executed on LP64 hosts.
The interp_name_len value should account for the nul terminator.  This
is needed for strncmp()s in brand checking code to work.

Sponsored by: DARPA, AFRL

5 years agoMFC r345547:
Edward Tomasz Napierala [Tue, 14 May 2019 20:19:29 +0000 (20:19 +0000)]
MFC r345547:

Factor out resource limit enforcement code in the ELF loader.
It makes the code slightly easier to follow, and might make
it easier to fix the resouce accounting to also account for
the interpreter.

The PROC_UNLOCK() is moved earlier - I don't see anything
it should protect; the lim_max() is a wrapper around lim_rlimit(),
and that, differently from lim_rlimit_proc(), doesn't require
the proc lock to be held.

Sponsored by: DARPA, AFRL

5 years agoMFC r345448:
Edward Tomasz Napierala [Tue, 14 May 2019 20:03:19 +0000 (20:03 +0000)]
MFC r345448:

Remove trunc_page_ps() and round_page_ps() macros.  This completes
the undoing of r100384.

Sponsored by: DARPA, AFRL

5 years agoMFC r344705:
Edward Tomasz Napierala [Tue, 14 May 2019 19:52:18 +0000 (19:52 +0000)]
MFC r344705:

Remove sv_pagesize, originally introduced with r100384.

In all of the architectures we have today, we always use PAGE_SIZE.
While in theory one could define different things, none of the
current architectures do, even the ones that have transitioned from
32-bit to 64-bit like i386 and arm. Some ancient mips binaries on
other systems used 8k instead of 4k, but we don't support running
those and likely never will due to their age and obscurity.

Differently from the original commit, the merge leaves the struct
member in place to preserve the ABI.

Sponsored by: DARPA, AFRL

5 years agoMFC r347566:
Konstantin Belousov [Tue, 14 May 2019 17:04:00 +0000 (17:04 +0000)]
MFC r347566:
Mitigations for Microarchitectural Data Sampling.

Reference: https://www.intel.com/content/www/us/en/security-center/advisory/intel-sa-00233.html
Security: CVE-2018-12126, CVE-2018-12127, CVE-2018-12130, CVE-2019-11091
Security: FreeBSD-SA-19:07.mds
Reviewed by: jhb
Tested by: emaste, lwhsu
Approved by: so (gtetlow)

5 years agoMFC r346028:
Ganbold Tsagaankhuu [Tue, 14 May 2019 03:08:37 +0000 (03:08 +0000)]
MFC r346028:
Fix URE_WDT6_SET_MODE value in the register definition.
Both linux and u-boot sources for RTL8152 driver has this value.
RTL8152 USB ethernet is used in NanoPI R1 board as second ethernet.
This fixes RTL8152 USB ethernet not detected problem after
reboot.

5 years agoMFC r347241 (partial), r347392, r347429: ifconfig(8) ifname <-> kld mapping
Kyle Evans [Tue, 14 May 2019 02:00:12 +0000 (02:00 +0000)]
MFC r347241 (partial), r347392, r347429: ifconfig(8) ifname <-> kld mapping

MFC r347241 (partial): Initial mechanism for mapping ifname <-> kld

if_tun/if_tap mappings have been removed and the vmnet mapping has been
updated to the if_tap module.

MFC r347392: ifconfig(8): Partial revert of r347241

r347241 introduced an ifname <-> kld mapping table, mostly so tun/tap/vmnet
can autoload the correct module on use. It also inadvertently made bogus
some previously valid uses of sizeof().

Revert back to ifkind on the stack for simplicity sake. This reduces the
diff from the previous version of ifmaybeload for easiser auditing.

MFC r347429: ifconfig(8): Add kld mappings for ipsec/enc

Additionally, providing mappings makes the comparison for already loaded
modules a little more strict. This should have been done at initial
introduction, but there was no real reason- however, it proves necessary for
enc which has a standard enc -> if_enc mapping but there also exists an
'enc' module that's actually CAM. The mapping lets us unambiguously
determine the correct module.

5 years agoMFC r347227:
Mark Johnston [Tue, 14 May 2019 00:34:08 +0000 (00:34 +0000)]
MFC r347227:
Simplify the test against maxproc in fork1().

5 years agoMFC r346708:
Stephen Hurd [Mon, 13 May 2019 18:48:08 +0000 (18:48 +0000)]
MFC r346708:

iflib: Better control over queue core assignment

By default, cores are now assigned to queues in a sequential
manner rather than all NICs starting at the first core. On a four-core
system with two NICs each using two queue pairs, the nic:queue -> core
mapping has changed from this:

0:0 -> 0, 0:1 -> 1
1:0 -> 0, 1:1 -> 1

To this:

0:0 -> 0, 0:1 -> 1
1:0 -> 2, 1:1 -> 3

Additionally, a device can now be configured to use separate cores for TX
and RX queues.

Two new tunables have been added, dev.X.Y.iflib.separate_txrx and
dev.X.Y.iflib.core_offset. If core_offset is set, the NIC is not part
of the auto-assigned sequence.

Reviewed by: marius
Sponsored by: Limelight Networks
Differential Revision: https://reviews.freebsd.org/D20029

5 years agoMFC r347031: iflib: remove assertion that isc_capabilities is nonzero
Ed Maste [Mon, 13 May 2019 14:52:50 +0000 (14:52 +0000)]
MFC r347031: iflib: remove assertion that isc_capabilities is nonzero

It's atypical, but not invalid, for a driver to pass no capabilities.

Submitted by: Gerald Aryeetey <aryeeteygerald_rogers.com>
Sponsored by: The FreeBSD Foundation

5 years agoMFC r347186: Reformat arm64 linux syscalls.master per current style
Ed Maste [Mon, 13 May 2019 14:50:51 +0000 (14:50 +0000)]
MFC r347186: Reformat arm64 linux syscalls.master per current style

5 years agoMFC r347160: Decode some more ATA commands found in ACS-4.
Alexander Motin [Mon, 13 May 2019 13:29:51 +0000 (13:29 +0000)]
MFC r347160: Decode some more ATA commands found in ACS-4.

5 years agoMFC r347158: Decode Deallocate Logical Block Features.
Alexander Motin [Mon, 13 May 2019 13:28:42 +0000 (13:28 +0000)]
MFC r347158: Decode Deallocate Logical Block Features.

5 years agoMFC r346965:
Dmitry Chagin [Mon, 13 May 2019 10:43:18 +0000 (10:43 +0000)]
MFC r346965:

Follow the FreeBSD and implement PDEATH_SIG prctl ops in the Linuxulator.
It was first introduced in r163734 and missied by me in r283383.

5 years agoMFC r347178:
Andrey V. Elsukov [Mon, 13 May 2019 08:29:28 +0000 (08:29 +0000)]
MFC r347178:
  Add ipsec.ko to required_modules for rc.d/ipsec script.

  Thus it can be automatically loaded if ipsec_enable="YES" and option IPSEC
  is not in the kernel config.

5 years agoMFC r346885:
Andrey V. Elsukov [Mon, 13 May 2019 08:26:21 +0000 (08:26 +0000)]
MFC r346885:
  Handle HAVE_PROTO flag and print "proto" keyword for O_IP4 and O_IP6
  opcodes when it is needed.
  This should fix the problem, when printed by `ipfw show` rule can not
  be added due to missing "proto" keyword.

5 years agoMFC r346073:
Andriy Voskoboinyk [Sun, 12 May 2019 12:30:45 +0000 (12:30 +0000)]
MFC r346073:
urtw(4), otus(4), iwi(4): allow to set non-default MAC address via ifconfig(8)

Was tested with Netgear WG111 v3 (RTL8187B, urtw(4)), STA mode.

5 years agoMFC r347150, r347180:
Konstantin Belousov [Sun, 12 May 2019 07:53:24 +0000 (07:53 +0000)]
MFC r347150, r347180:
Do not collapse objects with OBJ_NOSPLIT backing swap or default object.

5 years agoMFC r345829, r345831
Justin Hibbits [Sat, 11 May 2019 18:31:05 +0000 (18:31 +0000)]
MFC r345829, r345831

r345829:
powerpc: Apply r178139 from sparc64 to powerpc's fpu_sqrt

This fix was committed less than 2 months after the code was forked into the
powerpc kernel.  Though powerpc doesn't use quad-precision floating point,
or need it for emulation, the changes do look like correctness fixes
overall.

This was found while trying to get fsqrt emulation working on e5500, which
does have a real FPU, but lacks the fsqrt instruction.  This is not the
complete fix, the rest is to be committed separately.

r345831:
powerpc: Allow emulating optional FPU instructions on CPUs with an FPU

The e5500 has an FPU, but lacks the optional fsqrt instruction.  This
instruction gets emulated in the kernel, but the emulation uses stale data,
from the last switch out, and does not return the result of the operation
immediately.  Fix both of these conditions by saving and restoring the FPRs
around the emulation point.

5 years agoMFC r345435:
Justin Hibbits [Sat, 11 May 2019 18:25:15 +0000 (18:25 +0000)]
MFC r345435:

powernv: Add Hypervisor Maintenance Interrupt handler

Attempting to build www/firefox on POWER9 resulted in a HMI exception being
thrown, a fatal trap currently.  This is typically caused by timer facility
errors, but examination of the Hypervisor Maintenance Exception Register
(HMER) yielded only that an exception had recovered, with no information of
the actual exception cause.

When an HMI occurs, OPAL_HANDLE_HMI or OPAL_HANDLE_HMI2 must be called to
handle the exception at the firmware level.  If the exception is handled, we
can continue.

This adds only the preliminary handler, enough to prevent package building
from panicking.  An enhancement in the future is to use the flags returned
by OPAL_HANDLE_HMI2 to print more useful error messages, and log maintenance
events.

5 years agoMFC r347243:
Dimitry Andric [Sat, 11 May 2019 09:56:59 +0000 (09:56 +0000)]
MFC r347243:

Pull in r360099 from upstream llvm trunk (by Eli Friedman):

  [ARM] Glue register copies to tail calls.

  This generally follows what other targets do. I don't completely
  understand why the special case for tail calls existed in the first
  place; even when the code was committed in r105413, call lowering
  didn't work in the way described in the comments.

  Stack protector lowering breaks if the register copies are not glued
  to a tail call: we have to insert the stack protector check before
  the tail call, and we choose the location based on the assumption
  that all physical register dependencies of a tail call are adjacent
  to the tail call. (See FindSplitPointForStackProtector.) This is sort
  of fragile, but I don't see any reason to break that assumption.

  I'm guessing nobody has seen this before just because it's hard to
  convince the scheduler to actually schedule the code in a way that
  breaks; even without the glue, the only computation that could
  actually be scheduled after the register copies is the computation of
  the call address, and the scheduler usually prefers to schedule that
  before the copies anyway.

  Fixes https://bugs.llvm.org/show_bug.cgi?id=41417

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

This should fix several instances of "Bad machine code: Using an
undefined physical register", when compiling ports such as
multimedia/vlc, audio/alsa-lib and devel/avro-c for armv6, with
-fstack-protector-strong.

Reported by: jbeich
PR: 237074, 237783, 237784

5 years agoMFC r347133:
Konstantin Belousov [Sat, 11 May 2019 09:12:13 +0000 (09:12 +0000)]
MFC r347133:
arm64: Properly restore PAN when done with userspace access in casueword.

5 years agoMFC of 347064, 347066, and 347130
Kirk McKusick [Fri, 10 May 2019 23:45:16 +0000 (23:45 +0000)]
MFC of 347064, 347066, and 347130

Avoid leaking kernel stack when creating directory names.

5 years agoMFC r347234:
Cy Schubert [Fri, 10 May 2019 01:02:07 +0000 (01:02 +0000)]
MFC r347234:

Improve the legibility of the login.access.5 man page by separating
each argument into its own paragraph.

5 years agoMFC r346578:
Enji Cooper [Thu, 9 May 2019 17:02:47 +0000 (17:02 +0000)]
MFC r346578:

Build libclang_rt/profile on all clang-supported architectures

There's no reason why a special case needs to be added specifically for amd64,
arm, and i386, as the code is written in machine architecture agnostic C/C++.

This will make it possible for all supporting clang architectures to produce
runtime coverage with `--coverage`.

5 years agoMFC r347019:
Konstantin Belousov [Thu, 9 May 2019 09:49:07 +0000 (09:49 +0000)]
MFC r347019:
Cleanup for rtld_malloc.c.

PR: 237577

5 years agoMFC r346594: Add ATA power mode support to camcontrol
Steven Hartland [Thu, 9 May 2019 08:35:50 +0000 (08:35 +0000)]
MFC r346594: Add ATA power mode support to camcontrol

Sponsored by: Multiplay

5 years agoMFC r347198: Drop periph lock around cam_periph_unmapmem().
Alexander Motin [Thu, 9 May 2019 04:16:06 +0000 (04:16 +0000)]
MFC r347198: Drop periph lock around cam_periph_unmapmem().

Since r345656 it may call copyout(), that may sleep.

5 years agoMFC r346602, r346670-r346671, r347183: tun/tap race fixes
Kyle Evans [Thu, 9 May 2019 03:51:34 +0000 (03:51 +0000)]
MFC r346602, r346670-r346671, r347183: tun/tap race fixes

r346602:
tun(4): Defer clearing TUN_OPEN until much later

tun destruction will not continue until TUN_OPEN is cleared. There are brief
moments in tunclose where the mutex is dropped and we've already cleared
TUN_OPEN, so tun_destroy would be able to proceed while we're in the middle
of cleaning up the tun still. tun_destroy should be blocked until these
parts (address/route purges, mostly) are complete.

r346670:
tun/tap: close race between destroy/ioctl handler

It seems that there should be a better way to handle this, but this seems to
be the more common approach and it should likely get replaced in all of the
places it happens... Basically, thread 1 is in the process of destroying the
tun/tap while thread 2 is executing one of the ioctls that requires the
tun/tap mutex and the mutex is destroyed before the ioctl handler can
acquire it.

This is only one of the races described/found in PR 233955.

r346671:
tun(4): Don't allow open of open or dying devices

Previously, a pid check was used to prevent open of the tun(4); this works,
but may not make the most sense as we don't prevent the owner process from
opening the tun device multiple times.

The potential race described near tun_pid should not be an issue: if a
tun(4) is to be handed off, its fd has to have been sent via control message
or some other mechanism that duplicates the fd to the receiving process so
that it may set the pid. Otherwise, the pid gets cleared when the original
process closes it and you have no effective handoff mechanism.

Close up another potential issue with handing a tun(4) off by not clobbering
state if the closer isn't the controller anymore. If we want some state to
be cleared, we should do that a little more surgically.

Additionally, nothing prevents a dying tun(4) from being "reopened" in the
middle of tun_destroy as soon as the mutex is unlocked, quickly leading to a
bad time. Return EBUSY if we're marked for destruction, as well, and the
consumer will need to deal with it. The associated character device will be
destroyed in short order.

r347183:
geom: fix initialization order

There's a race between the initialization of devsoftc.mtx (by devinit)
and the creation of the geom worker thread g_run_events, which calls
devctl_queue_data_f. Both of those are initialized at SI_SUB_DRIVERS
and SI_ORDER_FIRST, which means the geom worked thread can be created
before the mutex has been initialized, leading to the panic below:

 wpanic: mtx_lock() of spin mutex (null) @ /usr/home/osstest/build.135317.build-amd64-freebsd/freebsd/sys/kern/subr_bus.c:620
 cpuid = 3
 time = 1
 KDB: stack backtrace:
 db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe003b968710
 vpanic() at vpanic+0x19d/frame 0xfffffe003b968760
 panic() at panic+0x43/frame 0xfffffe003b9687c0
 __mtx_lock_flags() at __mtx_lock_flags+0x145/frame 0xfffffe003b968810
 devctl_queue_data_f() at devctl_queue_data_f+0x6a/frame 0xfffffe003b968840
 g_dev_taste() at g_dev_taste+0x463/frame 0xfffffe003b968a00
 g_load_class() at g_load_class+0x1bc/frame 0xfffffe003b968a30
 g_run_events() at g_run_events+0x197/frame 0xfffffe003b968a70
 fork_exit() at fork_exit+0x84/frame 0xfffffe003b968ab0
 fork_trampoline() at fork_trampoline+0xe/frame 0xfffffe003b968ab0
 --- trap 0, rip = 0, rsp = 0, rbp = 0 ---
 KDB: enter: panic
 [ thread pid 13 tid 100029 ]
 Stopped at      kdb_enter+0x3b: movq    $0,kdb_why

Fix this by initializing geom at SI_ORDER_SECOND instead of
SI_ORDER_FIRST.

PR: 233955

5 years agoMFC r346960:
Mark Johnston [Wed, 8 May 2019 16:04:33 +0000 (16:04 +0000)]
MFC r346960:
Retry upon NET_RT_IFLIST sysctl failure.

PR: 195191

5 years agoMFC r346888:
Mark Johnston [Wed, 8 May 2019 16:01:59 +0000 (16:01 +0000)]
MFC r346888:
Stop checking TD_IDLETHREAD() in buffer cache routines.

5 years agoMFC r347139:
Cy Schubert [Wed, 8 May 2019 15:48:55 +0000 (15:48 +0000)]
MFC r347139:

MFV r347136: Update sqlite3-3.27.2 (3270200) --> sqlite3-3.28.0 (3280000)

Security: CVE-2019-9937, CVE-2019-9936

5 years agoMFC r346990:
Konstantin Belousov [Wed, 8 May 2019 15:44:53 +0000 (15:44 +0000)]
MFC r346990:
Fix another race between vm_map_protect() and vm_map_wire().

5 years agoMFC r346851:
Konstantin Belousov [Wed, 8 May 2019 15:43:22 +0000 (15:43 +0000)]
MFC r346851:
Remove witness warning, same as r346351 for busdma_dmar.

bounce_bus_dmamap_create() does not sleep either.

5 years agoMFC r346976: Respect quotes and escapes when splitting exports fields.
Alexander Motin [Wed, 8 May 2019 15:25:07 +0000 (15:25 +0000)]
MFC r346976: Respect quotes and escapes when splitting exports fields.

Without this r293305 was still unable to handle names with spaces.

5 years agoMFC r346898: ip multicast debug: fix strings vs defines
Alexander Motin [Wed, 8 May 2019 15:23:45 +0000 (15:23 +0000)]
MFC r346898: ip multicast debug: fix strings vs defines

Turning on multicast debug made multicast failure worse
because the strings and #define values no longer matched
up.  Fix them, and make sure they stay matched-up.

5 years agoMFC r346511: Report DIF protection type the disk is formatted with.
Alexander Motin [Wed, 8 May 2019 15:20:16 +0000 (15:20 +0000)]
MFC r346511: Report DIF protection type the disk is formatted with.

Some disks formatted with protection report errors if written without
protection used.  This should help to diagnose the problem.

5 years agoMFC r346491: Polish SCSI sense data validity checks.
Alexander Motin [Wed, 8 May 2019 15:17:04 +0000 (15:17 +0000)]
MFC r346491: Polish SCSI sense data validity checks.

According to specs and common sense, all sense data reported in descriptor
format should be valid.  But practice shows different, some devices return
descriptors with invalid data, resulting in error messages looking worse.

Decouple block/stream commands sense data and information field printing.
Looking on present specs, there are much more cases when those fields are
not related, and incomplete old code was not printing valid sense data and
leaving empty lines for invalid.

5 years agoMFC r347056:
Glen Barber [Wed, 8 May 2019 15:16:45 +0000 (15:16 +0000)]
MFC r347056:
 Increase the default size of the GCE disk image from 3GB to 20GB,
 as 3GB is too small as discovered in last week's snapshot builds.

Sponsored by: The FreeBSD Foundation

5 years agoMFC r346884:
Andrey V. Elsukov [Wed, 8 May 2019 15:13:59 +0000 (15:13 +0000)]
MFC r346884:
  Add IPv6 support for O_IPLEN opcode.

  Obtained from: Yandex LLC

5 years agoMFC r345576: Merge r345574 from vendor-crypto:
Ed Maste [Tue, 7 May 2019 19:48:39 +0000 (19:48 +0000)]
MFC r345576: Merge r345574 from vendor-crypto:

upstream: when checking that filenames sent by the server side

match what the client requested, be prepared to handle shell-style brace
alternations, e.g. "{foo,bar}".

"looks good to me" millert@ + in snaps for the last week courtesy
deraadt@

OpenBSD-Commit-ID: 3b1ce7639b0b25b2248e3a30f561a548f6815f3e

PR: 234965
Discussed with: des
Obtained from: OpenSSH-portable 3d896c157c722bc47adca51a58dca859225b5874

5 years agoMFC of 345758
Kirk McKusick [Mon, 6 May 2019 19:13:04 +0000 (19:13 +0000)]
MFC of 345758

Properly flush outstanding I/Os when forcibly deleteing a memory disk device.

Sponsored by: Netflix

5 years agoMFC r347142:
Toomas Soome [Mon, 6 May 2019 08:32:49 +0000 (08:32 +0000)]
MFC r347142:

loader: validate sectorsize argument in disk_open()

The bug and patch is reported against 11.2, but it is good idea to have
the check in place for all versions.

PR: 236585
Submitted by: john@feith.com
Reported by: john@feith.com

5 years agoMFC r344871:
Justin Hibbits [Mon, 6 May 2019 03:39:25 +0000 (03:39 +0000)]
MFC r344871:

powerpc: Save stack pointer in savectx

This allows 'show acttrace' to show backtrace on processes currently running
on CPUs.

Reported by: Brandon Bergren

5 years agoMFC r344613:
Justin Hibbits [Mon, 6 May 2019 03:35:44 +0000 (03:35 +0000)]
MFC r344613:

powerpc/mpc85xx: Synchronize timebase the platform correct way

Summary:
To safely synchronize timebase we need to disable the timebase on all
cores, set timebase, and resynchronize.  This adds two new devices, mutually
exclusive, which attach on the SoC simplebus, to freeze and unfreeze the
timebase.  The devices are singletons, and platform-specific, so no reason
to make them optional and in separate files.

This was found to be necessary for top(1) to work correctly on an AmigaOne
X5000 (P5020 SoC).  It also fixes bufdaemon and bufspacedaemon hangs at
shutdown.

5 years agoMFC r340262,344730
Justin Hibbits [Mon, 6 May 2019 03:31:27 +0000 (03:31 +0000)]
MFC r340262,344730

r340262: powerpc64: Fix "show spr" command on ELFv2 kernels
r344730: powerpc: fix 'show spr' for ELFv1 powerpc64

5 years agoMFC r339559,344083,344202,344203,344204
Justin Hibbits [Mon, 6 May 2019 03:15:07 +0000 (03:15 +0000)]
MFC r339559,344083,344202,344203,344204

Bulk merge of Book-E pmap changes

r339559: powerpc/booke: Turn tlb*_print_tlbentries() into 'show tlb*' DDB
commands
r344083: powerpc/booke: Use the 'tlbilx' instruction on newer cores
r344202,344204: powerpc/booke: Use DMAP where possible for page copy and zeroing
r344203: powerpc/booke: depessimize MAS register updates

5 years agoMFC: r346856
Rick Macklem [Mon, 6 May 2019 03:06:22 +0000 (03:06 +0000)]
MFC: r346856
Add #ifdef INET6 around declaration of nbuf.

It was reported that without #ifdef INET6 around the declaration of "nbuf",
a build would report an unused variable. For some reason, I didn't see that
warning when I did a build, but it seems reasonable to add these #ifdef INET6's.

5 years agoMFC r347027-r347028: libbe(3) mountpoint handling fixes
Kyle Evans [Mon, 6 May 2019 02:10:04 +0000 (02:10 +0000)]
MFC r347027-r347028: libbe(3) mountpoint handling fixes

r347027:
libbe(3): Properly mount BEs with mountpoint=none

Instead of pretending to successfully mount them while not actually
mounting anything, we'll now actually mount them *and* claim we mounted them
successfully.

Reported by: ler

r347028:
libbe: set mountpoint=none in be_import

If we're going to set a mountpoint at all, mountpoint=none makes more sense
than mountpoint=/.

5 years agoMFC r347021: fdt: Fix installation of aarch64 dtb
Kyle Evans [Mon, 6 May 2019 02:08:52 +0000 (02:08 +0000)]
MFC r347021: fdt: Fix installation of aarch64 dtb

r345519 rewrote parts of how we build .dtb, but mistakenly dropped the
vendor dir for aarch64.  Simply drop the :T for building ${DTB} in the
aarch64 case- it'll get applied at install-time as-needed, with :H:T for
determining the vendor dir.

5 years agoMFC r346854:
Michael Tuexen [Sat, 4 May 2019 13:58:45 +0000 (13:58 +0000)]
MFC r346854:
Some test scripts use ncat --sctp --listen port to run an SCTP discard
server in the background. However, when running in the background,
stdin is closed and ncat initiates a graceful shutdown of the SCTP
association. This is not expected by the client. Therefore, the
ncat-based discard server is replaced by a perl-based one.

In addition, to remove the dependency from ncat, which needs to be
installed via the nmap port, also the code testing for a free SCTP port
is changed to use the perl-based client.

Finally, remove some debug output from the report generated.

Reviewed by: lwhsu@
Differential Revision: https://reviews.freebsd.org/D20086

5 years agoMFC r346400:
Michael Tuexen [Sat, 4 May 2019 13:55:51 +0000 (13:55 +0000)]
MFC r346400:
Improve input validation for the socket option IPV6_CHECKSUM.

When using the IPPROTO_IPV6 level socket option IPV6_CHECKSUM on a raw
IPv6 socket, ensure that the value is either -1 or a non-negative even
number.

MFC r346401:
Avoid a buffer overwrite in rip6_output() when computing the checksum
as requested by the user via the IPPROTO_IPV6 level socket option
IPV6_CHECKSUM. The check if there are enough bytes in the packet to
store the checksum at the requested offset was wrong by 1.

MFC r346402:
When a checksum has to be computed for a received IPv6 packet because it
is requested by the application using the IPPROTO_IPV6 level socket option
IPV6_CHECKSUM on a raw socket, ensure that the packet contains enough
bytes to contain the checksum at the specified offset.

MFC r346406:
When an IPv6 packet is received for a raw socket which has the
IPPROTO_IPV6 level socket option IPV6_CHECKSUM enabled and the
checksum check fails, drop the message. Without this fix, an
ICMP6 message was sent indicating a parameter problem.

Thanks to bz@ for suggesting a way to simplify this fix.

Reviewed by: bz@
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D19966
Differential Revision:  https://reviews.freebsd.org/D19967
Differential Revision:  https://reviews.freebsd.org/D19968
Differential Revision:  https://reviews.freebsd.org/D19969

5 years agoMFC: r346715: Acpi MADT table correction for VM_MAXCPU > 21
Rodney W. Grimes [Sat, 4 May 2019 13:43:48 +0000 (13:43 +0000)]
MFC: r346715: Acpi MADT table correction for VM_MAXCPU > 21

The bhyve acpi MADT table was given a static space of 256 (0x100) bytes,
this is enough space to allow VM_MAXCPU to be 21, this patch changes that
so VM_MAXCPU can be of arbitrary value and not overflow the space by
actually calculating the space needed for the table.

PR: 212782
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Approved by: bde (mentor, implicit), jhb (maintainer)
Differential Revision: https://reviews.freebsd.org/D18815

5 years agoMFC r346197:
Michael Tuexen [Sat, 4 May 2019 13:05:21 +0000 (13:05 +0000)]
MFC r346197:
When sending a routing message, don't allow the user to set the
RTF_RNH_LOCKED flag in rtm_flags, since this flag is used only
internally.

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

5 years agoMFC r346182:
Michael Tuexen [Sat, 4 May 2019 13:02:46 +0000 (13:02 +0000)]
MFC r346182:
When sending IPv4 packets on a SOCK_RAW socket using the IP_HDRINCL option,
ensure that the ip_hl field is valid. Furthermore, ensure that the complete
IPv4 header is contained in the first mbuf. Finally, move the length checks
before relying on them when accessing fields of the IPv4 header.

Reported by: jtl@
Reviewed by: jtl@
Differential Revision: https://reviews.freebsd.org/D19181

5 years agoMFC r346134:
Michael Tuexen [Sat, 4 May 2019 13:00:39 +0000 (13:00 +0000)]
MFC r346134:
Fix an SCTP related locking issue. Don't report that the TCB_SEND_LOCK
is owned, when it is not.

This issue was found by running syzkaller.