FreeBSD/src 349451head/contrib/ipfilter/tools ipmon.c

Return a return code scripts might expect. I missed this while
reviewing and rewriting a patch in PR/238816.

PR:            238816
Reported by:    rgrimes@
Pointy hat to:  cy@
MFC after:      1 week
X-MFC with:     r349450

FreeBSD/src 349450head/contrib/ipfilter/tools ipmon.c

Update usage() to refect the current state of ipmon.

PR:            238816
MFC after:      1 week

FreeBSD/src 349449head/sbin/ipf/ipmon Makefile, head/tools/build/mk

Add the ipmon.5 man page.

PR/238816 initially addressed updates to usage() however the PR has
morphed into a shopping list of updates to usage() and man pages.

PR:            238816 (I added to the list during discussion)
MFC after:      1 week

FreeBSD/src 349448head/contrib/ipfilter/man ipmon.8

Fix a typo.

PR/238816 initially addressed updates to usage() however it has now
become a shopping list of fixes to ipmon man pages and usage().

PR:            238816
MFC after:      3 days

FreeBSD/src 349447projects/fuse2/sys/fs/fuse fuse_vnops.c

fusefs: fix some memory leaks

Fix memory leaks relating to FUSE_BMAP and FUSE_CREATE.  There are still
leaks relating to FUSE_INTERRUPT, but they'll be harder to fix since the
server is legally allowed to never respond to a FUSE_INTERRUPT operation.

Sponsored by:   The FreeBSD Foundation

FreeBSD/src 349446head/lib/libsecureboot vets.c readfile.c, head/lib/libsecureboot/h libsecureboot.h

libsecureboot: allow OpenPGP support to be dormant

Since we can now add OpenPGP trust anchors at runtime,
ensure the latent support is available.

Ensure we do not add duplicate keys to trust store.

Also allow reporting names of trust anchors added/revoked

We only do this for loader and only after initializing trust store.
Thus only changes to initial trust store will be logged.

Reviewed by:    stevek
MFC after:      1 week
Differential Revision:

FreeBSD/src 349445projects/fuse2/tests/sys/fs/fusefs

fusefs: tighten expectations in mmap tests

In r349378 I fixed mmap's habit of reading more data than was available.

Sponsored by:   The FreeBSD Foundation

FreeBSD/src 349444head/sys/arm64/arm64 freebsd32_machdep.c

In get_fpcontext32() and set_fpcontext32(), we can't just use memcpy() to
copy the VFP registers.
arvm7 VFP uses 32 64bits fp registers (but those could be used in pairs to
make 16 128bits registers), while aarch64 uses 32 128bits fp registers, so
we have to copy the value of each register.

FreeBSD/src 349443stable 11 12, stable/11/sys/amd64/vmm vmm_instruction_emul.c

MFC: r347065 (by jhb) Emulate the "ADD reg, r/m" instruction (opcode 03H).

OVMF's flash variable storage is using add instructions when indexing
the variable store bootrom location.

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

Revert one of the changes from r349323.  Specifically, undo the change
that replaced a pmap_invalidate_page() with a dsb(ishst) in
pmap_enter_quick_locked().  Even though this change is in principle
correct, I am seeing occasional, spurious bus errors that are only
reproducible without this pmap_invalidate_page().  (None of adding an
isb, "upgrading" the dsb to wait on loads as well as stores, or
disabling superpage mappings eliminates the bus errors.)  Add an XXX
comment explaining why the pmap_invalidate_page() is being performed.

Discussed with:      andrew, markj

FreeBSD/src 349441head/sys/amd64/vmm vmm_instruction_emul.c

Emulate the "TEST r/m{16,32,64}, imm{16,32,32}" instructions (opcode F7H).

This adds emulation for:
        test r/m16, imm16
        test r/m32, imm32
        test r/m64, imm32 sign-extended to 64

OpenBSD guests compiled with clang 8.0.0 use TEST directly against a
Local APIC register instead of separate read via MOV followed by a
TEST against the register.

PR:            238794
Submitted by:   jhb
Reported by:    Jason Tubnor jason at
Tested by:      Jason Tubnor jason at
Reviewed by:    markj, Patrick Mooney patrick.mooney at
MFC after:      3 days
Differential Revision:

FreeBSD/src 349440projects/fuse2/tests/sys/fs/fusefs

fusefs: annotate deliberate file descriptor leaks in the tests

closing a file descriptor causes FUSE activity that is superfluous to the
purpose of most tests, but would nonetheless require matching expectations.
Rather than do that, most tests deliberately leak file descriptors instead.
This commit moves the leakage from each test into two trivial functions:
leak and leakdir.  Hopefully Coverity will only complain about those
functions and not all of their callers.

Sponsored by:   The FreeBSD Foundation

FreeBSD/src 349439head/sbin/dhclient options.c

Free DHCP options with length zero.

Otherwise they are leaked, allowing an attacker to trigger memory

This is options.c rev. 1.70 from OpenBSD.

admbugs:        552
Obtained from:  OpenBSD
MFC after:      3 days

FreeBSD/src 349438head/sbin/dhclient packet.c

Avoid a divide-by-zero when bad checksum counters overflow.

A mixture of IP or UDP packets with valid and invalid checksum could
cause {ip,udp}_packets_bad_checksum to wrap around to 0, resulting
in a division by zero.

This is packet.c rev. 1.27 from OpenBSD.

admbugs:        552
Obtained from:  OpenBSD
MFC after:      3 days

FreeBSD/src 349437projects/fuse2/share/man/man5 fusefs.5

fusefs.5: remove deleted sysctls from man page

Sponsored by:   The FreeBSD Foundation

FreeBSD/src 349436projects/fuse2/tests/sys/fs/fusefs

fusefs: run the io tests with direct io, too

Now the io tests are run in all cache modes.  The fusefs test suite can now
get adequate coverage without changing the value of
vfs.fusefs.data_cache_mode, which is only needed for legacy file systems

Sponsored by:   The FreeBSD Foundation

FreeBSD/src 349435stable 11, stable/11/usr.sbin/bhyve rfb.c

MFC r349196:
Make zlib encoding messages idempotent.

PR:     238333

FreeBSD/src 349434stable 12, stable/12/usr.sbin/bhyve rfb.c

MFC r349196:
Make zlib encoding messages idempotent.

PR:     238333

FreeBSD/src 349433head/sys/dev/ow owc_gpiobus.c

fix up r349428, fix a typo made during "fdt" removal

Reported by:    ian
MFC after:      11 days

FreeBSD/src 349432head/sys/amd64/sgx sgx.c, head/sys/vm vm_page.c vm_object.c

Add a return value to vm_page_remove().

Use it to indicate whether the page may be safely freed following
its removal from the object.  Also change vm_page_remove() to assume
that the page's object pointer is non-NULL, and have callers perform
this check instead.

This is a step towards an implementation of an atomic reference counter
for each physical page structure.

Reviewed by:    alc, dougm, kib
MFC after:      1 week
Sponsored by:   Netflix
Differential Revision:

FreeBSD/src 349431projects/fuse2/sys/fs/fuse fuse_ipc.h fuse_internal.c, projects/fuse2/tests/sys/fs/fusefs

fusefs: implement protocol 7.23's FUSE_WRITEBACK_CACHE option

As of protocol 7.23, fuse file systems can specify their cache behavior on a
per-mountpoint basis.  If they set FUSE_WRITEBACK_CACHE in
fuse_init_out.flags, then they'll get the writeback cache.  If not, then
they'll get the writethrough cache.  If they set FOPEN_DIRECT_IO in every
FUSE_OPEN response, then they'll get no cache at all.

The old vfs.fusefs.data_cache_mode sysctl is ignored for servers that use
protocol 7.23 or later.  However, it's retained for older servers,
especially for those running in jails that lack access to the new protocol.

This commit also fixes two other minor test bugs:
* WriteCluster:SetUp was using an uninitialized variable.
* Read.direct_io_pread wasn't verifying that the cache was actually

Sponsored by:   The FreeBSD Foundation

FreeBSD/src 349430stable/12/share/man/man4 pwmc.4, stable/12/sys/arm/ti/am335x am335x_ehrpwm.c

MFC r343826, r346698, r349057-r349060, r349073-r349077, r349080-r349086, r349088,
    r349091-r349097, r349115, r349119, r349130-r349132, r349143-r349145,
    r349164-r349168, r349174, r349269-r349273

r343826 by yuripv:
pwm.8: fix markup in synopsis, add -f description

r346698 by manu:
arm: allwinner: aw_pwm: compile it as module too

Allow pwm(9) components to be selected individually, while 'device pwm'
still includes it all.

In detach(), check for failure of bus_generic_detach(), only release
resources if they got allocated (because detach() gets called from attach()
to handle various failures), and delete the pwmbus child if it got created.

Don't call pwmbus_attach_bus(), because it may not be present if this
driver is compiled into the kernel but pwmbus will be loaded as a module
when needed (and because of that, pwmbus_attach_bus() is going away in
the near future).  Instead, just directly do what that function did:
register the fdt xfef handle, and attach the pwmbus.

    [222 lines not shown]

FreeBSD/src 349429releng 11.3, releng/11.3/sys/netpfil/ipfw/nat64 nat64lsn.c

Merge from stable/11:
  Fix the uninitialized use of source IPv6 address in NAT64LSN.

  This code is already refactored in head/, but due to the missing
  epoch(9) support it is impossible to merge. So, it is direct commit to

  Reported by:  Patrick M. Hausen <hausen punkt de>
  Tested by:    Patrick M. Hausen <hausen punkt de>
Approved by: re (kib, gjb)

FreeBSD/src 349428head/sys/dev/ow owc_gpiobus.c

owc_gpiobus: clean / fix up the driver module things

"fdt" is removed from the driver module name as the driver does not
require FDT and can work very well on hints based systems.

A module dependency is added for gpiobus.  Without that owc cannot
resolve symbols in gpiobus if both are loaded as kernel modules.

Finally, a driver module module version is added.

Reviewed by:    imp
MFC after:      11 days

FreeBSD/src 349427head/sys/amd64/amd64 pmap.c

amd64 pmap: Fix pkru handling in pmap_remove().

When pmap_pkru_on_remove() is called, the sva argument value was
advanced.  Clear PKRU earlier when sva still specifies the start of
the region.

Noted and reviewed by:  alc
Sponsored by:   The FreeBSD Foundation
MFC after:      3 days

FreeBSD/src 349426head/sys/arm64/arm64 machdep.c

Fix debugging of 32bits arm binaries on arm64.

In set_regs32()/fill_regs32(), we have to get/set SP and LR from/to
tf_x[13] and tf_x[14].
set_regs() and fill_regs() may be called for a 32bits process, if the process
is ptrace'd from a 64bits debugger. So, in set_regs() and fill_regs(), get
or set PC and SPSR from where the debugger expects it, from tf_x[15] and

FreeBSD/src 349425stable 12, stable/12/lib/libcapsicum capsicum_helpers.3 capsicum_helpers.h

MFC r340130, r340134:

r340130: (by oshogbo)

libcapsicum: Introduce caph_{rights,ioctls,fcntls}_limit

The idea behind those functions is not to force consumers to remember that there
is a need to check errno on failure. We already have a caph_enter(3) function
which does the same for cap_enter(2).

r340134: (by oshogbo)

Fix a recusive call introduce in the r340130.

FreeBSD/src 349424head/contrib/elftoolchain/libdwarf libdwarf_attr.c

libdwarf: Use the cached strtab pointer when reading string attributes.

Previously we would perform a linear search of the DWARF section
list for ".debug_str".  However, libdwarf always caches a pointer to
the strtab image in its debug descriptor.  Using it gives a modest
performance improvement when iterating over the attributes of each

Reviewed by:    emaste
MFC after:      1 week
Sponsored by:   The FreeBSD Foundation
Differential Revision:

FreeBSD/src 349423head/contrib/elftoolchain/elfcopy sections.c

elfcopy: Provide a size hint when creating the section string table.

Use the input file's .shstrtab size as the hint if it exists.  This
gives a small performance improvement when processing files with
many sections.

Reviewed by:    emaste
MFC after:      1 week
Sponsored by:   The FreeBSD Foundation
Differential Revision:

FreeBSD/src 349422head/contrib/elftoolchain/libelftc elftc_string_table_create.3

libelftc: Fix the documented prototype for elftc_string_table_destroy().

MFC after:      1 week
Sponsored by:   The FreeBSD Foundation

FreeBSD/src 349421head/contrib/elftoolchain/libelftc elftc_string_table.c elftc_string_table_create.3

libelftc: Consistently use size_t for string table offsets and sizes.

Reviewed by:    emaste
MFC after:      1 week
Sponsored by:   The FreeBSD Foundation
Differential Revision:

FreeBSD/src 349420head/contrib/elftoolchain/libelftc elftc_string_table.c

libelftc: Micro-optimize string table insertion.

The string's length is already known, so use memcpy() instead of
strcpy() to add it to the string table image.

Reviewed by:    emaste
MFC after:      1 week
Sponsored by:   The FreeBSD Foundation
Differential Revision:

FreeBSD/src 349419head/sys/ufs/ffs ffs_softdep.c

Remove references to splbio in ffs_softdep.c.

Assert that the per-mountpoint softdep mutex is held in modified
functions that do not already have this assertion.  No functional
change intended.

Reviewed by:    kib, mckusick (previous version)
MFC after:      1 week
Sponsored by:   The FreeBSD Foundation
Differential Revision:

FreeBSD/src 349418head/sys/conf files.amd64

Fix qlxgbe(4) static build.

MFC after:      2 weeks

FreeBSD/src 349417head/libexec/rtld-elf debug.h rtld_printf.h

Use rtld_putstr() instead of write() for the rtld msg() macro

This removes an unnecessary libc dependency from rtld.
See for more details.

FreeBSD/src 349416head/lib/libc/stdlib realpath.c

Fix -Wsign-compare warnings in realpath.c

This is needed in order to build realpath.c as part of rtld.

FreeBSD/src 349415stable/12/share/man/man9 pwmbus.9 pwm.9, stable/12/sys/arm/allwinner aw_pwm.c

MFC r341268, r342003-r342007, r342087-r342088, r342091

r341268 by manu:
arm64: allwinner: Add a dtbo to have cpu operating points

This enables cpufreq on A64 boards.

r342003 by manu:
Add a pwm subsystem so we can configure pwm controller from kernel and userland.

The pwm subsystem consist of API for PWM controllers, pwmbus to register them
and a pwm(8) utility to talk to them from userland.

Reviewed by:    oshgobo (capsicum), bcr (manpage), 0mp (manpage)
Differential Revision:

r342004 by manu:
arm64: allwinner: Add pwm driver

Add a pwm driver for Allwinner PWM
Add pwm and aw_pwm to the GENERIC kernel

r342005 by manu:
arm64: allwinner: Add DTSO for pwm and r_pwm

    [28 lines not shown]

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

o In iflib_txq_drain():
  - Remove desc_used, which is only ever written to.
  - Remove a dead store to reclaimed.
  - Don't recycle avail.
  - Sort variables according to style(9).
  These changes will make a subsequent commit easier to read.
o In iflib_tx_credits_update(), don't bother checking whether the
  ift_txd_credits_update method pointer is NULL; _iflib_pre_assert()
  asserts upfront that this method has been assigned and functions
  like iflib_{fast_intr_rxtx,netmap_timer_adjust,txq_can_drain}()
  and _task_fn_tx() were already unconditionally relying on the
  method being callable.
+7-121 files

FreeBSD/src 349413releng/11.3/release/doc/share/xml release.ent

Bump the release.manpath.freebsd macro version, although I do not
see any place this is actually used.

Approved by:    re (implicit)
Sponsored by:   Rubicon Communications, LLC (Netgate)

FreeBSD/src 349412projects/fuse2/sys/fs/fuse fuse_ipc.h fuse_vfsops.c

fusefs: delete some unused mount options

The fusefs kernel module allegedly supported no_attrcache, no_readahed,
no_datacache, no_namecache, and no_mmap mount options, but the mount_fusefs
binary never did.  So there was no way to ever activate these options.
Delete them.  Some of them have alternatives:

no_attrcache: set the attr_valid time to 0 in FUSE_LOOKUP and FUSE_GETATTR
no_readahed: set max_readahead to 0 in the FUSE_INIT response.
no_datacache: set the vfs.fusefs.data_cache_mode sysctl to 0, or (coming
        soon) set the attr_valid time to 0 and set FUSE_AUTO_INVAL_DATA in
        the FUSE_INIT response.
no_namecache: set entry_valid time to 0 in FUSE_LOOKUP and FUSE_GETATTR

Sponsored by:   The FreeBSD Foundation

FreeBSD/src 349411stable/11/sys/netpfil/ipfw/nat64 nat64lsn.c

Fix the uninitialized use of source IPv6 address in NAT64LSN.

This code is already refactored in head/, but due to the missing
epoch(9) support it is impossible to merge. So, it is direct commit to

Reported by:    Patrick M. Hausen <hausen punkt de>
Tested by:      Patrick M. Hausen <hausen punkt de>
MFC after:      3 days

FreeBSD/src 349410head/lib/libusb libusb10_hotplug.c

Only call libusb_hotplug_enumerate() once from libusb_hotplug_register_callback().
Else when registering multiple filters the same USB device may appear twice in
the list.

MFC after:      3 days
Sponsored by:   Mellanox Technologies

FreeBSD/src 349409head/lib/libusb libusb10_hotplug.c libusb10.h

Fix support for LIBUSB_HOTPLUG_ENUMERATE in libusb. Currently all
devices are enumerated regardless of of the LIBUSB_HOTPLUG_ENUMERATE
flag. Make sure when the flag is not specified no arrival events are
generated for currently enumerated devices.

MFC after:      3 days
Sponsored by:   Mellanox Technologies

FreeBSD/src 349408head/share/man/man4 gpio.4

gpio.4: document device hints common to all devices on gpiobus

"at" keyword is documented in device.hints(5) for all buses, but it does
hurt to add another reference to it.
"pins" keyword is specific to gpiobus.
At least these two hints should be configured for any gpiobus device on
a hints based system.

MFC after:      10 days

FreeBSD/src 349407head/share/man/man4 owc.4

fix up r349406, add missing .El

MFC after:      1 week

FreeBSD/src 349406head/share/man/man4 owc.4

owc.4: document how to set up the 1-wire bus on a device.hints system

MFC after:      1 week

FreeBSD/src 349405head/sys/vm vm_map.c vm_map.h

Revert r349393, which leads to an assertion failure on bootup, in vm_map_stack_locked.

Reported by: ler at
Approved by: kib, markj (mentors, implicit)

FreeBSD/src 349404head/stand/efi/libefi efihttp.c, head/stand/efi/loader conf.c

Re-enable loader efi http boot and fix dv_open bug if dv_init failed

The code in efihttp.c was assuming that dv_open wouldn't be called if
dv_init failed. But the dv_init return value is currently ignored.

Add a new variable, `efihttp_init_done` and only proceed in dv_open if
it's true. This fixes the loader on systems without efi http support.

FreeBSD/src 349403projects/fuse2/sys/fs/fuse fuse_internal.c fuse_node.c, projects/fuse2/tests/sys/fs/fusefs mockfs.hh

fusefs: implement the "time_gran" feature.

If a server supports a timestamp granularity other than 1ns, it can tell the
client this as of protocol 7.23.  The client will use that granularity when
updating its cached timestamps during write.  This way the timestamps won't
appear to change following flush.

Sponsored by:   The FreeBSD Foundation

FreeBSD/src 349402head/sys/powerpc/include trap.h, head/sys/powerpc/powerpc trap.c

powerpc/booke: Handle misaligned floating point loads/stores as on AIM

Misaligned floating point loads and stores are already handled for AIM, but
use the DSISR to obtain the necessary data.  Book-E does not have the DSISR,
so these fixups are not performed, leading to a SIGBUS on misaligned FP
loads or stores.  Obtain the necessary data on the Book-E side, similar to
how is done for SPE.

MFC after:      1 week