]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agoMFC r360288:
Hans Petter Selasky [Mon, 18 May 2020 09:15:45 +0000 (09:15 +0000)]
MFC r360288:
Put advertising data in correct place.

Submitted by: Marc Veldman <marc@bumblingdork.com>
PR: 245848
Sponsored by: Mellanox Technologies

4 years agoMFC r360263:
Hans Petter Selasky [Mon, 18 May 2020 09:14:24 +0000 (09:14 +0000)]
MFC r360263:
Rename two commands to match the Bluetooth specification in hccontrol(8).
Fix some bad spelling while at it.

Submitted by: Marc Veldman <marc@bumblingdork.com>
PR: 245868
Sponsored by: Mellanox Technologies

4 years agoMFC r360243:
Hans Petter Selasky [Mon, 18 May 2020 09:13:03 +0000 (09:13 +0000)]
MFC r360243:
Add support for LE advertising to hccontrol(8).

Submitted by: Marc Veldman <marc@bumblingdork.com>
PR: 245848
Sponsored by: Mellanox Technologies

4 years agoMFC r360127:
Hans Petter Selasky [Mon, 18 May 2020 09:11:41 +0000 (09:11 +0000)]
MFC r360127:
Implement the atomic fetch add unless functions for the LinuxKPI.

Sponsored by: Mellanox Technologies

4 years agoMFC r360119:
Hans Petter Selasky [Mon, 18 May 2020 09:10:21 +0000 (09:10 +0000)]
MFC r360119:
Implement aligned LinuxKPI types for u16, u32 and u64.
Makes a difference for 32-bit platforms mostly.

Sponsored by: Mellanox Technologies

4 years agoMFC r360118:
Hans Petter Selasky [Mon, 18 May 2020 09:09:03 +0000 (09:09 +0000)]
MFC r360118:
Allow test_bit() in the LinuxKPI to accept a const pointer.

Sponsored by: Mellanox Technologies

4 years agoMFC r360790:
Hans Petter Selasky [Mon, 18 May 2020 09:07:14 +0000 (09:07 +0000)]
MFC r360790:
Set PCM_CAP_VIRTUAL for virtual DSP devices.

Submitted by: Kevin Zheng <kevinz5000@gmail.com>
PR: 246206
Sponsored by: Mellanox Technologies

4 years agoMFC r360528:
Hans Petter Selasky [Mon, 18 May 2020 09:05:29 +0000 (09:05 +0000)]
MFC r360528:
Implement kstrtou64() in the LinuxKPI.

Submitted by: ashafer_badland.io (Austin Shafer)
Sponsored by: Mellanox Technologies

4 years agoMFC r360377:
Hans Petter Selasky [Mon, 18 May 2020 09:03:12 +0000 (09:03 +0000)]
MFC r360377:
Add support for reading temperature in mlx5en(4).

Sponsored by: Mellanox Technologies

4 years agoMFC r360197:
Hans Petter Selasky [Mon, 18 May 2020 09:00:45 +0000 (09:00 +0000)]
MFC r360197:
Add support for Read_Local_Supported_Commands command to hccontrol(8).

Submitted by: Marc Veldman <marc@bumblingdork.com>
PR: 245811
Sponsored by: Mellanox Technologies

4 years agoMFC r360172:
Hans Petter Selasky [Mon, 18 May 2020 08:58:41 +0000 (08:58 +0000)]
MFC r360172:
Update string tables in hccontrol(8).

Submitted by: Marc Veldman <marc@bumblingdork.com>
PR: 245796
Sponsored by: Mellanox Technologies

4 years agoMFC r360116:
Hans Petter Selasky [Mon, 18 May 2020 08:57:21 +0000 (08:57 +0000)]
MFC r360116:
Substitute le_read_supported_status with le_read_supported_states.
Refer to bluetooth core v5.2 specifications Vol4. Part E. 7.8.27.

PR: 245763
Submitted by: Marc Veldman <marc@bumblingdork.com>
Sponsored by: Mellanox Technologies

4 years agoMFC r360115:
Hans Petter Selasky [Mon, 18 May 2020 08:55:49 +0000 (08:55 +0000)]
MFC r360115:
Allow the ERR_CAST() function in the LinuxKPI to take a const void pointer.
No functional change.

Sponsored by: Mellanox Technologies

4 years agoMFC r360095:
Hans Petter Selasky [Mon, 18 May 2020 08:52:06 +0000 (08:52 +0000)]
MFC r360095:
Fix cut and paste off-by-one error in hccontrol(8).
Make sure strncpy() doesn't write beyond its given buffer.

PR: 245739
Sponsored by: Mellanox Technologies

4 years agoMFC r360094:
Hans Petter Selasky [Mon, 18 May 2020 08:46:17 +0000 (08:46 +0000)]
MFC r360094:
Improve printing of le features in hccontrol(8).

Submitted by: Marc Veldman <marc@bumblingdork.com>
PR: 245739
Sponsored by: Mellanox Technologies

4 years agoMFC r360092:
Hans Petter Selasky [Mon, 18 May 2020 08:44:16 +0000 (08:44 +0000)]
MFC r360092:
Bring HCI error messages up-to-date.
See Bluetooth v5.6 core specification Vol.1 Part F: Controller error codes.

Submitted by: Marc Veldman <marc@bumblingdork.com>
PR: 245737
Sponsored by: Mellanox Technologies

4 years agoMFC r360070:
Hans Petter Selasky [Mon, 18 May 2020 08:40:39 +0000 (08:40 +0000)]
MFC r360070:
Add missing feature descriptions to hci_features2str().

The list of possible features in hccontrol/features2str() is incomplete.
Refer to "Bluetooth Core Specification 5.2 Vol. 2 Part C. 3.3 Feature Mask Definition".

Submitted by: Marc Veldman <marc@bumblingdork.com>
PR: 245354
Sponsored by: Mellanox Technologies

4 years agoMFC r360900:
Ryan Moeller [Mon, 18 May 2020 00:32:42 +0000 (00:32 +0000)]
MFC r360900:

vfs_exports: Tighten bounds and assert consistency of numsecflavors

We know the value must be greater than 0 and less than MAXSECFLAVORS.

Reject values outside this range in the initial check in vfs_export and add
KASSERTs in the later consumers.

Also check that we are called with one of either MNT_DELEXPORT or MNT_EXPORTED
set.

Reviewed by:    rmacklem
Approved by:    mav (mentor)
Sponsored by:   iXsystems, Inc.
Differential Revision:  https://reviews.freebsd.org/D24753

4 years agoMFC r361064
Peter Grehan [Sun, 17 May 2020 11:09:38 +0000 (11:09 +0000)]
MFC r361064
    Hide host CPUID 0x15 TSC/Crystal ratio/freq info from guest

    In recent Linux (5.3+) and OpenBSD (6.6+) kernels, and with hosts that
    support CPUID 0x15, the local APIC frequency is determined directly
    from the reported crystal clock to avoid calibration against the 8254
    timer.

    However, the local APIC frequency implemented by bhyve is 128MHz, where
    most h/w systems report frequencies around 25MHz. This shows up on
    OpenBSD guests as repeated keystrokes on the emulated PS2 keyboard
    when using VNC, since the kernel's timers are now much shorter.

    Fix by reporting all-zeroes for CPUID 0x15. This allows guests to fall
    back to using the 8254 to calibrate the local APIC frequency.

    Future work could be to compute values returned for 0x15 that would
    match the host TSC and bhyve local APIC frequency, though all dependencies
    on this would need to be examined (for example, Linux will start using
    0x16 for some hosts).

    PR: 246321
    Reported by: Jason Tubnor (and tested)

Approved by: bz (mentor)

4 years agoAdd new stats(7) man page and hook it up to the build.
Benedict Reuschling [Sun, 17 May 2020 09:34:29 +0000 (09:34 +0000)]
Add new stats(7) man page and hook it up to the build.

This man page contains stat utilities that are available in
the base system. This is a better approach than looking them
up via "apropos stat" or similar commands.

Thanks to Daniel Ebdrup Jensen for writing the original page
and incorporating the feedback given.

Submitted by: Daniel Ebdrup Jensen
Reviewed by: 0mp, allanjude, brueffer, bcr
Approved by: bcr
Relnotes: yes (new stats(7) man page)
Differential Revision: https://reviews.freebsd.org/D24417

4 years agoMFC r360613:
Alan Somers [Sun, 17 May 2020 02:36:42 +0000 (02:36 +0000)]
MFC r360613:

Fix intermittent cleanup failures in the ggated test

4 years agoMFC r360339, r360567
Alan Somers [Sun, 17 May 2020 02:35:50 +0000 (02:35 +0000)]
MFC r360339, r360567

r360339:
mac_bsdextended: ATFify the tests

The new tests have more complete setup and cleanup, are more granular, and
correctly annotate expected failures and skipped tests. A follow-up commit
will resolve a conflict with the fusefs tests (bug 244229).

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

r360567:
Resolve conflict between the fusefs(5) and mac_bsdextended(4) tests

mac_bsdextended(4), when enabled, causes ordinary operations to send many
more VOP_GETATTRs to file system. The fusefs tests expectations aren't
written with those in mind. Optionally expecting them would greatly
obfuscate the fusefs tests. Worse, certain fusefs functionality (like
attribute caching) would be impossible to test if the tests couldn't expect
an exact number of GETATTR operations.

This commit resolves that conflict by making two changes:

1. The fusefs tests will now check for mac_bsdextended, and skip if it's
   enabled.
2. The mac_bsdextended tests will now check whether the module is enabled, not
   merely loaded. If it's loaded but disabled, the tests will automatically
   enable it for the duration of the tests.

With these changes, a CI system can achieve best coverage by loading both
fusefs and mac_bsdextended at boot, and setting
security.mac.bsdextended.enabled=0

PR: 244229
Reported by: lwhsu
Reviewed by: cem
Differential Revision: https://reviews.freebsd.org/D24577

4 years agoMFC r359435:
Alan Somers [Sun, 17 May 2020 02:21:53 +0000 (02:21 +0000)]
MFC r359435:

fusefs: add a dtrace probe that fires after mounting is complete

This probe is useful for showing the protocol options negotiated with a FUSE
server.

4 years agoMFC r360087:
Alan Somers [Sun, 17 May 2020 01:55:07 +0000 (01:55 +0000)]
MFC r360087:

libbsm: fix some MLINKS

Add missing MLINKS entries for a few functions. Remove some old typo
entries.

Reported by: phk
Reviewed by: cem

4 years agoMFC r360080:
Alan Somers [Sun, 17 May 2020 01:51:25 +0000 (01:51 +0000)]
MFC r360080:

zfs-program.8: fix orphan .Xr

Reported by: phk
Reviewed by: avg
Differential Revision: https://reviews.freebsd.org/D24488

4 years agoMFC r360079:
Alan Somers [Sun, 17 May 2020 01:50:04 +0000 (01:50 +0000)]
MFC r360079:

cap_dns.3: fix some orphan .Xr links

Reported by: phk

4 years agoMFC r360078, r360086
Alan Somers [Sun, 17 May 2020 01:48:12 +0000 (01:48 +0000)]
MFC r360078, r360086

r360078:
bectl.8, beinstall.sh.8: fix man page section of beinstall.sh

Reported by: phk

r360086:
bectl.8: correctly sort SEE ALSO section after 360078

Reported by: yuripv
MFC with: 360078

4 years agoMFC r360077:
Alan Somers [Sun, 17 May 2020 01:46:00 +0000 (01:46 +0000)]
MFC r360077:

zfsd.8: fix orphan .Xr

Though ZFS is a kernel module, it has no man page in section 4.

Reported by: phk

4 years agoMFC r360845:
Konstantin Belousov [Sat, 16 May 2020 09:03:18 +0000 (09:03 +0000)]
MFC r360845:
Avoid spurious ENOMEMs from sysctl hw.pagesizes.

PR: 246215

4 years agoMFC r360848:
Mark Johnston [Sat, 16 May 2020 00:28:49 +0000 (00:28 +0000)]
MFC r360848:
rtwn: Add a new USB ID.

PR: 246315

4 years agoMFC r360551-r360554
Mitchell Horne [Fri, 15 May 2020 20:01:30 +0000 (20:01 +0000)]
MFC r360551-r360554

This set of changes allows booting with OpenSBI v0.7.

r360551:
Make mpentry independent of _start

r360552:
Add support for HSM SBI extension

r360553:
Use the HSM SBI extension to start APs

r360554:
Use the HSM SBI extension to halt CPUs

4 years agoMFC r360813:
Ryan Moeller [Fri, 15 May 2020 01:01:02 +0000 (01:01 +0000)]
MFC r360813:

Remove APPLEKEXT ifndefs

They are no longer useful.

Reviewed by:    rmacklem
Approved by:    mav (mentor)
Sponsored by:   iXsystems, Inc.
Differential Revision:  https://reviews.freebsd.org/D24752

4 years agoMFC r360952: Generate zlib.pc from source.
Xin LI [Fri, 15 May 2020 00:50:52 +0000 (00:50 +0000)]
MFC r360952: Generate zlib.pc from source.

4 years agoMFC r360594: ipfw: whitespace fix in SCTP_ABORT_ASSOCIATION case statement comment
Ed Maste [Thu, 14 May 2020 20:43:59 +0000 (20:43 +0000)]
MFC r360594: ipfw: whitespace fix in SCTP_ABORT_ASSOCIATION case statement comment

PR: Neel Chauhan <neel AT neelc DOT org>

4 years agoMFC r360398 and r360902
Eric Joyner [Thu, 14 May 2020 19:56:54 +0000 (19:56 +0000)]
MFC r360398 and r360902

These commits introduce a new iflib device-dependent method and
implements that method in the Intel ethernet network drivers;
this method tells iflib if the network interface needs to be
restarted when certain events happen.

This fixes several issues that occur when VLANs are registered
or unregistered with the network interface.

PR: 240818, 241785
Sponsored by: Intel Corporation

4 years agoBump Dd for r361044.
John Baldwin [Thu, 14 May 2020 19:15:21 +0000 (19:15 +0000)]
Bump Dd for r361044.

This is a direct commit to stable/{11,12} as I missed the bump in the
commit to head, but the file has already been removed from head.

4 years agoMFC r360915:
Dimitry Andric [Thu, 14 May 2020 19:09:13 +0000 (19:09 +0000)]
MFC r360915:

Use -fno-asynchronous-unwind-tables to compile lib/csu

Summary:
In r209294 kib added -fno-asynchronous-unwind-tables to the compile
flags for the GNU C startup components. This was done to work around a
BFD ld assertion, "no .eh_frame_hdr table will be created", which is
produced because of the layout of the startup objects.

Add the same flag to lib/csu too, for the same reason. And similarly to
r209294, also add -fno-omit-frame-pointer.

This is primarily meant to quickly MFC to stable/11, so it can end up in
the 11.4 release, as a fix for https://bugs.freebsd.org/246322.

PR: 246322
Differential Revision: https://reviews.freebsd.org/D24797

4 years agoMFC 360710: Deprecate ubsec(4) for FreeBSD 13.0.
John Baldwin [Thu, 14 May 2020 18:59:34 +0000 (18:59 +0000)]
MFC 360710: Deprecate ubsec(4) for FreeBSD 13.0.

With the removal of in-tree consumers of DES, Triple DES, and
MD5-HMAC, the only algorithm this driver still supports is SHA1-HMAC.
This is not very useful as a standalone algorithm (IPsec AH-only with
SHA1 would be the only user).

This driver has also not been kept up to date with the original driver
in OpenBSD which supports a few more cards and AES-CBC on newer cards.
The newest card currently supported by this driver was released in
2005.

Relnotes: yes

4 years agoMFC 360634: Add RFC reference for AES-CTR with IPsec.
John Baldwin [Thu, 14 May 2020 18:55:45 +0000 (18:55 +0000)]
MFC 360634: Add RFC reference for AES-CTR with IPsec.

4 years agoMFC 360399:
John Baldwin [Thu, 14 May 2020 18:49:43 +0000 (18:49 +0000)]
MFC 360399:
Update the cached MSI state when any MSI capability register is written.

bhyve uses cached copies of the MSI capability registers to generate
MSI interrupts for device models.  Previously, these cached fields
were only set when the MSI capability control register was updated.
The Linux kernel recently adopted a change to deal with races in MSI
interrupt delivery that writes to the MSI capability address and data
registers to alter the destination of MSI interrupts without writing
to the MSI capability control register.  bhyve was not updating its
cached registers for these writes and continued to send interrupts
with the old data value to the old address.  Fix this by recomputing
the cached values for every write to any MSI capability register.

4 years agoMFC 360818: Fix a memory leak for ENCIOC_GETSTRING I introduced in r360171.
John Baldwin [Thu, 14 May 2020 18:19:28 +0000 (18:19 +0000)]
MFC 360818: Fix a memory leak for ENCIOC_GETSTRING I introduced in r360171.

4 years agoMFC 360171,360179,360285,360388: Don't dereference various user pointers.
John Baldwin [Thu, 14 May 2020 17:56:43 +0000 (17:56 +0000)]
MFC 360171,360179,360285,360388: Don't dereference various user pointers.

360171:
Don't access a user buffer directly from the kernel.

The handle_string callback for the ENCIOC_SETSTRING ioctl was passing
a user pointer to memcpy().  Fix by using copyin() instead.

For ENCIOC_GETSTRING ioctls, the handler was storing the user pointer
in a CCB's data_ptr field where it was indirected by other code.  Fix
this by allocating a temporary buffer (which ENCIOC_SETSTRING already
did) and copying the result out to the user buffer after the CCB has
been processed.

360179:
Don't pass a user buffer pointer as the data pointer in a CCB.

Allocate a temporary buffer in the kernel to serve as the CCB data
pointer for a pass-through transaction and use copyin/copyout to
shuffle the data to/from the user buffer.

360285:
Don't indirect user pointers directly in two 802.11s ioctls.

IEEE80211_MESH_RTCMD_ADD was invoking memcmp() to validate the
supplied address directly on the user pointer rather than first doing
a copyin() and validating the copied value.

IEEE80211_MESH_RTCMD_DELETE was passing the user pointer directly to
ieee80211_mesh_rt_del() rather than copying the user buffer into a
temporary kernel buffer.

360388:
Don't run strcmp() against strings stored in user memory.

Instead, copy the strings into a temporary buffer on the stack and
run strcmp on the copies.

4 years agoMFC r360568:
David Bright [Thu, 14 May 2020 12:52:08 +0000 (12:52 +0000)]
MFC r360568:

Fix various Coverity-detected errors in nvme driver

This fixes several Coverity-detected errors in the nvme driver.

CIDs addressed: 100834410093771009380119374013054701403975,
1403980

Sponsored by: Dell EMC Isilon

4 years agoMFC r360491: Introduce a lower bound of 2 MSS to TCP Cubic.
Richard Scheffenegger [Thu, 14 May 2020 09:55:41 +0000 (09:55 +0000)]
MFC r360491:   Introduce a lower bound of 2 MSS to TCP Cubic.

Running TCP Cubic together with ECN could end up reducing cwnd down to 1 byte, if the
receiver continously sets the ECE flag, resulting in very poor transmission speeds.

In line with RFC6582 App. B, a lower bound of 2 MSS is introduced, as well as a typecast
to prevent any potential integer overflows during intermediate calculation steps of the
adjusted cwnd.

Reported by: Cheng Cui
Reviewed by: tuexen (mentor)
Approved by: tuexen (mentor)
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D23353

4 years agoMFC r360786:
Piotr Pawel Stefaniak [Thu, 14 May 2020 06:07:23 +0000 (06:07 +0000)]
MFC r360786:
ps: extend the non-standard option -d (tree view) to work with -p

4 years agoMFC 359047,359054: Deprecate procfs-based process debugging.
John Baldwin [Wed, 13 May 2020 21:16:02 +0000 (21:16 +0000)]
MFC 359047,359054: Deprecate procfs-based process debugging.

359047:
Mark procfs-based process debugging as deprecated for FreeBSD 13.

Attempting to use ioctls on /proc/<pid>/mem to control a process will
trigger warnings on the console.  The <sys/pioctl.h> include file will
also now emit a compile-time warning when used from userland.

359054:
Fix the workaround to ignore the #warning for GCC.

clang and gcc use different warning flags for #warning preprocessor
directives.

For both 12 and 11, adjust the GCC warning flags to only be added in
4.7 and later since 4.2.1 does not support -Wno-cpp.  For 11, add the
needed warning suppression to procctl's build.  procctl was removed in
12.0.

4 years agoMFC r360691:
Mark Johnston [Wed, 13 May 2020 12:33:51 +0000 (12:33 +0000)]
MFC r360691:
arm: Don't enable interrupts in init_secondary().

4 years agoMFC r359166: objcopy: add new sections also when there is no .shstrtab
Ed Maste [Tue, 12 May 2020 23:51:04 +0000 (23:51 +0000)]
MFC r359166: objcopy: add new sections also when there is no .shstrtab

Previously objcopy (elfcopy) --add-sections inserted new sections before
.shstrtab, but omitted them if there was no .shstrtab.

Now, after processing existing sections add new sections if they were
not yet added.

PR: 241437
Reported by: arrowd
Submitted by: Tiger Gao <tig@FreeBSDFoundation.org>
Sponsored by: The FreeBSD Foundation

4 years agoMFC r343969 by nwhitehorn:
Justin Hibbits [Tue, 12 May 2020 21:51:56 +0000 (21:51 +0000)]
MFC r343969 by nwhitehorn:

Performance improvements for octe(4):
- Distribute RX load across multiple cores, if present. This reverts
r217212, which is no longer relevant (I think because of the newer
SDK).
- Use newer APIs for pinning taskqueue entries to specific cores.
- Deepen RX buffers.

This more than doubles NAT forwarding throughput on an EdgeRouter Lite from,
with typical packet mixture, 90 Mbps to over 200 Mbps. The result matches
forwarding throughput in Linux without the UBNT hardware offload on the same
hardware, and thus likely reflects hardware limits.

4 years agoMFC r360777: Optimize ENA Rx refill for low memory conditions
Marcin Wojtas [Tue, 12 May 2020 18:44:41 +0000 (18:44 +0000)]
MFC r360777: Optimize ENA Rx refill for low memory conditions

Sometimes, especially when there is not much memory in the system left,
allocating mbuf jumbo clusters (like 9KB or 16KB) can take a lot of time
and it is not guaranteed that it'll succeed. In that situation, the
fallback will work, but if the refill needs to take a place for a lot of
descriptors at once, the time spent in m_getjcl looking for memory can
cause system unresponsiveness due to high priority of the Rx task. This
can also lead to driver reset, because Tx cleanup routine is being
blocked and timer service could detect that Tx packets aren't cleaned
up. The reset routine can further create another unresponsiveness - Rx
rings are being refilled there, so m_getjcl will again burn the CPU.
This was causing NVMe driver timeouts and resets, because network driver
is having higher priority.

Instead of 16KB jumbo clusters for the Rx buffers, 9KB clusters are
enough - ENA MTU is being set to 9K anyway, so it's very unlikely that
more space than 9KB will be needed.

However, 9KB jumbo clusters can still cause issues, so by default the
page size mbuf cluster will be used for the Rx descriptors. This can have a
small (~2%) impact on the throughput of the device, so to restore
original behavior, one must change sysctl "hw.ena.enable_9k_mbufs" to
"1" in "/boot/loader.conf" file.

As a part of this patch (important fix), the version of the driver
was updated to v2.1.2.

Submitted by:   cperciva
PR:             225791, 234838, 235856, 236989, 243531

4 years agoMFC r360968: libalias: fix potential memory disclosure from ftp module
Ed Maste [Tue, 12 May 2020 16:52:08 +0000 (16:52 +0000)]
MFC r360968: libalias: fix potential memory disclosure from ftp module

admbugs: 956
Submitted by: markj
Reported by: Vishnu Dev TJ working with Trend Micro Zero Day Initiative
Approved by: so
Security: FreeBSD-SA-20:13.libalias
Security: CVE-2020-7455
Security: ZDI-CAN-10849

4 years agoMFC r360967: libalias: validate packet lengths before accessing headers
Ed Maste [Tue, 12 May 2020 16:49:04 +0000 (16:49 +0000)]
MFC r360967: libalias: validate packet lengths before accessing headers

admbugs: 956
Submitted by: ae
Reported by: Lucas Leong (@_wmliang_) of Trend Micro Zero Day Initiative
Reported by: Vishnu working with Trend Micro Zero Day Initiative
Approved by: so
Security: FreeBSD-SA-20:12.libalias
Security: CVE-2020-7454
Security: ZDI-CAN-10624, ZDI-CAN-10850

4 years agoMFC 358394: Use stream_read() to read all 12 bytes of the RFB client version.
John Baldwin [Tue, 12 May 2020 16:05:21 +0000 (16:05 +0000)]
MFC 358394: Use stream_read() to read all 12 bytes of the RFB client version.

read() can return a short read, whereas stream_read() waits until the
full version string is read.

4 years agoMFC r360438:
Mark Johnston [Tue, 12 May 2020 14:01:14 +0000 (14:01 +0000)]
MFC r360438:
Make sendfile(SF_SYNC)'s CV wait interruptible.

4 years agoMFC r360844:
Konstantin Belousov [Tue, 12 May 2020 12:29:39 +0000 (12:29 +0000)]
MFC r360844:
Document BUS_OOMERR.

4 years agoMFC r360676: elfctl: update earliest FreeBSD revision to 12.2
Ed Maste [Tue, 12 May 2020 01:01:48 +0000 (01:01 +0000)]
MFC r360676: elfctl: update earliest FreeBSD revision to 12.2

elfctl has been merged to stable/12, and so will appear in FreeBSD 12.2

Reported by: Dewayne Geraghty
Sponsored by: The FreeBSD Foundation

4 years agoMFC 357643: Tidy the _set_tp function for RISC-V.
John Baldwin [Mon, 11 May 2020 21:24:22 +0000 (21:24 +0000)]
MFC 357643: Tidy the _set_tp function for RISC-V.

- Use a constant for the offset instead of a magic number.
- Use an addi instruction that writes to tp directly instead of a mv
  that writes the result of a compiler-generated addi.

4 years agoMFC 357632: Use the context created in makectx() for stack traces.
John Baldwin [Mon, 11 May 2020 20:58:27 +0000 (20:58 +0000)]
MFC 357632: Use the context created in makectx() for stack traces.

Always use the kdb_thr_ctx() for db_trace_thread() as on other
architectures.  Initialize pcb_ra to be the sepc from the saved
trapframe rather than the saved ra to avoid skipping a frame.

4 years agoMFC 357630: Fix DDB to unwind across exception frames.
John Baldwin [Mon, 11 May 2020 20:41:27 +0000 (20:41 +0000)]
MFC 357630: Fix DDB to unwind across exception frames.

While here, add an extra line of information for exceptions and
interrupts and compress the per-frame line down to one line to match
other architectures.

4 years agoMFC r350571:
Justin Hibbits [Mon, 11 May 2020 20:10:01 +0000 (20:10 +0000)]
MFC r350571:

Fix the build after r350570.

Signed char cannot compare to values above 0x7f.  Use unsigned instead.

4 years agoMFC 357594: Use csr_read() to read sstatus instead of inline assembly.
John Baldwin [Mon, 11 May 2020 19:57:45 +0000 (19:57 +0000)]
MFC 357594: Use csr_read() to read sstatus instead of inline assembly.

While here, remove a local variable to avoid the CSR read in non-debug
kernels.

4 years agoMFC 357595: Fix EXCP_MASK to include all relevant bits from scause.
John Baldwin [Mon, 11 May 2020 18:47:51 +0000 (18:47 +0000)]
MFC 357595: Fix EXCP_MASK to include all relevant bits from scause.

While cause codes higher than 16 are reserved, the exception code
field of the register is defined to be all bits but the upper-most
bit.

4 years agoMFC 356840,357344: Add stricter checks on user changes to SSTATUS.
John Baldwin [Mon, 11 May 2020 16:14:20 +0000 (16:14 +0000)]
MFC 356840,357344: Add stricter checks on user changes to SSTATUS.

356840:
Check for invalid sstatus values in set_mcontext().

Previously, this check was only in sys_sigreturn() which meant that
user applications could write invalid values to the register via
setcontext() or swapcontext().

357344:
Add stricter checks on user changes to SSTATUS.

Rather than trying to blacklist which bits userland can't write to via
sigreturn() or setcontext(), only permit changes to whitelisted bits.

- Permit arbitrary writes to bits in the user-writable USTATUS
  register that shadows SSTATUS.

- Ignore changes in write-only bits maintained by the CPU.

- Ignore the user-supplied value of the FS field used to track
  floating point state and instead set it to a value matching the
  actions taken by set_fpcontext().

4 years agoMFC r360381:
Mark Johnston [Mon, 11 May 2020 15:21:03 +0000 (15:21 +0000)]
MFC r360381:
Add some regression tests for read and write kevents on pipes.

4 years agoMFC r360380:
Mark Johnston [Mon, 11 May 2020 15:20:40 +0000 (15:20 +0000)]
MFC r360380:
Fix handling of EV_EOF for named pipes.

PR: 203366, 224615, 246350

4 years agoMFC r360379:
Mark Johnston [Mon, 11 May 2020 15:20:05 +0000 (15:20 +0000)]
MFC r360379:
Call pipeselwakeup() after toggling PIPE_EOF.

4 years agoMFC r360378:
Mark Johnston [Mon, 11 May 2020 15:17:57 +0000 (15:17 +0000)]
MFC r360378:
Avoid returning POLLIN if the pipe descriptor is not open for reading.

4 years agoMFC r360619:
Xin LI [Mon, 11 May 2020 07:20:37 +0000 (07:20 +0000)]
MFC r360619:
 - Fix logic error in swapoff case: follow same handling of p and
   linelen in the swapon case.
 - Use strlcpy instead of strncpy.

4 years agoMFC r360836:
Toomas Soome [Mon, 11 May 2020 06:59:01 +0000 (06:59 +0000)]
MFC r360836:

loader: vdev_read() can corrupt memory

When reading less than sector size but from sector boundary,
the vdev_read() will read full sector into the provided buffer
and therefore corrupting memory past buffer end.

4 years agoMFC r360801: Merge commit 21e5e1724b75 from llvm git:
Ed Maste [Sun, 10 May 2020 14:56:25 +0000 (14:56 +0000)]
MFC r360801: Merge commit 21e5e1724b75 from llvm git:

  getMainExecutable: Fix hand-rolled AT_EXECPATH for older FreeBSD

  Once we hit AT_NULL, we need to bail out of the loop; not just the
  enclosing switch.  This fixes basic usage (e.g. `cc --version`) when
  AT_EXECPATH isn't present on older branches (e.g. under
  emu-user-static, at the moment), where we would previously run off
  the end of ::environ.

  Patch By: kevans

  Reviewed By: arichardson

4 years agoMFC 356839: Save and restore floating point registers in get/set_mcontext().
John Baldwin [Sun, 10 May 2020 14:53:08 +0000 (14:53 +0000)]
MFC 356839: Save and restore floating point registers in get/set_mcontext().

arm64 and riscv were only saving and restoring floating point
registers for sendsig() and sys_sigreturn(), but not for getcontext(),
setcontext(), and swapcontext().

While here, remove an always-false check for uap being NULL from
sys_sigreturn().

4 years agoMerge r360138:
Gleb Smirnoff [Sun, 10 May 2020 14:46:46 +0000 (14:46 +0000)]
Merge r360138:

  Fix immediate crash when snmpd is bound to a specific IP address.

  The code that sets up msghdr must first fully fill in the msghdr
  itself, and only then use CMSG_xxx() macros.

PR: 246323

4 years agoMFC r360609:
Kristof Provost [Sun, 10 May 2020 09:50:44 +0000 (09:50 +0000)]
MFC r360609:

pf: Improve DIOCADDRULE validation

We expect the addrwrap.p.dyn value to be set to NULL (and assert such),
but do not verify it on input.

Reported-by: syzbot+936a89182e7d8f927de1@syzkaller.appspotmail.com

4 years agoMFC r360610: Add session locking in cfiscsi_ioctl_handoff().
Alexander Motin [Sun, 10 May 2020 02:13:38 +0000 (02:13 +0000)]
MFC r360610: Add session locking in cfiscsi_ioctl_handoff().

While there, remove ifdef around cs_target check in cfiscsi_ioctl_list().
I am not sure why this ifdef was added, but without this check code will
crash below on NULL dereference.

4 years agoMFC 357255,357337: Fix definition of SSTATUS_SD and MSTATUS_SD.
John Baldwin [Sun, 10 May 2020 00:34:09 +0000 (00:34 +0000)]
MFC 357255,357337: Fix definition of SSTATUS_SD and MSTATUS_SD.

357255:
Fix definition of SSTATUS_SD

The SD bit is defined as the MSB of the sstatus register, meaning its
position will vary depending on the CSR's length. Previously, there were
two (unused) defines for this, for the 32 and 64-bit cases, but their
definitions were swapped.

Consolidate these into one define: SSTATUS_SD, and make the definition
dependent on the value of __riscv_xlen.

357337:
Fix 64-bit value of SSTATUS_SD to use an unsigned long.

While here, fix MSTATUS_SD to match SSTATUS_SD.

4 years agoMFC 357313: Trim duplicate CSR swaps from user exceptions.
John Baldwin [Sat, 9 May 2020 21:34:50 +0000 (21:34 +0000)]
MFC 357313: Trim duplicate CSR swaps from user exceptions.

The stack pointer is swapped with the sscratch CSR just before the
jump to cpu_exception_handler_user where the first instruction swaps
it again.  The two swaps together are a no-op, but the csr swap
instructions can be expensive (e.g. on Bluespec RISC-V cores csr swap
instructions force a full pipeline stall).

4 years agoMFC 357305: Remove unused fields from struct pcb.
John Baldwin [Sat, 9 May 2020 21:32:44 +0000 (21:32 +0000)]
MFC 357305: Remove unused fields from struct pcb.

cpu_switch/throw() and savectx() do not save or restore any values in
these fields which mostly held non-callee-save registers.

makectx() copied these fields from kdb_frame, but they weren't used
except for PC_REGS using pcb_sepc.  Change PC_REGS to use
kdb_frame->tf_sepc directly instead.

4 years agoMFC 357591:
John Baldwin [Sat, 9 May 2020 20:14:05 +0000 (20:14 +0000)]
MFC 357591:
Read the breakpoint instruction to determine its length in BKPT_SKIP.

This fixes continuing from debug.kdb.enter=1 after enabling the use of
compressed instructions since the compiler can emit the two byte
c.ebreak instead of the 4 byte ebreak.

4 years agoMFC 357593: Remove stale workaround for the htif console.
John Baldwin [Sat, 9 May 2020 20:10:01 +0000 (20:10 +0000)]
MFC 357593: Remove stale workaround for the htif console.

In practice this discarded all characters entered at the DDB prompt.

4 years agoMFC 354289,354441,355095: Use lld on armv6.
John Baldwin [Sat, 9 May 2020 20:02:48 +0000 (20:02 +0000)]
MFC 354289,354441,355095: Use lld on armv6.

354289:
armv6: Switch to LLD by default

This could just be ${__TT} == "arm", except armv5 isn't slated for death until
EOY.

arm tinderbox builds.  Let's see what else shakes out.

354441:
arch.7: armv6 uses lld by default as of r354289

355095:
remove armv6 LLVM workaround introduced in r341812

r341812 enabled only arm target support in LLVM on arm and armv6,
because ld.bfd 2.17.50 lacked support for range extensions required for
linking such large binaries/libraries.  r341812 indicated that the
workaround should be removed once the userland can be linked by lld.

r354289 switched armv6 to use lld by default, so remove the workaround
on armv6.  The workaround remains in place for arm (v5), and will
presumably be removed when arm is retired.

4 years agoMFC 356499: Use clang and lld as the default toolchain for RISCV.
John Baldwin [Sat, 9 May 2020 17:14:59 +0000 (17:14 +0000)]
MFC 356499: Use clang and lld as the default toolchain for RISCV.

- Enable clang and lld as system toolchains.
- Don't use external GCC for universe by default.
- Re-enable riscv64sf since it builds fine with clang + lld.

Sponsored by: DARPA

4 years agoMFC r358689 (by jhibbits):
Dimitry Andric [Sat, 9 May 2020 11:18:34 +0000 (11:18 +0000)]
MFC r358689 (by jhibbits):

Fix a mistaken conditional in mfi_tbolt_send_frame()

As written, the condition of (cdb[0] != 0x28 || cdb[0] != 0x2A) will always
be true, since if it's one, it's obviously not the other.  Reading the code,
the intent appears to be that it should only perform the operation if it's
neither, otherwise the conditional can be elided.

Found by clang 10.

4 years agoMFC of 356666
Kirk McKusick [Sat, 9 May 2020 05:04:02 +0000 (05:04 +0000)]
MFC of 356666

Fix the way 'factor' behaves when using OpenSSL to match the description
of how it works when not compiled with OpenSSL.

4 years agoMFC 354603,354604,354717,354718: Sync PLIC code with head.
John Baldwin [Fri, 8 May 2020 15:05:05 +0000 (15:05 +0000)]
MFC 354603,354604,354717,354718: Sync PLIC code with head.

354603:
plic: fix PLIC_MAX_IRQS

The maximum number of PLIC interrupts is defined in the PLIC spec[1]
as 1024.

354604:
plic: check for sifive compatible string

The Linux dts for the HiFive Unleashed does not contain the usual
"riscv,plic0" compat string, but our PLIC driver is compatible.

354717:
plic: fix context calculation

The RISC-V PLIC (platform level interrupt controller) registers are divided up
by "context", which is purposefully left ambiguous in the PLIC spec. Currently
we assume each CPU number corresponds 1-to-1 with a context number, but that is
not correct. Most existing PLIC implementations (such as SiFive's) have
multiple contexts per-cpu. For example, a single CPU might have a context for
machine mode interrupts and a context for supervisor mode interrupts. To
complicate things further, FreeBSD renumbers the CPUs during boot, but the PLIC
driver still assumes that CPU ID equals the RISC-V hart number, meaning
interrupt enables/claims might be performed for the wrong context registers.

To fix this, we must calculate each CPU's context number during
attachment. This is done by reading the interrupt properties from the
device tree, from which a mapping from context to RISC-V hart to CPU
number can be created.

354718:
plic: support irq distribution

Our PLIC implementation only enables interrupts on the boot cpu.
Implement plic_bind_intr() so that they can be redistributed near the
end of boot during intr_irq_shuffle().

This also slightly modifies how enable bits are handled in an attempt to
better fit the PIC interface. plic_enable_intr()/plic_disable_intr() are
converted to manage an interrupt source's threshold value, since this
value can be used as to globally enable/disable an irq. All handing of the
per-context enable bits is moved to the new methods plic_setup_intr()
and plic_bind_intr().

4 years agoMFC 348611: Expose the kernel's build-ID through sysctl
John Baldwin [Fri, 8 May 2020 14:48:45 +0000 (14:48 +0000)]
MFC 348611: Expose the kernel's build-ID through sysctl

After our migration (of certain architectures) to lld the kernel is built
with a unique build-ID.  Make it available via a sysctl and uname(1) to
allow the user to identify their running kernel.

4 years agoMFC r360277:
Mark Johnston [Fri, 8 May 2020 14:13:30 +0000 (14:13 +0000)]
MFC r360277:
Fix handling of 1GB mappings in the arm64 minidump code.

4 years agoMFC r360280:
Mark Johnston [Fri, 8 May 2020 14:10:47 +0000 (14:10 +0000)]
MFC r360280:
Fix a race between _pmap_unwire_ptp() and MipsDoTLBMiss().

4 years agoMFC r360281:
Mark Johnston [Fri, 8 May 2020 14:10:29 +0000 (14:10 +0000)]
MFC r360281:
Fix a race in pmap_emulate_modified().

4 years agoMFC 354719,354720,354721,354722,357480: OpenSBI support.
John Baldwin [Fri, 8 May 2020 05:30:10 +0000 (05:30 +0000)]
MFC 354719,354720,354721,354722,357480: OpenSBI support.

354719:
RISC-V: pass arg6 in sbi_call

Allow for an additional argument to sbi_call which will be passed in a6.
This is required for SBI spec 0.2 support, as a6 will indicate the SBI
function ID.

While here, introduce some macros to clean up the calls.

354720:
RISC-V: add support for SBI spec v0.2

The Supervisor Binary Interface (SBI) specification v0.2 is a backwards
incompatible update to the SBI call interface for kernels running in
supervisor mode. The goal of this update was to make it easier for new
and optional functionality to be added to the SBI.

SBI functions are now called by passing an "extension ID" and a
"function ID" which are passed in a7 and a6 respectively. SBI calls
will also return an error and value in the following struct:

struct sbi_ret {
    long error;
    long value;
}

This version introduces several new functions under the "base"
extension. It is expected that all SBI implementations >= 0.2 will
support this base set of functions, as they implement some essential
services such as obtaining the SBI version, CPU implementation info, and
extension probing.

Existing SBI functions have been designated as "legacy". For the time
being they will remain implemented, but it is expected that in the
future their functionality will be duplicated or replaced by new SBI
extensions. Each legacy function has been assigned its own extension ID,
and for now we simply probe and assert for their existence.

Compatibility with legacy SBI implementations (such as BBL) is
maintained by checking the output of sbi_get_spec_version(). This
function is guaranteed to succeed by the new spec, but will return an
error in legacy implementations. We use this as an indicator of whether
or not we can rely on the new SBI base extensions.

For further info on the Supervisor Binary Interface, see:
https://github.com/riscv/riscv-sbi-doc/blob/master/riscv-sbi.adoc

354721:
Add missing files from r354720

354722:
RISC-V: Print SBI info at startup

SBI version 0.2 introduces functions for obtaining the details of the
SBI implementation, such as version and implemntation ID. Print this
info at startup when it is available.

357480:
Set the LMA of the riscv kernel to the OpenSBI jump target by default

This allows us to boot FreeBSD RISCV on QEMU using the -kernel command line
options. When using that option, QEMU maps the kernel ELF file to the
addresses specified in the LMAs in the program headers.

Since version 4.2 QEMU ships with OpenSBI fw_jump by default so this allows
booting FreeBSD using the following command line:
qemu-system-riscv64 -bios default -kernel /.../boot/kernel/kernel -nographic -M virt

Without this change the -kernel option cannot be used since the LMAs start
at address zero and QEMU already maps a ROM to these low physical addresses.

For targets that require a different kernel LMA the make variable
KERNEL_LMA can be overwritten in the config file. For example, adding
`makeoptions    KERNEL_LMA=0xc0200000` will create an ELF file that will be
loaded at 0xc0200000.

Before:
There are 4 program headers, starting at offset 64

Program Headers:
  Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
  LOAD           0x001000 0xffffffc000000000 0x0000000000000000 0x75e598 0x8be318 RWE 0x1000
  DYNAMIC        0x71fb20 0xffffffc00071eb20 0x000000000071eb20 0x000100 0x000100 RW  0x8
  GNU_STACK      0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW  0x0
  NOTE           0x693400 0xffffffc000692400 0x0000000000692400 0x000024 0x000024 R   0x4

After:

There are 4 program headers, starting at offset 64

Program Headers:
  Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
  LOAD           0x001000 0xffffffc000000000 0x0000000080200000 0x734198 0x893e18 RWE 0x1000
  DYNAMIC        0x6f7810 0xffffffc0006f6810 0x00000000808f6810 0x000100 0x000100 RW  0x8
  GNU_STACK      0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW  0x0
  NOTE           0x66ca70 0xffffffc00066ba70 0x000000008086ba70 0x000024 0x000024 R   0x4

4 years agoMFC r360231:
Kristof Provost [Thu, 7 May 2020 21:14:11 +0000 (21:14 +0000)]
MFC r360231:

libc: Shortcut if_indextoname() if index == 0

If the index we're trying to convert is 0 we can avoid a potentially
expensive call to getifaddrs(). No interface has an ifindex of zero, so
we can handle this as an error: set the errno to ENXIO and return NULL.

Submitted by: Nick Rogers
Sponsored by: RG Nets

4 years agoMFC r358887:
Li-Wen Hsu [Thu, 7 May 2020 20:27:32 +0000 (20:27 +0000)]
MFC r358887:

Temporarily skip 2 failing tests after llvm10 import

PR: 244732
Sponsored by: The FreeBSD Foundation

4 years agoMFC 356481:
John Baldwin [Thu, 7 May 2020 19:19:39 +0000 (19:19 +0000)]
MFC 356481:
Work around lld's inability to handle undefined weak symbols on risc-v.

lld on RISC-V is not yet able to handle undefined weak symbols for
non-PIC code in the code model (medany/medium) used by the RISC-V
kernel.

Both GCC and clang emit an auipc / addi pair of instructions to
generate an address relative to the current PC with a 31-bit offset.
Undefined weak symbols need to have an address of 0, but the kernel
runs with PC values much greater than 2^31, so there is no way to
construct a NULL pointer as a PC-relative value.  The bfd linker
rewrites the instruction pair to use lui / addi with values of 0 to
force a NULL pointer address.  (There are similar cases for 'ld'
becoming auipc / ld that bfd rewrites to lui / ld with an address of
0.)

To work around this, compile the kernel with -fPIE when using lld.
This does not make the kernel position-independent, but it does
force the compiler to indirect address lookups through GOT entries
(so auipc / ld against a GOT entry to fetch the address).  This
adds extra memory indirections for global symbols, so should be
disabled once lld is finally fixed.

A few 'la' instructions in locore that depend on PC-relative
addressing to load physical addresses before paging is enabled have to
use auipc / addi and not indirect via GOT entries, so change those to
use 'lla' which always uses auipc / addi for both PIC and non-PIC.

Note that the followup fix for SMP (r356675) was previously merged to
stable/12.

4 years agoMFC 357145: Compile hack.c with normal CFLAGS + -shared -nostdlib.
John Baldwin [Thu, 7 May 2020 18:47:54 +0000 (18:47 +0000)]
MFC 357145: Compile hack.c with normal CFLAGS + -shared -nostdlib.

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

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

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

4 years agoMFC 355403: Use "far" calls and branches so that lld uses valid relocations.
John Baldwin [Thu, 7 May 2020 15:59:55 +0000 (15:59 +0000)]
MFC 355403: 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).

4 years agoMFC r360498:
Mark Johnston [Thu, 7 May 2020 14:49:17 +0000 (14:49 +0000)]
MFC r360498:
Increase the iflib txq callout mutex name length to 32 bytes.

PR: 245712

4 years agoMFC 355428,356504: Add a new "riscv-relaxations" linker feature.
John Baldwin [Thu, 7 May 2020 14:20:52 +0000 (14:20 +0000)]
MFC 355428,356504: Add a new "riscv-relaxations" linker feature.

355428:
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.

356504:
Add -mno-relax to CFLAGS in bsd.prog/lib.mk instead of bsd.cpu.mk.

bsd.cpu.mk is included by bsd.init.mk before bsd.linker.mk, so it
was always setting the flag since LINKER_FEATURES wasn't defined.

4 years agoMFC 360202,360206: Deprecate 3des support in IPsec for FreeBSD 13.
John Baldwin [Wed, 6 May 2020 23:23:22 +0000 (23:23 +0000)]
MFC 360202,360206: Deprecate 3des support in IPsec for FreeBSD 13.

360202:
Deprecate 3des support in IPsec for FreeBSD 13.

RFC 8221 does not outright ban 3des as the algorithms deprecated for
13 in r348205, but it is listed as a SHOULD NOT and will likely be a
MUST NOT by the time 13 ships.

360206:
Fix name of 3DES cipher in deprecation warning.

Sponsored by: Chelsio Communications

4 years agoMFC 358415: Rename TOE TLS stats from [rt]x_tls_* to [rt]x_toe_tls_*.
John Baldwin [Wed, 6 May 2020 22:49:21 +0000 (22:49 +0000)]
MFC 358415: Rename TOE TLS stats from [rt]x_tls_* to [rt]x_toe_tls_*.

This more clearly differentiates TLS records encrypted and decrypted
in TOE connections from those encrypted via NIC TLS.

Sponsored by: Chelsio Communications

4 years agoMFC 354667,354686: Share routines for dealing with T6 key contexts.
John Baldwin [Wed, 6 May 2020 22:44:53 +0000 (22:44 +0000)]
MFC 354667,354686: Share routines for dealing with T6 key contexts.

354667:
Create a file to hold shared routines for dealing with T6 key contexts.

ccr(4) and TLS support in cxgbe(4) construct key contexts used by the
crypto engine in the T6.  This consolidates some duplicated code for
helper functions used to build key contexts.

354686:
Add t4_keyctx.c to sys/conf/files for the non-module build.

Missed in r354667.

Sponsored by: Chelsio Communications

4 years agoMFC 355724,360166: Software breakpoints on Intel CPUs.
John Baldwin [Wed, 6 May 2020 22:20:37 +0000 (22:20 +0000)]
MFC 355724,360166: Software breakpoints on Intel CPUs.

355724:
Support software breakpoints in the debug server on Intel CPUs.

- Allow the userland hypervisor to intercept breakpoint exceptions
  (BP#) in the guest.  A new capability (VM_CAP_BPT_EXIT) is used to
  enable this feature.  These exceptions are reported to userland via
  a new VM_EXITCODE_BPT that includes the length of the original
  breakpoint instruction.  If userland wishes to pass the exception
  through to the guest, it must be explicitly re-injected via
  vm_inject_exception().

- Export VMCS_ENTRY_INST_LENGTH as a VM_REG_GUEST_ENTRY_INST_LENGTH
  pseudo-register.  Injecting a BP# on Intel requires setting this to
  the length of the breakpoint instruction.  AMD SVM currently ignores
  writes to this register (but reports success) and fails to read it.

- Rework the per-vCPU state tracked by the debug server.  Rather than
  a single 'stepping_vcpu' global, add a structure for each vCPU that
  tracks state about that vCPU ('stepping', 'stepped', and
  'hit_swbreak').  A global 'stopped_vcpu' tracks which vCPU is
  currently reporting an event.  Event handlers for MTRAP and
  breakpoint exits loop until the associated event is reported to the
  debugger.

  Breakpoint events are discarded if the breakpoint is not present
  when a vCPU resumes in the breakpoint handler to retry submitting
  the breakpoint event.

- Maintain a linked-list of active breakpoints in response to the GDB
  'Z0' and 'z0' packets.

360166:
Add description string for VM_CAP_BPT_EXIT.

While here, replace the array of mapping structures with an array of
string pointers where the index is the capability value.