FreeBSD/src 74f3572sys/contrib/zlib gzread.c zlib.h, sys/contrib/zlib/contrib/gcc_gvmat64 gvmat64.S

MFC: MFV: zlib 1.3.2.

Relnotes:       yes

(cherry picked from commit 7aa1dba6b00ccfb7d66627badc8a7aaa06b02946)
DeltaFile
+0-574sys/contrib/zlib/contrib/gcc_gvmat64/gvmat64.S
+190-124sys/contrib/zlib/gzread.c
+213-94sys/contrib/zlib/zlib.h
+168-99sys/contrib/zlib/gzwrite.c
+38-151sys/contrib/zlib/inflate.c
+91-91sys/contrib/zlib/inffixed.h
+700-1,13331 files not shown
+1,622-1,75137 files

FreeBSD/src e8dac39. Makefile.inc1

Makefile.inc1: Remove extraneous }

Reported by:    tijl
Fixes: 17494c6e6b7d ("build: Boostrap LLVM_BINUTILS for cross-tools")
DeltaFile
+1-1Makefile.inc1
+1-11 files

FreeBSD/src 5f08cdcsys/x86/isa atpic.c icu.h

x86: move the NUM_ISA_IRQS symbol from atpic.c into x86/isa/icu.h

This is not the best location, but works for now.

Reviewed by:    markj
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D56003
DeltaFile
+0-2sys/x86/isa/atpic.c
+2-0sys/x86/isa/icu.h
+2-22 files

FreeBSD/src f404109sys/vm vm_fault.c

vm_fault: Avoid creating clean, writeable superpage mappings

The pmap layer requires writeable superpage mappings to be dirty.
Otherwise, during demotion, we may miss a hw update of the PDE which
sets the dirty bit.

When creating a managed superpage mapping without promotion, i.e., with
pmap_enter(psind == 1), we must therefore ensure that a writeable
mapping is created with the dirty bit pre-set.  To that end,
vm_fault_soft_fast(), when handling a map entry with write permissions,
checks whether all constituent pages are dirty, and if so, converts the
fault to a write fault, so that pmap_enter() does the right thing.  If
one or more pages is not dirty, we simply create a 4K mapping.

vm_fault_populate(), which may also create superpage mappings, did not
do this, and thus could create mappings which violate the invariant
described above.  Modify it to instead check whether all constituent
pages are already dirty, and if so, convert the fault to a write fault.
Otherwise the mapping is downgraded to read-only.

    [5 lines not shown]
DeltaFile
+18-2sys/vm/vm_fault.c
+18-21 files

FreeBSD/src 8f3227fsys/kern kern_event.c, sys/sys filedesc.h

kqueue: Fix a race when adding an fd-based knote to a queue

When registering a new kevent backed by a file descriptor, we first look
up the file description with fget(), then lock the kqueue, then see if a
corresponding knote is already registered.  If not, and KN_ADD is
specified, we add the knote to the kqueue.

closefp_impl() interlocks with this process by calling knote_fdclose(),
which locks each kqueue and checks to see if the fd is registered with a
knote.  But, if userspace closes an fd while a different thread is
registering it, i.e., after fget() succeeds but before the kqueue is
locked, then we may end up with a mismatch in the knote table, where the
knote kn_fp field points to a different file description than the knote
ident.

Fix the problem by double-checking before registering a knote.  Add a
new fget_noref_unlocked() helper for this purpose.  It is a clone of
fget_noref().  We could simply use fget_noref(), but I like having an
explicit unlocked variant.

    [5 lines not shown]
DeltaFile
+17-0sys/sys/filedesc.h
+13-1sys/kern/kern_event.c
+30-12 files

FreeBSD/src 8823ca9sys/x86/include frame.h

amd64: revert back struct trapframe to the pre-FRED definition

(cherry picked from commit 1ba29614c4ce5e261ade0bd7def94079b7b9647a)
DeltaFile
+4-0sys/x86/include/frame.h
+4-01 files

FreeBSD/src a7182edsys/dev/mlx5 driver.h, sys/dev/mlx5/mlx5_core mlx5_cmd.c

mlx5: postpone freeing the completed command entity to taskqueue

(cherry picked from commit f0d5f46a1e42b801d96447e544cc3820612748b1)
DeltaFile
+11-1sys/dev/mlx5/mlx5_core/mlx5_cmd.c
+1-0sys/dev/mlx5/driver.h
+12-12 files

FreeBSD/src 0d98b06sys/amd64/amd64 trap.c

amd64: move code to clear PSL_T on debug exception into a helper

(cherry picked from commit d92ebde76430e99f78156fb1d865a18916380aed)
DeltaFile
+13-8sys/amd64/amd64/trap.c
+13-81 files

FreeBSD/src bd70835sys/sys param.h

sys/param.h: bump __FreeBSD_version for amd64 struct trapframe size change

(cherry picked from commit 6275cd73aca7f31cbb3b9da2d031f6664814d58c)
DeltaFile
+2-1sys/sys/param.h
+2-11 files

FreeBSD/src 9f174a7sys/amd64/amd64 trap.c, sys/x86/include frame.h

x86 FRED: add hardware definitions for the trap frames fields

(cherry picked from commit e90950627327de9226b052851b36f341bc72b746)
DeltaFile
+49-6sys/x86/include/frame.h
+9-8sys/amd64/amd64/trap.c
+58-142 files

FreeBSD/src 1c0357fsys/amd64/amd64 trap.c

amd64 trap.c: provide tag for the struct sfhandlers definition

(cherry picked from commit 8cc1c0f35ec8d5a3edb4ee1ede962a3c1f6baef0)
DeltaFile
+4-2sys/amd64/amd64/trap.c
+4-21 files

FreeBSD/src 25b6a30sys/amd64/include md_var.h

amd64: add prototype for ia32_syscall()

(cherry picked from commit 23dc4850fbc9e7abfc54f0ce11f343e4677fd0fb)
DeltaFile
+2-0sys/amd64/include/md_var.h
+2-01 files

FreeBSD/src 504b27esys/amd64/amd64 fpu.c

amd64: remove assertion about sizeof(struct pcb)

(cherry picked from commit acce5fa3dbe87ea953fb5060a03859e424398db8)
DeltaFile
+0-7sys/amd64/amd64/fpu.c
+0-71 files

FreeBSD/src 870bb8dsys/amd64/amd64 exec_machdep.c, sys/amd64/ia32 ia32_signal.c

amd64: check that %cs and %ss values from ucontext fit into registers

(cherry picked from commit 8892176c86db18bd175cc00a2d52dff080babec1)
DeltaFile
+28-0sys/amd64/ia32/ia32_signal.c
+19-0sys/amd64/amd64/exec_machdep.c
+47-02 files

FreeBSD/src 41ca79bsys/amd64/amd64 trap.c

amd64: move code to check for traps with interrupts disabled into helpers

(cherry picked from commit e18449fbe2731399862e82e61fffaadd6739642c)
DeltaFile
+58-38sys/amd64/amd64/trap.c
+58-381 files

FreeBSD/src 06e71cfsys/x86/include specialreg.h, sys/x86/x86 identcpu.c

x86 FRED: add CPUID, MSR, and CR4 bits

(cherry picked from commit eb0a78f6cef0c2924b565d7c297cb08bb4de7cb0)
DeltaFile
+23-0sys/x86/include/specialreg.h
+7-4sys/x86/x86/identcpu.c
+30-42 files

FreeBSD/src 81c2819sys/amd64/amd64 trap.c

amd64: do reset %rip after page fault if pcb_onfault is set

(cherry picked from commit 8365f877b1e4b6d4c30df72e0826ca60a412ce7d)
DeltaFile
+20-13sys/amd64/amd64/trap.c
+20-131 files

FreeBSD/src 9759690sys/amd64/amd64 trap.c

amd64: move efirt trap checks into the helper

(cherry picked from commit 914a53570750ce5a104a5870403d7669656fddc3)
DeltaFile
+26-29sys/amd64/amd64/trap.c
+26-291 files

FreeBSD/src f7b368dlib/libc/gen rtld_get_var.3

rtld_get_var(3): provide explicit list of rtld vars that can be modified

Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D56055
DeltaFile
+17-0lib/libc/gen/rtld_get_var.3
+17-01 files

FreeBSD/src 9f16078libexec/rtld-elf/tests set_var_test.c Makefile

rtld: add a test for rtld_set_var (with LIBRARY_PATH_FDS)

PR:     294054
Reviewed by:    kib
MFC after:      1 week
DeltaFile
+38-0libexec/rtld-elf/tests/set_var_test.c
+1-0libexec/rtld-elf/tests/Makefile
+39-02 files

FreeBSD/src b9f046dlibexec/rtld-elf rtld.c

rtld: properly handle update of several vars in rtld_set_var()

Besides setting the value in the array of the values, rtld sometimes
needs to recalculate some internal control variable for the change to
take effect.  Allow the variable description to supply a method called
on the update.  Lock the function with the bind lock for safe operation.

Mark several variables as allowed for update, since the on_update method
is provided for them.  The list is LD_BIND_NOW, LD_BIND_NOT,
LD_LIBMAP_DISABLE, LD_LOADFLTR.

Reviewed by:    markj
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D56055
DeltaFile
+152-36libexec/rtld-elf/rtld.c
+152-361 files

FreeBSD/src f39754dlib/msun/aarch64 fenv.h, lib/msun/amd64 fenv.c

fenv.h: stop declaring feclearexcept() extern inline

The function is already exported from libm.  We only need to stop
declare it extern inline, and instead provide a macro which uses the
internal inline function __feclearexcept_int() instead.

PR:     277958
Reviewed by:    dim (x86)
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D55975
DeltaFile
+5-2lib/msun/aarch64/fenv.h
+6-1lib/msun/amd64/fenv.c
+6-1lib/msun/arm/fenv.c
+6-1lib/msun/i387/fenv.c
+6-1lib/msun/powerpc/fenv.c
+5-2lib/msun/x86/fenv.h
+34-85 files not shown
+58-1311 files

FreeBSD/src 7e7d4e7sys/x86/x86 cpu_machdep.c tsc.c

x86: Handle when MPERF/APERF MSRs aren't writable

For performance and/or correct reasons some hypervisors allow
MPERF/APERF MSRs to be read but not written to. This change
modifies the handling of these MSRs to not rely on writes.
This patch is part of Google Cloud Engine (GCE) C4-LSSD turnup.

Sponsored by:           Google
Tested by:              NetApp (previous)
PR:                     292808
MFC after:              3 days
Co-authored-by:         Jim Mattson <jmattson at google.com>
Reviewed by:            jrtc27, imp, kib, markj, olce, obiwac
Differential Revision:  https://reviews.freebsd.org/D55996
DeltaFile
+7-7sys/x86/x86/cpu_machdep.c
+6-3sys/x86/x86/tsc.c
+13-102 files

FreeBSD/src c505fc1sys/x86/x86 cpu_machdep.c

x86: Guard clock frequency against a divide by 0

We may be running in a Virtual Machine which may not fully support
hardware performance counters. If the MPERF counter somehow ends up
at zero, return an error and fail gracefully instead of panicking.
This patch is part of Google Cloud Engine (GCE) C4-LSSD turnup.

Sponsored by:           Google
Tested by:              NetApp (previous)
PR:                     292808
MFC after:              3 days
Co-authored-by:         Aymeric Wibo <obiwac at google.com>
Co-authored-by:         Jim Mattson <jmattson at google.com>
Suggested by:           jrtc27 (split out this part)
Reviewed by:            imp, obiwac, olce
Differential Revision:  https://reviews.freebsd.org/D56056
DeltaFile
+8-1sys/x86/x86/cpu_machdep.c
+8-11 files

FreeBSD/src 4b16ff4tests/sys/kern timerfd.c

timerfd: Guard expected performance failure

During the timerfd__periodic_timer_performance test, only expect
failures when the expiration count is less than 400000000. This
prevents the test from being reported as a true failure in environments
where scheduling latency is high enough to delay timerfd wakeups.

Fixes:          cb692380f1e0 ("timerfd: Expect periodic timer ...")
MFC after:      1 week
DeltaFile
+2-1tests/sys/kern/timerfd.c
+2-11 files

FreeBSD/src 557f502sys/amd64/conf NOTES, sys/i386/conf MINIMAL

sys: vt_efifb: EFI not supported on i386; move it back to amd64/NOTES

We do not support EFI boot on i386.  Thus:
1. Move (back) 'device vt_efifb' from x86/NOTES to amd64/NOTES.
2. Remove 'device vt_efifb' from i386/MINIMAL.

Reported by:    jhb
Fixes:          f224591746bd ("Add ASMC_DEBUG make option")
Fixes:          67599eef01f5 ("sys/x86/NOTES: Add vt_efifb")
Sponsored by:   The FreeBSD Foundation
(cherry picked from commit 9c25620e57f01d8227f0d53c6b2134ab37a49fdf)
DeltaFile
+3-0sys/amd64/conf/NOTES
+0-1sys/i386/conf/MINIMAL
+3-12 files

FreeBSD/src 6a1ebd1sys/fs/fuse fuse_node.h fuse_node.c, tests/sys/fs/fusefs read.cc rename.cc

fusefs: redo vnode attribute locking

Previously most fields in fuse_vnode_data were protected by the vnode
lock.  But because DEBUG_VFS_LOCKS was never enabled by default until
stable/15 the assertions were never checked, and many were wrong.
Others were missing.  This led to panics in stable/15 and 16.0-CURRENT,
when a vnode was expected to be exclusively locked but wasn't, for fuse
file systems that mount with "-o async".

In some places it isn't possible to exclusively lock the vnode when
accessing these fields.  So protect them with a new mutex instead.  This
fixes panics and unprotected field accesses in VOP_READ,
VOP_COPY_FILE_RANGE, VOP_GETATTR, VOP_BMAP, and FUSE_NOTIFY_INVAL_ENTRY.
Add assertions everywhere the protected fields are accessed.

Lock the vnode exclusively when handling FUSE_NOTIFY_INVAL_INODE.

During fuse_vnode_setsize, if the vnode isn't already exclusively
locked, use the vn_delayed_setsize mechanism.  This fixes panics during

    [14 lines not shown]
DeltaFile
+192-0tests/sys/fs/fusefs/read.cc
+80-11sys/fs/fuse/fuse_node.h
+90-0tests/sys/fs/fusefs/rename.cc
+71-18sys/fs/fuse/fuse_node.c
+74-7sys/fs/fuse/fuse_vnops.c
+24-18sys/fs/fuse/fuse_internal.c
+531-545 files not shown
+609-7911 files

FreeBSD/src 9ac21f8tests/sys/fs/fusefs bmap.cc

fusefs: add a regression test for a cluster_read bug

VOP_BMAP is purely advisory.  If VOP_BMAP returns an error during
readahead, cluster_read should still succeed, because the actual data
was still read just fine.

Add a regression test for PR 264196, wherein cluster_read would fail if
VOP_BMAP did.

PR:             264196
Reported by:    danfe
Reviewed by:    arrowd
Differential Revision: https://reviews.freebsd.org/D51316

(cherry picked from commit 6d408ac490730614b3ed0ebd3caffcd23f303fb4)
DeltaFile
+87-0tests/sys/fs/fusefs/bmap.cc
+87-01 files

FreeBSD/src 1ebccc3sys/kern vfs_cluster.c

vfs_cluster.c: Do not propagate VOP_BMAP errors to the caller

The code that makes this VOP_BMAP call tries to perform a read-ahead I/O
operation. Failing to do that for any reason isn't fatal for `cluster_read()`,
because we still can return some data to the caller. This change is consistent
with other places within `cluster_read()`, where error returned by VOP_BMAP is
not returned to the caller - see the `if (nblks > 1)` block above the changed
lines and `if (reqbp)` at the end of the function.

PR:     264196
Approved by:    markj, kib
Differential Revision: https://reviews.freebsd.org/D51254

(cherry picked from commit 62aef3f73f38db9fb68bffc12cc8900fecd58f0e)
DeltaFile
+3-1sys/kern/vfs_cluster.c
+3-11 files

FreeBSD/src d069250sys/fs/fuse fuse_ipc.c fuse_ipc.h

fusefs: remove the obsolete rename_lock

This lock was included in the original GSoC submission.  Its purpose
seems to have been to prevent concurrent FUSE_RENAME operations for the
current mountpoint, as well as to synchronize FUSE_RENAME with
fuse_vnode_setparent.  But it's obsolete, now that ef6ea91593e added
mnt_renamelock .

Sponsored by:   ConnectWise
Reviewed by:    kib
Differential Revision: https://reviews.freebsd.org/D55231

(cherry picked from commit 7755a406a6ae3801e885a79f714155f97c4d2bc6)
DeltaFile
+0-2sys/fs/fuse/fuse_ipc.c
+0-2sys/fs/fuse/fuse_ipc.h
+0-2sys/fs/fuse/fuse_vnops.c
+0-63 files