FreeBSD/src b3563d1 — sys/dev/virtio/random virtio_random.c

virtio_random: defer first enqueue until after DRIVER_OK

According to the virtio spec:

> The driver MUST NOT send any buffer available notifications to the
> device before setting DRIVER_OK.

DRIVER_OK isn't set until after attach completes, so defer the first
enqueue.  We haven't found any problems as a result of this to the best
of my knowledge: q35 and other devices that we *have* been used with
will apparently check when we go DRIVER_OK.

Tested with q35 virtio-random, which still works.

Reported by:    llm-postcr
Reviewed by:    kfv, markj
Fixes:  f1c5a2e3a62505 ("virtio_random: Pipeline fetching the data")
Sponsored by:   Stormshield
Sponsored by:   Klara, Inc.

    [2 lines not shown]
DeltaFile
+16-2sys/dev/virtio/random/virtio_random.c
+16-21 files

FreeBSD/src 601d2a9 — sys/dev/virtio/random virtio_random.c

virtio_random: stop on detach, don't poll

If the device is hung, then polling will block the detach and hang us.
Stop it and drain the queue instead.  This fixes a hang on detach in
some circumstances without the upcoming virtio_pci_modern fix.

Reviewed by:    bnovkov, kfv
Sponsored by:   Stormshield
Sponsored by:   Klara, Inc.

(cherry picked from commit cce522853aae3da45b131c2522dd2510edf083e7)
DeltaFile
+9-3sys/dev/virtio/random/virtio_random.c
+9-31 files

FreeBSD/src fcfae0a — sys/dev/virtio/pci virtio_pci_modern.c

virtio_pci_modern: enable virtqueues before completing attach

Most of our drivers setup interrupt(s) and virtqueues are enabled at
that time, but nothing will currently enable them for devices that we're
only going to poll.  This most notably affects virtio-random, and the
problem can be observed with qemu's q35 emulation and a random device
attached.  The q35 implementation ignores the ring unless it's enabled,
so vtrnd_harvest() will consistently EAGAIN rather than contribute
anything of value, but with this patch it becomes functional.

This can be reproduced with a qemu invocation like so:

qemu-system-x86_64 -machine q35,accel=tcg -cpu max -smp 2 -m 2G \
  -drive file=FreeBSD-16.0-CURRENT-amd64-ufs.qcow2,if=virtio \
  -device pcie-root-port,id=rp1,bus=pcie.0,chassis=1 \
  -object rng-random,id=rng0,filename=/dev/urandom \
  -device virtio-rng-pci,rng=rng0,bus=rp1 \
  -display curses


    [5 lines not shown]
DeltaFile
+10-0sys/dev/virtio/pci/virtio_pci_modern.c
+10-01 files

FreeBSD/src 41aa43f — sys/dev/virtio/random virtio_random.c

virtio_random: avoid using vtrnd_detach in the failure path

On the off chance that we discover more than one virtio-random device,
the second one will deregister the global instance or trip an invariant
when it fails to attach and calls vtrnd_detach().

We don't have that many resources to free, so just inline those.  This
is purely a hygiene thing, we haven't seen an instance of this in the
wild (to my knowledge).

Reviewed by:    bnovkov, kfv
Sponsored by:   Stormshield
Sponsored by:   Klara, Inc.

(cherry picked from commit 26ba71f73e8914ecd9e5b1e7bb864fee41158d04)
DeltaFile
+9-2sys/dev/virtio/random/virtio_random.c
+9-21 files

FreeBSD/src 1a10bff — sys/dev/virtio/random virtio_random.c

virtio_random: defer first enqueue until after DRIVER_OK

According to the virtio spec:

> The driver MUST NOT send any buffer available notifications to the
> device before setting DRIVER_OK.

DRIVER_OK isn't set until after attach completes, so defer the first
enqueue.  We haven't found any problems as a result of this to the best
of my knowledge: q35 and other devices that we *have* been used with
will apparently check when we go DRIVER_OK.

Tested with q35 virtio-random, which still works.

Reported by:    llm-postcr
Reviewed by:    kfv, markj
Fixes:  f1c5a2e3a62505 ("virtio_random: Pipeline fetching the data")
Sponsored by:   Stormshield
Sponsored by:   Klara, Inc.

    [2 lines not shown]
DeltaFile
+16-2sys/dev/virtio/random/virtio_random.c
+16-21 files

FreeBSD/src ffa1d4d — sys/dev/virtio/pci virtio_pci_modern.c

virtio_pci_modern: enable virtqueues before completing attach

Most of our drivers setup interrupt(s) and virtqueues are enabled at
that time, but nothing will currently enable them for devices that we're
only going to poll.  This most notably affects virtio-random, and the
problem can be observed with qemu's q35 emulation and a random device
attached.  The q35 implementation ignores the ring unless it's enabled,
so vtrnd_harvest() will consistently EAGAIN rather than contribute
anything of value, but with this patch it becomes functional.

This can be reproduced with a qemu invocation like so:

qemu-system-x86_64 -machine q35,accel=tcg -cpu max -smp 2 -m 2G \
  -drive file=FreeBSD-16.0-CURRENT-amd64-ufs.qcow2,if=virtio \
  -device pcie-root-port,id=rp1,bus=pcie.0,chassis=1 \
  -object rng-random,id=rng0,filename=/dev/urandom \
  -device virtio-rng-pci,rng=rng0,bus=rp1 \
  -display curses


    [5 lines not shown]
DeltaFile
+10-0sys/dev/virtio/pci/virtio_pci_modern.c
+10-01 files

FreeBSD/src ddfd685 — sys/dev/virtio/random virtio_random.c

virtio_random: stop on detach, don't poll

If the device is hung, then polling will block the detach and hang us.
Stop it and drain the queue instead.  This fixes a hang on detach in
some circumstances without the upcoming virtio_pci_modern fix.

Reviewed by:    bnovkov, kfv
Sponsored by:   Stormshield
Sponsored by:   Klara, Inc.

(cherry picked from commit cce522853aae3da45b131c2522dd2510edf083e7)
DeltaFile
+9-3sys/dev/virtio/random/virtio_random.c
+9-31 files

FreeBSD/src 45819a7 — sys/dev/virtio/random virtio_random.c

virtio_random: avoid using vtrnd_detach in the failure path

On the off chance that we discover more than one virtio-random device,
the second one will deregister the global instance or trip an invariant
when it fails to attach and calls vtrnd_detach().

We don't have that many resources to free, so just inline those.  This
is purely a hygiene thing, we haven't seen an instance of this in the
wild (to my knowledge).

Reviewed by:    bnovkov, kfv
Sponsored by:   Stormshield
Sponsored by:   Klara, Inc.

(cherry picked from commit 26ba71f73e8914ecd9e5b1e7bb864fee41158d04)
DeltaFile
+9-2sys/dev/virtio/random/virtio_random.c
+9-21 files

FreeBSD/src ec66296 — sys/compat/linux linux_file.c

linux: Bound native getdents and getdents64 batches

linux_getdents() and linux_getdents64() round their native read size up
to DEV_BSIZE before converting entries. For an unaligned caller buffer,
the native batch can contain more entries than fit in the Linux buffer.
Conversion then returns EINVAL even after copying complete entries,
and the native read has already advanced the directory position.

For counts of at least DEV_BSIZE, use min(args->count, MAXBSIZE) instead.
A 768-byte request, such as rustix's initial directory read, now uses a
768-byte native buffer rather than 1024. The converted Linux dirent and
dirent64 records are no larger than their native counterparts, so the
whole translated batch fits. Returning a short batch is allowed, and
consuming the whole native batch avoids needing to rewind the directory
position.

Keep the existing sizing for counts below DEV_BSIZE. This fixes the
oversized-batch case in both getdents interfaces, including legacy
getdents for 32-bit and 64-bit callers. The remaining small-buffer,

    [8 lines not shown]
DeltaFile
+18-2sys/compat/linux/linux_file.c
+18-21 files

FreeBSD/src 91bcaea — sys/amd64/amd64 machdep.c

amd64: make hw.splitlock_force adjustable at runtime

(cherry picked from commit 57bc1e1c2f4c01953336bdf03743e30f4ba12cdc)
DeltaFile
+22-3sys/amd64/amd64/machdep.c
+22-31 files

FreeBSD/src edaa6ba — sys/opencrypto cryptodev.c

cryptodev: zero key material before freeing it

The /dev/crypto cipher and MAC keys are copied from userland and
released with free(), leaving the key bytes in freed kernel memory.
Use zfree() so the key material is cleared on session teardown and on
the setup error path.

Reviewed by:    markj
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D61324
DeltaFile
+4-4sys/opencrypto/cryptodev.c
+4-41 files

FreeBSD/src a7e3b8e — . meson.build configure.ac, libpkgconf libpkgconf.h

Vendor import of pkgconf 3.0.10

Obtained from https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-3.0.10.tar.gz

SHA1: c8677d3e1cec2d05b6f24b718b06a452c34c9a68  -
SHA256: 11818a25f2730132f3b258ac8be4e82f83b9db03a1a99a6c29cd01b94fc9d310  -
SHA512: 8680602b31c88dbcfa31cd2c3979b9a00f608422fbe1c0a9cf703e416d8c2e656a8f7b1640ed364d1c0387badf2567267b3fe2e2d6da4ddbdce816560fac0e6a  -

Sponsored by:   The FreeBSD Foundation
DeltaFile
+6-0NEWS
+2-2libpkgconf/libpkgconf.h
+1-1meson.build
+1-1configure.ac
+1-1Makefile.lite
+11-55 files

FreeBSD/src 04a3a6e — sys/powerpc/powerpc cpu.c

powerpc/idle: Set 'RL' field in PSSCR on POWER9

The POWER9 does not do automatic state transitions when idling, so the
'MTL' field (Maximum Transition Level) is ignored.  Thus, setting '0'
for the 'RL' field (Requested Level) as was done means it
doesn't transition to any power saving level.  To fix this, set both the
'MTL' and the 'RL' fields to the same level.

On a Talos II at idle this drops the reported temperatures by ~10-15%.

MFC after:      3 days
DeltaFile
+2-1sys/powerpc/powerpc/cpu.c
+2-11 files

FreeBSD/src f22d659 — contrib/elftoolchain/libdwarf dwarf.h dwarf_dump.c

libdwarf: standard DWARF 5 form names, DW_LANG_C17 and C23

7bb441c86678 added the fixed-size string and address index forms
0x25 to 0x2c as DW_FORM_ref_strx1..4 and DW_FORM_ref_addrx1..4; the
standard (DWARF 5, table 7.6) names them DW_FORM_strx1..4 and
DW_FORM_addrx1..4, with no "ref".  Rename them, keep the old spellings
as aliases since the header is installed, and update dwarf_dump.c's
form names accordingly.  Add DW_LANG_C17 (0x2c) and DW_LANG_C23 (0x3e),
which clang emits for -std=c17 and -std=c23 units.  ctfconv(1) needs
all of these; it carried them in a private header until now.

Reviewed by:    markj, emaste
MFC after:      1 week
Differential Revision: https://reviews.freebsd.org/D61154
DeltaFile
+16-16contrib/elftoolchain/libdwarf/dwarf_dump.c
+19-8contrib/elftoolchain/libdwarf/dwarf.h
+35-242 files

FreeBSD/src ea623d9 — sys/crypto/openssl/aarch64 sm4-armv8.S vpsm4_ex-armv8.S, sys/crypto/openssl/i386 rc5-586.S cast-586.S

openssl: stop generating asm that nothing builds

Makefile.asm generated eight perlasm outputs that neither libcrypto nor
the kernel builds. Additionally, upstream does not build them for these
architectures with FreeBSD's configuration:

- aarch64: ecp_sm2p256-armv8, sm3-armv8, sm4-armv8, vpsm4-armv8 and
  vpsm4_ex-armv8.  SM2, SM3 and SM4 are disabled (disable-sm2/sm3/sm4).
- i386: cast-586 (upstream's x86 configuration uses the C CAST code)
  and rc5-586 (RC5 is disabled by default).
- powerpc: aes-gcm-ppc.  Upstream builds it only for 64-bit
  little-endian; libcrypto and ossl(4) use it only on powerpc64 and
  powerpc64le, whose copies stay.

Remove them from Makefile.asm and delete the generated files, so the
next vendor import does not regenerate them.  If one of these algorithms
is ever enabled, add its script back to Makefile.asm and run "make
buildasm".


    [10 lines not shown]
DeltaFile
+0-5,021sys/crypto/openssl/aarch64/vpsm4-armv8.S
+0-4,543sys/crypto/openssl/aarch64/vpsm4_ex-armv8.S
+0-2,002sys/crypto/openssl/i386/cast-586.S
+0-1,264sys/crypto/openssl/i386/rc5-586.S
+0-1,093sys/crypto/openssl/aarch64/sm4-armv8.S
+0-988sys/crypto/openssl/powerpc/aes-gcm-ppc.S
+0-14,9113 files not shown
+3-16,2769 files

FreeBSD/src 1a65fd9 — lib/libc/string bstring.3

Revert "bstring.3: no cross reference to self"

This reverts commit ef7d29b0df91d32c0b880796acd969a0a00ecf47.
DeltaFile
+9-1lib/libc/string/bstring.3
+9-11 files

FreeBSD/src 724bb39 — sys/contrib/zlib gzwrite.c inflate.c

MFV: zlib 1.4

MFC after:      1 week
DeltaFile
+100-41sys/contrib/zlib/gzread.c
+73-37sys/contrib/zlib/deflate.c
+44-33sys/contrib/zlib/zlib.h
+37-37sys/contrib/zlib/gzlib.c
+43-13sys/contrib/zlib/inflate.c
+40-8sys/contrib/zlib/gzwrite.c
+337-16917 files not shown
+452-19723 files

FreeBSD/src 18eec80 — lib/libc/string string.3

Revert "string.3: no cross reference to self"

This reverts commit 0448f4d0a4359670e8ad2ec72d0a826685517ae7.
DeltaFile
+17-0lib/libc/string/string.3
+17-01 files

FreeBSD/src ba64f15 — usr.sbin/mountd mountd.8

mountd.8: fix link to syslog(3)

Reported by: des (prev. commit)
DeltaFile
+1-1usr.sbin/mountd/mountd.8
+1-11 files

FreeBSD/src 9b6bfb5 — lib/libc/stdio mktemp.3, lib/libpmc pmc.dmc-620.3

manpages: normalizing date format
DeltaFile
+1-1usr.bin/genl/genl.1
+1-1sys/teken/libteken/teken.3
+1-1lib/libpmc/pmc.dmc-620.3
+1-1lib/libc/stdio/mktemp.3
+4-44 files

FreeBSD/src 11a64df — share/man/man4 uhid.4 splash.4, share/man/man9 osd.9

manpages: normalizing date format
DeltaFile
+1-1share/man/man9/osd.9
+1-1share/man/man4/uhid.4
+1-1share/man/man4/splash.4
+1-1share/man/man4/pfsync.4
+1-1share/man/man4/ncthwm.4
+1-1share/man/man4/nctgpio.4
+6-63 files not shown
+9-99 files

FreeBSD/src e9c132d — sys/netinet/libalias alias_local.h alias_db.h

libalias: index fully specified inbound links by remote endpoint

Inbound lookups find the (alias address, alias port, link type) group
with a splay tree and then walk grp->full, a list of every fully
specified link in that group, comparing the remote address and port.
With redirect_addr in front of a busy server, every client connection
to public:443 lands in the same group, so each inbound packet that is
not near the head of the list walks all of it.  TCP links live up to
24 hours unless libalias sees a clean close, so the list can grow to
hundreds of thousands of entries and saturate a core at a few hundred
packets per second.

Keep the fully specified links of a group in an RB tree ordered by
(dst_addr, dst_port).  Links that share an endpoint are ordered newest
first by a per-instance insertion counter, which keeps the "most recent
link wins" behaviour of the list (tested by 3_natin:2_portoverlap).

Lookups with an unknown remote address and a known port still scan the
group.  Each link grows by 16 bytes.

    [10 lines not shown]
DeltaFile
+102-42sys/netinet/libalias/alias_db.c
+7-1sys/netinet/libalias/alias_db.h
+4-1sys/netinet/libalias/alias_local.h
+113-443 files

FreeBSD/src 7c348a7 — sys/netinet/libalias alias_smedia.c alias_skinny.c

libalias: Handle GetNewPort() errors properly

AddLink() fails when memory allocation fails or no free port is
available; both are error conditions.  However, functions such as
FindUdpTcpIn() were converting such failures to PKT_ALIAS_IGNORED, which
effectively means, "pass the packet without translation," which isn't
what we want.

Fix the problem by making sure that AddLink() errors are converted to
PKT_ALIAS_ERROR where appropriate.  The diff is a bit large but is
mostly mechanical: functions like TcpAliasOut() are converted to return
a result code, and an additional out-parameter is added to return the
alias_link pointer.

Reported by:    Yuxiang Yang <yangyx22 at mails.tsinghua.edu.cn>
Tested by:      Yuxiang Yang <yangyx22 at mails.tsinghua.edu.cn>
MFC after:      2 months
Differential Revision:  https://reviews.freebsd.org/D47778

(cherry picked from commit fb2ea26f3c3681f5ef639af9c798a631d800864b)
DeltaFile
+95-69sys/netinet/libalias/alias.c
+63-25sys/netinet/libalias/alias_db.c
+14-12sys/netinet/libalias/alias_local.h
+2-2sys/netinet/libalias/alias_smedia.c
+2-2sys/netinet/libalias/alias_skinny.c
+2-2sys/netinet/libalias/alias_irc.c
+178-1126 files

FreeBSD/src f102113 — sys/netinet/libalias alias_local.h alias.h, tests/sys/netinet/libalias 2_natout.c

libalias: Add support for EIM NAT

Add support for endpoint-independent mapping ("full cone NAT") in
Libalias's UDP NAT.

This conforms to RFC 4787 requirements 1 and 3. All UDP packets sent out from a
particular internal address:port leave via the same NAT address:port,
regardless of their destination.

Add some libalias tests and supporting defines.

Reviewed by:    igoro, thj
Differential Revision:  https://reviews.freebsd.org/D46689D

(cherry picked from commit 61bf830cbb260c2a046cb44421d319184393e028)
DeltaFile
+170-0tests/sys/netinet/libalias/2_natout.c
+56-2sys/netinet/libalias/alias_db.c
+31-12sys/netinet/libalias/alias_db.h
+21-1sys/netinet/libalias/libalias.3
+20-0sys/netinet/libalias/alias.h
+4-2sys/netinet/libalias/alias_local.h
+302-172 files not shown
+304-188 files

FreeBSD/src 2b27613 — lib/libc/gen uexterr_gettext.3, lib/libc/posix1e mac.conf.5

manpages: date typos
DeltaFile
+1-1share/man/man9/sx.9
+1-1share/man/man4/ufintek.4
+1-1share/man/man4/pflog.4
+1-1share/man/man4/mac_seeotheruids.4
+1-1lib/libc/posix1e/mac.conf.5
+1-1lib/libc/gen/uexterr_gettext.3
+6-63 files not shown
+9-99 files

FreeBSD/src ebd89b9 — lib/libsys sched_getcpu.3, lib/libsysdecode sysdecode_mask.3

manpages: missing section argument for .Xr macro
DeltaFile
+2-2usr.sbin/nfsd/pnfsserver.4
+1-1usr.sbin/pnfsdsfile/pnfsdsfile.8
+1-1usr.sbin/nfsd/pnfs.4
+1-1share/man/man7/environ.7
+1-1lib/libsysdecode/sysdecode_mask.3
+1-1lib/libsys/sched_getcpu.3
+7-71 files not shown
+8-87 files

FreeBSD/src 22b4975 — lib/libc/gen uexterror.3 uexterr_gettext.3, share/man/man9 exterror.9

manpages: Fix unusual Xr order
DeltaFile
+1-1usr.sbin/quot/quot.8
+1-1share/man/man9/exterror.9
+1-1lib/libc/gen/uexterror.3
+1-1lib/libc/gen/uexterr_gettext.3
+4-44 files

FreeBSD/src 989ff10 — usr.sbin/setaudit setaudit.8

setaudit.8: remove empty macro Xr
DeltaFile
+0-1usr.sbin/setaudit/setaudit.8
+0-11 files

FreeBSD/src fddd0bc — lib/libc/gen setproctitle.3, lib/libmd sha512.3

manpages: missing comma before name
DeltaFile
+1-2lib/msun/man/clog.3
+1-1lib/msun/man/sqrt.3
+1-1lib/libpmc/pmc.amd.3
+1-1lib/libmd/sha512.3
+1-1lib/libc/gen/setproctitle.3
+5-65 files

FreeBSD/src 186f14e — share/man/man3 pthread_join.3 tree.3, share/man/man9 OF_device_from_xref.9

manpages: missing comma before name
DeltaFile
+2-2share/man/man3/tree.3
+1-1share/man/man9/OF_device_from_xref.9
+1-1share/man/man3/pthread_join.3
+4-43 files