FreeBSD/src 348277stable 12, stable/12/sys/compat/linuxkpi/common/include/linux seq_file.h

MFC r347892:
LinuxKPI: Finalize import of seq_file.

seq_file.h and linux_seq_file.c was imported form ports earlier but
linux_seq_file.c was never compiled in with the module. With this
commit base seq_file will replace ports seq_file and it required a
few modifications to not break functionality and build.

Reviewed by:    hps
Approved by:    imp (mentor), hps

FreeBSD/src 348276stable 12, stable/12/sys/kern kern_descrip.c

MFC r344486:
Change seq_read to seq_load to avoid namespace conflicts with lkpi

Sponsored by:   iX Systems

FreeBSD/src 348275stable/12/sys/conf files

LinuxKPI: Register new linuxkpi and lindebugfs source files.

This change is a partial MFC of r344487.

Reviewed by:    hps
Approved by:    imp (mentor), hps
Obtained from:  mmacy

FreeBSD/src 348274head/share/man/man5 devfs.conf.5

We don't really need two entries to describe how to deal with
optical drives in devfs.conf(5).

MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation

FreeBSD/src 348273stable 12, stable/12/sys/compat lindebugfs

MFC r344485:
import linux debugfs support

Reviewed by:    hps@
Sponsored by:   iX Systems
Differential Revision:

FreeBSD/src 348272user/cperciva/freebsd-update-build/scripts build.subr

Switch logic in indexfiles to always remove the uarch flag.

On UFS filesystems, this is unneeded. On ZFS filesystems, the uarch
flag is automatically set on file creation (and maybe update?). This
is causing a lot of churn in the freebsd-update cycle where
discrepancies in the uarch flag makes the system think a lot of metadata
need to be corrected.

FreeBSD/src 348271stable/11/sys/amd64/vmm vmm.c vmm_dev.c, stable/11/sys/amd64/vmm/amd svm.c

MFC: r346714: Add accessor function for vm->maxcpus

Replace most VM_MAXCPU constant useses with an accessor function to
vm->maxcpus which for now is initialized and kept at the value of

This is a rework of Fabian Freyer (
work from D10070 to adjust it for the cpu topology changes that
occured in r332298

Approved by:           re (kib)

FreeBSD/src 348270head/libexec/bootpd bootpd.c

Correctly align usage: output

FreeBSD/src 348269stable 11, stable/11/usr.sbin/bhyve smbiostbl.c bhyverun.h

MFC: r346717: Make bhyve SMBIOS table topology aware

When the CPU Topology was added to bhyve in r332298 the SMBIOS table was
missed, this table passes topology information to the system and was still
using the old concept of each vCPU is a socket with 1 core and 1 thread.
This code did not even try to use the old sysctl information to adjust
this data.

Correct that by building a proper SMBios table, mapping the > 254 cases to
0 per the SMBios 2.6 specification that is claimed by the structure.

Approved by:           re (kib)

FreeBSD/src 348268head/sys/conf files.i386 files.amd64, head/sys/crypto/aesni aesni_ccm.c aesni.c

Add an AESNI-optimized version of the CCM/CBC cryptographic and authentication
code.  The primary client of this is probably going to be ZFS encryption.

Reviewed by:    jhb, cem
Sponsored by:   iXsystems Inc, Kithrup Enterprises
Differential Revision:

FreeBSD/src 348267head/sys/powerpc/aim moea64_native.c

powerpc64/pmap: Reapply r334235 to OEA64 pmap, clearing HID0_RADIX

This was lost in the re-merger of ISA3 MMU into moea64_native.

FreeBSD/src 348266user/cperciva/freebsd-update-build/scripts build.subr

Add limit for XZ_THREADS to the buildworld invocation.

This is needed for high core count machines on i386. The auto detect
was exhausting the address space in i386.

FreeBSD/src 348265user/cperciva/freebsd-update-build/scripts/11.0-RELEASE/amd64 build.conf, user/cperciva/freebsd-update-build/scripts/11.0-RELEASE/i386 build.conf

Cleanup: Update EOL for 11.0-RELEASE to reflect reality.

FreeBSD/src 348264user/cperciva/freebsd-update-build/scripts build.subr

Only fetch the iso (and hence overwrite) if the file isn't already there.

This allows us to drop the iso in the right place and avoid redownload.

FreeBSD/src 348263user/cperciva/freebsd-update-build/scripts build.subr

Fix for newer versions of openssl.

FreeBSD/src 348262head/sys/dev/virtio/pci virtio_pci.c

virtio_pci(4): Fix typo in read_ivar method

Prior to this revision, vtpci's BUS_READ_IVAR method on VIRTIO_IVAR_SUBVENDOR
accidentally returned the PCI subdevice.

The typo seems to have been introduced with the original commit adding
VIRTIO_IVAR_{{SUB,}DEVICE,{SUB,}VENDOR} to virtio_pci.  The commit log and code
strongly suggest that the ivar was intended to return the subvendor rather than
the subdevice; it was likely just a copy/paste mistake.

Go ahead and rectify that.

FreeBSD/src 348261stable/11/contrib zlib, stable/11/lib/libz FREEBSD-upgrade Makefile

MFC r347244:

Move contrib/zlib to sys/contrib/zlib so that we can use it in kernel.
This is a prerequisite of unifying kernel zlib instances.

Submitted by:   Yoshihiro Ota <ota at>
Approved by:    re (kib)

FreeBSD/src 348260stable 11, stable/11/sbin/fsck_ffs dir.c

MFC of 348074

Rewrite fsck_readdir() and dircheck() for clarity and correctness.

Approved by: re (gjb)

FreeBSD/src 348259head/sys/geom/nop g_nop.c

When using the destroy option to shut down a nop GEOM module, I/O
operations already in its queue were not being properly drained.
The GEOM framework does the queue draining, but the module needs
to wait for the draining to happen. The waiting is done by adding
a g_nop_providergone() function to wait for the I/O operations to
finish up. This change is similar to change -r345758 made to the
memory-disk driver.

Submitted by: Chuck Silvers
Tested by:    Chuck Silvers
MFC after:    1 week
Sponsored by: Netflix

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

Fix too loose assert in pmap_large_unmap().

The upper bound for the valid address from the large map used
function-like macro for proper upper value.

Noted by:       markj
Reviewed by:    alc, markj
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:

FreeBSD/src 348257head/sys/amd64/include pmap.h

Add PG_PS_PDP_FRAME symbol.

Similar to PG_FRAME and PG_PS_FRAME, it denotes the mask of the
physical address component of 1G superpage PDP entry.

Reviewed by:    alc, markj
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:

FreeBSD/src 348256stable 12, stable/12/sbin/fsck_ffs dir.c

MFC of 348074

Rewrite fsck_readdir() and dircheck() for clarity and correctness.

FreeBSD/src 348255head/sys/kern kern_intr.c

Disable intr_storm_threshold mechanism by default

The ixl.4 manual page has documented that the threshold falsely detects
interrupt storms on 40Gbit NICs as long ago as 2015, and we have seen
similar false positives with the ioat(4) DMA device (which can push GB/s).

For example, synthetic load can be generated with tools/tools/ioat
'ioatcontrol 0 200 8192 1 1000' (allocate 200x8kB buffers, generate an
interrupt for each one, and do this for 1000 milliseconds).  With
storm-detection disabled, the Broadwell-EP version of this device is capable
of generating ~350k real interrupts per second.

The following historical context comes from jhb@: Originally, the threshold
worked around incorrect routing of PCI INTx interrupts on single-CPU systems
which would end up in a hard hang during boot.  Since the threshold was
added, our PCI interrupt routing was improved, most PCI interrupts use
edge-triggered MSI instead of level-triggered INTx, and typical systems have
multiple CPUs available to service interrupts.

On the off chance that the threshold is useful in the future, it remains
available as a tunable and sysctl.

Reviewed by:    jhb
Sponsored by:   Dell EMC Isilon
Differential Revision:

FreeBSD/src 348254head/sys/dev/cxgbe t4_sge.c, head/sys/net if_lagg.c if_vlan.c

Restructure mbuf send tags to provide stronger guarantees.

- Perform ifp mismatch checks (to determine if a send tag is allocated
  for a different ifp than the one the packet is being output on), in
  ip_output() and ip6_output().  This avoids sending packets with send
  tags to ifnet drivers that don't support send tags.

  Since we are now checking for ifp mismatches before invoking
  if_output, we can now try to allocate a new tag before invoking
  if_output sending the original packet on the new tag if allocation

  To avoid code duplication for the fragment and unfragmented cases,
  add ip_output_send() and ip6_output_send() as wrappers around
  if_output and nd6_output_ifp, respectively.  All of the logic for
  setting send tags and dealing with send tag-related errors is done
  in these wrapper functions.

  For pseudo interfaces that wrap other network interfaces (vlan and
  lagg), wrapper send tags are now allocated so that ip*_output see
  the wrapper ifp as the ifp in the send tag.  The if_transmit
  routines rewrite the send tags after performing an ifp mismatch
  check.  If an ifp mismatch is detected, the transmit routines fail
  with EAGAIN.

    [54 lines not shown]

FreeBSD/src 348253head/usr.sbin/bhyve gdb.c

Add initial support for 'qSupported' to the debug server.

This doesn't recognize any features yet, but does parse the features
string.  It advertises an arbitrary packet size of 4k.

Reviewed by:    markj, Scott Phillips <d.scott.phillips at>
MFC after:      2 weeks
Differential Revision:

FreeBSD/src 348252svnadmin/conf mentors

Release rgrimes@ from mentorship.

Discussed with: bde@, phk@
Approved by:    core@

FreeBSD/src 348251head/sys/fs/ext2fs ext2_inode.c, head/sys/fs/fuse fuse_io.c fuse_vnops.c

Remove "struct ucred*" argument from vtruncbuf

vtruncbuf takes a "struct ucred*" argument. AFAICT, it's been unused ever
since that function was first added in r34611. Remove it.  Also, remove some
"struct ucred" arguments from fuse and nfs functions that were only used by

Reviewed by:    cem
MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
Differential Revision:

FreeBSD/src 348250head/sys/powerpc/conf GENERIC64

Add snd_hda(4) to GENERIC64 used by powerpc64.

amd64 also has snd_hda(4) in GENERIC.

Approved by:    jhibbits (src committer), linimon (mentor)

FreeBSD/src 348249head/stand, head/stand/ficl loader.c

ficl pfopen: verify file

If the file is verified - do not allow write
otherwise do not allow read.

Add O_ACCMODE to stand.h

Reviewed by:    stevek,
MFC after:      3 days
Sponsored by:   Juniper Networks
Differential Revision:

FreeBSD/src 348248head/sys/powerpc/conf GENERIC64

Make options MD_ROOT_MEM default on PPC64

Having this option enabled by default on PowerPC64 kernels makes
booting ISO images much easier when on PowerNV.

With it, the ISO may simply be given to the -i flag of kexec.
Better yet, the ISO may be loop mounted on PetitBoot and its
kernel may be used to load itself.

Without this option, booting ISOs on remote PPC64 machines usually
involve preparing a separate kernel, with this option enabled.

FreeBSD/src 348247head/sys/dev/isp isp.c isp_freebsd.c

Fix FC-Tape bugs caused in part by r345008.

The point of r345008 was to reset the Command Reference Number (CRN)
in some situations where a device stayed in the topology, but had
changed somehow.

This can include moving from a switch connection to a direct
connection or vice versa, or a device that temporarily goes away
and comes back.  (e.g. moving to a different switch port)

There were a couple of bugs in that change:
- We were reporting that a device had not changed whenever the
  Establish Image Pair bit was not set.  That is not quite correct.
  Instead, if the Establish Image Pair bit stays the same (set or
  not), the device hasn't changed in that way.

- We weren't setting PRLI Word0 in the port database when a new
  device arrived, so comparisons with the old value for the
  Establish Image Pair bit weren't really possible.  So, make sure
  PRLI Word0 is set in the port database for new devices.

- We were resetting the CRN whenever the Establish Image Pair bit
  was set for a device, even when the device had stayed the same
  and the value of the bit hadn't changed.  Now, only reset the
  CRN for devices that have changed, not devices that sayed the

    [31 lines not shown]

FreeBSD/src 348246head/sys/amd64/amd64 pmap.c, head/sys/i386/i386 pmap.c

Fix a corner case in demotion of kernel mappings.

It is possible for the kernel mapping to be created with superpage by
directly installing pde using pmap_enter_2mpage() without filling the
corresponding page table page.  This can happen e.g. if the range is
already backed by reservation and vm_fault_soft_fast() conditions are
satisfied, which was observed on the pipe_map.

In this case, demotion must fill the page obtained from the pmap
radix, same as if the page is newly allocated.  Use PG_PROMOTED bit as
an indicator that the page is valid, instead of the wire count of the
page table page.

Since the PG_PROMOTED bit is set on pde when we leave TLB entries for
4k pages around, which in particular means that the ptes were filled,
it provides more correct indicator.  Note that pmap_protect_pde()
clears PG_PROMOTED, which handles the case when protection was changed
on the superpage without adjusting ptes.

Reported by:    pho
In collaboration with:  alc
Tested by:      alc, pho
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:

FreeBSD/src 348245stable 12, stable/12/sys/compat/linuxkpi/common/include/linux ww_mutex.h

MFC r347596:
LinuxKPI: Add context member to ww_mutex and bump FreeBSD version.

This patch is part of

Reviewed by:    hps
Approved by:    imp (mentor), hps

FreeBSD/src 348244stable 12, stable/12/sys/compat/linuxkpi/common/include/linux preempt.h

MFC r347891:
LinuxKPI: Add in_task macro.

This patch is part of D19565

Reviewed by:    hps, bwidawsk
Approved by:    imp (mentor), hps
Obtained from:  bwidawsk

FreeBSD/src 348243stable 12, stable/12/sys/compat/linuxkpi/common/include/linux sched.h

MFC r347843:
LinuxKPI: Add group_leader member to struct task_struct.

Assign self as group leader at creation to act as the only member of a
new process group.
Bump FreeBSD version.
This patch is part of D19565

Reviewed by:    hps
Approved by:    imp (mentor), hps

FreeBSD/src 348242stable 12, stable/12/sys/compat/linuxkpi/common/include/linux interrupt.h

MFC r347852:
LinuxKPI: Updates to tasklets for Linux 5.0.

DRM drivers expect tasklets to have a counter for enable/disable calls.
Also, add a few more tasklet locking functions.
MFC also includes powerpc build fix from r347889.

This patch is part of D19565

Reviewed by:    hps
Approved by:    imp (mentor), hps

FreeBSD/src 348241head Makefile

Modernize the MAKE_JUST_KERNELS hint in the top-level makefile.

It doesn't make sense to limit to -j12 anymore, build scalability
is better than it used to be.  Fold the hint into the description
of the universe target.

Reviewed by:    imp
MFC after:      1 week
Differential Revision:
+2-71 files

FreeBSD/src 348240stable 12, stable/12/sys/compat/linuxkpi/common/include/linux uaccess.h

MFC r347837:
LinuxKPI: Update access_ok macro for v5.0.

Check LINUXKPI_VERSION macro for backwards compatibility.
It's recommended to update any drivers that depend on the older KPI
so we can deprecate < 5.0 code as we update to newer Linux version.
This patch is part of D19565

Reviewed by:    hps
Approved by:    imp (mentor), hps

FreeBSD/src 348239head/tools/tools/nanobsd/dhcpd common, head/tools/tools/nanobsd/pcengines common.conf

nanobsd: exclude .git (and .hg) in the same places we exclude .svn

Allow support of other VCSes.  Note that two other nanobsd files already
had a similar case, excluding .git and .hg in addition to CVS and .svn.

Sponsored by:   The FreeBSD Foundation

FreeBSD/src 348238stable 12, stable/12/share/man/man9 DRIVER_MODULE.9

MFC r348002:

FreeBSD/src 348237stable 12, stable/12/sys/modules Makefile

MFC r346598: Enable Mellanox drivers (modules) on AArch64

PR:            237055
Submitted by:   Greg V <greg at>

FreeBSD/src 348236head/sys/netinet6 in6_src.c

Restore IPV6_NEXTHOP option support that seem was partially broken
since r286195.

Do not forget results of route lookup and initialize rt and ifp pointers.

PR:            238098
Submitted by:   Masse Nicolas <nicolas.masse at stormshield eu>
MFC after:      1 week

FreeBSD/src 348235head/sbin/ipfw tables.c ipfw.8

Add `missing` and `or-flush` options to "ipfw table <NAME> create"
command to simplify firewall reloading.

The `missing` option suppresses EEXIST error code, but does check that
existing table has the same parameters as new one. The `or-flush` option
implies `missing` option and additionally does flush for table if it
is already exist.

Submitted by:   lev
MFC after:      2 weeks
Differential Revision:

FreeBSD/src 348234stable/12/sys/netinet ip_gre.c, stable/12/sys/netinet6 ip6_gre.c

Fix the build. Use NET_EPOCH_ENTER_ET() and NET_EPOCH_EXIT_ET().

This is direct commit to stable/12, since macros are different in stable/12
and head/ branches.

FreeBSD/src 348233stable/12/sbin/ifconfig ifgre.c, stable/12/share/man/man4 gre.4

MFC r346630:
  Add GRE-in-UDP encapsulation support as defined in RFC8086.

  This GRE-in-UDP encapsulation allows the UDP source port field to be
  used as an entropy field for load-balancing of GRE traffic in transit
  networks. Also most of multiqueue network cards are able distribute
  incoming UDP datagrams to different NIC queues, while very little are
  able do this for GRE packets.

  When an administrator enables UDP encapsulation with command
  `ifconfig gre0 udpencap`, the driver creates kernel socket, that binds
  to tunnel source address and after udp_set_kernel_tunneling() starts
  receiving of all UDP packets destined to 4754 port. Each kernel socket
  maintains list of tunnels with different destination addresses. Thus
  when several tunnels use the same source address, they all handled by
  single socket.  The IP[V6]_BINDANY socket option is used to be able bind
  socket to source address even if it is not yet available in the system.
  This may happen on system boot, when gre(4) interface is created before
  source address become available. The encapsulation and sending of packets
  is done directly from gre(4) into ip[6]_output() without using sockets.

  Reviewed by:  eugen
  Relnotes:     yes
  Differential Revision:

FreeBSD/src 348232stable 12, stable/12/sys/netinet6 mld6.c

MFC r347383:
  In mld_v2_cancel_link_timers() check number of references and disconnect
  inm before releasing the last reference. This fixes possible panics and

  PR:          237329
  Reviewed by:  mmacy

FreeBSD/src 348231head/lib/geom/eli geom_eli.c

Correct the argument passed to g_eli_algo2str()

MFC with:       r348206
Sponsored by:   The FreeBSD Foundation

FreeBSD/src 348230stable 12, stable/12/share/man/man4 ip.4

Merge r344481:
  Support struct ip_mreqn as argument for IP_ADD_MEMBERSHIP. Legacy support
  for struct ip_mreq remains in place.

  The struct ip_mreqn is Linux extension to classic BSD multicast API. It
  has extra field allowing to specify the interface index explicitly. In
  Linux it used as argument for IP_MULTICAST_IF and IP_ADD_MEMBERSHIP.
  FreeBSD kernel also declares this structure and supports it as argument
  to IP_MULTICAST_IF since r170613. So, we have structure declared but
  not fully supported, this confused third party application configure

  Code handling IP_ADD_MEMBERSHIP was mixed together with code for
  IP_ADD_SOURCE_MEMBERSHIP.  Bringing legacy and new structure support
  into the mess would made the "argument switcharoo" intolerable, so
  code was separated into its own switch case clause.

FreeBSD/src 348229head/sys/dev/amdgpio amdgpio.c

amdgpio: small formatting cleanup

MFC after:      2 weeks

FreeBSD/src 348228head/sys/dev/amdgpio amdgpio.c

amdgpio: fix reading status of input pins

AMD FCH GPIO controller uses different bits for setting the output level
and for reporting the input level.

MFC after:      2 weeks