FreeBSD/src 340449stable 11, stable/11/sbin/ipfw ipfw.8

MFC r338977:

Add description, parameters, options, sysctl and examples of using AQMs to ipfw man page. 
CoDel, PIE, FQ-CoDel and FQ-PIE AQM for Dummynet exist in FreeBSD 11 and 10.3.

Submitted by:   ralsaadi at swin.edu.au
Reviewed by:    AllanJude
Differential Revision:  https://reviews.freebsd.org/D12507

FreeBSD/src 340448head/sys/cam/ata ata_da.c, head/sys/cam/scsi scsi_da.c

Remove trailing white space in advance of other changes.

FreeBSD/src 340447stable 12, stable/12/sys/dev/amdtemp amdtemp.c

MFC r340426 (by cem)

amdtemp(4): Fix temperature reporting on AMD 2990WX

Update the AMD family 17h temperature reporting based on AMD Tech Doc 56255
OSRR, section 4.2.1.

For CPUS w/CUR_TEMP_RANGE_SEL set, scale the reported temperature into the
range -49..206; i.e., subtract 49°C.

Submitted by:   gallatin@
Reported by:    bcran@
Reviewed by:    cem (long ago)
Approved by:    re (kib)
Relnotes:       yes
Differential Revision:  https://reviews.freebsd.org/D16855

FreeBSD/src 340446stable 12, stable/12/sys/dev/amdsmn amdsmn.c

MFC r340425 (by cem)

amdsmn(4)/amdtemp(4): Attach to Ryzen 2 hostbridges

As reported, tested, and patch supplied by Johannes.

There may be future work to do to support multiple sensors, but for now, any
sensor at all is a strict improvement for Ryzen 2 systems.

PR:            228480
Submitted by:   Johannes Lundberg <johalun0 AT gmail.com> (earlier version)
Reported by:    deischen@, Johannes, and numerous others
Early MFC approved by:  cem
Approved by:    re (kib)
Relnotes:       yes

FreeBSD/src 340445head/sys/net iflib.c

Clear RX completion queue state veriables in iflib_stop()

iflib_stop() was not resetting the rxq completion queue state variables.
This meant that for any driver that has receive completion queues, after a
reinit, iflib would start asking what's available on the rx side starting at
whatever the completion queue index was prior to the stop, instead of at 0.

Submitted by:   pkelsey
Reported by:    pkelsey
MFC after:      3 days
Sponsored by:   Limelight Networks

FreeBSD/src 340444stable/12 UPDATING, stable/12/usr.sbin/ctm/ctm ctm.1 ctm.c

MFC S340428: Prepare move of ctm from base to a port (misc/ctm) by:
- Adding a note to UPDATING
- Adding a note to the history section of the manpage ctm.1
- Adding a message printed to STDERR to the ctm program

This version is meant for release in FreeBSD-12.0 and should remain in
FreeBSD-12 over its life-time.

A follow-up commit will remove ctm from -CURRENT after the MFC to 12
has happened.

Approved by:    re
Relnotes:       yes
Differential Revision:  https://reviews.freebsd.org/D17969

FreeBSD/src 340443head/sys/kern init_main.c

Initialize compatibility epoch tracker for thread0. Fixes
panics for drivers that call if_maddr_lock() during startup.

Reported by:    cy

FreeBSD/src 340442head/usr.sbin/mountd mountd.c

mountd has no way to configure the listen queue depth; rather than add a new
option, we pass -1 down to listen, which causes it to use the
kern.ipc.soacceptqueue sysctl.

Approved by:    mav
MFC after:      2 weeks
Sponsored by:   iXsystems Inc

FreeBSD/src 340441head/sys/x86/x86 msi.c

Revert r332735 and fix MSI-X to properly fail allocations when full.

The off-by-one errors in 332735 weren't actual errors and were
preventing the last MSI interrupt source from being used.  Instead,
the issue is that when all MSI interrupt sources were allocated, the
loop in msix_alloc() would terminate with 'msi' still set to non-null.
The only check for 'i' overflowing was in the 'msi' == NULL case, so
msix_alloc() would try to reuse the last MSI interrupt source instead
of failing.

Fix by moving the check for all sources being in use to just after the
loop.

Reviewed by:    kib, markj
MFC after:      1 month
Differential Revision:  https://reviews.freebsd.org/D17976

FreeBSD/src 340440head/usr.sbin/ntp/ntpd Makefile

Fix typo introduced in r340439 - s/ETN/ETC/

Reported by:    jhb, yuripv
Approved by:    eugen
MFC after:      3 days
X-MFC-With:     340439
Sponsored by:   Rubicon Communications, LLC (Netgate)

FreeBSD/src 340439head/usr.sbin/ntp/ntpd Makefile

Fix /etc/ntp permissions. According to mtree it must be 0700

Reviewed by:    imp
Approved by:    imp
MFC after:      3 days
Sponsored by:   Rubicon Communications, LLC (Netgate)
Differential Revision:  https://reviews.freebsd.org/D17973

FreeBSD/src 340438head/share/man/man4 Makefile

Hook mac_ntpd.4 up to the build.

PR:            232757
Submitted by:   Yasuhiro KIMURA <yasu at utahime.org>
MFC after:      3 days

FreeBSD/src 340437head ObsoleteFiles.inc

Fix the path to malloc_domain.9.

Reported by:    yuripv
MFC after:      3 days
Sponsored by:   The FreeBSD Foundation

FreeBSD/src 340436head/sys/dev/netmap if_vtnet_netmap.h, head/sys/dev/virtio/network if_vtnet.c if_vtnetvar.h

vtnet: fix netmap support

netmap(4) support for vtnet(4) was incomplete and had multiple bugs.
This commit fixes those bugs to bring netmap on vtnet in a functional state.

Changelist:
  - handle errors returned by virtqueue_enqueue() properly (they were
    previously ignored)
  - make sure netmap XOR rest of the kernel access each virtqueue.
  - compute the number of netmap slots for TX and RX separately, according to
    whether indirect descriptors are used or not for a given virtqueue.
  - make sure sglist are freed according to their type (mbufs or netmap
    buffers)
  - add support for mulitiqueue and netmap host (aka sw) rings.
  - intercept VQ interrupts directly instead of intercepting them in txq_eof
    and rxq_eof. This simplifies the code and makes it easier to make sure
    taskqueues are not running for a VQ while it is in netmap mode.
  - implement vntet_netmap_config() to cope with changes in the number of queues.

Reviewed by:    bryanv
Approved by:    gnn (mentor)
MFC after:      3 days
Sponsored by:   Sunny Valley Networks
Differential Revision:  https://reviews.freebsd.org/D17916

FreeBSD/src 340435head/sys/net iflib.c

Prevent POLA violation with TSO/CSUM offload

Ensure that any time CSUM_IP_TSO or CSUM_IP6_TSO is set that the corresponding
CSUM_IP6?_TCP / CSUM_IP flags are also set.

Rather than requireing drivers to bake-in an understanding that TSO implies
checksum offloads, make it explicit.

This change requires us to move the IFLIB_NEED_ZERO_CSUM implementation to
ensure it's zeroed for TSO.

Reported by:    Jacob Keller <jacob.e.keller at intel.com>
MFC after:      1 week
Sponsored by:   Limelight Networks
Differential Revision:  https://reviews.freebsd.org/D17801

FreeBSD/src 340434head/sys/net iflib.c

Fix leaks caused by ifc_nhwtxqs never being initialized

r333502 removed initialization of ifc_nhwtxqs, and it's not clear
there's a need to copy it into the struct iflib_ctx at all. Use
ctx->ifc_sctx->isc_ntxqs instead.

Further, iflib_stop() did not clear the last ring in the case where
isc_nfl != isc_nrxqs (such as when IFLIB_HAS_RXCQ is set). Use
ctx->ifc_sctx->isc_nrxqs here instead of isc_nfl.

Reported by:    pkelsey
Reviewed by:    pkelsey
MFC after:      3 days
Sponsored by:   Limelight Networks
Differential Revision:  https://reviews.freebsd.org/D17979

FreeBSD/src 340433head/contrib/smbfs/smbutil smbutil.1

smbutil(1): Improve mdoc formatting.

Also, make the path to the example configuration file absolute.

Reviewed by:    bcr
Approved by:    krion (mentor, implicit), mat (mentor, implicit)
Differential Revision:  https://reviews.freebsd.org/D17985

FreeBSD/src 340432head/sys/arm/conf ARMADA38X GENERIC, head/sys/arm/mv mv_spi.c files.arm7

Add the driver for the SPI controller on ARMADA38X.

Tested on Clearfog (Pro) and SG-3100.

Sponsored by:   Rubicon Communications, LLC (Netgate)

FreeBSD/src 340431head/lib/libc/sys getdirentries.2, head/share/man/man5 dir.5

Add d_off support for multiple filesystems.

The d_off field has been added to the dirent structure recently.
Currently filesystems don't support this feature.  Support has been
added and tested for zfs, ufs, ext2fs, fdescfs, msdosfs and unionfs.
A stub implementation is available for cd9660, nandfs, udf and
pseudofs but hasn't been tested.

Motivation for this feature: our usecase is for a userspace nfs server
(nfs-ganesha) with zfs.  At the moment we cache direntry offsets by
calling lseek once per entry, with this patch we can get the offset
directly from getdirentries(2) calls which provides a significant
speedup.

Submitted by:   Jack Halford <jack at gandi.net>
Reviewed by:    mckusick, pfg, rmacklem (previous versions)
Sponsored by:   Gandi.net
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D17917

FreeBSD/src 340430head/contrib/jemalloc/src extent.c

Pick 57553c3b1a5592dc4c03f3c6831d9b794e523865 from upstream:

    Avoid touching all pages in extent_recycle for debug build.

    We may have a large number of pages with *zero set (since they are populated on
    demand).  Only check the first page to avoid paging in all of them.

This makes it easy to compare performance with and without 'retain:true'.

Discussed with: jasone
Obtained from:  Qi Wang <interwq at gwu dot edu>
MFC after:      2 weeks
Sponsored by:   DARPA, AFRL

FreeBSD/src 340429head/lib/libc/locale c16rtomb.c c32rtomb.c

Fix WITHOUT_ICONV build after r340276.

Reported by:    olivier
Approved by:    kib (mentor, implicit)

FreeBSD/src 340428head UPDATING, head/usr.sbin/ctm/ctm ctm.1 ctm.c

Prepare move of ctm from base to a port (misc/ctm) by:
- Adding a note to UPDATING
- Adding a note to the history section of the manpage ctm.1
- Adding a message printed to STDERR to the ctm program

This version is meant for release in FreeBSD-12.0 and should remain in
FreeBSD-12 over its life-time.

A follow-up commit will remove ctm from -CURRENT after the MFC to 12
has happened.

Approved by:    imp, rgrimes, bcr (man-page)
MFC after:      3 days
Relnotes:       yes
Differential Revision:  https://reviews.freebsd.org/D17969

FreeBSD/src 340427projects/clang700-import/sbin/tunefs tunefs.c, projects/clang700-import/sys/compat/freebsd32 capabilities.conf

Merge ^/head r340368 through r340426.

FreeBSD/src 340426head/sys/dev/amdtemp amdtemp.c

amdtemp(4): Fix temperature reporting on AMD 2990WX

Update the AMD family 17h temperature reporting based on AMD Tech Doc 56255
OSRR, section 4.2.1.

For CPUS w/CUR_TEMP_RANGE_SEL set, scale the reported temperature into the
range -49..206; i.e., subtract 49°C.

Submitted by:   gallatin@
Reported by:    bcran@
Reviewed by:    me (long ago)
MFC after:      22.57 seconds
Relnotes:       yea
Differential Revision:  https://reviews.freebsd.org/D16855

FreeBSD/src 340425head/sys/dev/amdsmn amdsmn.c, head/sys/dev/amdtemp amdtemp.c

amdsmn(4)/amdtemp(4): Attach to Ryzen 2 hostbridges

As reported, tested, and patch supplied by Johannes.

There may be future work to do to support multiple sensors, but for now, any
sensor at all is a strict improvement for Ryzen 2 systems.

PR:            228480
Submitted by:   Johannes Lundberg <johalun0 AT gmail.com> (earlier version)
Reported by:    deischen@, Johannes, and numerous others
MFC after:      3.72 days

FreeBSD/src 340424head/sys/compat/freebsd32 capabilities.conf syscalls.conf, head/sys/kern makesyscalls.sh

Use the main capabilities.conf for freebsd32.

Allow the location of capabilities.conf to be configured.

Also allow a per-abi syscall prefix to be configured with the
abi_func_prefix syscalls.conf variable and check syscalls against
entries in capabilities.conf with and without the prefix amended.

Take advantage of these two features to allow use shared capabilities.conf
between the default syscall vector and the freebsd32 compatability
layer.  We've been inconsistent about keeping the two in sync as
evidenced by the bugs fixed in r340294.  This eliminates that problem
going forward.

Reviewed by:    kib
Obtained from:  CheriBSD
Sponsored by:   DARPA, AFRL
Differential Revision:  https://reviews.freebsd.org/D17932

FreeBSD/src 340423head/sys/kern kern_thread.c

Fix build on some architectures after r340413. On amd64 epoch.h
appeared to be included implicitly.

FreeBSD/src 340422head/sbin/dump traverse.c main.c

Fix build break from dump incompatibility I introduced in -r340411

Pointy-hat to: mckusick

FreeBSD/src 340421head/usr.sbin/cpucontrol cpucontrol.c intel.c

cpucontrol(8): De-duplicate common update logic

Every µcode-updater must open the cpucontrol devfs node RDWR, open a
firmware file, validate the FW file has a positive length, mmap it, etc.
De-duplicate that identical logic between every individual platform.

Also, constify references to the readonly-mapped firmware files while here.

Sponsored by:   Dell EMC Isilon

FreeBSD/src 340420head/sys/kern subr_epoch.c

epoch(9) revert r340097 - no longer a need for multiple sections per cpu

I spoke with Samy Bahra and recent changes to CK to make ck_epoch_call and
ck_epoch_poll not modify the record have eliminated the need for this.

FreeBSD/src 340419head/sys/kern subr_epoch.c

style(9), mostly adjusting overly long lines.

FreeBSD/src 340418head/sys/dev/tws tws_cam.c tws_services.h

Remove support for versions prior to FreeBSD 7.0 from twa(4)

This was for pre-7.0 CAM support. Neither the CAM nor the busdma
changes over the years have not been ifdef'd. The code cannot build
on 6.x anymore. Support for 6.4 ended in 2010, so remove them.

FreeBSD/src 340417head/sys/kern subr_epoch.c genoffset.c

With epoch not inlined, there is no point in using _lite KPI. While here,
remove some unnecessary casts.

FreeBSD/src 340416head/sbin/dump traverse.c main.c

Plug build break after r340411.

FreeBSD/src 340415head/sys/kern subr_epoch.c, head/sys/sys epoch.h

The dualism between epoch_tracker and epoch_thread is fragile and
unnecessary. So, expose CK types to kernel and use a single normal
structure for epoch_tracker.

Reviewed by:    jtl, gallatin

FreeBSD/src 340414head/sys/amd64/conf NOTES

Add ZFS to amd64 NOTES to catch future breakage of static linking

FreeBSD/src 340413head/sys/kern subr_epoch.c kern_thread.c, head/sys/net if.c if_var.h

For compatibility KPI functions like if_addr_rlock() that used to have
mutexes but now are converted to epoch(9) use thread-private epoch_tracker.
Embedding tracker into ifnet(9) or ifnet derived structures creates a non
reentrable function, that will fail miserably if called simultaneously from
two different contexts.
A thread private tracker will provide a single tracker that would allow to
call these functions safely. It doesn't allow nested call, but this is not
expected from compatibility KPIs.

Reviewed by:    markj

FreeBSD/src 340412head/sys/dev/nvme nvme_ns.c

Use atomic_load_acq_int() here too to poll done, ala r328521

FreeBSD/src 340411head/lib/libufs getinode.3, head/sbin/ffsinfo ffsinfo.c

In preparation for adding inode check-hashes, clean up and
document the libufs interface for fetching and storing inodes.
The undocumented getino / putino interface has been replaced
with a new getinode / putinode interface.

Convert the utilities that had been using the undocumented
interface to use the new documented interface.

No functional change (as for now the libufs library does not
do inode check-hashes).

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

FreeBSD/src 340410head/sys/kern kern_rwlock.c kern_mutex.c

locks: plug warnings about unitialized variables

They only showed up after I redefined LOCKSTAT_ENABLED to 0.

doing_lockprof in mutex.c is a real (but harmless) bug. Should the
value be non-zero it will do checks for lock profiling which would
otherwise be skipped.

state in rwlock.c is a wart from the compiler, the value can't be
used if lock profiling is not enabled.

Sponsored by:   The FreeBSD Foundation

FreeBSD/src 340409head/sys/kern kern_rwlock.c kern_sx.c

Make no assertions about lock state when the scheduler is stopped.

Change the assert paths in rm, rw, and sx locks to match the lock
and unlock paths.  I did this for mutexes in r306346.

Reported by:    Travis Lane <tlane at isilon.com>
MFC after:      2 weeks
Sponsored by:   Dell EMC Isilon

FreeBSD/src 340408head/lib/libnv common_impl.h msgio.c, head/lib/libnv/tests nvlist_send_recv_test.c

Ensure that libnv can be used when kern.trap_enotcap=1.

libnv used fcntl(fd, F_GETFL) to test whether fd is a valid file
descriptor.  Aside from being racy, this check requires CAP_FCNTL
rights on fd.  Instead, use fcntl(fd, F_GETFD), which does not require
any capability rights.

Also remove some redundant fd_is_valid() checks to avoid extra system
calls; in many cases we were performing this check immediately before
dup()ing the descriptor.

Reviewed by:    cem, oshogbo (previous version)
MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D17963

FreeBSD/src 340407head Makefile.inc1, head/release/scripts make-manifest.sh

In followup to r340406, remove doc from the EXTRA_DISTRIBUTIONS
list and remaining references from the script used to create the
MANIFEST file used by bsdinstall(8).

No MFC is planned at this time.

Sponsored by:   The FreeBSD Foundation

FreeBSD/src 340406head/release/scripts make-manifest.sh

The roff ascii.gz documentation installed to /usr/share/doc
was removed in r318881 when roff was removed from the base
system.

This results in the doc.txz distribution set containing a
single directory (./) which is empty.

Remove the "Additional documentation" option from the menu
selection of bsdinstall(8), as the plain-text documentation
installed in /usr/share/doc is installed as part of the
packageworld target.

The doc entry has not been removed from EXTRA_DISTRIBUTIONS
in Makefile.inc1, in case its removal triggers an issue with
freebsd-update(8), which is currently aware of the world/doc
component, so the empty doc.txz continues to be created as
a precaution.

Noticed by:     rgrimes
MFC after:      2 days
MFC before:     12.0-RC1
Sponsored by:   The FreeBSD Foundation

FreeBSD/src 340405head/sys/vm uma_core.c uma_int.h

Add accounting to per-domain UMA full bucket caches.

In particular, track the current size of the cache and maintain an
estimate of its working set size.  This will be used to decide how
much to shrink various caches when the kernel attempts to reclaim
pages.  As a secondary effect, it makes statistics aggregation (done
by, e.g., vmstat -z) cheaper since sysctl_vm_zone_stats() no longer
needs to iterate over lists of cached buckets.

Discussed with: alc, glebius, jeff
Tested by:      pho (previous version)
MFC after:      1 month
Differential Revision:  https://reviews.freebsd.org/D16666

FreeBSD/src 340404head/sys/kern subr_epoch.c, head/sys/sys epoch_private.h epoch.h

Uninline epoch(9) entrance and exit. There is no proof that modern
processors would benefit from avoiding a function call, but bloating
code. In fact, clang created an uninlined real function for many
object files in the network stack.

- Move epoch_private.h into subr_epoch.c. Code copied exactly, avoiding
  any changes, including style(9).
- Remove private copies of critical_enter/exit.

Reviewed by:    kib, jtl
Differential Revision:  https://reviews.freebsd.org/D17879

FreeBSD/src 340403stable/11/sys/dev/mpr mpr_pci.c, stable/11/sys/dev/mps mps_pci.c

Fix a regression from prior to 11.2 that caused MSI (not MSI-X) interrupt
allocation to fail.  While here, refactor the code so that it's more clear
and less likely to break in the future.  This is not an MFC due to the code
in 12/head being very different, but it follows the latter's structure
more closely than before.

Reported by:    Harry Schmalzbauer

FreeBSD/src 340402head/sys/kern subr_blist.c, head/sys/sys blist.h

Allow allocations across meta boundaries.

Remove restrictions that prevent allocation requests to cross the
boundary between two meta nodes.

Replace the bmu_avail field in meta nodes with a bitmap that identifies
which subtrees have some free memory, and iterate over the nonempty
subtrees only in blst_meta_alloc.  If free memory is scarce, this should
make searching for it faster.

Put the code for handling the next-leaf allocation in a separate
function.  When taking blocks from the next leaf empties the leaf, be
sure to clear the appropriate bit in its parent, and so on, up to the
least-common ancestor of this leaf and the next.

Eliminate special terminator nodes, and rely instead on the fact that
there is a 0-bit at the end of the bitmask at the root of the tree that
will stop a meta_alloc search, or a next-leaf search, before the search
falls off the end of the tree. Make sure that the tree is big enough to
have space for that 0-bit.

Eliminate special all-free indicators.  Lazy initialization of subtrees
stands in the way of having an allocation span a meta-node boundary, so
a subtree of all free blocks is not treated specially.  Subtrees of
all-allocated blocks are still recognized by looking at the bitmask at

    [9 lines not shown]

FreeBSD/src 340401stable/12/share/man/man9 contigmalloc.9, stable/12/sys/dev/hwpmc hwpmc_mod.c

MFC r339927:
Add malloc_domainset(9) and _domainset variants to other allocator KPIs.

Approved by:    re (gjb)

FreeBSD/src 340400head/sys/riscv/include cpu.h

RISC-V: Implement get_cyclecount(9).

Add the missing implementation for get_cyclecount(9) on RISC-V by
reading the cycle CSR.

Submitted by:   Mitchell Horne <mhorne063 at gmail.com>
Reviewed by:    jhb
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D17953