FreeBSD/src 343166head/sys/amd64/vmm x86.c

vmm(4): Mask Spectre feature bits on AMD hosts

For parity with Intel hosts, which already mask out the CPUID feature
bits that indicate the presence of the SPEC_CTRL MSR, do the same on
AMD.

Eventually we may want to have a better support story for guests, but
for now, limit the damage of incorrectly indicating an MSR we do not yet
support.

Eventually, we may want a generic CPUID override system for
administrators, or for minimum supported feature set in heterogenous
environments with failover.  That is a much larger scope effort than
this bug fix.

PR:            235010
Reported by:    Rys Sommefeldt <rys AT sommefeldt.com>
Sponsored by:   Dell EMC Isilon

FreeBSD/src 343165head/usr.bin/top top.c

Fix top(1) long options handling

getopt_long(3) requires the long options be terminated by a NULL block.
Without the terminator, an invalid long option results in a segmentation
fault.

Reported by:    Brandon Bergren
MFC after:      1 week

FreeBSD/src 343164head/usr.sbin/jail command.c

Clarify error messages a bit.

X-Found-With:   r343112
MFC after:      1 month

FreeBSD/src 343163head/sys/dev/atkbdc psm.c, head/sys/sys mouse.h

psm(4): detect Lenovo top-button clickpads

libinput has special handling for Lenovo ThinkPad *40 series, where it
treats clicks on the top button area as if they came from the TrackPoint:
https://wayland.freedesktop.org/libinput/doc/latest/t440-support.html

Detect these devices and set the corresponding evdev property.

Submitted by:          Greg V <greg at unrelenting.technology>
MFC after:             2 weeks
Differential Revision:  https://reviews.freebsd.org/D18676

FreeBSD/src 343162head/sys/netinet siftr.c

Make SIFTR work again after r342125 (D18443).

Correct a logic error.

Only disable when already enabled or enable when disabled.

Submitted by:   Richard Scheffenegger
Reviewed by:    Cheng Cui
Obtained from:  Cheng Cui
MFC after:      3 days
Differential Revision:  https://reviews.freebsd.org/D18885

FreeBSD/src 343161head/include/protocols talkd.h, head/libexec/talkd talkd.c

Use a private definition of osockaddr rather then relying on type
namespace polution in sys/socket.h.

Also remove support for operation on 4.3BSD.

PR:            224529
Differential Revision:  https://reviews.freebsd.org/D14505

FreeBSD/src 343160stable 11, stable/11/sys/dev/evdev evdev_utils.c

MFC r340926:

evdev: Fix pause key release event in AT keyboard set 1 to evdev xlat-or.

FreeBSD/src 343159stable 12, stable/12/sys/dev/evdev evdev_utils.c

MFC r340926:

evdev: Fix pause key release event in AT keyboard set 1 to evdev xlat-or.

FreeBSD/src 343158stable 11, stable/11/sys/dev/atkbdc psm.c atkbdc.c

MFC r340912,r340913:

psm(4): Revert r328640 and add minimal support for active AUX port
        multiplexers

Active PS/2 multiplexing is a method for attaching up to four PS/2
pointing devices to a computer. Enabling of multiplexed mode allows
commands to be directed to individual devices using routing prefixes.
Multiplexed mode reports input with each byte tagged to identify
its source. This method differs from one currently supported by psm(4)
where so called guest device (trackpoint) is attached to special
interface located on the host device (touchpad) and latter performs
guest protocol conversion to special encapsulation packet format.

At present time active PS/2 multiplexing is used in some models of
HP laptops e.g. EliteBook 8560w, 9470m. Enabling of absolute operation
mode on such touchpads is connected with following problems:
1. Touchpad's port priority is lower than trackpoint's. That blocks
   information queries thus prevents touchpad detection and configuration.
2. Touchpad and trackpoint have different protocol packet sizes and
   sync bytes.

As PS/2 usage is on decline only minimal possible set of changes to
support Synaptics touchpad and generic mouses is implemented.
Active multiplexing mode is enabled only at probe stage to scan through

    [21 lines not shown]

FreeBSD/src 343157stable 12, stable/12/sys/dev/atkbdc psm.c atkbdc.c

MFC r340912,r340913:

psm(4): Revert r328640 and add minimal support for active AUX port
        multiplexers

Active PS/2 multiplexing is a method for attaching up to four PS/2
pointing devices to a computer. Enabling of multiplexed mode allows
commands to be directed to individual devices using routing prefixes.
Multiplexed mode reports input with each byte tagged to identify
its source. This method differs from one currently supported by psm(4)
where so called guest device (trackpoint) is attached to special
interface located on the host device (touchpad) and latter performs
guest protocol conversion to special encapsulation packet format.

At present time active PS/2 multiplexing is used in some models of
HP laptops e.g. EliteBook 8560w, 9470m. Enabling of absolute operation
mode on such touchpads is connected with following problems:
1. Touchpad's port priority is lower than trackpoint's. That blocks
   information queries thus prevents touchpad detection and configuration.
2. Touchpad and trackpoint have different protocol packet sizes and
   sync bytes.

As PS/2 usage is on decline only minimal possible set of changes to
support Synaptics touchpad and generic mouses is implemented.
Active multiplexing mode is enabled only at probe stage to scan through

    [21 lines not shown]

FreeBSD/src 343156head/sys/dev/usb usbdevs, head/sys/dev/usb/quirk usb_quirk.c

[usb] Add HID_IGNORE quirks for multiple UPS devices

Without HID_IGNORE quirk enabled these models appear in the system as a uhid
devices while NUT (Network UPS Tool) expects them to be ugen.

PR:            131521
Submitted by:   Naoyuki Tai <ntai at smartfruit.com>, John Bayly <john.bayly at tipstrade.net>
MFC after:      1 week

FreeBSD/src 343155stable 12, stable/12/sys/dev/usb/input uhid.c wmt.c

MFC r340338:
wmt(4): Add PNP record so it could be picked by devd/devmatch.
Fix uhid(4) conflict with blacklisting of multitouch HID-usages
in uhid(4) probe handler.

Reviewed by:    imp
Differential Revision:  https://reviews.freebsd.org/D17689

FreeBSD/src 343154head ObsoleteFiles.inc

Remove leading slash from OLD_DIRS assignment in ObsoleteFiles.inc.  The
"make delete-old" mechanism will already take care of such prefixes, and
this prevents a double leading slash from being displayed.

FreeBSD/src 343153head/usr.sbin/freebsd-update freebsd-update.8

freebsd-update.8: mandoc -Tlint fixes

PR:            185389
Reported by:    bcr
MFC after:      3 days
Sponsored by:   The FreeBSD Foundation

FreeBSD/src 343152head/usr.sbin/freebsd-update freebsd-update.sh

freebsd-update: Use BASEDIR when checking for src component

src could potentially be installed under the based dir
and not under the root or vice versa.

PR:            224048
Submitted by:   Gerald Aryeetey <aryeeteygerald_rogers.com>
Reviewed by:    delphij
MFC after:      1 month
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D18849

FreeBSD/src 343151stable 11, stable/11/sys/dev/asmc asmcvar.h asmc.c

MFC r342822:

asmc: Add support for Mac mini 4,1 (Mid-2010)

FreeBSD/src 343150stable 12, stable/12/sys/dev/asmc asmcvar.h asmc.c

MFC r342822:

asmc: Add support for Mac mini 4,1 (Mid-2010)

FreeBSD/src 343149stable 11, stable/11/sys/dev/asmc asmcvar.h asmc.c

MFC r342770:

asmc: Patch to add MacBook Pro 9,2 support

PR:            211513
Submitted by:  William Theesfeld Jr <wtheesfeld at mailbox.org>
Reported by:   William Theesfeld Jr <wtheesfeld at mailbox.org>

FreeBSD/src 343148stable 12, stable/12/sys/dev/asmc asmcvar.h asmc.c

MFC r342770:

asmc: Patch to add MacBook Pro 9,2 support

PR:            211513
Submitted by:   William Theesfeld Jr <wtheesfeld at mailbox.org>
Reported by:    William Theesfeld Jr <wtheesfeld at mailbox.org>

FreeBSD/src 343147head/sys/x86/x86 busdma_bounce.c

i386/PAE busdma: allow more bounce pages.

If i386 has more than 4G of memory, allow the same number of busdma
bounce pages as for amd64.  In fact, in this case bouncing sometimes
is much heavier than on amd64.

Reviewed by:    markj
Tested by:      pho
Sponsored by:   The FreeBSD Foundation
MFC after:      2 weeks
Differential revision:  https://reviews.freebsd.org/D18854

FreeBSD/src 343146head/sys/x86/include busdma_impl.h, head/sys/x86/x86 busdma_bounce.c busdma_machdep.c

x86 busdma: fix mis-use of bus_addr_t where vm_paddr_t is assumed.

Right now bus_addr_t and vm_paddr_t are always aliased to the same
underlying integer type on x86, which makes the interchange hard to
detect.  Shortly, i386 kernel would use uint64_t for vm_paddr_t to
enable automatic use of PAE paging structures if hardware allows it,
while bus_addr_t would be extended to 64bit only when PAE option is
specified.

Fix all places that were identified as using bus_addr_t while page
address was assumed.  This was performed by testing the complete PAE
merging patch on machine with > 4G of RAM enabled.

Reviewed by:    markj
Tested by:      pho
Sponsored by:   The FreeBSD Foundation
MFC after:      2 weeks
Differential revision:  https://reviews.freebsd.org/D18854

FreeBSD/src 343145head/sys/vm vm_reserv.c vm_phys.h

MI VM: Make it possible to set size of superpage at boot instead of compile time.

In order to allow single kernel to use PAE pagetables on i386 if
hardware supports it, and fall back to classic two-level paging
structures if not, superpage code should be able to adopt to either 2M
or 4M superpages size.  There I make MI VM structures large enough to
track the biggest possible superpage, by allowing architecture to
define VM_NFREEORDER_MAX and VM_LEVEL_0_ORDER_MAX constants.
Corresponding VM_NFREEORDER and VM_LEVEL_0_ORDER symbols can be
defined as runtime values and must be less than the _MAX constants.
If architecture does not define _MAXs, it is assumed that _MAX ==
normal constant.

Reviewed by:    markj
Tested by:      pho (as part of the larger patch)
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D18853

FreeBSD/src 343144head/sys/dev/nvdimm nvdimm_spa.c nvdimm_var.h

nvdimm: initialize SPA uuids statically.

The SPA ids are published numbers, so it's safe (if not a bit
annoying) to copy them into a source file.

Submitted by:   D Scott Phillips <d.scott.phillips at intel.com>
Sponsored by:   Intel Corporation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D18733

FreeBSD/src 343143head/sys/dev/nvdimm nvdimm.c nvdimm_var.h

nvdimm: add a driver for the NVDIMM root device

The NVDIMM root device is parent to the individual ACPI NVDIMM
devices.  Add a driver for the NVDIMM root device that can own
enumeration of NVDIMM devices as well as NVDIMM SPA ranges that the
system has.

Submitted by:   D Scott Phillips <d.scott.phillips at intel.com>
Sponsored by:   Intel Corporation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D18346

FreeBSD/src 343142stable 11, stable/11/sys/netpfil/ipfw ip_fw2.c

MFC 342925:
  Relax requirement to packet size of CARP protocol and remove version check.

  CARP shares protocol number 112 with VRRP (RFC 5798). And the size of
  VRRP packet may be smaller than CARP. ipfw_chk() does m_pullup() to at
  least sizeof(struct carp_header) and can fail when packet is VRRP. This
  leads to packet drop and message about failed pullup attempt.
  Also, RFC 5798 defines version 3 of VRRP protocol, this version number
  also unsupported by CARP and such check leads to packet drop.

  carp_input() does its own checks for protocol version and packet size,
  so we can remove these checks to be able pass VRRP packets.

  PR:          234207

FreeBSD/src 343141stable 12, stable/12/sys/netpfil/ipfw ip_fw2.c

MFC r342925:
  Relax requirement to packet size of CARP protocol and remove version check.

  CARP shares protocol number 112 with VRRP (RFC 5798). And the size of
  VRRP packet may be smaller than CARP. ipfw_chk() does m_pullup() to at
  least sizeof(struct carp_header) and can fail when packet is VRRP. This
  leads to packet drop and message about failed pullup attempt.
  Also, RFC 5798 defines version 3 of VRRP protocol, this version number
  also unsupported by CARP and such check leads to packet drop.

  carp_input() does its own checks for protocol version and packet size,
  so we can remove these checks to be able pass VRRP packets.

  PR:          234207

FreeBSD/src 343140stable/12/usr.sbin/cpucontrol cpucontrol.c intel.c

MFC r340421 (by cem), r342934:
cpucontrol(8): De-duplicate common update logic.

FreeBSD/src 343139stable 10, stable/10/sys/netinet6 ip6_output.c

MFC r342884:
Fix loopback traffic when using non-lo0 link local IPv6 addresses.

The loopback interface can only receive packets with a single scope ID,
namely the scope ID of the loopback interface itself. To mitigate this
packets which use the scope ID are appearing as received by the real
network interface, see "origifp" in the patch. The current code would
drop packets which are designated for loopback which use a link-local
scope ID in the destination address or source address, because they
won't match the lo0's scope ID. To fix this restore the network
interface pointer from the scope ID in the destination address for
the problematic cases. See comments added in patch for a more detailed
description.

This issue was introduced with route caching by karels@ .

Reviewed by:           bz (network)
Differential Revision:  https://reviews.freebsd.org/D18769
Sponsored by:          Mellanox Technologies

FreeBSD/src 343138stable 11, stable/11/sys/netinet6 ip6_output.c

MFC r342884:
Fix loopback traffic when using non-lo0 link local IPv6 addresses.

The loopback interface can only receive packets with a single scope ID,
namely the scope ID of the loopback interface itself. To mitigate this
packets which use the scope ID are appearing as received by the real
network interface, see "origifp" in the patch. The current code would
drop packets which are designated for loopback which use a link-local
scope ID in the destination address or source address, because they
won't match the lo0's scope ID. To fix this restore the network
interface pointer from the scope ID in the destination address for
the problematic cases. See comments added in patch for a more detailed
description.

This issue was introduced with route caching by karels@ .

Reviewed by:           bz (network)
Differential Revision:  https://reviews.freebsd.org/D18769
Sponsored by:          Mellanox Technologies

FreeBSD/src 343137stable 12, stable/12/sys/netinet6 ip6_output.c

MFC r342884:
Fix loopback traffic when using non-lo0 link local IPv6 addresses.

The loopback interface can only receive packets with a single scope ID,
namely the scope ID of the loopback interface itself. To mitigate this
packets which use the scope ID are appearing as received by the real
network interface, see "origifp" in the patch. The current code would
drop packets which are designated for loopback which use a link-local
scope ID in the destination address or source address, because they
won't match the lo0's scope ID. To fix this restore the network
interface pointer from the scope ID in the destination address for
the problematic cases. See comments added in patch for a more detailed
description.

This issue was introduced with route caching by karels@ .

Reviewed by:           bz (network)
Differential Revision:  https://reviews.freebsd.org/D18769
Sponsored by:          Mellanox Technologies

FreeBSD/src 343136stable 10, stable/10/sys/dev/usb usb_hub.c usb_request.c

MFC r342778:
Reduce timeout for reading the USB HUB port status to 1000ms and try to filter
out dead USB HUB devices by implementing an error counter, so that the USB
enumeration thread does not spend all its time reading from non-responding
devices, blocking user-space access in the end.

Tested by:      Matthias Apitz <guru at unixarea.de>
Sponsored by:   Mellanox Technologies

FreeBSD/src 343135stable 11, stable/11/sys/dev/usb usb_hub.c usb_request.c

MFC r342778:
Reduce timeout for reading the USB HUB port status to 1000ms and try to filter
out dead USB HUB devices by implementing an error counter, so that the USB
enumeration thread does not spend all its time reading from non-responding
devices, blocking user-space access in the end.

Tested by:      Matthias Apitz <guru at unixarea.de>
Sponsored by:   Mellanox Technologies

FreeBSD/src 343134stable 12, stable/12/sys/dev/usb usb_hub.c usb_request.c

MFC r342778:
Reduce timeout for reading the USB HUB port status to 1000ms and try to filter
out dead USB HUB devices by implementing an error counter, so that the USB
enumeration thread does not spend all its time reading from non-responding
devices, blocking user-space access in the end.

Tested by:      Matthias Apitz <guru at unixarea.de>
Sponsored by:   Mellanox Technologies

FreeBSD/src 343133stable 10, stable/10/sys/dev/usb usb_generic.c

MFC r342730:
Improve USB generic debug messages. Print process ID and name when opening
and closing usb/ugenX.Y character device nodes.

Sponsored by:   Mellanox Technologies

FreeBSD/src 343132stable 11, stable/11/sys/dev/usb usb_generic.c

MFC r342730:
Improve USB generic debug messages. Print process ID and name when opening
and closing usb/ugenX.Y character device nodes.

Sponsored by:   Mellanox Technologies

FreeBSD/src 343131stable 12, stable/12/sys/dev/usb usb_generic.c

MFC r342730:
Improve USB generic debug messages. Print process ID and name when opening
and closing usb/ugenX.Y character device nodes.

Sponsored by:   Mellanox Technologies

FreeBSD/src 343130head/sys/netpfil/pf if_pfsync.c

pf: fix pfsync breaking carp

Fix missing initialisation of sc_flags into a valid sync state on clone which
breaks carp in pfsync.

This regression was introduce by r342051.

PR:            235005
Submitted by:   smh at FreeBSD.org
Pointy hat to:  kp
MFC after:      3 days
Differential Revision:  https://reviews.freebsd.org/D18882

FreeBSD/src 343129head/sys/cam/ata ata_da.c

[ata] Add workaround for KingDian S200 SSD crash on receiving TRIM command

- Add ADA_Q_NO_TRIM quirk to be used with the device that falsely advertise TRIM support
- Add ADA_Q_NO_TRIM entry for KingDian S200 SSD

PR:            222802
Submitted by:   Bertrand Petit <bsdpr at phoe.frmug.org>
MFC after:      1 week

FreeBSD/src 343128head/tools/build/mk OptionalObsoleteFiles.inc

Add ypldap to the list of conditional obsolete files

ypldap should be removed during delete-old if WITHOUT_NIS flag is enabled

PR:            230727
Submitted by:   Dmitry Wagin <dmitry.wagin at ya.ru>
MFC after:      1 week

FreeBSD/src 343127head/usr.bin/compress compress.c

Fix descriptor/memory leak in compress(1) code

This is mostly a style fix since the code in question is not called multiple
times and doesn't have cummulative effect.

PR:            204953
Submitted by:   David Binderman <dcb314 at hotmail.com>
MFC after:      1 week

FreeBSD/src 343126stable 12, stable/12/sys/sys random.h param.h

MFC r342398:

Enable sys/random.h #include from C++

And bump __FreeBSD_version, just in case.

PR:            234180
Submitted by:   Ralf van der Enden <tremere AT cainites.net>

FreeBSD/src 343125head/sys/dev/ioat ioat.h

ioat(4): Set __result_use_check on ioat_acquire_reserve

Even M_WAITOK callers must check for failure.  For example, if the device is
quiescing, either due to automatic error-recovery induced reset, or due to
administrative detach, the routine will return ENXIO and the acquire
reference will not be held.  So, there is no mode in which it is safe to
assume the routine succeeds without checking.

Sponsored by:   Dell EMC Isilon

FreeBSD/src 343124head/stand/libsa printf.c stand.h

libsa: add asprintf()

asprintf() is a nice tool for string processing.

MFC after:      2 weeks

FreeBSD/src 343123head/stand/libsa/zfs zfsimpl.c

loader should ignore active multi_vdev_crash_dump feature on zpool

Since the loader zfs reader does not need to read the dump zvol, we can
just enable the feature.

illumos issue #9051 https://www.illumos.org/issues/9051

MFC after:      2 weeks

FreeBSD/src 343122head/usr.sbin/freebsd-update freebsd-update.sh

freebsd-update: Clarify unsupported release upgrade error message

Notify users that upgrading from -CURRENT or -STABLE is unsupported by
freebsd-update.

Also ensure --currently-running provides a correctly formatted release
(as done by -r).

PR:            234771
Submitted by:   Gerald Aryeetey <aryeeteygerald_rogers.com>
Reported by:    yuri
Reviewed by:    bcran
MFC after:      1 month
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D18803

FreeBSD/src 343121head/usr.sbin/nscd nscd.c

Workaround for nscd(8) failure with large entries.

It fixes a case where eg a 2KB group entry would take several seconds
to complete with cache enabled in nsswitch.conf.

MFC after:      2 weeks
Sponsored by:   Chalmers University of Technology
Differential Revision:  https://reviews.freebsd.org/D18392

FreeBSD/src 343120head/sys/x86/include specialreg.h, head/sys/x86/x86 identcpu.c

Add definitions for AMD Spectre/Meltdown CPUID information

No functional change, aside from printing recognized bits in CPU
identification.

The bits are documented in 111006-B "Indirect Branch Control Extension"[1] and
124441 "Speculative Store Bypass Disable."[2]

Notably missing (left as future work):
  * Integration with hw.spec_store_bypass_disable and hw_ssb_active flag,
    which are currently Intel-specific
  * Integration with hw_ibrs_active global flag, which are currently
    Intel-specific
  * SSB_NO integration in hw_ssb_recalculate()
  * Bhyve integration (PR 235010)

[1]:
https://developer.amd.com/wp-content/resources/111006-B_AMD64TechnologyIndirectBranchControlExtenstion_WP_7-18Update_FNL.pdf

[2]:
https://developer.amd.com/wp-content/resources/124441_AMD64_SpeculativeStoreBypassDisable_Whitepaper_final.pdf

PR:            235010 (related, but does not fix)
MFC after:      a week

FreeBSD/src 343119head/sys/arm/allwinner if_awg.c

Revert r343095

This was intended to fix the soft reset timeout on boot for OrangePi One/R1
with internal PHY, but seems to cause other problems later on due to soft
resetting around some state changes that may or may not make the NIC
non-functional.

Reverting this for now while a better solution is sought out.

FreeBSD/src 343118head/usr.sbin Makefile trim, head/usr.sbin/trim trim.c trim.8

Re-add new small tool trim(8) to delete contents for blocks
on devices using wear-leveling algorithms as a few weeks passed
after review and discussion of trim(8) ceased and
we still have no utility to perform the job.

Reviewed by:    hackers@
MFC after:      2 weeks

FreeBSD/src 343117head/usr.bin/cmp cmp.c

Fix handling of rights on stdio streams.

- Limit rights on stdio before opening input files.  Otherwise, open()
  may return one of the standard descriptors and we end up limiting
  rights such that we cannot read from one of the input files.
- Use caph_limit_stdio(), which suppresses EBADF, to ensure that
  we don't emit an error if one of the stdio streams is closed.
- Don't bother further limiting rights on stdin when stdin isn't going
  to be used.  Doing so correctly requires checking for a number of
  edge cases, and it doesn't provide any significant benefit.

PR:            234885
Reviewed by:    oshogbo
MFC after:      3 days
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D18860