]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agolibc: add _get_tp() private function
Konstantin Belousov [Mon, 5 Apr 2021 03:30:35 +0000 (06:30 +0300)]
libc: add _get_tp() private function

(cherry picked from commit 06d8a116bd6b6f70b8aedc6a6a2c4085c53f63ac)

3 years agortld: define TLS_DTV_OFFSET on all architectures
Konstantin Belousov [Wed, 7 Apr 2021 06:25:34 +0000 (09:25 +0300)]
rtld: define TLS_DTV_OFFSET on all architectures

(cherry picked from commit 99c2ce7ef12f0852f25155d1d6718beccafbae0e)

3 years agolibc: include rtld.h into static implementations of rtld interface
Konstantin Belousov [Mon, 5 Apr 2021 03:41:46 +0000 (06:41 +0300)]
libc: include rtld.h into static implementations of rtld interface

(cherry picked from commit 7f7489eba391a858b3930a34e7749d642b374c5c)

3 years agolibc: constify dummy error message string for dlfcn
Konstantin Belousov [Mon, 5 Apr 2021 04:14:39 +0000 (07:14 +0300)]
libc: constify dummy error message string for dlfcn

(cherry picked from commit 93c14c55ec0da311dc09c1c8c1c7ecd5f2fae51a)

3 years agortld_lock.h: Expand scope for IN_RTLD to avoid some conflicts with libc
Konstantin Belousov [Mon, 5 Apr 2021 04:12:22 +0000 (07:12 +0300)]
rtld_lock.h: Expand scope for IN_RTLD to avoid some conflicts with libc

(cherry picked from commit 34ca6025ddfea9899024eb6e7617091c5bc5149a)

3 years agortld/x86/reloc.c: style
Konstantin Belousov [Wed, 7 Apr 2021 06:12:10 +0000 (09:12 +0300)]
rtld/x86/reloc.c: style

(cherry picked from commit f61ecf60cfce6172df803a9e5e099aab2d4aedcd)

3 years agortld_lock.h: remove tautological extern's
Konstantin Belousov [Mon, 5 Apr 2021 04:11:49 +0000 (07:11 +0300)]
rtld_lock.h: remove tautological extern's

(cherry picked from commit 38e0610df7d5cd5ddd43a477c139ec6ce342c5c2)

3 years agortld dl_iterate_phdr(): dlpi_tls_data is wrong
Konstantin Belousov [Mon, 5 Apr 2021 03:05:44 +0000 (06:05 +0300)]
rtld dl_iterate_phdr(): dlpi_tls_data is wrong

(cherry picked from commit d36d6816151705907393889d661cbfd25c630ca8)

3 years agolinuxkpi: remove erronously committed diff save file
Konstantin Belousov [Tue, 6 Apr 2021 00:42:13 +0000 (03:42 +0300)]
linuxkpi: remove erronously committed diff save file

(cherry picked from commit 5b3b19db7305f8255f021d6f8d94d17ab778660f)

3 years agolinuxkpi: drop single-use variable
Konstantin Belousov [Tue, 30 Mar 2021 08:46:42 +0000 (11:46 +0300)]
linuxkpi: drop single-use variable

(cherry picked from commit 8011fb795baa59ba14371d6db5ab661a5db77615)

3 years agolinuxkpi: avoid counting per-thread use for the embedded linux cdevs
Konstantin Belousov [Tue, 30 Mar 2021 08:45:24 +0000 (11:45 +0300)]
linuxkpi: avoid counting per-thread use for the embedded linux cdevs

(cherry picked from commit f6b108837e7df7d7bfb35ec447f7cb62afa79441)

3 years agolinuxkpi: do not destroy/free embedded linux cdevs
Konstantin Belousov [Tue, 30 Mar 2021 08:44:19 +0000 (11:44 +0300)]
linuxkpi: do not destroy/free embedded linux cdevs

(cherry picked from commit 7f9867f8c65b1b3e590dba4dc432a4bc8cf01f68)

3 years agolinuxkpi: rename cdev to ldev
Konstantin Belousov [Tue, 30 Mar 2021 08:43:21 +0000 (11:43 +0300)]
linuxkpi: rename cdev to ldev

(cherry picked from commit 28b482e2baf43cdd30e8b9bd090e6d9f405cf4b3)

3 years agolinuxkpi: copy ldev into local to test and free the same pointer
Konstantin Belousov [Tue, 30 Mar 2021 08:41:00 +0000 (11:41 +0300)]
linuxkpi: copy ldev into local to test and free the same pointer

(cherry picked from commit 7b0125cbec1579a0a1bf38f7abe583b5f6fd79e7)

3 years agoFix leak in libc NFSv4 ACL flags parsing
Andrew Walker [Tue, 20 Apr 2021 19:34:44 +0000 (15:34 -0400)]
Fix leak in libc NFSv4 ACL flags parsing

Free memory allocated by strdup() in parse_flags_verbose().

Submitted by: Andrew Walker <walker.aj325_gmail.com>
Reported by: valgrind
Reviewed by: allanjude, freqlabs, rpokala
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D29871

(cherry picked from commit dd559118ab3f065ae230b324c3fe4bb1c9b7ca56)

3 years agotcp: Deal with DSACKs, and adjust rescue hole on success.
Richard Scheffenegger [Tue, 20 Apr 2021 12:53:56 +0000 (14:53 +0200)]
tcp: Deal with DSACKs, and adjust rescue hole on success.

When a rescue retransmission is successful, rather than
inserting new holes to the left of it, adjust the old
rescue entry to cover the missed sequence space.

Also, as snd_fack may be stale by that point, pull it forward
in order to never create a hole left of snd_una/th_ack.

Finally, with DSACKs, tcp_sack_doack() may be called
with new full ACKs but a DSACK block. Account for this
eventuality properly to keep sacked_bytes >= 0.

MFC after: 3 days
Reviewed By: kbowling, tuexen, #transport
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D29835

(cherry picked from commit a649f1f6fd7a098ab173a69fe87916c04a8c6f8d)

3 years agotcp: keep SACK scoreboard sorted when doing rescue retransmission
Richard Scheffenegger [Sun, 18 Apr 2021 20:14:14 +0000 (22:14 +0200)]
tcp: keep SACK scoreboard sorted when doing rescue retransmission

Reviewed By: tuexen, kbowling, #transport
MFC after: 3 days
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D29825

(cherry picked from commit b87cf2bc841b2a336b7f0c6cd89573610412a84f)

3 years agopms(4): Limit maximum I/O size to 256KB instead of 1MB.
Alexander Motin [Fri, 16 Apr 2021 19:39:01 +0000 (15:39 -0400)]
pms(4): Limit maximum I/O size to 256KB instead of 1MB.

There is a weird limit of AGTIAPI_MAX_DMA_SEGS (128) S/G segments per
I/O since the initial driver import.  I don't know why it was added,
can only guess some hardware limitation, but in worst case it means
maximum I/O size of 508KB.  Respect it to be safe, rounding to 256KB.

MFC after: 1 week
Sponsored by: iXsystems, Inc.

(cherry picked from commit 3e347834200b5d91a33384e696793e4ac20a44d4)

3 years agopms(4): Do not return CAM_REQ_CMP on errors.
Alexander Motin [Fri, 16 Apr 2021 19:16:09 +0000 (15:16 -0400)]
pms(4): Do not return CAM_REQ_CMP on errors.

It is a direct request for data corruptions, one report of which we
have received.  I am very surprised that only one.

MFC after: 1 week
Sponsored by: iXsystems, Inc.

(cherry picked from commit 8434a65ce49bd6bc6779f0e57b0ce0f4bc46f48e)

3 years agorack: Fix ECN on finalizing session.
Richard Scheffenegger [Sat, 17 Apr 2021 18:16:06 +0000 (20:16 +0200)]
rack: Fix ECN on finalizing session.

Maintain code similarity between RACK and base stack
for ECN. This may not strictly be necessary, depending
when a state transition to FIN_WAIT_1 is done in RACK
after a shutdown() or close() syscall.

MFC after: 3 days
Reviewed By: tuexen, #transport
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D29658

(cherry picked from commit 2e97826052d169f6e2e1d2f87b086f56d1cf2b0b)

3 years agotcp: Prepare PRR to work with NewReno LossRecovery
Richard Scheffenegger [Thu, 8 Apr 2021 16:52:20 +0000 (18:52 +0200)]
tcp: Prepare PRR to work with NewReno LossRecovery

Add proper PRR vnet declarations for consistency.
Also add pointer to tcpopt struct to tcp_do_prr_ack, in preparation
for it to deal with non-SACK window reduction (after loss).

No functional change.

MFC after: 2 weeks
Reviewed By: tuexen, #transport
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D29440

(cherry picked from commit 90cca08e91f54214747af0419c988aba868398ed)

3 years agotcp: Use PRR for ECN congestion recovery
Richard Scheffenegger [Fri, 26 Mar 2021 01:05:22 +0000 (02:05 +0100)]
tcp: Use PRR for ECN congestion recovery

MFC after: 2 weeks
Reviewed By: #transport, rrs
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D28972

(cherry picked from commit b9f803b7d4b7ee3799ab94f66c02c3b6e58c153a)

3 years agotcp: Refactor PRR code
Richard Scheffenegger [Thu, 25 Mar 2021 22:58:46 +0000 (23:58 +0100)]
tcp: Refactor PRR code

No functional change intended.

MFC after: 2 weeks
Reviewed By: #transport, rrs
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D29411

(cherry picked from commit eb3a59a83112f5fcd60aab44ac0ac68331b6aedf)

3 years agostats.7: Add dwatch(1) to the list
Fernando Apesteguía [Thu, 22 Apr 2021 13:54:45 +0000 (15:54 +0200)]
stats.7: Add dwatch(1) to the list

PR: 255303
Approved by: 0mp (mentor)
Differential Revision: https://reviews.freebsd.org/D29924

(cherry picked from commit 2e5929a75634504d388cc04d24e6a558840e18cb)

3 years agozfs: merge openzfs/zfs@3522f57b6 (master)
Martin Matuska [Wed, 14 Apr 2021 10:49:10 +0000 (12:49 +0200)]
zfs: merge openzfs/zfs@3522f57b6 (master)

Notable upstream pull request merges:
  #11742 When specifying raidz vdev name, parity count should match
  #11744 Use a helper function to clarify gang block size
  #11771 Support running FreeBSD buildworld on Arm-based macOS hosts

This is the last update that will be MFCed into stable/13.

From now on, the tracking of OpenZFS branches will be different:
- main continues tracking openzfs/zfs/master
- stable/13 is going to track openzfs/zfs/zfs-2.1-release

Obtained from: OpenZFS

(cherry picked from commit 6db169e920810bf1d7e9bd2fad5da92bfb696677)

3 years agopowerpc64: add missing TLB invalidations to radix
Leandro Lupori [Tue, 6 Apr 2021 11:31:44 +0000 (08:31 -0300)]
powerpc64: add missing TLB invalidations to radix

Radix MMU code was missing TLB invalidations when some Level 3 PDEs were
modified. This caused TLB multi-hit machine check interrupts when
superpages were enabled.

Reviewed by: jhibbits
Sponsored by: Eldorado Research Institute (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D29511

(cherry picked from commit 28d14569c8735060d0a1646a3422562c0741ac44)

3 years agopowerpc64: clear low-order bits of ARPN
Leandro Lupori [Thu, 25 Mar 2021 16:30:56 +0000 (13:30 -0300)]
powerpc64: clear low-order bits of ARPN

PowerISA 2.07B says that the low-order p-12 bits of the real page number
contained in ARPN and LP fields of a PTE must be 0s and are ignored
by the hardware (Book III-S, 5.7.7.1), where 2^p is the actual page size
in bytes, but we were clearing only the LP field.

This worked on bare metal and QEMU with KVM, that ignore these bits,
but caused a kernel panic on QEMU with TCG, that expects them to be
cleared.

This fixes running FreeBSD with HPT superpages enabled on QEMU
with TCG.

Sponsored by: Eldorado Research Institute (eldorado.org.br)

(cherry picked from commit 3d0399c718b260da087d28825069f26d4f670065)

3 years agonfsd: fix replies from session cache for retried RPCs
Rick Macklem [Thu, 8 Apr 2021 21:04:22 +0000 (14:04 -0700)]
nfsd: fix replies from session cache for retried RPCs

Recent testing of network partitioning a FreeBSD NFSv4.1
server from a Linux NFSv4.1 client identified problems
with both the FreeBSD server and Linux client.

The FreeBSD server failec to reply using the cached
reply in the session slot when an RPC was retried on
the session slot, as indicated by same slot sequence#.

This patch fixes this.  It should also fix a similar
failure for NFSv4.0 mounts, when the sequence# in
the open/lock_owner requires a reply be done from
an entry locked into the DRC.

This fix affects the fairly rare case where a NFSv4
client retries a non-idempotent RPC, such as a lock
operation.  Note that retries only occur after the
client has needed to create a new TCP connection.

(cherry picked from commit 05a39c2c1c18cd0c4382a4f58e0952d3f77e7dfa)

3 years agoAllow lib/msun/logarithm_test to pass on ld128 platforms
Alex Richardson [Mon, 19 Apr 2021 23:22:45 +0000 (00:22 +0100)]
Allow lib/msun/logarithm_test to pass on ld128 platforms

For some reason the ld128 log1pl() implementation is less accurate than
logl(), but does at least guarantee precision >= the ld80 implementation.
Mark log1p_accuracy_tests as XFAIL for ld128 and increase the log1p tolerance
to the ld80 equivalent in accuracy_tests to avoid losing test coverage for
the other functions.

PR: 253984
Reviewed By: ngie, dim
Differential Revision: https://reviews.freebsd.org/D29039

(cherry picked from commit 1ad83445fc0f1d2aecd32635f4ae713a057aa091)

3 years agoRemove XFAIL from tests/lib/msun/lround_test:main
Alex Richardson [Thu, 15 Apr 2021 15:07:58 +0000 (16:07 +0100)]
Remove XFAIL from tests/lib/msun/lround_test:main

This test no longer fails after 3b00222f156dca5700c839d73e36daf479fa640c.

PR: 205451
MFC after: 1 week

(cherry picked from commit 062293c2c471c6affb46f0ba44e7b7ee5b77b591)

3 years agoRemove amd64 XFAIL from tests/lib/msun/fma_test:infinities
Alex Richardson [Thu, 15 Apr 2021 15:04:19 +0000 (16:04 +0100)]
Remove amd64 XFAIL from tests/lib/msun/fma_test:infinities

This test no longer fails after 3b00222f156dca5700c839d73e36daf479fa640c.

PR: 205448
MFC after: 1 week

(cherry picked from commit 3f01d8c2fe5d31866258c9872f35030d98828e48)

3 years agolib/msun: Exclude ignored-pragmas from -Werror
Alex Richardson [Thu, 15 Apr 2021 15:27:52 +0000 (16:27 +0100)]
lib/msun: Exclude ignored-pragmas from -Werror

This avoids build failures due to the clang 12 warning:
    '#pragma FENV_ACCESS' is not supported on this target - ignored

Clang 12 currently emits this warning for all non-x86 architectures.
While this can result in incorrect code generation (e.g. on AArch64 some
exceptions are not raised as expected), this is a pre-existing issue and
we should not fail the build due to this warning.

Reviewed By: dim, emaste
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D29743

(cherry picked from commit 168234fa67c38f898b784b3265dd77ace0b0a2f9)

3 years agolib/msun/tests: Drop WARNS=6
Alex Richardson [Mon, 22 Mar 2021 16:56:10 +0000 (16:56 +0000)]
lib/msun/tests: Drop WARNS=6

This is the default already, so there is no need to override it.

Reported by: kevans

(cherry picked from commit f33b4fa2f0d4acf3978c7490b25c999b319c543b)

3 years agolib/msun/tests: Re-enable csqrt_test on AArch64
Alex Richardson [Mon, 22 Mar 2021 16:54:38 +0000 (16:54 +0000)]
lib/msun/tests: Re-enable csqrt_test on AArch64

The LLVM bug was fixed a long time ago and with D29076 this test actually
passes now.

Reviewed By: andrew
Differential Revision: https://reviews.freebsd.org/D29092

(cherry picked from commit dbb2d6f5e1231a9f6b49efdc720ce97b520da2ba)

3 years agoFix lib/msun/tests/csqrt_test on platforms with 128-bit long double
Alex Richardson [Mon, 22 Mar 2021 16:54:02 +0000 (16:54 +0000)]
Fix lib/msun/tests/csqrt_test on platforms with 128-bit long double

If long double has more than 64 mantissa bits, using uint64_t to hold the
mantissa bits will truncate the value and result in test failures. To fix
this problem use __uint128_t since all platforms that have
__LDBL_MANT_DIG__ > 64 also have compiler support for 128-bit integers.

Reviewed By: rlibby
Differential Revision: https://reviews.freebsd.org/D29076

(cherry picked from commit ce88eb476b86cac63cef7466bd71f14b611ab03a)

3 years agoFix unused functions in invtrig_test.c
Alex Richardson [Mon, 22 Mar 2021 13:05:28 +0000 (13:05 +0000)]
Fix unused functions in invtrig_test.c

I only tested the WARNS=6 change on AArch64 and AMD64, but this file has
unused functions for architectures with LDBL_PREC == 53.

While touching this file change the LDBL_PREC == 53 checks to i386 checks.
The long double tests should only be disabled for i386 (due to the rather
odd rounding mode that it uses) not all architectures where long double
is the same as double.

PR: 205449
Fixes: 87d65c747a43 ("lib/msun: Allow building tests with WARNS=6")
Reported by: Jenkins

(cherry picked from commit 7f5693d05329ab976287b8d449e694e7a0f99e88)

3 years agoDon't add -Winline for WARNS=6
Alex Richardson [Mon, 22 Mar 2021 11:55:45 +0000 (11:55 +0000)]
Don't add -Winline for WARNS=6

This warning is very rarely useful (inline is a hint and not mandatory).
This flag results in many warnings being printed when compiling C++
code that uses the standard library with GCC.

This flag was originally added in back in r94332 but the flag is a no-op
in Clang ("This diagnostic flag exists for GCC compatibility, and has no
effect in Clang"). Removing it should make the GCC build output slightly
more readable.

Reviewed By: jrtc27, imp
Differential Revision: https://reviews.freebsd.org/D29235

(cherry picked from commit c8c62548bffb83f3d25e062929c45d66fea755f1)

3 years agolib/msun/tests: Add more debug output to fenv_test.c
Alex Richardson [Thu, 4 Mar 2021 18:41:06 +0000 (18:41 +0000)]
lib/msun/tests: Add more debug output to fenv_test.c

Output a hex dump of the current fenv and the expected value to allow
comparing them without having to resort to interactive use of GDB.

(cherry picked from commit 6ccdee8ab576577224fb9e4baed05bd0efe933fd)

3 years agolib/msun/tests: Skip fenv_test:masking if exceptions can't be trapped
Alex Richardson [Mon, 22 Mar 2021 11:53:40 +0000 (11:53 +0000)]
lib/msun/tests: Skip fenv_test:masking if exceptions can't be trapped

Some CPUs (e.g. AArch64 QEMU) cannot trap on floating point exceptions and
therefore ignore the writes to the floating point control register inside
feenableexcept(). If no exceptions are enabled after
feenableexcept(FE_ALL_EXCEPT), we can assume that the CPU does not
support exceptions and we can then skip the test.

Reviewed By: dim
Differential Revision: https://reviews.freebsd.org/D29095

(cherry picked from commit 2b9dbcd390dfbd573d3403360a36c5ade9815266)

3 years agolib/msun: Allow building tests with WARNS=6
Alex Richardson [Thu, 25 Feb 2021 14:28:17 +0000 (14:28 +0000)]
lib/msun: Allow building tests with WARNS=6

The only change needed is to mark a few variables as static.

(cherry picked from commit 87d65c747a4389901c2bbbcb1ec4878b2df7b32c)

3 years agoImprove test messages for msun tests
Alex Richardson [Mon, 22 Mar 2021 11:42:07 +0000 (11:42 +0000)]
Improve test messages for msun tests

Also print the mismatched values when numbers compare not equal.

Reviewed By: dim
Differential Revision: https://reviews.freebsd.org/D29091

(cherry picked from commit b424e0038a00dffbec800a6f0778db0ffdabe9d6)

3 years agoRemove XFAILs from fmaxmin test
Alex Richardson [Mon, 22 Mar 2021 11:40:17 +0000 (11:40 +0000)]
Remove XFAILs from fmaxmin test

These appears to have been resolved by compiling the test with -fno-builtin
and/or using a newer compiler.

PR: 208703
Reviewed By: ngie
Differential Revision: https://reviews.freebsd.org/D28884

(cherry picked from commit b358534ab1a953fac5830012751232e2f0807cc0)

3 years agoConvert the msun tests to ATF
Alex Richardson [Mon, 22 Mar 2021 11:15:13 +0000 (11:15 +0000)]
Convert the msun tests to ATF

This provides better error messages that just an assertion failure and
also makes it easier to mark individual tests as XFAIL.
It was also helpful when coming up with D28786 and D28787.

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

(cherry picked from commit 133bc645077d77ddb3c7d49130b4ec6fd93e7d34)

3 years agolib/msun: Fix x86 GCC6 build after 221622ec0c8e184
Alex Richardson [Fri, 12 Mar 2021 18:44:42 +0000 (18:44 +0000)]
lib/msun: Fix x86 GCC6 build after 221622ec0c8e184

Apparently GCC only supports arithmetic expressions that use static
const variables in initializers starting with GCC8. To keep older
versions happy use a macro instead.

Fixes: 221622ec0c ("lib/msun: Avoid FE_INEXACT for x86 log2l/log10l")
Reported by: Jenkins
Reviewed By: imp
Differential Revision: https://reviews.freebsd.org/D29233

(cherry picked from commit 05eac56a0432d07acd7f159125855437a4dd6259)

3 years agolib/msun: Avoid FE_INEXACT for x86 log2l/log10l
Alex Richardson [Mon, 8 Mar 2021 09:39:29 +0000 (09:39 +0000)]
lib/msun: Avoid FE_INEXACT for x86 log2l/log10l

This fixes tests/lib/msun/logarithm_test after compiling the test with
-fno-builtin (D28577). Adding invln10_lo + invln10_10 results in
FE_INEXACT (for all inputs) and the same for the log2l invln2_lo + invln2_hi.
This patch avoids FE_INEXACT (for exact results such as 0) by defining a
constant and using that.

Reviewed By: dim
Differential Revision: https://reviews.freebsd.org/D28786

(cherry picked from commit 221622ec0c8e184dd1ea7e1f77fb45d2d32cb6e2)

3 years agoAllow ssp_test:read to pass more reliably
Alex Richardson [Mon, 1 Mar 2021 19:50:38 +0000 (19:50 +0000)]
Allow ssp_test:read to pass more reliably

It appears that the stackframe layout can be slightly different depending on
compiler and target architecture. For example, when using CHERI LLVM for RISC-V
we can actually overflow the buffer by up to 8 bytes without SSP detecting it.
Fix this by increasing the overflow to 15 bytes.

Reviewed By: ngie, emaste
Differential Revision: https://reviews.freebsd.org/D28997

(cherry picked from commit c88c1f23a8989b881a5ca51223289ddb4ce74277)

3 years agos_scalbn.c: Add missing float.h include
Alex Richardson [Mon, 1 Mar 2021 14:10:24 +0000 (14:10 +0000)]
s_scalbn.c: Add missing float.h include

This caused LDBL_MANT_DIG to not be defined and therefore the scalbnl
alias was not being emitted for double==long double platforms.

Fixes: 760b2ffc ("Update scalbn* functions to the musl versions")
Reported by: Jenkins

(cherry picked from commit f5542795b99206a2b4e5a57429d18b9478264e24)

3 years agoAlso use the musl scalbn code for ldexp()
Alex Richardson [Thu, 25 Feb 2021 14:29:44 +0000 (14:29 +0000)]
Also use the musl scalbn code for ldexp()

Instead of copying the code as 00646ca2047305fce32d99edc7a8e6dfd801f3b4
did, include the implementation with the function name re-defined.

(cherry picked from commit aac21e66f94e0a8ad52c1f8cd8dce50fcdd35cca)

3 years agoUpdate scalbn* functions to the musl versions
Alex Richardson [Wed, 24 Feb 2021 16:56:53 +0000 (16:56 +0000)]
Update scalbn* functions to the musl versions

The only diff compared to musl is a minor change to scalbnl() to replace
musl's union ldshape with union IEEEl2bits.
This fixes the scalbn tests on non-x86 (since x86 has an assembly version
that is used instead).

Musl commit messages:
commit 8c44a060243f04283ca68dad199aab90336141db
Author: Szabolcs Nagy <nsz@port70.net>
Date:   Mon Apr 3 02:38:13 2017 +0200

    fix scalbn when result is in the subnormal range

    in nearest rounding mode scalbn could introduce double rounding error
    when an intermediate value and the final result were both in the
    subnormal range e.g.

      scalbn(0x1.7ffffffffffffp-1, -1073)

    returned 0x1p-1073 instead of 0x1p-1074, because the intermediate
    computation got rounded to 0x1.8p-1023.

    with the fix an intermediate value can only be in the subnormal range
    if the final result is 0 which is correct even after double rounding.
    (there still can be two roundings so signals may be raised twice, but
    that's only observable with trapping exceptions which is not supported.)

commit 2eaed464e2080d8321d3903b71086a1ecfc4ee4a
Author: Szabolcs Nagy <nsz@port70.net>
Date:   Wed Sep 4 15:52:54 2013 +0000

    math: use float_t and double_t in scalbnf and scalbn

    remove STRICT_ASSIGN (c99 semantics is assumed) and use the conventional
    union to prepare the scaling factor (so libm.h is no longer needed)

commit 1b77b9072f374bd26eb0574b83a0d5f18d75ec60
Author: Szabolcs Nagy <nsz@port70.net>
Date:   Thu Aug 15 10:07:46 2013 +0000

    math: minor scalbn*.c simplification

commit c4359e01303da2755fe7e8033826b132eb3659b1
Author: Szabolcs Nagy <nsz@port70.net>
Date:   Tue Nov 13 10:55:35 2012 +0100

    math: excess precision fix modf, modff, scalbn, scalbnf

    old code was correct only if the result was stored (without the
    excess precision) or musl was compiled with -ffloat-store.
    now we use STRICT_ASSIGN to work around the issue.
    (see note 160 in c11 section 6.8.6.4)

commit 666271c105e4137bdfa195e217799d74143370d4
Author: Szabolcs Nagy <nsz@port70.net>
Date:   Tue Nov 13 10:30:40 2012 +0100

    math: fix scalbn and scalbnf on overflow/underflow

    old code was correct only if the result was stored (without the
    excess precision) or musl was compiled with -ffloat-store.
    (see note 160 in n1570.pdf section 6.8.6.4)

commit 8051e08e10d2b739fcfcbc6bc7466e8d77fa49f1
Author: nsz <nsz@port70.net>
Date:   Mon Mar 19 10:54:07 2012 +0100

    simplify scalbn*.c implementations

    The old scalbn.c was wrong and slow, the new one is just slow.
    (scalbn(0x1p+1023,-2097) should give 0x1p-1074, but the old code gave 0)

Reviewed By: dim
Differential Revision: https://reviews.freebsd.org/D28872

(cherry picked from commit 760b2ffc552985017c5bc74fb9966d4dc1b5b691)

3 years agolib/msun/ctrig_test: Print the mismatched values on failure
Alex Richardson [Tue, 23 Feb 2021 09:38:57 +0000 (09:38 +0000)]
lib/msun/ctrig_test: Print the mismatched values on failure

This test fails on aarch64 but debugging it is difficult without the
results being printed.

Now the failing AArch64 test prints:
root@freebsd-aarch64:/nfsroot/usr/tests/lib/msun # kyua debug ctrig_test:test_nan_inputs
*** Check failed: /local/scratch/alr48/cheri/freebsd/lib/msun/tests/ctrig_test.c:211: (ctan)(_d) (0 + -1 I) != expected (-0 + -1 I)
*** Check failed: /local/scratch/alr48/cheri/freebsd/lib/msun/tests/ctrig_test.c:211: ctan fetestexcept((0x00000002 | 0x00000010 | 0x00000001 | 0x00000004 | 0x00000008)) (0x10) != 0
*** Check failed: /local/scratch/alr48/cheri/freebsd/lib/msun/tests/ctrig_test.c:211: (ctan)(_d) (0 + 1 I) != expected (-0 + 1 I)
*** Check failed: /local/scratch/alr48/cheri/freebsd/lib/msun/tests/ctrig_test.c:211: ctan fetestexcept((0x00000002 | 0x00000010 | 0x00000001 | 0x00000004 | 0x00000008)) (0x10) != 0
*** Check failed: /local/scratch/alr48/cheri/freebsd/lib/msun/tests/ctrig_test.c:211: (ctanf)(_d) (0 + -1 I) != expected (-0 + -1 I)
*** Check failed: /local/scratch/alr48/cheri/freebsd/lib/msun/tests/ctrig_test.c:211: ctanf fetestexcept((0x00000002 | 0x00000010 | 0x00000001 | 0x00000004 | 0x00000008)) (0x10) != 0
*** Check failed: /local/scratch/alr48/cheri/freebsd/lib/msun/tests/ctrig_test.c:211: (ctanf)(_d) (0 + 1 I) != expected (-0 + 1 I)
*** Check failed: /local/scratch/alr48/cheri/freebsd/lib/msun/tests/ctrig_test.c:211: ctanf fetestexcept((0x00000002 | 0x00000010 | 0x00000001 | 0x00000004 | 0x00000008)) (0x10) != 0
*** Check failed: /local/scratch/alr48/cheri/freebsd/lib/msun/tests/ctrig_test.c:217: (ctanh)(_d) (1 + 0 I) != expected (1 + -0 I)
*** Check failed: /local/scratch/alr48/cheri/freebsd/lib/msun/tests/ctrig_test.c:217: ctanh fetestexcept((0x00000002 | 0x00000010 | 0x00000001 | 0x00000004 | 0x00000008)) (0x10) != 0
*** Check failed: /local/scratch/alr48/cheri/freebsd/lib/msun/tests/ctrig_test.c:217: (ctanhf)(_d) (1 + 0 I) != expected (1 + -0 I)
*** Check failed: /local/scratch/alr48/cheri/freebsd/lib/msun/tests/ctrig_test.c:217: ctanhf fetestexcept((0x00000002 | 0x00000010 | 0x00000001 | 0x00000004 | 0x00000008)) (0x10) != 0
*** Check failed: /local/scratch/alr48/cheri/freebsd/lib/msun/tests/ctrig_test.c:217: (ctanh)(_d) (-1 + 0 I) != expected (-1 + -0 I)
*** Check failed: /local/scratch/alr48/cheri/freebsd/lib/msun/tests/ctrig_test.c:217: ctanh fetestexcept((0x00000002 | 0x00000010 | 0x00000001 | 0x00000004 | 0x00000008)) (0x10) != 0
*** Check failed: /local/scratch/alr48/cheri/freebsd/lib/msun/tests/ctrig_test.c:217: (ctanhf)(_d) (-1 + 0 I) != expected (-1 + -0 I)
*** Check failed: /local/scratch/alr48/cheri/freebsd/lib/msun/tests/ctrig_test.c:217: ctanhf fetestexcept((0x00000002 | 0x00000010 | 0x00000001 | 0x00000004 | 0x00000008)) (0x10) != 0
ctrig_test:test_nan_inputs  ->  failed: 16 checks failed; see output for more details

Reviewed By: ngie
Differential Revision: https://reviews.freebsd.org/D28788

(cherry picked from commit f3f7b0dc065ce30f29b221788c58079d78931a77)

3 years agoUpdate libm tests from NetBSD
Alex Richardson [Mon, 22 Feb 2021 17:19:06 +0000 (17:19 +0000)]
Update libm tests from NetBSD

I did this without a full vendor update since that would cause too many
conflicts. Since these files now almost match the NetBSD sources the
next git subtree merge should work just fine.

Reviewed By: lwhsu
Differential Revision: https://reviews.freebsd.org/D28797

(cherry picked from commit 1ec3feb64826d2a43d41e74684690985bf20e71c)

3 years agodu_test: Skip three tests if sparse files are not supported
Alex Richardson [Wed, 3 Feb 2021 16:07:05 +0000 (16:07 +0000)]
du_test: Skip three tests if sparse files are not supported

This fixes running the du tests with /tmp as tmpfs (which is what we do in the
CheriBSD CI).

Obtained from: CheriBSD
Reviewed By: ngie
Differential Revision: https://reviews.freebsd.org/D28398

(cherry picked from commit 39a1f858ad735ef816a9b1fb7eeade2c6802eb98)

3 years agosbin/bectl: Skip tests if sparse files are not supported
Alex Richardson [Wed, 3 Feb 2021 09:31:32 +0000 (09:31 +0000)]
sbin/bectl: Skip tests if sparse files are not supported

The tests create a 1GB test file and this causes the tests to fail in the
CheriBSD CI setup where we run tests with a tmpfs mount on /tmp. Tmpfs
does not support sparse files and it appears that tmpfs default to creating
a 1GB mount, so there is not enough space to run these tests.

Instead of checking for at least 1GB of free space, this commit skips the
tests on file systems that do not support sparse files.

Reviewed By: kevans
Differential Revision: https://reviews.freebsd.org/D28463

(cherry picked from commit d6f4e1a8973daff2ffe4480b66c973562982ffc7)

3 years agoFix build with read-only source dir after 83c20b8a2da0
Alex Richardson [Wed, 3 Feb 2021 09:29:08 +0000 (09:29 +0000)]
Fix build with read-only source dir after 83c20b8a2da0

I changed the Makefile to use SRCS instead of LDADD, but since there is
still and absolute path to the source the .o file was created inside the
source directory instead of the build directory.
It would be nice if this was an error/warning by default, but for now just
fix this issue by using .PATH and the base name of the file.

Reported by: cy, peterj

(cherry picked from commit 8b820df156e065f48857dca89a89462074659e14)

3 years agotests/sys/kern/crc32: Check for SSE4.2 before using it
Alex Richardson [Tue, 2 Feb 2021 09:52:52 +0000 (09:52 +0000)]
tests/sys/kern/crc32: Check for SSE4.2 before using it

This avoids a SIGILL when running these tests on QEMU (which
defaults to a basic amd64 CPU without SSE4.2).

This commit also tests the table-based implementations in addition to
testing the hw-accelerated crc32 versions.

Reviewed By: cem, kib, markj
Differential Revision: https://reviews.freebsd.org/D28395

(cherry picked from commit 83c20b8a2da04937cf4af127366b3dc92c855784)

3 years agoAvoid double output in fenv_test
Alex Richardson [Fri, 29 Jan 2021 09:29:26 +0000 (09:29 +0000)]
Avoid double output in fenv_test

This tests fork()s, so if there is still data in the stdout buffer on fork
it will print it again in the child process. This was happening in the
CheriBSD CI and caused the test to complain about malformed TAP output.

Reviewed By: ngie
Differential Revision: https://reviews.freebsd.org/D28397

(cherry picked from commit 892a05ee3a6abd8d84f46a1b895b1d2bf805d08a)

3 years agoImprove size readability.
Michael Reifenberger [Mon, 15 Feb 2021 19:23:32 +0000 (20:23 +0100)]
Improve size readability.
Preserve more space for swap devise names.
Prevent line overflow with long devise name.
Don't draw a bar when swap is not used at all.
Simplify and optimize code.
Change the label to end at end of 100%.
PR: 251655
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D27496

(cherry picked from commit 8d06c3e7a40831ac139d83b85b282206229b426f)

3 years agogdb: report specific stop reason for watchpoints
Mitchell Horne [Mon, 8 Mar 2021 19:04:51 +0000 (15:04 -0400)]
gdb: report specific stop reason for watchpoints

The remote protocol allows for implementations to report more specific
reasons for the break in execution back to the client [1]. This is
entirely optional, so it is only implemented for amd64, arm64, and i386
at the moment.

[1] https://sourceware.org/gdb/current/onlinedocs/gdb/Stop-Reply-Packets.html

Reviewed by: jhb
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
NetApp PR: 51

(cherry picked from commit 7446b0888d920124516284eaa32714d63353e2c9)

3 years agogdb: allow setting/removing hardware watchpoints
Mitchell Horne [Mon, 8 Mar 2021 19:03:45 +0000 (15:03 -0400)]
gdb: allow setting/removing hardware watchpoints

Handle the 'z' and 'Z' remote packets for manipulating hardware
watchpoints.

This could be expanded quite easily to support hardware or software
breakpoints as well.

https://sourceware.org/gdb/onlinedocs/gdb/Packets.html

Reviewed by: cem, markj
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
NetApp PR: 51

(cherry picked from commit 4beb385813c8b1014f8250a31b07fdc09a059713)

3 years agoddb: replace watchpoint set/clear functions
Mitchell Horne [Mon, 8 Mar 2021 15:27:19 +0000 (11:27 -0400)]
ddb: replace watchpoint set/clear functions

Use the new kdb variants. Print more specific error messages.

Reviewed by: jhb, markj
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.

(cherry picked from commit 9d81dd5404b3ad7108059d7065814d56a722a96c)

3 years agoarm: implement kdb watchpoint functions
Mitchell Horne [Thu, 4 Mar 2021 00:14:42 +0000 (20:14 -0400)]
arm: implement kdb watchpoint functions

Implement wrappers around the existing debug_monitor interface, to be
consumed by MI kernel debugger code.

For now, the various db_printf() calls in this code remain. In the
future, they could be converted to printf() or removed altogether, to
properly decouple the DDB and GDB options.

Reviewed by: jhb, kib, markj
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.

(cherry picked from commit 5a2933d0bf9fb0018349b67a39fa85cbb3740779)

3 years agoarm64: implement kdb watchpoint functions
Mitchell Horne [Thu, 4 Mar 2021 21:53:21 +0000 (17:53 -0400)]
arm64: implement kdb watchpoint functions

Add wrappers around the debug_monitor interface, to be consumed by MI
kernel debugger code.  Update dbg_setup_watchpoint() and
dbg_remove_watchpoint() to return specific error codes, not just -1.

Reviewed by: jhb, kib, markj
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.

(cherry picked from commit 3ef68bc62c1e3ca9c452177f5cb9fd4de0df590d)

3 years agox86: implement kdb watchpoint functions
Mitchell Horne [Fri, 19 Feb 2021 22:36:08 +0000 (18:36 -0400)]
x86: implement kdb watchpoint functions

Add wrappers around the dbreg interface that can be consumed by MI
kernel debugger code. The dbreg functions themselves are updated to
return error codes, not just -1. dbreg_set_watchpoint() is extended to
accept access bits as an argument.

Reviewed by: jhb, kib, markj
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.

(cherry picked from commit 15dc1d44528a1e2693df41d5452d6ebb42ecafeb)

3 years agoIntroduce kdb-level watchpoint functions
Mitchell Horne [Mon, 8 Mar 2021 15:23:40 +0000 (11:23 -0400)]
Introduce kdb-level watchpoint functions

This basically mirrors what already exists in ddb, but provides a
slightly improved interface. It allows the caller to specify the
watchpoint access type, and returns more specific error codes to
differentiate failure cases.

This will be used to support hardware watchpoints in gdb(4).

Stubs are provided for architectures lacking hardware watchpoint logic
(mips, powerpc, riscv), while other architectures are added individually
in follow-up commits.

Reviewed by: jhb, kib, markj
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.

(cherry picked from commit 763107f26c3c3f4c8bb314a7cabc0a5548abff03)

3 years agox86: consolidate hw watchpoint logic into new file
Mitchell Horne [Fri, 19 Mar 2021 19:39:12 +0000 (16:39 -0300)]
x86: consolidate hw watchpoint logic into new file

This is a prerequisite to using these functions outside of ddb, but also
provides some cleanup and minor refactoring. This code is almost
entirely duplicated between the two implementations, the only
significant difference being the lack of dbreg synchronization on i386.

Cleanups are:
 - demote some internal functions to static
 - use the constant NDBREGS instead of a '4' literal
 - remove K&R definitions
 - some added comments

Reviewed by: kib, jhb
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.

(cherry picked from commit c02c04f113fe65001bc21363ae3ad08cf6c763eb)

3 years agospigen.4: Fix typos
Mateusz Piotrowski [Sun, 18 Apr 2021 07:45:18 +0000 (09:45 +0200)]
spigen.4: Fix typos

MFC after: 3 days

(cherry picked from commit 40277af7f23405c276edf02c3ddc8e770a06e3f6)

3 years agoRemove reference to the pfctlinput2() from domain(9) after 237c1f932b.
Dmitry Chagin [Tue, 13 Apr 2021 21:40:20 +0000 (00:40 +0300)]
Remove reference to the pfctlinput2() from domain(9) after 237c1f932b.

Reviewed by: glebius
Differential Revision: https://reviews.freebsd.org/D29751

(cherry picked from commit 86887853c39b0803009579e2b927bd67d524af63)

3 years agoEnable GitHub actions CI for stable/13 as well
Alex Richardson [Tue, 20 Apr 2021 08:50:36 +0000 (09:50 +0100)]
Enable GitHub actions CI for stable/13 as well

All cross-building patches have been merged to stable/13 so it should
also build fine on macOS+Linux.

Reviewed By: uqs
MFC after: immediately
Differential Revision: https://reviews.freebsd.org/D29831

(cherry picked from commit 6bc0bb2936a41674bc992887ba17fddfa928ac90)

3 years agoExplain the newfs naming convention
Mateusz Piotrowski [Wed, 20 Jan 2021 10:40:20 +0000 (11:40 +0100)]
Explain the newfs naming convention

It might be unclear why newfs and newfs_msdos should cross-reference
each other. Add a note explaining it.

This is a follow-up to 74bd20769706041108a573601cf0b61c755bdc56.

Reported by: kib
Reviewed by:    imp, kib, rpokala
MFC after: 3 days

(cherry picked from commit 5b9b65e92fb40703038cbcf61feb4616c42e0b6e)

3 years agodevelopment(7): mention the Git mirror list in the manual page
Evgeniy Khramtsov [Fri, 19 Mar 2021 12:52:21 +0000 (20:52 +0800)]
development(7): mention the Git mirror list in the manual page

MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D29234

(cherry picked from commit 8ef03ce6db330fcc20e800c4d15a9f4915c56c43)

3 years agopowerpc/aim: Update timebase directly on resume instead of through platform
Justin Hibbits [Wed, 31 Mar 2021 16:54:27 +0000 (11:54 -0500)]
powerpc/aim: Update timebase directly on resume instead of through platform

This only works on single-CPU G4 systems, and more work is needed for
dual-CPU systems.  That said, platform sleep does not work, and this is
currently only used for PMU-based CPU speed change.

The elimination of the platform_smp_timebase_sync() call is so that the
timebase sync rendezvous can be enhanced to perform better
synchronization, which requires a full rendezvous.  This would be
impossible to do on this single-threaded run.

(cherry picked from commit 921716186f121a2f6a27178cb302415f37412a79)

3 years agopowerpc/powermac: Constrain 'cpu_sleep()' for AIM to mpc745x
Justin Hibbits [Wed, 31 Mar 2021 16:54:11 +0000 (11:54 -0500)]
powerpc/powermac: Constrain 'cpu_sleep()' for AIM to mpc745x

Rename cpu_sleep() to mpc745x_sleep() to denote what it's actually
intended for.  This function is very G4-specific, and will not work on
any other CPU.  This will afterward eliminate a
platform_smp_timebase_sync() call by directly updating the timebase
instead.

(cherry picked from commit b6d8f3b517dec010f3dfad1b33e9945eaa606be5)

3 years agousr.sbin/services_mkdb: diff reduction against NetBSD.
Xin LI [Sun, 21 Mar 2021 17:22:50 +0000 (10:22 -0700)]
usr.sbin/services_mkdb: diff reduction against NetBSD.

(cherry picked from commit 57b9a062d147563ecda72227f0bb051f60eff608)

3 years agousr.sbin/uefisign: prevent specifying certificate, key or output
Xin LI [Sun, 21 Mar 2021 17:12:34 +0000 (10:12 -0700)]
usr.sbin/uefisign: prevent specifying certificate, key or output
multiple times.

(cherry picked from commit 6234a0bfc8630fc556295812c15d72bde0f6427a)

3 years agopf tests: Test multi-wan rdr
Kristof Provost [Tue, 6 Apr 2021 11:25:49 +0000 (13:25 +0200)]
pf tests: Test multi-wan rdr

This replicates an issue observed on pfSense: https://redmine.pfsense.org/issues/11436

In essence, reply-to is needed to ensure that connections always leave
the WAN interface they came in on, but this confused the state tracking.

MFC after: 2 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit f37667e2359245ad123fd775c072fd82c81bc476)

3 years agopf: Do not short-circuit processing for REPLY_TO
Kristof Provost [Wed, 7 Apr 2021 13:46:44 +0000 (15:46 +0200)]
pf: Do not short-circuit processing for REPLY_TO

When we find a state for packets that was created by a reply-to rule we
still need to process the packet. The state may require us to modify the
packet (e.g. in rdr or nat cases), which we won't do with the shortcut.

MFC after: 2 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 6d786845cf63c8bf57174e3e43b0b5c5eca75be3)

3 years agopf: Add static DTrace probe points
Kristof Provost [Fri, 2 Apr 2021 13:53:34 +0000 (15:53 +0200)]
pf: Add static DTrace probe points

These two have proven to be useful during debugging. We may as well keep
them permanently.
Others will be added as their utility becomes clear.

Reviewed by: gnn
MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29555

(cherry picked from commit f4c02909167b6f791df470afddfe31cabf009c4d)

3 years agopf: change pf_route so pf only runs when packets enter and leave the stack.
Kristof Provost [Fri, 2 Apr 2021 10:23:42 +0000 (12:23 +0200)]
pf: change pf_route so pf only runs when packets enter and leave the stack.

before this change pf_route operated on the semantic that pf runs
when packets go over an interface, so when pf_route changed which
interface the packet was on it would run pf_test again. this change
changes (restores) the semantic that pf is only supposed to run
when packets go in or out of the network stack, even if route-to
is responsibly for short circuiting past the network stack.

just to be clear, for normal packets (ie, those not touched by
route-to/reply-to/dup-to), there isn't a difference between running
pf when packets enter or leave the stack, or having pf run when a
packet goes over an interface.

the main reason for this change is that running the same packet
through pf multiple times creates confusion for the state table.
by default, pf states are floating, meaning that packets are matched
to states regardless of which interface they're going over. if a
packet leaving on em0 is rerouted out em1, both traversals will end
up using the same state, which at best will make the accounting
look weird, or at worst fail some checks in the state and get
dropped.

another reason for this commit is is to make handling of the changes
that route-to makes consistent with other changes that are made to
packet. eg, when nat is applied to a packet, we don't run pf_test
again with the new addresses.

the main caveat with this diff is you can't have one rule that
pushes a packet out a different interface, and then have a rule on
that second interface that NATs the packet. i'm not convinced this
ever worked reliably or was used much anyway, so we don't think
it's a big concern.

discussed with many, with special thanks to bluhm@, sashan@ and
sthen@ for weathering most of that pain.
ok claudio@ sashan@ jmatthew@

Obtained from: OpenBSD
MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29554

(cherry picked from commit 829a69db855b48ff7e8242b95e193a0783c489d9)

3 years agoFix direct route installation with net/bird.
Alexander V. Chernikov [Sat, 10 Apr 2021 15:25:24 +0000 (16:25 +0100)]
Fix direct route installation with net/bird.

Slighly relax the gateway validation rules imposed by the
 2fe5a79425c7, by requiring only first 8 bytes (everyhing
 before sdl_data to be present in the AF_LINK gateway.

Reported by: olivier
PR: 255089

(cherry picked from commit 7f5f3fcc32bfa553faa007579dfcaed84be3b047)

3 years agoRename struct device to struct _device
Mark Johnston [Mon, 12 Apr 2021 13:32:30 +0000 (09:32 -0400)]
Rename struct device to struct _device

types.h defines device_t as a typedef of struct device *.  struct device
is defined in subr_bus.c and almost all of the kernel uses device_t.
The LinuxKPI also defines a struct device, so type confusion can occur.

This causes bugs and ambiguity for debugging tools.  Rename the FreeBSD
struct device to struct _device.

Reviewed by: gbe (man pages)
Reviewed by: rpokala, imp, jhb
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29676

(cherry picked from commit dfff37765ce4ea4fd7db4d293b459dc84008f411)

3 years agonetmap: don't use linux type struct device *
Vincenzo Maffione [Sun, 11 Apr 2021 21:06:43 +0000 (21:06 +0000)]
netmap: don't use linux type struct device *

Such type cannot be used in code that is in common between
FreeBSD and Linux. Use the FreeBSD type instead.

MFC after: 3 days
Reported by: markj
Differential Revision: https://reviews.freebsd.org/D29677

(cherry picked from commit 70275a6735df8a514f48be77418491f2f8dba817)

3 years agolinuxkpi: Fix pcie_set_readrq()
Mark Johnston [Mon, 12 Apr 2021 13:32:21 +0000 (09:32 -0400)]
linuxkpi: Fix pcie_set_readrq()

We were passing a LinuxKPI struct device * to a pci(4) function that
expects a device_t.

Reviewed by: manu, hselasky, bz
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29675

(cherry picked from commit 3f322b22e02d6aae147e9948ab50ca1bee9a9dd4)

3 years agoqlnxr: Properly initialize the Linux device structure
Mark Johnston [Mon, 12 Apr 2021 13:32:08 +0000 (09:32 -0400)]
qlnxr: Properly initialize the Linux device structure

The driver needs to provide a LinuxKPI device structure to register
itself with the IB subsystem.  It was erroneously using a copy of its
FreeBSD device structure for this purpose.

Use linux_pci_attach_device() instead, following the example of the
Chelsio iwarp driver.  Also ensure that we don't leak the faked device
during detach.

Reviewed by: hselasky
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29595

(cherry picked from commit 56cbd386fbaefc009541870ee013b2ff8d096bfc)

3 years agocxgb: Use device_t in preference to struct device *
Mark Johnston [Mon, 12 Apr 2021 13:32:04 +0000 (09:32 -0400)]
cxgb: Use device_t in preference to struct device *

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 9771af4942ec735d3f16d0697bb705a911a67266)

3 years agoal_eth: Use device_t in preference to struct device *
Mark Johnston [Mon, 12 Apr 2021 13:32:02 +0000 (09:32 -0400)]
al_eth: Use device_t in preference to struct device *

Sponsored by: The FreeBSD Foundation

(cherry picked from commit d8b1601d54e94a47af37742420403b16be239ad2)

3 years agogenet: Use device_t in preference to struct device *
Mark Johnston [Mon, 12 Apr 2021 13:31:58 +0000 (09:31 -0400)]
genet: Use device_t in preference to struct device *

Sponsored by: The FreeBSD Foundation

(cherry picked from commit f66a1f40740c63741b6ebe48cb0cbce9e52ef34e)

3 years agoRevert "lib/libc/net/nsdispatch.c: Fix missing unlock and add locking annotations"
Alex Richardson [Mon, 19 Apr 2021 08:36:47 +0000 (09:36 +0100)]
Revert "lib/libc/net/nsdispatch.c: Fix missing unlock and add locking annotations"

This commit should not have introduced any functional changes, but
apparently it did. This appears to have broken LDAP setups.
Reverting for now. Will reland once I have fixed the breakage.

This reverts commit 3496971e61dc9f6e725e57fb7b5f0c57631bbfc2.
Reported By: Александр Недоцуков, brd

(cherry picked from commit 738314e445ceac4d3dd6c77c636044141623b8dc)

3 years agonfsd: make the server repeat CB_RECALL every couple of seconds
Rick Macklem [Mon, 5 Apr 2021 01:15:54 +0000 (18:15 -0700)]
nfsd: make the server repeat CB_RECALL every couple of seconds

Commit 01ae8969a9ee stopped the NFSv4.1/4.2 server from implicitly
binding the back channel to a new TCP connection so that it
conforms to RFC5661, for NFSv4.1/4.2. An effect of this
for the Linux NFS client is that it will do a
BindConnectionToSession when it sees NFSV4SEQ_CBPATHDOWN
set in a sequence reply. This will fix the back channel, but the
first attempt at a callback like CB_RECALL will already have
failed. Without this patch, a CB_RECALL will not be retried
and that can result in a 5 minute delay until the delegation
times out.

This patch modifies the code so that it will retry the
CB_RECALL every couple of seconds, often avoiding the
5 minute delay.

This is not critical for correct behaviour, but avoids
the 5 minute delay for the case where the Linux client
re-binds the back channel via BindConnectionToSession.

(cherry picked from commit 7a606f280a3e174dcdd12736b7b976903809eb9c)

3 years agoEnsure that the mount command shows "with quotas" when quotas are enabled.
Kirk McKusick [Wed, 14 Apr 2021 22:22:12 +0000 (15:22 -0700)]
Ensure that the mount command shows "with quotas" when quotas are enabled.

(cherry picked from commit 14d0cd7225e250015eb6d9c79a7eb4e944211b23)

3 years agonfsd: fix BindConnectionToSession so that it clears "cb path down"
Rick Macklem [Sun, 4 Apr 2021 22:05:39 +0000 (15:05 -0700)]
nfsd: fix BindConnectionToSession so that it clears "cb path down"

Commit 01ae8969a9ee stopped the NFSv4.1/4.2 server from implicitly
binding the back channel to a new TCP connection so that it
conforms to RFC5661, for NFSv4.1/4.2. An effect of this
for the Linux NFS client is that it will do a
BindConnectionToSession when it sees NFSV4SEQ_CBPATHDOWN
set in a sequence reply. It will do this for every RPC
reply until it no longer sees the flag.
Without that patch, this will happen until the client does
an Open, which will clear LCL_CBDOWN.

This patch clears LCL_CBDOWN right away, so that
NFSV4SEQ_CBPATHDOWN will no longer be sent to the client
in Sequence replies and the Linux client will not repeat
the BindConnectionToSession RPCs.

This is not critical for correct behaviour, but reduces
RPC overheads for cases where the Open will not be done
for a while.

(cherry picked from commit 6f2addd838810ce33c7e9ad9543827d45e0b491c)

3 years agosystat.1: Remove Tn macros
Mateusz Piotrowski [Sat, 6 Feb 2021 13:14:20 +0000 (14:14 +0100)]
systat.1: Remove Tn macros

They are no longer supported by mdoc(7).

MFC after: 1 week

(cherry picked from commit fcbaf46b763a91bb41fe68afdcf59a7d210bc2f7)

3 years agosystat.1: Fix synopsis
Mateusz Piotrowski [Wed, 10 Feb 2021 17:02:14 +0000 (18:02 +0100)]
systat.1: Fix synopsis

systat does not have a "-display" flag. Use Ar to indicate that
"display" is meant to be substituted with an actual display command.

(cherry picked from commit e6f59be239aa17f80b44ded4779e29f5d5352b28)

3 years agoossl(4): Install the man page also for arm64
Gordon Bergling [Wed, 14 Apr 2021 16:32:56 +0000 (18:32 +0200)]
ossl(4): Install the man page also for arm64

In 22bd0c9731d7 ossl(4) was ported to arm64. The manual page was
adapted, but never installed since the ossl(4) manual page was
i386 / amd64 only.

Reviewed by: mhorne
Differential Revision: https://reviews.freebsd.org/D29762

(cherry picked from commit b1ab802ce4908b6af93e3a3b4328377003735357)

3 years agotcp: Use jenkins_hash32() in hostcache
Richard Scheffenegger [Thu, 8 Apr 2021 18:28:43 +0000 (20:28 +0200)]
tcp: Use jenkins_hash32() in hostcache

As other parts of the base tcp stack (eg.
tcp fastopen) already use jenkins_hash32,
and the properties appear reasonably good,
switching to use that.

Reviewed By: tuexen, #transport, ae
MFC after: 2 weeks
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D29515

(cherry picked from commit b878ec024bbee063f4181c9be08476a864fa6a7b)

3 years agotcp: Use sbuf_drain unconditionally
Richard Scheffenegger [Fri, 2 Apr 2021 18:26:48 +0000 (20:26 +0200)]
tcp: Use sbuf_drain unconditionally

After making sbuf_drain safe for external use,
there is no need to protect the call.

MFC after: 2 weeks
Reviewed By: tuexen, #transport
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D29545

(cherry picked from commit 38ea2bd0698e434ec531b97fa94b24db24e16629)
(cherry picked from commit a04906f0273fa6d80eb3ebf22b9b84e53e6b21e0)

3 years agotcp: Shouldn't drain empty sbuf
Richard Scheffenegger [Thu, 1 Apr 2021 15:18:04 +0000 (17:18 +0200)]
tcp: Shouldn't drain empty sbuf

MFC after: 2 weeks
Reviewed By: tuexen, #transport
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D29524

(cherry picked from commit 9aef4e7c2bd4371e526e4e3feb26064d361ad8ce)

3 years agotcp: Add hash histogram output and validate bucket length accounting
Richard Scheffenegger [Thu, 1 Apr 2021 12:44:05 +0000 (14:44 +0200)]
tcp: Add hash histogram output and validate bucket length accounting

Provide a histogram output to check, if the hashsize or
bucketlimit could be optimized. Also add some basic sanity
checks around the accounting of the hash utilization.

MFC after: 2 weeks
Reviewed By: tuexen, #transport
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D29506

(cherry picked from commit 02f26e98c7f4d43d6bd077421286da455e069146)

3 years agotcp: For hostcache performance, use atomics instead of counters
Richard Scheffenegger [Thu, 1 Apr 2021 08:00:32 +0000 (10:00 +0200)]
tcp: For hostcache performance, use atomics instead of counters

As accessing the tcp hostcache happens frequently on some
classes of servers, it was recommended to use atomic_add/subtract
rather than (per-CPU distributed) counters, which have to be
summed up at high cost to cache efficiency in a hot codepath.

PR: 254333
MFC after: 2 weeks
Sponsored by: NetApp, Inc.
Reviewed By: #transport, tuexen, jtl
Differential Revision: https://reviews.freebsd.org/D29522

(cherry picked from commit 529a2a0f2765f6c57c50a5af6be242c03bf714e3)

3 years agotcp: Make hostcache.cache_count MPSAFE by using a counter_u64_t
Richard Scheffenegger [Wed, 31 Mar 2021 17:30:20 +0000 (19:30 +0200)]
tcp: Make hostcache.cache_count MPSAFE  by using a counter_u64_t

Addressing the underlying root cause for cache_count to
show unexpectedly high  values, by protecting all arithmetic on
that global variable by using counter(9).

PR: 254333
Reviewed By: tuexen, #transport
MFC after: 2 weeks
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D29510

(cherry picked from commit 95e56d31e348594973affd0ea81d8f8383bc3031)

3 years agotcp: drain tcp_hostcache_list in between per-bucket locks
Richard Scheffenegger [Wed, 31 Mar 2021 17:24:01 +0000 (19:24 +0200)]
tcp: drain tcp_hostcache_list in between per-bucket locks

Explicitly drain the sbuf after completing each hash bucket
to minimize the work performed while holding the hash
bucket lock.

PR: 254333
MFC after: 2 weeks
Reviewed By: tuexen, jhb, #transport
Sponsored by:  NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D29483

(cherry picked from commit 869880463cc2ce64e2e6599eaec880a981f3ced6)