FreeBSD/src 351218head/sys/arm/ti ti_sdhci.c

ti: sdhci: Correct voltage caps

ti,dual-volt property say that the eMMC support 1.8V and 3.3V not 3.0V
Use the correct caps for the mmc stack.
Note that the MMCHS_SD_CAPA register can only be written once after bootup
so if one is using a u-boot compiled with eMMC support (this is the default)
this code is a no-op but just in case someone have u-boot compiled without
eMMC support this make eMMC works when the kernel is booted.

MFC after:      1 week

FreeBSD/src 351217head/sys/arm/mv a37x0_gpio.c

arm64: a37x0_gpio: Use syscon instead of MMIO region

The fdt node for this driver is a simple-mfd and syscon compatible one
meaning that simplemfd will be the driver attached for it. The gpio driver
is attached to the 'gpio' subnode so use syscon_get_handle_default to
obtain the handle of the syscon from the parent device and use this
to read/write to the memory region.

MFC after:      1 week

FreeBSD/src 351216head/sbin/ping6 ping6.c

ping6: revert r350857

Some socket options require root privileges to set.  The old code did indeed
drop privileges at the earliest opportunity.

Submitted by:   Ján Sučan <sucanjan at gmail.com>
MFC after:      Never
Sponsored by:   Google, Inc. (Google Summer of Code 2019)
Differential Revision:  https://reviews.freebsd.org/D21319

FreeBSD/src 351215head/sys/kern vfs_mount.c

vfs: fix up r351193 ("stop always overwriting ->mnt_stat in VFS_STATFS")

fs-specific part of vfs_statfs routines only fill in small portion of the
structure. Previous code was always copying everything at a higher layer to
acoomodate it and this patch does the same.

'df' (no arguments) worked fine because the caller uses mnt_stat itself as the
target buffer, making all the copying a no-op for its own case.
'df /' and similar use a different consumer which passes its own buffer and
this is where you can run into trouble.

Reported by:    cy
Fixes: r351193
Sponsored by:   The FreeBSD Foundation

FreeBSD/src 351214head/sys/kern uipc_socket.c

Use TAILQ_FOREACH_SAFE() macro to avoid use after free in soclose().

PR:            239893
MFC after:      1 week

FreeBSD/src 351213head/sys/kern subr_trap.c

assert that td_lk_slocks is not leaked upon return from kernel

This is similar to checks for td_sx_slocks and td_rw_rlocks.
Although td_lk_slocks is an implementation detail, it still makes sense
to validate it.

MFC after:      1 week
Sponsored by:   Panzura

FreeBSD/src 351212head/tests/sys/netpfil/common pft_ping.py sniffer.py, head/tests/sys/netpfil/pf pft_ping.py sniffer.py

netpfil tests: Move pft_ping.py and sniffer.py to the common test directory

The pft_ping.py and sniffer.py tool is moved from tests/sys/netpfil/pf to
tests/sys/netpfil/common directory because these tools are to be used in
common for all the firewalls.

Submitted by:   Ahsan Barkati
Reviewed by:    kp, thj
Sponsored by:   Google, Inc. (GSoC 2019)
Differential Revision:  https://reviews.freebsd.org/D21276

FreeBSD/src 351211head/tests/sys/kern pdeathsig.c

sys.kern.pdeathsig.signal_delivered_ptrace: fix startup.

Inform D that C executed procctl(PROC_PDEATHSIG_CTL).  Otherwise D
might allow B to exit before C is set up to receive a signal on the
parent exit.  In this case, C waits forever for the signal and test
hangs.

PR:     237657
Reported and tested by: lwhsu
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week

FreeBSD/src 351210head/tests/sys/kern pdeathsig.c

sys.kern.pdeathsig.signal_delivered_ptrace: fix debugger detach

ptrace(PT_DETACH) requires stopped debuggee, otherwise it fails.  When
the call fails, the C process is left as debuggee of the process D,
and might be killed too early if process D exits occurs fast enough.

Since pipes are not closed in the forked children, this resulted in
the test hanging, since no write occured from C to wake A.

PR:     237657
Reported and tested by: lwhsu
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week

FreeBSD/src 351209stable 11, stable/11/cddl/contrib/opensolaris/cmd/zfs zfs_iter.c

MFC r350893: Allow ZVOL bookmarks to be listed recursively

PR:            197821

FreeBSD/src 351208stable 12, stable/12/cddl/contrib/opensolaris/cmd/zfs zfs_iter.c

MFC r350893: Allow ZVOL bookmarks to be listed recursively

PR:            197821

FreeBSD/src 351207stable 11, stable/11/share/man/man8 rc.8

MFC r350701,r350702: rc.8: add a reference to service(8)

FreeBSD/src 351206stable 12, stable/12/share/man/man8 rc.8

MFC r350701,r350702: rc.8: add a reference to service(8)

FreeBSD/src 351205head/sbin/fsck_msdosfs fat.c

Use calloc().

MFC after:      2 weeks

FreeBSD/src 351204head/sbin/fsck_msdosfs dir.c

Remove redundant check and wrong fix: fat.c checks already take care
about cluster chains.

Obtained from:  OpenBSD
MFC after:      2 weeks

FreeBSD/src 351203head/usr.sbin/periodic periodic.sh

periodic: replace "tty" with "test -t 0"

Apparently using tty for this purpose has been deprecated since 4.4 Lite.

Reviewed by:    cy
MFC after:      1 month
Differential Revision:  https://reviews.freebsd.org/D21318

FreeBSD/src 351202head RELNOTES

Add an entry to RELNOTES for r351201.
DeltaFile
+9-0head/RELNOTES
+9-01 files

FreeBSD/src 351201head/sys/kern vfs_default.c

Add a vop_stdioctl() that performs a trivial FIOSEEKDATA/FIOSEEKHOLE.

Without this patch, when an application performed lseek(SEEK_DATA/SEEK_HOLE)
on a file in a file system that does not have its own VOP_IOCTL(), the
lseek(2) fails with errno ENOTTY. This didn't seem appropriate, since
ENOTTY is not listed as an error return by either the lseek(2) man page
nor the POSIX draft for lseek(2).
A discussion on freebsd-current@ seemed to indicate that implementing
a trivial algorithm that returns the offset argument for FIOSEEKDATA and
returns the file's size for FIOSEEKHOLE was the preferred fix.
http://docs.FreeBSD.org/cgi/mid.cgi?CAOtMX2iiQdv1+15e1N_r7V6aCx_VqAJCTP1AW+qs3Yg7sPg9wA
The Linux kernel appears to implement this trivial algorithm as well.

This patch adds a vop_stdioctl() that implements this trivial algorithm.
It returns errors consistent with vn_bmap_seekhole() and, as such, will
still return ENOTTY for non-regular files.

I have proposed a separate patch that maps errors not described by the
lseek(2) man page nor POSIX draft to EINVAL. This patch is under separate
review.

Reviewed by:    kib
Relnotes:       yes
Differential Revision:  https://reviews.freebsd.org/D21299

FreeBSD/src 351200head/sys/amd64/amd64 mp_machdep.c, head/sys/dev/acpica acpi_pxm.c acpivar.h

Allocate all per-cpu datastructures in domain correct memory.

Reviewed by:    kib, gallatin (some objections)
Tested by:      pho
Sponsored by:   Netflix
Differential Revision:  https://reviews.freebsd.org/D21242

FreeBSD/src 351199head/usr.sbin/bluetooth/iwmbtfw iwmbt_hw.c

iwmbtfw(8): Fix compilation on platforms using gcc.

X-MFC with:     r351197

FreeBSD/src 351198head/sys/amd64/amd64 pmap.c, head/sys/amd64/include vmparam.h pmap.h

Allocate amd64's page array using pages and page directory pages from the
NUMA domain that the pages describe.  Patch original from gallatin.

Reviewed by:    kib
Tested by:      pho
Sponsored by:   Netflix
Differential Revision:  https://reviews.freebsd.org/D21252

FreeBSD/src 351197head/usr.sbin/bluetooth/iwmbtfw main.c iwmbt_hw.c

iwmbtfw: Firmware loader for Intel Wireless 8260 based Bluetooth USB devices

Currently supported models are: 8260, 8265, 9560, 9260 and 22161.
Firmware files can be installed with comms/iwmbt-firmware port.

PR:                   237083
Reviewed by:           hps, emax
X-MFC with:            r351196
Differential Revision:  https://reviews.freebsd.org/D21071

FreeBSD/src 351196head/sys/conf files, head/sys/modules/netgraph/bluetooth/ubt Makefile

ng_ubt(4): do not attach Intel Wireless 8260/8265 in bootloader mode.

Add helper function for synchronous execution of HCI commands at probe
stage and use this function to check firmware state of Intel Wireless
8260/8265 bluetooth devices found in many post 2016 year laptops.

Attempt to initialize FreeBSD bluetooth stack while such a device is in
bootloader mode locks the adapter hardly so it requires power on/off
cycle to restore.

This change blocks ng_ubt attachment unless operational firmware is
loaded thus preventing the lock up.

PR:                   237083
Reviewed by:           hps, emax
MFC after:             2 weeks
Differential Revision:  https://reviews.freebsd.org/D21071

FreeBSD/src 351195head/sys/fs/tmpfs tmpfs_vfsops.c, head/sys/kern vfs_default.c

Fix an issue with executing tmpfs binary.

Suppose that a binary was executed from tmpfs mount, and the text
vnode was reclaimed while the binary was still running.  It is
possible during even the normal operations since tmpfs vnode'
vm_object has swap type, and no references on the vnode is held.  Also
assume that the text vnode was revived for some reason.  Then, on the
process exit or exec, unmapping of the text mapping tries to remove
the text reference from the vnode, but since it went from
recycle/instantiation cycle, there is no reference kept, and assertion
in VOP_UNSET_TEXT_CHECKED() triggers.

Fix this by keeping a use reference on the tmpfs vnode for each exec
reference.  This prevents the vnode reclamation while executable map
entry is active.

Do it by adding per-mount flag MNTK_TEXT_REFS that directs
vop_stdset_text() to add use ref on first vnode text use, and
per-vnode VI_TEXT_REF flag, to record the need on unref in
vop_stdunset_text() on last vnode text use going away.  Set
MNTK_TEXT_REFS for tmpfs mounts.

Reported by:    bdrewery
Tested by:      sbruno, pho (previous version)
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week

FreeBSD/src 351194head/sys/compat/linux linux_misc.c, head/sys/kern vnode_if.src

Change locking requirements for VOP_UNSET_TEXT().

Require the vnode to be locked for the VOP_UNSET_TEXT() call.  This
will be used by the following bug fix for a tmpfs issue.

Tested by:      sbruno, pho (previous version)
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week

FreeBSD/src 351193head/sys/kern vfs_syscalls.c vfs_mount.c

vfs: stop always overwriting ->mnt_stat in VFS_STATFS

The struct is already populated on each mount (and remount). Fields are either
constant or not used by filesystem in the first place.

Some infrequently used functions use it to avoid having to allocate a new buffer
and are left alone.

The current code results in an avoidable copying single-threaded and significant
cache line bouncing multithreaded

While here deduplicate initial filling of the struct.

Reviewed by:    kib
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D21317

FreeBSD/src 351192head/usr.sbin/periodic periodic.sh

periodic: fix anticongestion for scripts run after security

Revision 316342, which introduced the anticongestion feature, failed to
consider that the periodic scripts are executed by a recursive invocation of
periodic.  The recursive invocation wrongly cleaned up a temporary file that
should've been cleaned up only by the original invocation.  The result is
that if the first script that requests an anticongestion sleep runs after
the security scripts, the sleep won't happen.

Fix this bug by delaying cleanup until the end of the original invocation.

PR:            236564
Submitted by:   Yasuhiro KIMURA <yasu at utahime.org>
Reviewed by:    imp
MFC after:      1 month

FreeBSD/src 351191head/sys/dev/random random_harvestq.c randomdev.c

random(4): Reorder configuration of random source modules

Move fast entropy source registration to the earlier
SI_SUB_RANDOM:SI_ORDER_FOURTH and move random_harvestq_prime after that.
Relocate the registration routines out of the much later randomdev module
and into random_harvestq.

This is necessary for the fast random sources to actually register before we
perform random_harvestq_prime() early in the kernel boot.

No functional change.

Reviewed by:    delphij, markjm
Approved by:    secteam(delphij)
Differential Revision:  https://reviews.freebsd.org/D21308

FreeBSD/src 351190head/share/man/man9 atomic.9, head/sys/i386/include atomic.h

i386: Implement atomic_load_64(9) and atomic_store_64(9).

Sponsored by:   The FreeBSD Foundation
MFC after:      1 week

FreeBSD/src 351189head/sys/dev/fdt simple_mfd.c

Fix bug introduced by r351184.
We should check the returned handle, not the pointer to it.

Noticed by:     ian
X-MFC with:     r351184
MFC after:      1 week

FreeBSD/src 351188head/sys/kern kern_synch.c, head/sys/sys refcount.h

Add a blocking wait bit to refcount.  This allows refs to be used as a simple
barrier.

Reviewed by:    markj, kib
Discussed with: jhb
Sponsored by:   Netflix
Differential Revision:  https://reviews.freebsd.org/D21254

FreeBSD/src 351187head/sys/arm64/rockchip rk_pinctrl.c

Improve rk_pinctrl driver:
- add support for 'output-low', 'output-high', 'output-low' and
  'output-enable' properties. These are use in RK3288 DT files
- add support for RK3288
- to reduce overall file size, use local macros for initialization
  of pinctrl description structures.

MFC after:      2 weeks

FreeBSD/src 351186head/sys/arm64/rockchip rk_i2c.c

Improve rk_i2c driver:
- Properly handle IIC_M_NOSTOP and IIC_M_NOSTART flags.
- add polling mode, so driver can be used even if interrupts are not
  enabled (this is necessary for proper support of PMICs).
- add support for RK3288

MFC after:      2 weeks

FreeBSD/src 351185head/sys/dev/mmc/host dwmmc.c dwmmc_var.h

Enhance support of extres in dwmmc driver.
Handle all clocks, regulators and resets defined by dwmmc bindings.

MFC after:      2 weeks

FreeBSD/src 351184head/sys/dev/extres/syscon syscon.c syscon_if.m, head/sys/dev/fdt simple_mfd.c

Add method for getting of syscon handle from parent device.

If simple multifuction device also provides syscon interface, its
childern should be able to consume it. Due to this:
- declare coresponding method in syscon interface
- implement it in simple multifunction device driver

MFC after:      1 week

FreeBSD/src 351183head/sys/vm vm_phys.c

Remove unnecessary debugging from r351181 that caused powerpc build to fail.

Tested by:      make universe TARGETS=powerpc

FreeBSD/src 351182head/sys/vm vm_phys.c

vm_phys_avail_find is only used on NUMA kernels.  Fix a build error.

FreeBSD/src 351181head/sys/vm vm_phys.c vm_page.c

Encapsulate phys_avail manipulation in a set of simple routines.  Add a
NUMA aware boot time memory allocator that will be used to allocate early
domain correct structures.  Code partially submitted by gallatin.

Reviewed by:    gallatin, kib
Tested by:      pho
Sponsored by:   Netflix
Differential Revision:  https://reviews.freebsd.org/D21251

FreeBSD/src 351180head/sys/ofed/include/rdma rdma_sdp.h

OFED: Fix accidental double-copy of rdma_sdp.h in r351176

The mistake came about like this: the first attempt to commit was blocked by
a pre-commit hook due to missing SVN tags.  svn revert doesn't delete new
files, I guess.  While reapplying the fixed diff, the non-empty target file
was just concatenated with the new contents?  Ugh. :-(

FreeBSD/src 351179head/release/picobsd/tinyware/simple_httpd simple_httpd.c

simple_httpd was not buildable for some time due to multiple missing
"static" keywords and -Werror,-Wmissing-variable-declarations

This change adds needed "static" so it builds again with WARNS?=6
No functional changes.

MFC after:      1 week

FreeBSD/src 351178head/sys/arm/mv a37x0_gpio.c

Revert r351130

This driver should use the syscon handle exposed by the parent simple-mfd one.

FreeBSD/src 351177head/sys/dev/fdt simple_mfd.c

Revert r351129

the point of syscon node is to avoid multiple device driver reading/writing
to the same area.

Reported by:    ian

FreeBSD/src 351176head/sys/ofed/drivers/infiniband/core ib_cma.c, head/sys/ofed/drivers/infiniband/ulp/sdp sdp.h

OFED: Unbreak SDP support in ibcore

This regression was introduced in the r326169 Linux v4.9 Infiniband upgrade.
Restore the functionality.

Reviewed by:    hselasky
Sponsored by:   Dell EMC Isilon
Differential Revision:  https://reviews.freebsd.org/D21298

FreeBSD/src 351175head/sys/kern kern_fork.c

fork: rework locking around do_fork

- move allproc lock into the func, it is of no use prior to it
- the code would lock p1 and p2 while holding allproc to partially
construct it after it gets added to the list. instead we can do the
work prior to adding anything.
- protect lastpid with procid_lock

As a side effect we do less work with allproc held.

Sponsored by:   The FreeBSD Foundation

FreeBSD/src 351174head/sys/kern kern_fork.c

fork: bump process count before checking for permission to cross the limit

The limit is almost never reached. Do the check only on failure to see if
we can override it.

No change in user-visible behavior.

Sponsored by:   The FreeBSD Foundation

FreeBSD/src 351173head/sys/kern kern_fork.c

fork: stop skipping < 100 ids on wrap around

Code doing this is commented with a claim that these IDs are occupied by
daemons, but that's demonstrably false. To an extent the range is used by init
and kernel processes (and on sufficiently big machines it indeed is fully
populated).

On a sample box 40-way box the highest id in the range is 63. On a different one
it is 23. Just use the range.

Sponsored by:   The FreeBSD Foundation

FreeBSD/src 351172head/sbin/ping6 Makefile

ping6: Raise WARNS level to 6

Submitted by:   Ján Sučan <sucanjan at gmail.com>
MFC after:      2 weeks
Sponsored by:   Google, inc. (Google Summer of Code 2019)
Differential Revision:  https://reviews.freebsd.org/D21260

FreeBSD/src 351171head/sbin/ping utils.c ping.c

ping: Move in_cksum() to a separate source file

This is a preparation step for adding ATF tests of in_cksum(), which has been
modified to operate on unaligned data. ping.o cannot be linked to the test
executable because both of them contain 'main' symbol.

Submitted by:   Ján Sučan <sucanjan at gmail.com>
MFC after:      2 weeks
Sponsored by:   Google, inc. (Google Summer of Code 2019)
Differential Revision:  https://reviews.freebsd.org/D21288

FreeBSD/src 351170head/sbin/ping6 ping6.c

ping6: Fix dnsdecode() bug introduced by r350859

Revision 350859 removed level of indirection that was needed for setting the
caller's `cp' pointer. dnsdecode() uses return value to indicate error or
success. It returns pointer to a buffer holding a decompressed DNS name or
NULL. The caller uses that value only to find out the result, not for accessing
the buffer.

We use the return value to propagate the new value of `cp' pointer to
the caller instead of using an output argument.

Submitted by:   Ján Sučan <sucanjan at gmail.com>
MFC after:      2 weeks
MFC-With:       350859
Sponsored by:   Google, Inc (Google Summer of Code 2019)
Differential Revision:  https://reviews.freebsd.org/D21266
DeltaFile
+28-10head/sbin/ping6/ping6.c
+28-101 files

FreeBSD/src 351169head/sys/ofed/drivers/infiniband/ulp/sdp sdp_cma.c

SDP: Fix brain-o from r351162

Lost in translation between different SDP stacks.

Reported by:    hselasky