FreeBSD/src 350207head/share/man/man9 VOP_PATHCONF.9

VOP_PATHCONF.9: correct the type of the retval argument

It was changed from int to register_t in r22521 and from register_t to long
in r328099, but the man page wasn't updated either time.

MFC after:      2 weeks

FreeBSD/src 350206head/sys/powerpc/aim mmu_oea64.c

powerpc64/mmu: Make moea64_pvo_enter() return if an entry already exists

Summary:
Instead of searching for a PVO entry before adding, take advantage of
the fact that RB_INSERT() returns NULL if it inserts, and the existing entry if
an entry exists, without inserting a new entry.  This saves an extra tree
traversal in the cases where the PVO does not exist.

Reviewed by:    luporl
Differential Revision: https://reviews.freebsd.org/D20944

FreeBSD/src 350205stable/12/sys/dev/nand nand_cdev.c

nand: create device with 0640 permission

rw-r----- is the usual/standard permissions for such devices.

Direct commit to stable/12 as this code has been removed in HEAD.

MFC after:      1 week
Sponsored by:   The FreeBSD Foundation

FreeBSD/src 350204head/share/man/man9 refcount.9, head/sys/sys refcount.h

Switch the rest of the refcount(9) functions to bool return type.

There are some explicit comparisions of refcount_release(9) result
with 0/1, which are fine.

Reviewed by:    markj, mjg
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D21014

FreeBSD/src 350203head/sys/dev/iicbus nxprtc.c

Add support for setting the aging/frequency-offset register via sysctl.

The 2127 and 2129 chips support a frequency tuning value in the range of
-7 through +8 PPM; add a sysctl handler to read and set the value.

FreeBSD/src 350202head/sys/arm64/arm64 pmap.c

With the introduction of software dirty bit emulation for managed mappings,
we should test ATTR_SW_DBM, not ATTR_AP_RW, to determine whether to set
PGA_WRITEABLE.  In effect, we are currently setting PGA_WRITEABLE based on
whether the dirty bit is preset, not whether the mapping is writeable.
Correct this mistake.

Reviewed by:    markj
X-MFC with:     r350004
Differential Revision:  https://reviews.freebsd.org/D21013

FreeBSD/src 350201head/lib/libcasper/services/cap_fileargs Makefile

Link fileargs_lstat.3.

Sponsored by:   The FreeBSD Foundation

FreeBSD/src 350200head/sys/sys refcount.h

Fix userspace build after r350199.

Sponsored by:   The FreeBSD Foundation
MFC after:      1 week

FreeBSD/src 350199head/sys/kern kern_descrip.c uipc_usrreq.c, head/sys/sys refcount.h file.h

Check and avoid overflow when incrementing fp->f_count in
fget_unlocked() and fhold().

On sufficiently large machine, f_count can be legitimately very large,
e.g. malicious code can dup same fd up to the per-process
filedescriptors limit, and then fork as much as it can.
On some smaller machine, I see
        kern.maxfilesperproc: 939132
        kern.maxprocperuid: 34203
which already overflows u_int.  More, the malicious code can create
transient references by sending fds over unix sockets.

I realized that this check is missed after reading
https://secfault-security.com/blog/FreeBSD-SA-1902.fd.html

Reviewed by:    markj (previous version), mjg
Tested by:      pho (previous version)
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D20947

FreeBSD/src 350198stable 12, stable/12/usr.sbin/bhyve net_backends.c

MFC r349952

usr.sbin/bhyve: close backend file descriptor during tap init error

Submitted by:   seanc
Coverity CID:   1402953
Reviewed by:    scottl, markj, aleksandr.fedorov -at- itglobal.com
Approved by:    vmaffione, jhb
Differential Revision:  https://reviews.freebsd.org/D20913

FreeBSD/src 350197stable 12, stable/12/usr.sbin/bhyve pci_virtio_net.c

MFC r349935

usr.sbin/bhyve: free resources when erroring out of pci_vtnet_init()

Submitted by:   seanc
Coverity CID:   1402978
Approved by:    vmaffione
Reviewed by:    jhb
Differential Revision:  https://reviews.freebsd.org/D20912

FreeBSD/src 350196stable 12, stable/12/usr.sbin/bhyve net_backends.c Makefile

MFC r349868

bhyve: net_backends.c: add missing __FBSDID

Reviewed by:    jhb
Differential Revision:  https://reviews.freebsd.org/D20883

FreeBSD/src 350195stable 12, stable/12/usr.sbin/bhyve net_utils.c net_backends.c

MFC r349867

bhyve: add missing license identifiers in net_utils and net_backend

Reviewed by:    jhb, markj, imp
Differential Revision:  https://reviews.freebsd.org/D20874

FreeBSD/src 350194head/share/misc organization.dot

Mark Felder has stepped down from portmgr and ports-secteam

FreeBSD/src 350193stable/12/usr.sbin/bhyve net_backends.c pci_virtio_net.c

MFC r349803

bhyve: abstraction for network backends

Bhyve can currently emulate two virtual NICs, namely virtio-net and e1000,
and connect to the host network through two backends, namely tap and netmap.
However, there is no interface between virtual NIC functionalities and
backend functionalities. As a result, the backend code is duplicated between
the two virtual NIC implementations and also within the same virtual NIC.
Also, e1000 cannot currently use netmap as a backend.
This patch introduces a network backend API between virtio-net/e1000 and
tap/netmap, to improve code reuse and add missing functionalities.
Virtual NICs and backends can negotiate virtio-net features, such as checksum
offload and TSO. If the backend supports the features, it will propagate this
information to the guest, so that the latter can make use of them. Currently,
only netmap VALE ports support the features, but support should be added to
tap in the future.

Reviewed by:    jhb, bryanv
Differential Revision:  https://reviews.freebsd.org/D20659

FreeBSD/src 350192stable 12, stable/12/sys/x86/iommu intel_drv.c

MFC r349988:
In dmar_find(), refuse to search for DMAR unit for non-PCI device.

PR:     239143

FreeBSD/src 350191head/sys/arm64/arm64 pmap.c

Introduce pmap_store(), and use it to replace pmap_load_store() in places
where the page table entry was previously invalid.  (Note that I did not
replace pmap_load_store() when it was followed by a TLB invalidation, even
if we are not using the return value from pmap_load_store().)

Correct an error in pmap_enter().  A test for determining when to set
PGA_WRITEABLE was always true, even if the mapping was read only.

In pmap_enter_l2(), when replacing an empty kernel page table page by a
superpage mapping, clear the old l2 entry and issue a TLB invalidation.  My
reading of the ARM architecture manual leads me to believe that the TLB
could hold an intermediate entry referencing the empty kernel page table
page even though it contains no valid mappings.

Replace a couple direct uses of atomic_clear_64() by the new
pmap_clear_bits().

In a couple comments, replace the term "paging-structure caches", which is
an Intel-specific term for the caches that hold intermediate entries in the
page table, with wording that is more consistent with the ARM architecture
manual.

Reviewed by:    markj
X-MFC after:    r350004
Differential Revision:  https://reviews.freebsd.org/D20998

FreeBSD/src 350190head/sys/powerpc/aim slb.c

powerpc: Remove an unnecessary #ifdef guard from slb.c

slb.c is only compiled for powerpc64, so no need for the #ifdef in this block.

FreeBSD/src 350189stable 11 12, stable/11/sys/contrib/ipfilter/netinet ip_state.c

MFC r349980:

Calculate the offset of the interface name using FR_NAME rather than
calclulating it "by hand". This improves consistency with the rest of
the code and is in line with planned fixes and other work.

FreeBSD/src 350188stable 12 11, stable/11/sys/contrib/ipfilter/netinet fil.c ip_fil.h

MFC r349979:

Recycle the unused FR_CMPSIZ macro which became orphaned in ipfilter 5
prior to its import into FreeBSD. This macro calculates the size to be
compared within the frentry structure. The ipfilter 4 version of the
macro calculated the compare size based upon the static size of the
frentry struct. Today it uses the ipfilter 5 method of calculating the
size based upon the new to ipfilter 5 fr_size value found in the
frentry struct itself.

No effective change in code is intended.

FreeBSD/src 350187head/sbin/fsck_ffs pass1.c

Treat any inode with bad content as unknown (i.e., ask if it should
be cleared).

Sponsored by: Netflix

FreeBSD/src 350186head/sbin/fsck_ffs suj.c

When running with journaled soft updates, some updated inodes were not
having their check hashes recomputed which resulted in spurious inode
check-hash errors when the system came back up after a crash.

Reported by:  Alan Somers
Sponsored by: Netflix

FreeBSD/src 350185head/sys/dev/iicbus nxprtc.c

Rewrite the nxprtc chip init to extend battery life by using power-saving
features offered by the chips.

For 2127 and 2129 chips, fix the detection of when chip-init is needed.  The
chip config needs to be reset whenever power was lost, but the logic was
wrong for 212x chips (it only worked for 8523).  Now the "oscillator
stopped" bit rather than the power manager mode is used to detect startup
after powerfail.

For all chips, disable the clock output pin.

For chips that have a timestamp/tamper-monitor feature, turn off monitoring
of the timestamp trigger pin.

The 8523, 2127, and 2129 chips have a "power manager" feature that offers
several options.  We've been using the default mode which enables
everything.  Now the code sets the power manager options to

 - direct-switch (when Vdd < Vbat, without extra threshold check)
 - no battery monitor
 - no external powerfail monitor

This reduces the current draw while running on battery from 1930nA to 880nA,
which should roughly double the lifespan of the battery under load.


    [5 lines not shown]

FreeBSD/src 350184head/libexec/rc/rc.d motd, head/share/man/man5 motd.5

motd: Generate from template to /var/run

Update login(1), its manual pages, similar utilities, and motd.5 to refer to
the new location.

Suggested by:   delphij@ (re: r349256)
Reviewed by:    bcr (manpages), delphij
Differential Revision:  https://reviews.freebsd.org/D20721

FreeBSD/src 350183head/sbin/swapon swapon.c

In trimming on startup, invoke swapon before closing the fd used for
trimming so that a geli device isn't detached before swapon is
invoked.

Submitted by: sigsys_gmail.com
Discussed with: alc
Approved by: markj (mentor)
Differential Revision:  https://reviews.freebsd.org/D21006

FreeBSD/src 350182head/sys/vm vm_page.c

Rename vm_page_{import,release}() to vm_page_zone_{import,release}().

I would like to use the name vm_page_release() for a different purpose,
and vm_page_{import,release}() are local to vm_page.c.

Reviewed by:    kib
MFC after:      1 week

FreeBSD/src 350181head/sys/powerpc/booke spe.c

powerpc/SPE: Enable SPV bit for EFSCFD instruction emulation

EFSCFD (floating point single convert from double) emulation requires saving
the high word of the register, which uses SPE instructions.  Enable the SPE
to avoid an SPV Unavailable exception.

MFC after:      1 week

FreeBSD/src 350180head/sys/dts/arm/overlays sun8i-h3-i2c0.dtso, head/sys/modules/dtb/allwinner Makefile

dtso: allwinner: Add an overlay for H3 i2c0

Most of the H3 boards don't enable i2c as it is unused.
Add an overlay so it's easier for user to use i2c device.

FreeBSD/src 350179head/lib/libutil expand_number.3

expand_number(3) parses suffixes, not prefixes.

While here, tidy the opening sentence a bit.

MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D20791

FreeBSD/src 350178head/sys/amd64/vmm/io vatpit.c

Improve the precision of bhyve's vPIT.

Use 'struct bintime' instead of 'sbintime_t' to manage times in vPIT
to postpone rounding to final results rather than intermediate
results.  In tests performed by Joyent, this reduced the error measured
by Linux guests by 59 ppm.

Smart OS bug:   https://smartos.org/bugview/OS-6923
Submitted by:   Patrick Mooney
Reviewed by:    rgrimes
Obtained from:  SmartOS / Joyent
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D20335

FreeBSD/src 350177head/contrib compiler-rt, head/contrib/libunwind/src assembly.h

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
8.0.1 final release r366581.  The only functional change is a fix for a
mismerge of upstream r360816, which properly restores the r2 register
when unwinding on PowerPC64 (See https://reviews.freebsd.org/D20337).

Relnotes:       yes
PR:            236062
MFC after:      3 days
X-MFC-With:     r349004

FreeBSD/src 350176vendor/llvm-openmp openmp-release_801-r366581

Tag LLVM openmp 8.0.1 release r366581.

FreeBSD/src 350175vendor/lldb lldb-release_801-r366581

Tag lldb 8.0.1 release r366581.

FreeBSD/src 350174vendor/lld lld-release_801-r366581

Tag lld 8.0.1 release r366581.

FreeBSD/src 350173vendor/llvm-libunwind libunwind-release_801-r366581

Tag LLVM libunwind 8.0.1 release r366581.

FreeBSD/src 350172vendor/llvm-libunwind/dist-release_80/src assembly.h

Vendor import of LLVM libunwind 8.0.1 release r366581:
https://llvm.org/svn/llvm-project/libunwind/tags/RELEASE_801/final at 366581

FreeBSD/src 350171vendor/libc++ libc++-release_801-r366581

Tag libc++ 8.0.1 release r366581.

FreeBSD/src 350170vendor/compiler-rt compiler-rt-release_801-r366581

Tag compiler-rt 8.0.1 release r366581.

FreeBSD/src 350169vendor/clang clang-release_801-r366581

Tag clang 8.0.1 release r366581.

FreeBSD/src 350168vendor/clang/dist-release_80/lib/Basic Version.cpp

Vendor import of clang 8.0.1 release r366581:
https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_801/final at 366581

FreeBSD/src 350167vendor/llvm llvm-release_801-r366581

Tag llvm 8.0.1 release r366581.

FreeBSD/src 350166head/sys/arm64/arm64 identcpu.c elf_machdep.c, head/sys/arm64/include elf.h cpu.h

arm64: Implement HWCAP

Add HWCAP support for arm64.
defines are the same as in Linux and a userland program can use
elf_aux_info to get the data.
We only save the common denominator for all cores in case the
big and little cluster have different support (this is known to
exists even if we don't support those SoCs in FreeBSD)

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

FreeBSD/src 350165stable 12, stable/12/share/man/man9 VOP_GETPAGES.9

MFC r349543

Fix VOP_PUTPAGES(9) in regards to the use of VM_PAGER_CLUSTER_OK

Submitted by:   Ka Ho Ng <khng300 at gmail.com>
Reviewed by:    mckusick
MFC after:      3 days
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D20695

FreeBSD/src 350164stable 12, stable/12/tests/sys/opencrypto cryptodev.py

MFC r349872:

Correct definitions in sys.opencrypto.runtests.main for 32bit platform

Reviewed by:    cem, jhb
MFC after:      3 days
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D20894

FreeBSD/src 350163projects/fuse2/tests/sys/fs/fusefs readdir.cc write.cc

fusefs: fix warnings in the tests reported by GCC

Sponsored by:   The FreeBSD Foundation

FreeBSD/src 350162head/sys/dev/sdhci sdhci_fdt.c

Add emmc support for Rockchip RK3399 SoC.
Tested on NanoPC-T4 board.

Reviewed by:    manu
Differential Revision:  https://reviews.freebsd.org/D20156

FreeBSD/src 350161head/sys/arm64/conf GENERIC, head/sys/arm64/rockchip rk3399_emmcphy.c

Add driver for Rockchip RK3399 eMMC PHY.
Tested on NanoPC-T4 board.

Reviewed by:    manu
Differential Revision:  https://reviews.freebsd.org/D20840

FreeBSD/src 350160head/lib/libc/tests/string wcsnlen_test.c

Avoid copying too much from the input string.

This avoids reading past the end of the static strings.  On a system
with bounds checking these tests fault.

Reviewed by:    asomers
Obtained from:  CheriBSD
MFC after:      1 week
Sponsored by:   DARPA, AFRL
Differential Revision:  https://reviews.freebsd.org/D21004

FreeBSD/src 350159head/share/mk bsd.cpu.mk

Make setting mips endian and ABI less verbose.

Allow ABI to be over ridden to allow (with other changes) programs to be
built targeting ABIs other than the default.  This is used in CheriBSD.

Reviewed by:    imp
Obtained from:  CheriBSD
MFC after:      1 week
Sponsored by:   DARPA, AFRL
Differential Revision:  https://reviews.freebsd.org/D21001

FreeBSD/src 350158head/lib/libproc proc_bkpt.c

Remove an unneeded temporary variable in two functions.

There is no need to convert an intptr_t to a long just to cast it to a
(void *).

Obtained from:  CheriBSD
MFC after:      1 week
Sponsored by:   DARPA, AFRL