Bjoern A. Zeeb [Fri, 17 Nov 2023 00:47:11 +0000 (00:47 +0000)]
dpaa2: defer link_state updates until we are up
dpaa2_ni_media_change() was called in early setup stages, before we
were fully setup. That lead to internal driver state being all synched
and fine but hardware state was lost/never setup corrently.
Introduce dpaa2_ni_media_change_locked() so we can avoid reccursive
locking and call "dpaa2_ni_media_change()" instead of mii_mediachg()
as the latter does not setup our state there either.
In order for this all to work, call if_setdrvflagbits() just before
rather than after the above.
Also remove an unecessary direct call to dpaa2_ni_miibus_statchg()
which mii_mediachg() will trigger anyway.
This all fixes a problem [1] that one had to lose the link (either
unplugging/replugging the cable or using ifconfig media none;
ifconfig media auto) to re-trigger the all updates and get the
full state programmed when hardware expected.
Bjoern A. Zeeb [Wed, 15 Nov 2023 11:46:44 +0000 (11:46 +0000)]
dpaa2: make software VLANs usable on dpni
dpni announces IFCAP_VLAN_MTU but internally does not increase the
maximum frame length. Createing a vlan interface on top of a dpni
interface will result in full-sized frames not passing.
Extend the maximum frame length by ETHER_VLAN_ENCAP_LEN to allow at
least for one layer of (software) vlans for now
[tcp] add PRR 6937bis heuristic and retire prr_conservative sysctl
Improve Proportional Rate Reduction (RFC6937) by using a
heuristic, which automatically chooses between
conservative CRB and more aggressive SSRB modes.
Only when snd_una advances (a partial ACK), SSRB may be
used. Also, that ACK must not have any indication of
ongoing loss - using the addition of new holes into the
scoreboard as proxy for such an event.
Notable upstream pull request merges:
#15516 da51bd17e Fix snap_obj_array memory leak in check_filesystem()
#15519 35da34516 L2ARC: Restrict write size to 1/4 of the device
#15529 03e9caaec Add a tunable to disable BRT support
Lock the vnode in the most exclusive lock mode requested, once.
All callers already ensure that vp1 != vp2 or are careful enough to only
unlock once otherwise.
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D42642
Instead, use a here document for the input. This allows us to run the
while loop in the main script so we can build the list of asserts in
a shell variable. We then print out the list of asserts at the end of
the loop.
John Baldwin [Thu, 16 Nov 2023 00:53:53 +0000 (16:53 -0800)]
pkg: Allocate a suitably-sized string for the local ABI
Previously the local ABI string was written to an on-stack buffer and
the pointer to that buffer was saved in a global before the function
returned. This had two issues: c[ABI].val pointed to a
no-longer-valid on-stack buffer after config_init returned, and the
string could potentially be truncated. Fix both of those by changing
pkg_get_myabi to return a pointer to a string allocated by asprintf.
Note that the allocated string is left in the global config array
until it is implicitly freed on process exit.
Brooks Davis [Wed, 15 Nov 2023 23:42:37 +0000 (23:42 +0000)]
libc: centralize a few numeric symbols
fabs, __infinity, and __nan are universally implemented so declare them
in gen/Symbol.map.
We would also include __flt_rounds, but it's under FBSD_1.3 on arm so
until that's gone we're stuck with it. Likewise, everyone but i386
implements fp[gs]etmask.
Brooks Davis [Wed, 15 Nov 2023 23:41:35 +0000 (23:41 +0000)]
libc: centralize {_,sig,}{set,long}jmp symbols
These symbols are universally exposed and documented so declare them
centrally. Double- and triple-underscore versions exist on some
platforms, but leave those alone for now.
Brooks Davis [Wed, 15 Nov 2023 23:39:46 +0000 (23:39 +0000)]
lib{c,lzma,z}: remove -DSYMBOL_VERSIONING from CFLAGS
This was part of a libkse and libpthread transition aide when libc
gained symbol versions in e62165c8b0f7d6452c0033127a0fd8ad1d9e34d3
(March 2006). The code that cared about this macro was removed in
commit 00fb440c1a145b56b6c75fd405d80071aef2aab1 (May 2007) when symbol
versioning was enabled by default and libthr became the default
threading library. For unknown reasons, it stayed in libc (which
seemingly never used it) and seems to have been copied to liblzma and
libz.
Mark Bloch [Sun, 19 Feb 2023 14:05:16 +0000 (14:05 +0000)]
net/mlx5: Fix auto group size calculation
Once all the large flow groups (defined by the user when the flow table
is created - max_num_groups) were created, then all the following new
flow groups will have only one flow table entry, even though the flow table
has place to larger groups.
Fix the condition to prefer large flow group.
Warner Losh [Wed, 15 Nov 2023 22:28:05 +0000 (15:28 -0700)]
Revert "awk: Merge upstream 2nd Edition Awk Book"
The pre-push testing I did turned out to be testing the old version with
the old testsuite (for reasons I don't understnad). There's issues with
the new version, the new test in the suite or (likely) both. Revert
until they can be chased down.
This should also fix the github CI that's gone red since this commit.
Andrew Turner [Wed, 15 Nov 2023 17:42:02 +0000 (17:42 +0000)]
Add an Armv8 rndr random number provider
Armv8.5 adds an optional random number generator. This is implemented
as two special registers one to read a random number, the other to
re-seed the entropy pool before reading a random number. Both registers
will set the condition flags to tell the caller they can't produce a
random number in a reasonable amount of time.
Without a signal to reseed the entropy pool use the latter register
to provide random numbers to the kernel pool. If at a later time we
had a way to tell the provider if it needs to reseed or not we could
use the former.
On an Amazon AWS Graviton3 VM this never failed, however this may not
be the case on low end CPUs so retry reading the random number 10 times
before returning an error.
Reviewed by: imp, delphij (csprng)
Sponsored by: The FreeBSD Foundation
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D35411
Andrew Turner [Mon, 13 Nov 2023 15:29:30 +0000 (15:29 +0000)]
arm64: Make kern_delta unneeded in the boot params
Use pmap_early_vtophys to translate from a virtual to physical where
we were previously using the calculated delta. This means that, while
we still calculate it, we don't need to pass it to initarm or either
pmap bootstrap functions.
While here remove an unneeded printf that indirectly used it or was
related to the previous printf.
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D42567
Andrew Turner [Mon, 13 Nov 2023 16:34:56 +0000 (16:34 +0000)]
arm64: Use pmap_early_vtophys in pmap_bootstrap_san
Use pmap_early_vtophys to find the physical address of the kernel base
rather than using the calculated offset as it will be removed in a
latter commit.
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D42566
Andrew Turner [Sat, 11 Nov 2023 09:27:30 +0000 (09:27 +0000)]
arm64: Use adrp + :lo12: to load globals from asm
When loading a global variable we can use a pseudo-instruction similar
to "ldr, xn, =global" to load the address of the symbol. As this is
unlikely to be supported by a mov instruction a pc-relative load is
used, with the absolute address written at the end of the function so
it will be loaded.
This load can be partially replaced with an adrp instruction. This
generates the address, aligned to a 4k boundary, using a pc-relative
addition. Because the address is 4k-aligned we then update reading the
global variable using a load with the offset of the load the low
12-bits of the global. Arm64 assemblers have :lo12: to support this,
e.g. "ldr xn, [xn, :lo12:global]".
The only remaining users of "ldr, xn, =global" that I can find are
executed from the physical address space the kernel was loaded in and
need an address in the kernels virtual address space. Because of this
they can't use adrp.
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D42565
Brooks Davis [Wed, 15 Nov 2023 17:46:57 +0000 (17:46 +0000)]
Sort .git-blame-ignore-revs by commit order
This makes it easier to add blocks of commits such as 4ca5df80393e1f2..c90d0600ee000e78 which do a single thing over the
course of multiple commits. Sorting by hash would require manually
inserting each one with a comment.
Andrew Gallatin [Wed, 15 Nov 2023 16:11:53 +0000 (11:11 -0500)]
smbios: handle smbios3 for arm64
Get smbios working on arm64 where it seems to be
exclusively smbios version 3.x
The "interesting" thing here is that the smbios table seems to be
RAM in the EFI runtime services table. This makes it owned by "ram0",
and not io memory. That prevents bus_alloc_resource() from being able
to claim it, since ram0 already owns it. According to jhb, this is
how things are supposed to work. Eg, bus_alloc_resource() is meant
to be used with IO memory, not physical memory. Following his
suggestion, I converted the driver to simply use pmap_mapbios().
This is a prerequisite for getting IPMI to attach via the SSIF
attachment on arm64 servers, where all IPMI that I've seen
uses SSIF.
Note that this change is based on initial work by Allan Jude in
https://reviews.freebsd.org/D28739.
Doug Moore [Wed, 15 Nov 2023 09:25:45 +0000 (03:25 -0600)]
vm_phys: fix freelist_contig
vm_phys_find_freelist_contig is called to search a list of max-sized
free page blocks and find one that, when joined with adjacent blocks
in memory, can satisfy a request for a memory allocation bigger than
any single max-sized free page block. In commit fa8a6585c7522b7de6d29802967bd5eba2f2dcf1, I defined this function in
order to offer two improvements: 1) reduce the worst-case search time,
and 2) allow solutions that include less-than max-sized free page
blocks at the front or back of the giant allocation. However, it turns
out that this change introduced an error, reported in In Bug
274592. That error concerns failing to check segment boundaries. This
change fixes an error in vm_phys_find_freelist_config that resolves
that bug. It also abandons improvement 2), because the value of that
improvement is small and because preserving it would require more
testing than I am able to do.
John Baldwin [Wed, 15 Nov 2023 02:37:25 +0000 (18:37 -0800)]
sys: Disable -Walloc-size-larger-than for GCC 9+
By default this warns about sizes larger than PTRDIFF_MAX passed to
malloc (rather than SIZE_MAX). This doesn't trigger
deterministically, but it does trigger for kmalloc() of struct_size()
in iwlwifi's iwl_configure_rxq even when struct_size() is changed to
use PTRDIFF_MAX. NB: struct_size() in Linux caps the size at
SIZE_MAX, not PTRDIFF_MAX via size_mul().
John Baldwin [Wed, 15 Nov 2023 02:35:04 +0000 (18:35 -0800)]
bsd.sys.mk: Disable -Wdangling-reference for GCC 13+
GCC raises this warning for libc++'s istream. It raises false
positives in other cases as well (GCC bugs 109640, 109642, 109671).
Warning from <istream>:
/usr/include/c++/v1/istream:1464:34: error: possibly dangling reference to a temporary [-Werror=dangling-reference]
1464 | const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc());
| ^~~~
/usr/include/c++/v1/istream:1464:71: note: the temporary was destroyed at the end of the full expression 'std::__1::use_facet<ctype<char> >(std::__1::ios_base::getloc() const())'
1464 | const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc());
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
John Baldwin [Wed, 15 Nov 2023 02:34:01 +0000 (18:34 -0800)]
libcasper: Neuter false positive -Wuse-after-free warnings from GCC 13
GCC 13 incorrectly thinks a call to free after a failed realloc is a
use after free.
lib/libcasper/services/cap_grp/cap_grp.c: In function 'group_resize':
lib/libcasper/services/cap_grp/cap_grp.c:65:17: error: pointer 'buf' may be used after 'realloc' [-Werror=use-after-free]
65 | free(buf);
| ^~~~~~~~~
lib/libcasper/services/cap_grp/cap_grp.c:63:19: note: call to 'realloc' here
63 | gbuffer = realloc(buf, gbufsize);
| ^~~~~~~~~~~~~~~~~~~~~~
In make target rules, one needs to use subshell if there are
change directory commands that should only have an effect on the
other commands in the same line. Otherwise, if make is not running in
compatibility mode (for example, when -j flag is specified), commands
would be executed in a single shell and lines following the "cd" might
not work as expected.
Adjust the target script lines that use "cd" to run in a subshell
by adding appropriate parenthesis.
Alexander Motin [Tue, 14 Nov 2023 21:47:57 +0000 (16:47 -0500)]
L2ARC: Restrict write size to 1/4 of the device
PR #15457 exposed weird logic in L2ARC write sizing. If it appeared
bigger than device size, instead of liming write it reset all the
system-wide tunables to their default. Aside of being excessive,
it did not actually help with the problem, still allowing infinite
loop to happen.
This patch removes the tunables reverting logic, but instead limits
L2ARC writes (or at least eviction/trim) to 1/4 of the capacity.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: George Amanakis <gamanakis@gmail.com> Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored by: iXsystems, Inc.
Closes #15519
Justin Hibbits [Thu, 2 Nov 2023 20:09:14 +0000 (16:09 -0400)]
bcm2835/spi: Support SPI_FLAG_KEEP_CS
Summary: 3c08673438 brought in SPI_FLAG_KEEP_CS to keep the SPI chip select held
post-transfer completion. Add this support to bcm2835 SPI for SPI
devices that need it. As part of this, the owner thread needed carried
through so that no other thread can take over the SPI bus until the
owner releases the chip select.
Reviewed by: manu
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D42599
lib/libc/tests/string: add extended unit tests for strcmp()
This changeset add a new set of tests that comprehensively test strcmp() on
various alignments of the input. This made it easy to smoke out many
exciting new bugs in the new SSE strcmp() implementation from D41971.
MFC after: 1 week
Reviewed by: ngie
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41970
pkgbase: create package with SRCRELDATE not OSRELDATE as OSVERSION
In 188fe88ec50eac7c10e1d8350bf1180f8c16e463 OSVERSION has been set
to OSRELDATE which is the RELDATE of the building OS while we wanted
to use SRCRELDATE which is the RELDATE of the target system
pkgbase: set the prefix of debug files and macros to /usr/src
When the macro PACKAGE_BUILDING is set, then consider we are building package
for pkgbase, this has already been used in Makefile.inc1 and reuse the
PACKAGE_BUILDING macros already used for that purpose in the ports tree
In the future this should be tied to REPRODUCIBLE_BUILD
MFC After: 3 days
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D42569
John Baldwin [Tue, 14 Nov 2023 01:00:52 +0000 (17:00 -0800)]
abort2: Generate a core dump
Call sigexit rather than exit1 so that a core is generated.
If running the SIGABRT handler is desired, this would need to use
kern_psignal() instead. In that case a userspace wrapper in libc
would be needed to force an exit if the handler doesn't exit. Given
that abort2(2)'s intended use case is when userland is in a
sufficiently bad state such that it can't safely call syslog(3) before
abort(3), a userspace abort2(3) wrapper in libc might be dubious.