FreeBSD/src 352483head/share/mk src.libnames.mk

Add the missing bits for LIBADD to properly function now that
libarchive is linked to libzstd

Pointy hat:     bapt
Reported by:    antoine

FreeBSD/src 352482head Makefile.inc1, head/lib Makefile

Add native support for zstd to libarchive

Note that old pkg will failed to build after this. A recent ports tree (one
providing pkg 1.12+) is required to build. Older already built pkg, should
continue working as expected

PR:            238797
Exp run by:     antoine
Reviewed by:    cem
Approved by:    cem
Differential Revision:  https://reviews.freebsd.org/D20752

FreeBSD/src 352481stable 11, stable/11/sys/net if_spppsubr.c

MFC r352137:
Callout drain does not have to be followed by a callout stop call.
Fix bogus code.

Sponsored by:   Mellanox Technologies

FreeBSD/src 352480stable 12, stable/12/sys/net if_spppsubr.c

MFC r352137:
Callout drain does not have to be followed by a callout stop call.
Fix bogus code.

Sponsored by:   Mellanox Technologies

FreeBSD/src 352479stable 11, stable/11/sys/compat/linuxkpi/common/src linux_work.c

MFC r352207:
Use true and false when dealing with bool type in the LinuxKPI.
No functional change.

Sponsored by:          Mellanox Technologies

FreeBSD/src 352478stable 12, stable/12/sys/compat/linuxkpi/common/src linux_work.c

MFC r352207:
Use true and false when dealing with bool type in the LinuxKPI.
No functional change.

Sponsored by:          Mellanox Technologies

FreeBSD/src 352477stable 12, stable/12/sys/compat/linuxkpi/common/src linux_work.c

MFC r352206:
Fix synchronous work drain issue in the LinuxKPI.

A work callback may restart itself. Loop in the drain function to see if the
work has been rescheduled and stop the subsequent reschedules, if any.

Sponsored by:          Mellanox Technologies

FreeBSD/src 352476stable 11, stable/11/sys/compat/linuxkpi/common/src linux_work.c

MFC r352206:
Fix synchronous work drain issue in the LinuxKPI.

A work callback may restart itself. Loop in the drain function to see if the
work has been rescheduled and stop the subsequent reschedules, if any.

Sponsored by:          Mellanox Technologies

FreeBSD/src 352475stable 12, stable/12/sys/amd64/amd64 pmap.c

MFC r350463
  In pmap_advise(), when we encounter a superpage mapping, we first demote
  the mapping and then destroy one of the 4 KB page mappings so that there
  is a potential trigger for repromotion.  Currently, we destroy the first
  4 KB page mapping that falls within the (current) superpage mapping or the
  virtual address range [sva, eva).  However, I have found empirically that
  destroying the last 4 KB mapping produces slightly better results,
  specifically, more promotions and fewer failed promotion attempts.
  Accordingly, this revision changes pmap_advise() to destroy the last 4 KB
  page mapping.  It also replaces some nearby uses of boolean_t with bool.

FreeBSD/src 352474stable 11, stable/11/sys/compat/linuxkpi/common/include/linux interrupt.h

MFC r352205:
Fix broken DECLARE_TASKLET() macro after r347852.

Sponsored by:          Mellanox Technologies

FreeBSD/src 352473stable 12, stable/12/sys/arm64/arm64 gicv3_its.c

MFC r340602:

gitv3_its: fixes for multiple GIC ITS blocks

First pass of support for multiple GIC ITS blocks with ACPI.
Changes are to:
 * register the correct subset of interrupts with pic_register
   in case of ACPI.
 * initialize just the cpu interface for the first ITS, when
   domain information is not avialable. This has to be done
   until we split the per-CPU init to do LPI setup just once.
 * remove duplicate check for the GIC ITS domain, the sc_cpus
   are setup from domain, so the check again in per-CPU init
   seems unnecessary.

Reviewed by:    andrew
Differential Revision:  https://reviews.freebsd.org/D17841

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

MFC r352205:
Fix broken DECLARE_TASKLET() macro after r347852.

Sponsored by:          Mellanox Technologies

FreeBSD/src 352471stable 12, stable/12/sys/dev/acpica acpi.c acpi_resource.c

MFC r340599-r340601

r340599:
acpica, pci_host_generic_acpi: redo pci_host_generic_acpi.c

This is a major update for pci_host_generic_acpi.c, the current
implementation has some gaps that are better fixed up in one go.
The changes are to:
 * Follow x86 method of not adding PCI resources to PCI host bridge in
   ACPI code. This has been moved to pci_host_generic_acpi.c, where we
   walk thru its resources of the host bridge and add them.
 * Fixup code in pci_host_generic_acpi.c to read all decoded ranges
   and update the 'ranges' property. This allows us to share most of
   the code with generic implementation (and the FDT one).
 * Parse and setup IO ranges and bus ranges when walking the resources
   above. Drop most of the changes related to this from acpica code.
 * Add the ECAM memory area as mem resource 0. Implement the logic to
   get the ECAM area from MCFG (using bus range which we now decode),
   or from _CBA (using _BBN/bus range). Drop aarch64 ifdefs from acpica
   code which did part of this.
 * Switch resource activation to similar code as FDT implementation,
   this can be moved into generic implementation in a later pass.
 * Drop the mechanism of using the 7th bit of bus number as the domain,
   this is not correct and will work only in very specific cases. Use
   _SEG as PCI domain and use the bus ranges of the host bridge to

    [27 lines not shown]

FreeBSD/src 352470stable 12, stable/12/sys/arm/arm generic_timer.c

MFC r340598:

acpica: rework INTRNG interrupts

On arm64 (where INTRNG is enabled), the interrupts have to be mapped
with ACPI_BUS_MAP_INTR() before adding them as resources to devices.

The earlier code did the mapping before calling acpi_set_resource(),
which bypassed code that checked for PCI link interrupts.

To fix this, move the call to map interrupts into acpi_set_resource()
and that requires additional work to lookup interrupt properties.
The changes here are to:
 * extend acpi_lookup_irq_handler() to lookup an irq in the ACPI
   resources
 * create a helper function acpi_map_intr() which uses the updated
   acpi_lookup_irq_handler() to look up an irq, and then map it
   with ACPI_BUS_MAP_INTR()
 * use acpi_map_intr() in acpi_pcib_route_interrupt() to map
   pci link interrupts.

With these changes, we can drop the ifdefs in acpi_resource.c, and
we can also drop the call for mapping interrupts in generic_timer.c

Reviewed by:    andrew
Differential Revision:  https://reviews.freebsd.org/D17790

FreeBSD/src 352469stable 12, stable/12/sys/arm64/arm64 pmap.c

MFC r350347
  Implement pmap_advise().  (Without a working pmap_advise() implementation
  madvise(MADV_DONTNEED) and madvise(MADV_FREE) are NOPs.)

FreeBSD/src 352468stable 12, stable/12/sys/dev/pci pci_host_generic.c pci_host_generic_acpi.c

MFC r340595-r340597

r340595:
pci_host_generic: remove unneeded ThunderX2 quirk

The current quirk implementation writes a fixed address to the PCI BAR
to fix a firmware bug. The PCI BARs are allocated by firmware and will
change depending on PCI devices present. So using a fixed address here
is not correct.

This quirk worked around a firmware bug that programmed the MSI-X bar
of the SATA controller incorrectly. The newer firmware does not have
this issue, so it is better to drop this quirk altogether.

Reviewed by:    andrew
Differential Revision:  https://reviews.freebsd.org/D17655

r340596:
pci_host_generic: allocate resources against devices

Fix up pci_host_generic.c and pci_host_generic_fdt.c to allocate
resources against devices that requested them. Currently the
allocation happens against the pcib, which is incorrect.

This is needed for the upcoming changes for fixing up

    [15 lines not shown]

FreeBSD/src 352467head/share/man/man5 src.conf.5

src.conf(5): regenerate after r352465, r352466

These changed the defaults for the GOOGLETEST knob and added a description
for WITH_GOOGLETEST.

FreeBSD/src 352466head/tools/build/options WITH_GOOGLETEST

Add description for WITH_GOOGLETEST

This is the logical negation of WITHOUT_GOOGLETEST, and helpful to have as
we now have different per-arch defaults for this option.

FreeBSD/src 352465head/share/mk src.opts.mk

googletest: default-disable on all of MIPS for now

Parts of the fusefs tests trigger a bug in current versions of llvm: IR
representation of some routine for the MIPS targets is a function with a
large number of arguments. This then leads the compiler on an hour+ long
goose chase, which is OK if you build the current tree but less-so if you're
trying external toolchain or doing a universe build involving mips when it
eventually gets switched over to LLVM.

Better, accurate details can be found in LLVM PR43263.

FreeBSD/src 352464head/stand/mips/uboot Makefile

mips: ubldr: use truncated load address for mips32

BFD appears to silently truncate 0xffffffff80800000 when it processes the
ldscript for 32-bit mips, but LLD chokes on it as the linker script tries to
place elements above 32-bit range. It's unclear to me if silent truncation
is kosher or not and whether this patch is really what we want to do, but it
is one approach at least.

Reviewed by:    imp, mizhka
Differential Revision:  https://reviews.freebsd.org/D21487

FreeBSD/src 352463head/tests/sys/netpfil/common tos.sh

Temporarily skip sys.netpfil.common.tos.pf_tos on i386 CI as it always fails

PR:            240086
Sponsored by:   The FreeBSD Foundation

FreeBSD/src 352462head/tests/sys/netpfil/common forward.sh

Temporarily skip sys.netpfil.common.forward.pf_v4 on i386 CI as it always fails

PR:            240085
Sponsored by:   The FreeBSD Foundation

FreeBSD/src 352461head/usr.sbin/newsyslog newsyslog.conf

Use correct filename in newsyslog.conf

Approved by:           bapt (implicit)
Differential Revision:  https://reviews.freebsd.org/D21561

FreeBSD/src 352460head/usr.sbin/newsyslog newsyslog.conf, head/usr.sbin/syslogd syslog.conf

log daemon.info to /var/log/daemon.log by default

log daemon facility now that daemon(8) has syslog support which defaults to
daemon facility, info priority

Reviewed by:           bapt
Approved by:           bapt
Differential Revision:  https://reviews.freebsd.org/D21561

FreeBSD/src 352459head/sbin/ifconfig ifmedia.c

ifconfig: add report of the string from SIOCGIFDOWNREASON.

Sample output:
# ifconfig mce0
mce0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=3ed07bb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM,TSO4,TSO6,LRO,VLAN_HWFILTER,VLAN_HWTSO,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6,TXRTLMT,HWRXTSTMP>
        ether e4:1d:2d:e7:10:0a
        media: Ethernet autoselect <full-duplex,rxpause,txpause>
        status: no carrier (Negotiation failure)
        nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>

Reviewed by:    hselasky, rrs
Sponsored by:   Mellanox Technologies
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D21527

FreeBSD/src 352458head/sys/net if.h if.c, head/sys/sys sockio.h

Add SIOCGIFDOWNREASON.

The ioctl(2) is intended to provide more details about the cause of
the down for the link.

Eventually we might define a comprehensive list of codes for the
situations.  But interface also allows the driver to provide free-form
null-terminated ASCII string to provide arbitrary non-formalized
information.  Sample implementation exists for mlx5(4), where the
string is fetched from firmware controlling the port.

Reviewed by:    hselasky, rrs
Sponsored by:   Mellanox Technologies
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D21527

FreeBSD/src 352457head/sys/fs/nfsclient nfs_clport.c

Further refine r352393, only call vnode_pager_setsize() outside the
node lock when shrinking.

This is similar to r252528, applied to the above commit.

Apparently there is a race which makes necessary at least to keep the
n_size and pager size consistent when extending.  Current suspect is
that iod threads perform vnode_pager_setsize() without taking the
vnode lock, which corrupts the file content.

Reported and tested by: Masachika ISHIZUKA <ish at amail.plala.or.jp>
Discussed with: rmacklem (related issues)
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week

FreeBSD/src 352456head/contrib/jemalloc/src jemalloc.c

realloc(x, 0) should not return NULL.

See http://www.open-std.org/jtc1/sc22/wg14/www/docs/summary.htm#dr_400.
Upstream jemalloc issue is opened by emaste at
https://github.com/jemalloc/jemalloc/issues/1629.

Reviewed by:    emaste
PR:     240456
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
DIfferential revision:  https://reviews.freebsd.org/D21632

FreeBSD/src 352455head/lib/libc/sys open.2, head/sys/kern vfs_vnops.c

Return EISDIR when directory is opened with O_CREAT without O_DIRECTORY.

Reviewed by:    bcr (man page), emaste (previous version)
PR:     240452
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
DIfferential revision:  https://reviews.freebsd.org/D21634

FreeBSD/src 352454head/stand/forth loader.4th

loader: provide u> and xemit words if needed

We have external interpreter (userboot.so) which may be lagging behind
with updates and may be missing u> xemit words.

FreeBSD/src 352453head/sys/kern vfs_cluster.c

The VFS-level clustering code collects together sequential blocks
by issuing delayed-writes (bdwrite()) until a non-sequential block
is written or the maximum cluster size is reached. At that point
it collects the delayed buffers together (using bread()) to write
them in a single operation. The assumption was that since we just
looked at them they will still be in memory so there is no need to
check for a read error from bread(). Very occationally (apparently
every 10-hours or so when being pounded by Peter Holm's tests)
this assumption is wrong.

The fix is to check for errors from bread() and fail the cluster
write thus falling back to the default individual flushing of any
still dirty buffers.

Reported by: Peter Holm and Chuck Silvers
Reviewed by: kib
MFC after:   3 days

FreeBSD/src 352452stable 12, stable/12/sys/arm64/arm64 pmap.c trap.c

MFC r349117, r349122, r349183, r349897, r349943, r350004, r350029, r350038,
  r350191, r350202, r350422, r350427, r350525

r349117:
  Three enhancements to arm64's pmap_protect():

  Implement protection changes on superpage mappings.  Previously, a superpage
  mapping was unconditionally demoted by pmap_protect(), even if the
  protection change applied to the entire superpage mapping.

  Precompute the bit mask describing the protection changes rather than
  recomputing it for every page table entry that is changed.

  Skip page table entries that already have the requested protection changes
  in place.

r349122:
  Three changes to arm64's pmap_unwire():

  Implement wiring changes on superpage mappings.  Previously, a superpage
  mapping was unconditionally demoted by pmap_unwire(), even if the wiring
  change applied to the entire superpage mapping.

  Rewrite a comment to use the arm64 names for bits in a page table entry.
  Previously, the bits were referred to by their x86 names.

    [100 lines not shown]

FreeBSD/src 352451head/stand/libsa zalloc_malloc.c

loader: revert r352421

As insisted by kib, malloc(0) is quite legal.

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

vfs: apply r352437 to the fast path as well

This one is very hard to run into. If the filesystem is being unmounted or
the mount point is freed the vfs_op_thread_enter will fail. For it to
succeed the mount point itself would have to be reallocated in the time
window between the initial read and the attempt to enter.

Sponsored by:   The FreeBSD Foundation

FreeBSD/src 352449head/lib/libbe be.c

fixup up fallout from r352447 in libbe

I totally forgot that we now have another in-tree consumer of libzfs.

MFC after:      3 days
X-MFC with:     r352447

FreeBSD/src 352448head/contrib/netbsd-tests/lib/libc/sys t_stat.c

Temporarily skip flakey test case lib.libc.sys.stat_test.stat_socket

PR:            240621
Sponsored by:   The FreeBSD Foundation

FreeBSD/src 352447head/cddl/contrib/opensolaris/cmd/zfs zfs.8 zfs_main.c, head/cddl/contrib/opensolaris/lib/libzfs/common libzfs_sendrecv.c libzfs.h

MFZoL: Add -vnP support to 'zfs send' for bookmarks

zfsonlinux/zfs at 835db58592d7d947e5818eb7281882e2a46073e0

We have long supported estimating a size of an incremental stream from a
snapshot.  We should do the same for bookmarks as well.

Obtained from:  ZoL
Author:        loli10K <ezomori.nozomu at gmail.com>
MFC after:      3 days

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

loader.efi: efipart needs to use ioalign

UEFI specification 2.7A, EFI_BLOCK_IO_PROTOCOL, page 566.

The ioalign property does define the alignment of data buffer.

If the alignment is required and our buffer is not aligned, or if
the data buffer is not multiple of Blocksize, we need to use bounce buffer
to perform the block IO. This is much like with BIOS version, except
there the INT13 needs buffer to be located in low memory.

Additionally, we need to handle disk writes properly.

FreeBSD/src 352445head/stand/libsa zalloc.c zalloc_malloc.c

loader: add memalign() to libsa

Implement memalign(size_t alignment, size_t size) to allocate aligned memory.

FreeBSD/src 352444head/stand/libsa stand.h

loader: stand.h should define reallocf as Reallocf

Use the same approach as other zalloc functions.

FreeBSD/src 352443head/stand/libsa zalloc.c zalloc_malloc.c

loader: cstyle cleanup libsa zalloc sources

Clean up libstand zalloc* sources. Note that it is not 100% whitespace cleanup.
I also reduced block in znalloc and zfree as those were obvious simplifications
and did help to save one level of indent.

FreeBSD/src 352442stable 12, stable/12/sys/arm/arm physmem.c

MFC r351649 Check for region dups.

FreeBSD/src 352441stable 12, stable/12/sys/arm64/arm64 cpufunc_asm.S

MFC r343042, r343875

r343042:
Ensure the I-Cache is correctly handled in arm64_icache_sync_range

The cache_handle_range macro to handle the arm64 instruction and data
cache operations would return when it was complete. This causes problems
for arm64_icache_sync_range and arm64_icache_sync_range_checked as they
assume they can execute the i-cache handling instruction after it has been
called.

Fix this by making this assumption correct.

While here add missing instruction barriers and adjust the style to
match the rest of the assembly.

Sponsored by:   DARPA, AFRL
Differential Revision:  https://reviews.freebsd.org/D18838

r343875:
Add a missing data barrier to the start of arm64_tlb_flushID.

We need to ensure the page table store has happened before the tlbi.

Reported by:    jchandra

    [3 lines not shown]

FreeBSD/src 352440stable 12, stable/12/sys/arm64/arm64 trap.c

MFC r342552:
Pass VM_PROT_EXECUTE to vm_fault for instruction faults.

We need to tell vm_fault the reason for the fault was because we tried to
execute from the memory location. Without this it may return with success
as we only request read-only memory, then we return to the same location
and try to execute from the same memory address. This leads to an infinite
loop raising the same fault and returning to the same invalid location.

Sponsored by:   DARPA, AFRL
Differential Revision:  https://reviews.freebsd.org/D18511

FreeBSD/src 352439head/stand/libsa zalloc_malloc.c

loader: factor out guard location setup from Realloc

To simplify and make it easier to read, use ga_Bytes field from guard
structure.

FreeBSD/src 352438head/sys/netinet sctp_auth.c

Only allow a SCTP-AUTH shared key to be updated by the application
if it is not deactivated and not used.
This avoids a use-after-free problem.

Reported by:           da_cheng_shao at yeah.net
MFC after:             3 days

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

vfs: fix braino resulting in NULL pointer deref in r352424

The breakage was added after all the testing and the testing which followed
was not sufficient to find it.

Reported by:    pho
Sponsored by:   The FreeBSD Foundation

FreeBSD/src 352436projects/clang900-import/share/man/man3 arb.3, projects/clang900-import/sys/kern vfs_mount.c

Merge ^/head r352319 through r352435.

FreeBSD/src 352435projects/clang900-import/lib/atf/libatf-c++ Makefile, projects/clang900-import/lib/googletest Makefile.inc

Another round of attempting to squelch -Wdeprecated-declarations, which
has become very trigger-happy with libc++ 9.0.0.

It does not help that gcc's implementation of this warning is even more
trigger-happy, in the sense that it already warns on the declaration
itself, not when you are using it.  This is very annoying with our use
of -Wsystem-headers.  That should really be disabled for gcc.

FreeBSD/src 352434head/sys/mips/include pcpu.h, head/sys/mips/mips pmap.c

mips: move support for temporary mappings above KSEG0 to per-CPU data

This is derived from similar work done in r310481 for i386 and r312610 for
armv6/armv7. Additionally, use a critical section to keep the thread
pinned for per-CPU operations instead of completely disabling local interrupts.

No objections from:     adrian, jmallett, imp
Differential Revision:  https://reviews.freebsd.org/D18593