FreeBSD/src 354751head/share/doc/IPv6 IMPLEMENTATION, head/sys/netinet ip6.h

Remove now unused IPv6 macros and update docs.

After r354748-354750 all uses of the IP6_EXTHDR_CHECK() and
IP6_EXTHDR_GET() macros are gone from the kernel.  IP6_EXTHDR_GET0()
was unused.  Remove the macros and update the documentation.

Sponsored by:   Netflix

FreeBSD/src 354750head/sys/netinet tcp_input.c

IP6_EXTHDR_CHECK(): remove the last instances

While r354748 removed almost all IP6_EXTHDR_CHECK() calls, these
are not part of the PULLDOWN_TESTS.
Equally convert these IP6_EXTHDR_CHECK()s here to m_pullup() and remove
the extra check and m_pullup() in tcp_input() under isipv6 given
tcp6_input() has done exactly that pullup already.

MFC after:      8 weeks
Sponsored by:   Netflix

FreeBSD/src 354749head/sys/netinet ip_carp.c, head/sys/netinet6 sctp6_usrreq.c

netinet*: replace IP6_EXTHDR_GET()

In a few places we have IP6_EXTHDR_GET() left in upper layer protocols.
The IP6_EXTHDR_GET() macro might perform an m_pulldown() in case the data
fragment is not contiguous.

Convert these last remaining instances into m_pullup()s instead.
In CARP, for example, we will a few lines later call m_pullup() anyway,
the IPsec code coming from OpenBSD would otherwise have done the m_pullup()
and are copying the data a bit later anyway, so pulling it in seems no
better or worse.

Note: this leaves very few m_pulldown() cases behind in the tree and we
might want to consider removing them as well to make mbuf management
easier again on a path to variable size mbufs, especially given
m_pulldown() still has an issue not re-checking M_WRITEABLE().

Reviewed by:    gallatin
MFC after:      8 weeks
Sponsored by:   Netflix
Differential Revision:  https://reviews.freebsd.org/D22335

FreeBSD/src 354748head/sys/netinet6 icmp6.c ip6_input.c

netinet6: Remove PULLDOWN_TESTs.

Remove the KAME introduced PULLDOWN_TESTs which did not even
have a compile-time option in sys/conf to turn them on for a
custom kernel build. They made the code a lot harder to read
or more complicated in a few cases.

Convert the IP6_EXTHDR_CHECK() calls into FreeBSD looking code.
Rather than throwing the packet away if it would not fit the
KAME mbuf expectations, convert the macros to m_pullup() calls.
Do not do any extra manual conditional checks upfront as to
whether the m_len would suffice (*), simply let m_pullup() do
its work (incl. an early check).

Remove extra m_pullup() calls where earlier in the function or
the only caller has already done the pullup.

Discussed with: rwatson (*)
Reviewed by:    ae
MFC after:      8 weeks
Sponsored by:   Netflix
Differential Revision:  https://reviews.freebsd.org/D22334

FreeBSD/src 354747head/share/mk bsd.dep.mk

Allow per-file lex and yacc options.

In order to allow software with multiple (different) options
for lex and yacc add extra per-file options to the calls.
This is especially useful when one .l file needs -Pprefix.

Reviewed by:           imp
MFC after:             3 weeks
Differential Revision:  https://reviews.freebsd.org/D22337

FreeBSD/src 354746head/stand/common part.c

loader: add support for hybrid PMBR for GPT partition table

Note hybrid table is nor really UEFI specification compliant.

Sample hybrid partition table:
> ::mbr
Format: unknown
Signature: 0xaa55 (valid)
UniqueMBRDiskSignature: 0

PART TYPE                  ACTIVE  STARTCHS    ENDCHS      SECTOR     NUMSECT
0    EFI_PMBR:0xee         0       1023/254/63 1023/254/63 1          409639
1    0xff                  0       1023/254/63 1023/254/63 409640     978508408
2    FDISK_EXT_WIN:0xc     0       1023/254/63 1023/254/63 978918048  31250000
3    0xff                  0       1023/254/63 1023/254/63 1010168048 32
>

FreeBSD/src 354745svnadmin/conf access mentors

Take in idle commit bits

Approved by:    core (implicit)
With hat:              core-secretary

FreeBSD/src 354744head/sys/mips/mips elf_machdep.c

Combine ELF sysvecs for MIPS to reduce code duplication.

Reviewed by:    brooks, kevans
Tested on:      mips, mips64
Sponsored by:   DARPA
Differential Revision:  https://reviews.freebsd.org/D22357

FreeBSD/src 354743head/stand/efi/libefi efipart.c

loader: r354415 did miss to sort subpaths below the partitions

Tested on actual system (MBP with UEFI 1.10).

FreeBSD/src 354742head/sys/dev/cxgbe t4_iov.c t4_vf.c

cxgbev(4): Catch up with the pciids in the PF driver.

MFC after:      3 days
Sponsored by:   Chelsio Communications

FreeBSD/src 354741head/sys/compat/freebsd32 freebsd32_misc.c, head/sys/kern imgact_elf.c kern_exec.c

Add a sv_copyout_auxargs() hook in sysentvec.

Change the FreeBSD ELF ABIs to use this new hook to copyout ELF auxv
instead of doing it in the sv_fixup hook.  In particular, this new
hook allows the stack space to be allocated at the same time the auxv
values are copied out to userland.  This allows us to avoid wasting
space for unused auxv entries as well as not having to recalculate
where the auxv vector is by walking back up over the argv and
environment vectors.

Reviewed by:    brooks, emaste
Tested on:      amd64 (amd64 and i386 binaries), i386, mips, mips64
Sponsored by:   DARPA
Differential Revision:  https://reviews.freebsd.org/D22355

FreeBSD/src 354740head/share/mk bsd.files.mk

Fix build race in bsd.files.mk

We need to ensure that installdirs-FOO runs before installfiles-FOO since
otherwise the directory may not exist when we attempt to install the target.
This was randomly causing failures in our Jenkins instance when installing
drti.o in cddl/lib/drti.

Reviewed By:    brooks
Differential Revision: https://reviews.freebsd.org/D22382

FreeBSD/src 354739head/usr.sbin/makefs ffs.c

makefs: Also set UFS di_birthtime when building on Linux

Since st_birthtime doesn't exists on Linux (unless you use statx(2)), we
instead populate it with the st_ctime value.

Reviewed By:    emaste
Differential Revision: https://reviews.freebsd.org/D22386

FreeBSD/src 354738head/usr.sbin/makefs msdos.c

Fix contents= being ignored in msdosfs makefs mtree

I noticed this while trying to build an EFI boot image

Reviewed By:    emaste
Differential Revision: https://reviews.freebsd.org/D22387

FreeBSD/src 354737head/sys/dev/cxgbe t4_main.c

Fix regression from r353841: ctx.rc needs to be initialized,
otherwise driver might silently fail to initialize.

Pointy hat to:  glebius

FreeBSD/src 354736head/share/mk bsd.compiler.mk bsd.linker.mk

Use __ as the separator for the exported vars in bsd.compiler/linker.mk

By using '__' instead of '.' as the separator we can also support systems
that use dash as /bin/sh (it's the default shell on Ubuntu/Debian). Dash
will unset any environment variables that use a non alphanumeric+undedscore
character and therefore submakes will fail to import the COMPILER_*
variables if we use '.' as the separator.

Reviewed By:    emaste
Differential Revision: https://reviews.freebsd.org/D22381

FreeBSD/src 354735stable 11, stable/11/sys/kern imgact_elf.c

MFC r354228: avoid kernel stack data leak in core dump thrmisc note

bzero the entire thrmisc struct, not just the padding.  Other core dump
notes are already done this way.

Sponsored by:   The FreeBSD Foundation

FreeBSD/src 354734stable 12, stable/12/sys/kern imgact_elf.c

MFC r354228: avoid kernel stack data leak in core dump thrmisc note

bzero the entire thrmisc struct, not just the padding.  Other core dump
notes are already done this way.

Sponsored by:   The FreeBSD Foundation

FreeBSD/src 354733head/contrib/ntp/ntpd ntpd.c

Disable ntpd stack gap. When ASLR with STACK GAP != 0 ntpd suffers SIGSEGV.

PR:            241421, 241960
Reported by:    Vladimir Zakharov <zakharov.vv at gmail.com>,
               dewayne at heuristicsystems.com.au
Reviewed by:    kib, imp (previous version), ian (suggestion)
MFC after:      3 days
Differential Revision:  https://reviews.freebsd.org/D22358

FreeBSD/src 354732head/sys/compat/linux linux_file.c

Support O_CLOEXEC in linux(4) open(2) and openat(2).

Reviewed by:    emaste
MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D21966

FreeBSD/src 354731head/sys/netinet6 nd6.c

nd6: simplify code

We are taking the same actions in both cases of the branch inside the block.
Simplify that code as the extra branch is not needed.

MFC after:      3 weeks
Sponsored by:   Netflix

FreeBSD/src 354730head/sys/x86/x86 busdma_machdep.c

Revert a patch that accidentally was committed with r354729

FreeBSD/src 354729head/sys/x86/x86 busdma_machdep.c cpu_machdep.c

Fix a typo in how the AVX512DQ feature bit is checked.

Reviewed by:    kib
Sponsored by:   Intel

FreeBSD/src 354728head/sys/ofed/include/rdma ib_verbs.h

Prevent potential underflow in ibcore.

Linux commit:
a9018adfde809d44e71189b984fa61cc89682b5e

MFC after:      1 week
Sponsored by:   Mellanox Technologies

FreeBSD/src 354727head/sys/contrib/rdma/krping krping.c, head/sys/ofed/include/rdma ib_verbs.h

Correct MR length field to be 64-bit in ibcore.

Linux commit:
edd31551148c09608feee6b8756ad148d550ee3b

MFC after:      1 week
Sponsored by:   Mellanox Technologies

FreeBSD/src 354726head/sys/net if_llatbl.c

if_llatbl: cleanup

Remove function prototypes which are not needed (no use before function
definition for these file static functions).

MFC after:      3 weeks
Sponsored by:   Netflix

FreeBSD/src 354725stable/12/libexec/rc rc.conf, stable/12/libexec/rc/rc.d watchdogd

MFC r353039: add ability to set watchdog timeout for a shutdown

This change allows to specify a watchdog(9) timeout for a system
shutdown.  The timeout is activated when the watchdogd daemon is
stopped.  The idea is to a prevent any indefinite hang during late
stages of the shutdown.  The feature is implemented in rc.d/watchdogd,
it builds upon watchdogd -x option.

Note that the shutdown timeout is not actiavted when the watchdogd
service is individually stopped by an operator.  It is also not
activated for the 'shutdown' to the single-user mode.  In those cases it
is assumed that the operator knows what they are doing and they have
means to recover the system should it hang.

Significant subchanges and implementation details:
- the argument to rc.shutdown, completely unused before, is assigned to
  rc_shutdown variable that can be inspected by rc scripts
- init(8) passes "single" or "reboot" as the argument, this is not
  changed
- the argument is not mandatory and if it is not set then rc_shutdown is
  set to "unspecified"
- however, the default jail management scripts and jail configuration
  examples have been updated to pass "jail" to rc.shutdown, just in case
- the new timeout can be set via watchdogd_shutdown_timeout rc option
- for consistency, the regular timeout can now be set via

    [5 lines not shown]

FreeBSD/src 354724head/contrib/llvm/lib/Transforms/InstCombine InstCombineCompares.cpp

Merge commit 5bbb604bb from llvm git (by Craig Topper):

  [InstCombine] Disable some portions of foldGEPICmp for GEPs that
  return a vector of pointers. Fix other portions.

  llvm-svn: 370114

This should fix instances of 'Assertion failed: (isa<X>(Val) &&
"cast<Ty>() argument of incompatible type!"), function cast, file
/usr/src/contrib/llvm/include/llvm/Support/Casting.h, line 255', when
building openjdk8 for aarch64 and armv7.

Reported by:    jbeich
PR:            236566
MFC after:      3 days

FreeBSD/src 354723head/sys/powerpc/include atomic.h, head/sys/sys _atomic_subword.h

atomic: Add atomic_cmpset_masked to powerpc and use it

Summary:
This is a more optimal way of doing atomic_compset_masked() than the
fallback in sys/_atomic_subword.h.  There's also an override for
_atomic_fcmpset_masked_word(), which may or may not be necessary, and is
unused for powerpc.

Reviewed by:    kevans, kib
Differential Revision:  https://reviews.freebsd.org/D22359

FreeBSD/src 354722head/sys/riscv/include sbi.h, head/sys/riscv/riscv sbi.c machdep.c

RISC-V: Print SBI info at startup

SBI version 0.2 introduces functions for obtaining the details of the
SBI implementation, such as version and implemntation ID. Print this
info at startup when it is available.

Reviewed by:    jhb, kp
MFC after:      3 weeks
Differential Revision:  https://reviews.freebsd.org/D22327

FreeBSD/src 354721head/sys/riscv/include sbi.h md_var.h

Add missing files from r354720

MFC with:       r354720
Differential Revision:  https://reviews.freebsd.org/D22326

FreeBSD/src 354720head/sys/conf files.riscv, head/sys/riscv/riscv sbi.c identcpu.c

RISC-V: add support for SBI spec v0.2

The Supervisor Binary Interface (SBI) specification v0.2 is a backwards
incompatible update to the SBI call interface for kernels running in
supervisor mode. The goal of this update was to make it easier for new
and optional functionality to be added to the SBI.

SBI functions are now called by passing an "extension ID" and a
"function ID" which are passed in a7 and a6 respectively. SBI calls
will also return an error and value in the following struct:

struct sbi_ret {
    long error;
    long value;
}

This version introduces several new functions under the "base"
extension. It is expected that all SBI implementations >= 0.2 will
support this base set of functions, as they implement some essential
services such as obtaining the SBI version, CPU implementation info, and
extension probing.

Existing SBI functions have been designated as "legacy". For the time
being they will remain implemented, but it is expected that in the
future their functionality will be duplicated or replaced by new SBI

    [15 lines not shown]

FreeBSD/src 354719head/sys/riscv/include sbi.h

RISC-V: pass arg6 in sbi_call

Allow for an additional argument to sbi_call which will be passed in a6.
This is required for SBI spec 0.2 support, as a6 will indicate the SBI
function ID.

While here, introduce some macros to clean up the calls.

Reviewed by:    kp, jhb
MFC after:      3 weeks
Differential Revision:  https://reviews.freebsd.org/D22325

FreeBSD/src 354718head/sys/riscv/riscv plic.c

plic: support irq distribution

Our PLIC implementation only enables interrupts on the boot cpu.
Implement plic_bind_intr() so that they can be redistributed near the
end of boot during intr_irq_shuffle().

This also slightly modifies how enable bits are handled in an attempt to
better fit the PIC interface. plic_enable_intr()/plic_disable_intr() are
converted to manage an interrupt source's threshold value, since this
value can be used as to globally enable/disable an irq. All handing of the
per-context enable bits is moved to the new methods plic_setup_intr()
and plic_bind_intr().

Reviewed by:    br
MFC after:      3 weeks
Differential Revision:  https://reviews.freebsd.org/D21928

FreeBSD/src 354717head/sys/riscv/riscv plic.c

plic: fix context calculation

The RISC-V PLIC (platform level interrupt controller) registers are divided up
by "context", which is purposefully left ambiguous in the PLIC spec. Currently
we assume each CPU number corresponds 1-to-1 with a context number, but that is
not correct. Most existing PLIC implementations (such as SiFive's) have
multiple contexts per-cpu. For example, a single CPU might have a context for
machine mode interrupts and a context for supervisor mode interrupts. To
complicate things further, FreeBSD renumbers the CPUs during boot, but the PLIC
driver still assumes that CPU ID equals the RISC-V hart number, meaning
interrupt enables/claims might be performed for the wrong context registers.

To fix this, we must calculate each CPU's context number during
attachment. This is done by reading the interrupt properties from the
device tree, from which a mapping from context to RISC-V hart to CPU
number can be created.

Reviewed by:    br
MFC after:      3 weeks
Differential Revision:  https://reviews.freebsd.org/D21927
DeltaFile
+138-12head/sys/riscv/riscv/plic.c
+138-121 files

FreeBSD/src 354716head/sys/dev/vmware/pvscsi pvscsi.c

Fix build with GCC

Fix suggested by:       jhb, scottl
Sponsored by:   Panzura

FreeBSD/src 354715head/share/man/man4 pvscsi.4, head/sys/dev/vmware/pvscsi pvscsi.c pvscsi.h

Add the pvscsi driver to the tree.

This driver allows to usage of the paravirt SCSI controller
in VMware products like ESXi.  The pvscsi driver provides a
substantial performance improvement in block devices versus
the emulated mpt and mps SCSI/SAS controllers.

Error handling in this driver has not been extensively tested
yet.

Submitted by:   vbhakta at vmware.com
Relnotes:       yes
Sponsored by:   VMware, Panzura
Differential Revision:  D18613

FreeBSD/src 354714head/sys/arm64/arm64 machdep_boot.c machdep.c, head/sys/arm64/conf GENERIC

Boot arm64 kernel using booti command from U-boot.

Summary:
Boot arm64 kernel using booti command from U-boot. booti can relocate initrd
image into higher ram addresses, therefore align the initrd load address to 1GiB
and create VA = PA map for it. Create L2 pagetable entries to copy the initrd
image into KVA.
(parts of the code in https://reviews.freebsd.org/D13861 was referred and used
as appropriate)

Submitted by:   Siddharth Tuli <siddharthtuli_gmail.com>
Reviewed by:    manu
Sponsored by:   Juniper Networks, Inc
Differential Revision: https://reviews.freebsd.org/D22255

FreeBSD/src 354713head/sys/conf kmod.mk

[PowerPC64] Fix broken kernel modules due to LLD 9+ TOC optimization

LLD9 introduced a TOC optimization that isn't compatible with kernel dynamic
linker causing panic when loading kernel modules (pf, linuxkpi etc.)

This patch disables TOC optimization when building kernel modules.

Submitted by: Alfredo Dal'Ava Junior <alfredo.junior at eldorado.org.br>
Approved by: jhibbits (mentor)
Differential Revision: https://reviews.freebsd.org/D22317

FreeBSD/src 354712head/sys/arm64/arm64 busdma_bounce.c

arm64: busdma_bounce: fix BUS_DMA_ALLOCNOW for non-paged aligned sizes

For any size that isn't page-aligned, we end up not pre-allocating enough
for a single mapping because we truncate the size instead of rounding up to
make sure the last bit is accounted for, leaving us one page shy of what we
need to fulfill a request.

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

FreeBSD/src 354711head/sys/compat/freebsd32 syscalls.master, head/sys/i386/linux syscalls.master

Tidy syscall declerations.

Pointer arguments should be of the form "<type> *..." and not "<type>* ...".

No functional change.

Reviewed by:    kevans
Sponsored by:   DARPA, AFRL
Differential Revision:  https://reviews.freebsd.org/D22373

FreeBSD/src 354710head/sys/conf files.arm

Compile in arm/unwind.c if options STACK is in effect; the new arm stack(9)
code now uses unwind.c.

FreeBSD/src 354709head/sys/arm/arm stack_machdep.c, head/sys/arm/conf std.armv7 std.armv6

Rewrite arm/stack_machdep.c for EABI; add stack(9) support to arm kernels.

The old stack_machdep.c code was written for the APCS ABI (aka "oldabi").
When we switched to ARM EABI (back in freebsd 10) this file never got
updated, and apparently nobody noticed that until now.

The new implementation uses the same stack unwinder code used by the
arm implemenation of the db_trace stuff.

FreeBSD/src 354708head/sys/netinet/cc cc_cubic.c

For idle TCP sessions using the CUBIC congestio control, reset ssthresh
to the higher of the previous ssthresh or 3/4 of the prior cwnd.

Submitted by:          Richard Scheffenegger
Reviewed by:           Cheng Cui
Differential Revision:  https://reviews.freebsd.org/D18982

FreeBSD/src 354707head/contrib/llvm/lib/Support/Unix Path.inc

llvm: use elf_aux_info to get executable's path, if available

Obtained from:  LLVM a0a38b81ea
MFC with:       r354692
Sponsored by:   The FreeBSD Foundation

FreeBSD/src 354706stable 11, stable/11/sys/net if_vlan.c

MFC r354443:
  Enqueue lladdr_task to update link level address of vlan, when its parent
  interface has changed.

  During vlan reconfiguration without destroying interface, it is possible,
  that parent interface will be changed. This usually means, that link
  layer address of vlan will be different. Therefore we need to update all
  associated with vlan's addresses permanent llentries - NDP for IPv6
  addresses, and ARP for IPv4 addresses. This is done via lladdr_task
  execution. To avoid extra work, before execution do the check, that L2
  address is different.

FreeBSD/src 354705stable 12, stable/12/sys/net if_vlan.c

MFC r354443:
  Enqueue lladdr_task to update link level address of vlan, when its parent
  interface has changed.

  During vlan reconfiguration without destroying interface, it is possible,
  that parent interface will be changed. This usually means, that link
  layer address of vlan will be different. Therefore we need to update all
  associated with vlan's addresses permanent llentries - NDP for IPv6
  addresses, and ARP for IPv4 addresses. This is done via lladdr_task
  execution. To avoid extra work, before execution do the check, that L2
  address is different.

FreeBSD/src 354704stable 12, stable/12/stand/efi/libefi devpath.c

MFC r354435:
loader: implement fallback efi_devpath_to_name()

UEFI 1.10 on macs does not seem to provide devpath to name translation,
provide our own (limited) version, so we can get information about commmon
devices.

FreeBSD/src 354703head/sys/dev/ioat ioat.c

Pass more reasonable WAIT flags to bus_dma(9) calls.

MFC after:      2 weeks

FreeBSD/src 354702head/sys/dev/ntb ntb.c ntb.h, head/sys/dev/ntb/ntb_hw ntb_hw_plx.c ntb_hw_amd.c

Make ntb(4) send bus_get_dma_tag() requests to parent buses passing real
bus' child pointers instead of grandchilds.

DMAR does not like requests from devices not parented directly by PCI.

MFC after:      2 weeks