]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agolinux(4): Handle incorrect FUTEX_CLOCK_REALTIME option bit.
Dmitry Chagin [Thu, 29 Jul 2021 09:55:33 +0000 (12:55 +0300)]
linux(4): Handle incorrect FUTEX_CLOCK_REALTIME option bit.

Return ENOSYS if the FUTEX_CLOCK_REALTIME option bit is specified for an
inappropriate futex operation.

MFC after: 2 weeks

2 years agolinux(4): Handle FUTEX_LOCK_PI2 oeration.
Dmitry Chagin [Thu, 29 Jul 2021 09:55:02 +0000 (12:55 +0300)]
linux(4): Handle FUTEX_LOCK_PI2 oeration.

FUTEX_LOCK_PI2 was added to support clock selection as FUTEX_LOCK_PI uses a
CLOCK_REALTIME based absolute value since it was implemented, but it does not
require that the FUTEX_CLOCK_REALTIME bit is set, because that was introduced
later.

MFC after: 2 weeks

2 years agolinux(4): Use variable name not type for sizeof() to calculate storage size.
Dmitry Chagin [Thu, 29 Jul 2021 09:54:32 +0000 (12:54 +0300)]
linux(4): Use variable name not type for sizeof() to calculate storage size.

MFC after: 2 weeks

2 years agolinux(4): Move len variable initialization to the appropriate place.
Dmitry Chagin [Thu, 29 Jul 2021 09:54:16 +0000 (12:54 +0300)]
linux(4): Move len variable initialization to the appropriate place.

MFC after: 2 weeks

2 years agolinux(4): Use linux_tdfind() in get_robust_list.
Dmitry Chagin [Thu, 29 Jul 2021 09:53:59 +0000 (12:53 +0300)]
linux(4): Use linux_tdfind() in get_robust_list.

In the Linux emulation layer linux_tdfind() has a special purpose to
handle glibc specific TID mangling and we should use it instead of tdfind().

MFC after: 2 weeks

2 years agolinux(4): Eliminate unnecessary error initialization.
Dmitry Chagin [Thu, 29 Jul 2021 09:53:41 +0000 (12:53 +0300)]
linux(4): Eliminate unnecessary error initialization.

MFC after: 2 weeks

2 years agolinux(4): Eliminate unnecessary head initialization.
Dmitry Chagin [Thu, 29 Jul 2021 09:53:25 +0000 (12:53 +0300)]
linux(4): Eliminate unnecessary head initialization.

MFC after: 2 weeks

2 years agolinux(4): style, wrap too long line.
Dmitry Chagin [Thu, 29 Jul 2021 09:53:07 +0000 (12:53 +0300)]
linux(4): style, wrap too long line.

MFC after: 2 weeks

2 years agolinux(4): Eliminating remnants of futex sdt.
Dmitry Chagin [Thu, 29 Jul 2021 09:52:36 +0000 (12:52 +0300)]
linux(4): Eliminating remnants of futex sdt.

MFC after: 2 weeks

2 years agolinux(4): Eliminating an accidental comment.
Dmitry Chagin [Thu, 29 Jul 2021 09:51:56 +0000 (12:51 +0300)]
linux(4): Eliminating an accidental comment.

MFC after: 2 weeks

2 years agolinux(4): Handle special case for regular futex in handle_futex_death().
Dmitry Chagin [Thu, 29 Jul 2021 09:51:39 +0000 (12:51 +0300)]
linux(4): Handle special case for regular futex in handle_futex_death().

Handle some races in handle_futex_death() which can prevents a wakeup of
potential waiters which can cause these waiters to block forever.

Differential Revision: https://reviews.freebsd.org/D31280
MFC after: 2 weeks

2 years agolinux(4): Futex address must be 32-bit aligned.
Dmitry Chagin [Thu, 29 Jul 2021 09:50:58 +0000 (12:50 +0300)]
linux(4): Futex address must be 32-bit aligned.

Linux futex documentation explicitly states that EINVAL is returned if
the futex is not 4-byte aligned. Check futex alignment as a Linux do
and return EINVAL.

Differential Revision: https://reviews.freebsd.org/D31279
MFC after: 2 weeks

2 years agolinux(4): Finish cf8d74e3fe63.
Dmitry Chagin [Thu, 29 Jul 2021 09:50:43 +0000 (12:50 +0300)]
linux(4): Finish cf8d74e3fe63.

Add forgotten val3_compare initialization in case of time64 futex.

MFC after: 2 weeks

2 years agolinux(4): Replace casuword32 by casueword32.
Dmitry Chagin [Thu, 29 Jul 2021 09:50:11 +0000 (12:50 +0300)]
linux(4): Replace casuword32 by casueword32.

Follow the r349951 (30b3018d), add check to react to stops and requests
to terminate between retries.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D31254
MFC after: 2 weeks

2 years agolinux(4): Implement pi futexes using umtx.
Dmitry Chagin [Thu, 29 Jul 2021 09:49:42 +0000 (12:49 +0300)]
linux(4): Implement pi futexes using umtx.

Differential Revision: https://reviews.freebsd.org/D31240
MFC after: 2 weeks

2 years agolinux(4): Replace copyin() by fueword32() in handle_futex_death().
Dmitry Chagin [Thu, 29 Jul 2021 09:48:59 +0000 (12:48 +0300)]
linux(4): Replace copyin() by fueword32() in handle_futex_death().

According to fetch(9) fueword facility designed to fetch atomically
small amount of data from user space.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D31239
MFC after: 2 weeks

2 years agoumtx: Add new pi_futex type.
Dmitry Chagin [Thu, 29 Jul 2021 09:48:34 +0000 (12:48 +0300)]
umtx: Add new pi_futex type.

Differential Revision: https://reviews.freebsd.org/D31250
MFC after: 2 weeks

2 years agoumtx: Split do_unlock_pi on two counterparts.
Dmitry Chagin [Thu, 29 Jul 2021 09:47:39 +0000 (12:47 +0300)]
umtx: Split do_unlock_pi on two counterparts.

The umtx_pi_frop() will be used by Linux emulation layer.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D31238
MFC after: 2 weeks

2 years agoumtx: Expose some of the pi umtx structures and API to the rest of the kernel.
Dmitry Chagin [Thu, 29 Jul 2021 09:46:58 +0000 (12:46 +0300)]
umtx: Expose some of the pi umtx structures and API to the rest of the kernel.

Differential Revision: https://reviews.freebsd.org/D31237
MFC after: 2 weeks

2 years agolinux(4): Eliminate unused includes.
Dmitry Chagin [Thu, 29 Jul 2021 09:46:35 +0000 (12:46 +0300)]
linux(4): Eliminate unused includes.

MFC after: 2 weeks

2 years agolinux(4): Reimplement futexes using umtx.
Dmitry Chagin [Thu, 29 Jul 2021 09:43:48 +0000 (12:43 +0300)]
linux(4): Reimplement futexes using umtx.

Differential Revision: https://reviews.freebsd.org/D31236
MFC after: 2 weeks

2 years agoumtx: Add umtxq_requeue Linux emulation layer extension.
Dmitry Chagin [Thu, 29 Jul 2021 09:43:07 +0000 (12:43 +0300)]
umtx: Add umtxq_requeue Linux emulation layer extension.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D31235
MFC after: 2 weeks

2 years agoumtx: Add bitset conditional wakeup functionality.
Dmitry Chagin [Thu, 29 Jul 2021 09:42:49 +0000 (12:42 +0300)]
umtx: Add bitset conditional wakeup functionality.

The bitset is a Linux emulation layer extension. This 32-bit mask, in which at
least one bit must be set, is used to select which threads should be woken up.

The bitset is stored in the umtx_q structure, which is used to enqueue the waiter
into the umtx waitqueue. Put the bitset into the hole, that appeared on LP64 due
to data alignment, to prevent the growth of the struct umtx_q.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D31234
MFC after: 2 weeks

2 years agoumtx: Expose some of the umtx structures and API to the rest of the kernel.
Dmitry Chagin [Thu, 29 Jul 2021 09:42:17 +0000 (12:42 +0300)]
umtx: Expose some of the umtx structures and API to the rest of the kernel.

Differential Revision: https://reviews.freebsd.org/D31233
MFC after: 2 weeks

2 years agoumtx: Expose struct abs_timeout to the rest of the kernel.
Dmitry Chagin [Thu, 29 Jul 2021 09:41:58 +0000 (12:41 +0300)]
umtx: Expose struct abs_timeout to the rest of the kernel.

Add umtx_ prefix to all abs_timeout facility and add declaration for it.
For consistency with others abs_timeout mark inline abs_timeout_init2.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D31249
MFC after: 2 weeks

2 years agoumtx: Split umtx.h on two counterparts.
Dmitry Chagin [Thu, 29 Jul 2021 09:41:29 +0000 (12:41 +0300)]
umtx: Split umtx.h on two counterparts.

To prevent umtx.h polluting by future changes split it on two headers:
umtx.h - ABI header for userspace;
umtxvar.h - the kernel staff.

While here fix umtx_key_match style.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D31248
MFC after: 2 weeks

2 years agofreebsd32: Remove the unnecessary spaces.
Dmitry Chagin [Thu, 29 Jul 2021 09:40:36 +0000 (12:40 +0300)]
freebsd32: Remove the unnecessary spaces.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D31247
MFC after: 2 weeks

2 years agofreebsd32: Remove unused umtx.h include.
Dmitry Chagin [Thu, 29 Jul 2021 09:40:08 +0000 (12:40 +0300)]
freebsd32: Remove unused umtx.h include.

Differential Revision: https://reviews.freebsd.org/D31246
MFC after: 2 weeks

2 years agofreebsd32: Eliminate spaces at end of line.
Dmitry Chagin [Thu, 29 Jul 2021 09:39:30 +0000 (12:39 +0300)]
freebsd32: Eliminate spaces at end of line.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D31245
MFC after: 2 weeks

2 years agoFix mac_veriexec version mismatch
Wojciech Macek [Thu, 29 Jul 2021 09:02:43 +0000 (11:02 +0200)]
Fix mac_veriexec version mismatch

mac_veriexec sets its version to 1, but the mac_veriexec_shaX modules which depend on it expect MAC_VERIEXEC_VERSION = 2.
Be consistent and use MAC_VERIEXEC_VERSION everywhere.
This unbreaks loading of mac_veriexec modules at boot time.

Authored by:  Kornel Duleba <mindal@semihalf.com>
Obtained from:  Semihalf
Sponsored by:  Stormshield
Differential Revision:  https://reviews.freebsd.org/D31268

2 years agoAdd missing arm64 ID registers
Andrew Turner [Wed, 28 Jul 2021 19:00:36 +0000 (19:00 +0000)]
Add missing arm64 ID registers

These may contain values we export to userpsace.

Sponsored by: The FreeBSD Foundation

2 years agoSort the arm64 ID_AA64* user registers
Andrew Turner [Wed, 28 Jul 2021 18:30:09 +0000 (18:30 +0000)]
Sort the arm64 ID_AA64* user registers

Sponsored by: The FreeBSD Foundation

2 years agoMinor language improvements. Note that they can't be changed
David Malone [Thu, 29 Jul 2021 08:23:39 +0000 (09:23 +0100)]
Minor language improvements. Note that they can't be changed
by sysctl (I think they can be changed as a tuneable.)

2 years agovirtio: enable VTNET_LEGACY_TX when ALTQ is enabled.
Luiz Otavio O Souza [Thu, 26 Oct 2017 02:30:54 +0000 (21:30 -0500)]
virtio: enable VTNET_LEGACY_TX when ALTQ is enabled.

ALTQ only works on network drivers which use if_start (rather than
if_transmit). vtnet uses if_start if built with VTNET_LEGACY_TX. Default
to that the kernel is built with ALTQ enabled, to reduce user surprise.

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

2 years agoUPDATING: document if_bridge MTU changes
Kristof Provost [Thu, 29 Jul 2021 07:36:52 +0000 (09:36 +0200)]
UPDATING: document if_bridge MTU changes

Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years agolinux(4): Fix gcc buld.
Dmitry Chagin [Thu, 29 Jul 2021 06:52:33 +0000 (09:52 +0300)]
linux(4): Fix gcc buld.

gcc failed as it didn't inlined the builtins and generates calls to
the libgcc, ld can't find libgcc as cross-toolchain libgcc is not installed.
To avoid this add internal vDSO ffs functions without optimized builtins.

Reported by: jhb
MFC after: 2 weeks

2 years agohexdump: Flush stdout after '*' (repeat) lines.
Poul-Henning Kamp [Thu, 29 Jul 2021 06:37:39 +0000 (06:37 +0000)]
hexdump: Flush stdout after '*' (repeat) lines.

The canonical annoying example being:   hexdump < /dev/zero | less

2 years agolibc qsort(3): Eliminate ambiguous sign comparison
Conrad Meyer [Fri, 23 Jul 2021 18:04:21 +0000 (11:04 -0700)]
libc qsort(3): Eliminate ambiguous sign comparison

The left side of the MIN() expression is the (signed) result of pointer
subtraction (ptrdiff_t).  The right hand side is the also the (signed)
result of pointer subtraction, additionally subtracting the element size
('es'), which is unsigned size_t.  This coerces the right-hand
expression into an unsigned value.  MIN(signed, unsigned) triggers
-Wsign-compare.

Sorting elements of size greater than SSIZE_MAX is nonsensical, so we
can instead treat the element size as ssize_t, leaving the right-hand
result the same signedness as the left.

Reviewed by: arichardson, kib
Differential Revision: https://reviews.freebsd.org/D31292

2 years agokern: remove deprecated makesyscalls.sh
Kyle Evans [Thu, 29 Jul 2021 03:18:13 +0000 (22:18 -0500)]
kern: remove deprecated makesyscalls.sh

makesyscalls was rewritten in Lua and introduced in d3276301ab.  In the
time since, no objections have risen and a warning was introduced long
ago on invocation of makesyscalls.sh that it would be removed before
FreeBSD 13. Belatedly follow through on that.

2 years agocli.lua.8: make the command match the code
Warner Losh [Thu, 29 Jul 2021 02:53:18 +0000 (20:53 -0600)]
cli.lua.8: make the command match the code

It's disable-device, not device-disable

Spotted by: jrtc27
Sponsored by: Netflix

2 years agoRefactor/optimize cpu_search_*().
Alexander Motin [Thu, 29 Jul 2021 01:18:50 +0000 (21:18 -0400)]
Refactor/optimize cpu_search_*().

Remove cpu_search_both(), unused for many years.  Without it there is
less sense for the trick of compiling common cpu_search() into separate
cpu_search_lowest() and cpu_search_highest(), so split them completely,
making code more readable.  While there, split iteration over children
groups and CPUs, complicating code for very small deduplication.

Stop passing cpuset_t arguments by value and avoid some manipulations.
Since MAXCPU bump from 64 to 256, what was a single register turned
into 32-byte memory array, requiring memory allocation and accesses.
Splitting struct cpu_search into parameter and result parts allows to
even more reduce stack usage, since the first can be passed through
on recursion.

Remove CPU_FFS() from the hot paths, precalculating first and last CPU
for each CPU group in advance during initialization.  Again, it was
not a problem for 64 CPUs before, but for 256 FFS needs much more code.

With these changes on 80-thread system doing ~260K uncached ZFS reads
per second I observe ~30% reduction of time spent in cpu_search_*().

MFC after: 1 month

2 years agodebugnet: Fix false-positive assertions for dp_state
Bryan Drewery [Tue, 27 Jul 2021 20:12:37 +0000 (13:12 -0700)]
debugnet: Fix false-positive assertions for dp_state

debugnet_handle_arp:
  An assertion is present to ensure the pcb is only modified when the state is
  DN_STATE_INIT. Because debugnet_arp_gw() is asynchronous it is possible for
  ARP replies to come in after the gateway address is known and the state
  already changed.

debugnet_handle_ip:
  Similarly it is possible for packets to come in, from the expected
  server, during the gateway mac discovery phase.  This can happen from
  testing disconnects / reconnects in quick succession.  This later
  causes some acks to be sent back but hit an assertion because the
  state is wrong.

Reviewed by: cem, debugnet_handle_arp: markj, vangyzen
Sponsored by: Dell EMC
Differential Revision: https://reviews.freebsd.org/D31327

2 years agolua loader: Add disable-device to disable a device.
Warner Losh [Wed, 28 Jul 2021 22:52:38 +0000 (16:52 -0600)]
lua loader: Add disable-device to disable a device.

disable-device fooX will set hint.foo.X.disabled=1 as a way to easily
disable a device attaching during boot.

Reviewed by: tsoome
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31297

2 years agonfscl: Cache an open stateid for the "oneopenown" mount option
Rick Macklem [Wed, 28 Jul 2021 22:48:27 +0000 (15:48 -0700)]
nfscl: Cache an open stateid for the "oneopenown" mount option

For NFSv4.1/4.2, if the "oneopenown" mount option is used,
there is, at most, only one open stateid for each NFS vnode.
When an open stateid for a file is acquired, set a pointer to
the open structure in the NFS vnode.  This pointer can be used to
acquire the open stateid without searching the open linked list
when the following is true:
- No delegations have been issued for the file.  Since delegations
  can outlive an NFS vnode for a file, use the global
  NFSMNTP_DELEGISSUED flag on the mount to determine this.
- No lock stateid has been issued for the file.  To determine
  this, a new NFS vnode flag called NMIGHTBELOCKED is set when a lock
  stateid is issued, which can then be tested.

When this open structure pointer can be used, it avoids the need to
acquire the NFSCLSTATELOCK() and searching the open structure list for
an open.  The NFSCLSTATELOCK() can be highly contended when there are
a lot of opens issued for the NFSv4.1/4.2 mount.

This patch only affects NFSv4.1/4.2 mounts when the "oneopenown"
mount option is used.

MFC after: 2 weeks

2 years agonfscl: Set correct lockowner for "oneopenown" mount option
Rick Macklem [Wed, 28 Jul 2021 22:23:05 +0000 (15:23 -0700)]
nfscl: Set correct lockowner for "oneopenown" mount option

For NFSv4.1/4.2, the client may use either an open, lock or
delegation stateid as the stateid argument for an I/O operation.
RFC 5661 defines an order of preference of delegation, then lock
and finally open stateid for the argument, although NFSv4.1/4.2
servers are expected to handle any stateid type.

For the "oneopenown" mount option, the lock owner was not being
correctly generated and, as such, the I/O operation would use an
open stateid, even when a lock stateid existed.  Although this
did not and should not affect an NFSv4.1/4.2 server's behaviour,
this patch makes the behaviour for "oneopenown" the same as when
the mount option is not specified.

Found during inspection of packet captures.  No failure during
testing against NFSv4.1/4.2 servers of the unpatched code occurred.

MFC after: 2 weeks

2 years agopkgbase: improve pkg --version parsing
Ed Maste [Wed, 28 Jul 2021 20:02:49 +0000 (16:02 -0400)]
pkgbase: improve pkg --version parsing

In some cases `pkg --version` might produce unexpected or additional
output.  Use a regex /^[0-9.]+$/ to match only the line containing the
version number.

Reported by: Michael Butler on freebsd-current@
Fixes: 4e224e4be7c3 ("pkgbase: accommodate pkg < 1.17")
Sponsored by: The FreeBSD Foundation

2 years agoDo not expose to scheduler caches of single CPU.
Alexander Motin [Wed, 28 Jul 2021 20:15:43 +0000 (16:15 -0400)]
Do not expose to scheduler caches of single CPU.

Before this change my dual-Xeon(R) Gold 6242R always reported 3 levels
or topology (root, package/L3 and core/L2).  But with SMT disabled
core/L2 matches thread, so additional topology level only causes more
traversal work.  With this change SMT case is reported same as before,
while non-SMT is reported with only 2 much more simple levels.

MFC after: 2 weeks

2 years agocompilert-rt: build out-of-line LSE atomics helpers for aarch64
Dimitry Andric [Wed, 28 Jul 2021 20:30:04 +0000 (22:30 +0200)]
compilert-rt: build out-of-line LSE atomics helpers for aarch64

Both clang >= 12 and gcc >= 10.1 now default to -moutline-atomics for
aarch64. This requires a bunch of helper functions in libcompiler_rt.a,
to avoid link errors like "undefined symbol: __aarch64_ldadd8_acq_rel".

(Note: of course you can use -mno-outline-atomics as a workaround too,
but this would negate the potential performance benefit of the faster
LSE instructions.)

Bump __FreeBSD_version so ports maintainers can easily detect this.

PR: 257392
MFC after: 2 weeks

2 years agobridge tests: verify that we can't change MTU of bridge member interfaces
Kristof Provost [Mon, 26 Jul 2021 11:51:22 +0000 (13:51 +0200)]
bridge tests: verify that we can't change MTU of bridge member interfaces

Reviewed by: donner
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31305

2 years agonet: disallow MTU changes on bridge member interfaces
Kristof Provost [Mon, 26 Jul 2021 10:18:27 +0000 (12:18 +0200)]
net: disallow MTU changes on bridge member interfaces

if_bridge member interfaces should always have the same MTU as the
bridge itself, so disallow MTU changes on interfaces that are part of an
if_bridge.

Reviewed by: donner
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31304

2 years agobridge tests: test changing the bridge MTU
Kristof Provost [Fri, 23 Jul 2021 15:46:10 +0000 (17:46 +0200)]
bridge tests: test changing the bridge MTU

Changing the bridge MTU will now also change all of the member interface
MTUs. Test this.

Reviewed by: donner
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31289

2 years agoif_bridge: allow MTU changes
Kristof Provost [Fri, 23 Jul 2021 15:22:18 +0000 (17:22 +0200)]
if_bridge: allow MTU changes

if_bridge used to only allow MTU changes if the new MTU matched that of
all member interfaces. This doesn't really make much sense, in that we
really shouldn't be allowed to change the MTU of bridge member in the
first place.

Instead we now change the MTU of all member interfaces. If one fails we
revert all interfaces back to the original MTU.

We do not address the issue where bridge member interface MTUs can be
changed here.

Reviewed by: donner
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31288

2 years agoloader: support.4th resets the read buffer incorrectly
John Hood [Wed, 28 Jul 2021 19:43:02 +0000 (13:43 -0600)]
loader: support.4th resets the read buffer incorrectly

Large nextboot.conf files (over 80 bytes) are not read correctly by the
Forth loader, causing file parsing to abort, and nextboot configuration
fails to apply.

Simple repro:

nextboot -e foo=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
shutdown -r now

That will cause the bug to cause a parse failure but shouldn't otherwise
affect the boot.  Depending on your loader configuration, you may also
have to set beastie_disable and/or reduce the number of modules loaded
to see the error on a small console screen.  12.0 or CURRENT users will
also have to explicitly use the Forth loader instead of the Lua loader.
The error will look something like:

Warning: syntax error on file /boot/loader.conf.local
foo="xxxxxxxxxxxxxxnextboot_enable="YES"
                                    ^
/boot/support.4th has crude file I/O buffering, which uses a buffer
'read_buffer', defined to be 80 bytes by the 'read_buffer_size'
constant.  The loader first tastes nextboot.conf, reading and parsing
the first line in it for nextboot_enable="YES".  If this is true, then
it reopens the file and parses it like other loader .conf files.

Unfortunately, the file I/O buffering code does not fully reset the
buffer state in the reset_line_reading word.  If the last file was read
to the end, that doesn't matter; the file buffer is treated as empty
anyway.  But in the nextboot.conf case, the loader will not read to the
end of file if it is over 80 bytes, and the file buffer may be reused
when reading the next file.  When the file is reread, the corrupt text
may cause file parsing to abort on bad syntax (if the corrupt line has
<>2 quotes in it), the wrong variable to be set, no variable to be set
at all, or (if the splice happens to land at a line ending) something
approximating normal operation.

The bug is very old, dating back to at least 2000 if not before, and is
still present in 12.0 and CURRENT r345863 (though it is now hidden by
the Lua loader by default).

Suggested one-line attached.  This does change the behavior of the
reset_line_reading word, which is exported in the line-reading
dictionary (though the export is not documented in loader man pages).
But repo history shows it was probably exported for the PNP support
code, which was never included in the loader build, and was removed 5
months ago.

One thing that puzzles me: how has this bug gone unnoticed/unfixed for
nearly 2 decades?  I find it hard to believe that nobody's tried to do
something interesting with nextboot, like load a kernel and filesystem,
which is what I'm doing.

Tested by: Gary Jennejohn
PR: 239315
MFC After: 3 weeks
Reviewed by: imp (and correctly applied this time)
Differential Revision: https://reviews.freebsd.org/D31328

2 years agogenoffset: simplify and rewrite in sh
Warner Losh [Wed, 28 Jul 2021 19:47:05 +0000 (13:47 -0600)]
genoffset: simplify and rewrite in sh

genoffset used the fully generic ASSYM macro to generate the offsets
needed for the thread_lite structure. However, since these are offsets
into a structure, they will always be necessarily small and positive. As
such, just create a simple character array of the right size and use a
naming convention such that we can recover the field name, structure
name and type. Use nm -t d and sort -n to sort these into order, then
loop over the resutls to generate the thread_lite structure.

MFC After: 2 weeks
Reviewed by: kib, markj (earlier versions)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31203

2 years agogenassym.sh: Fix two minor issues found by shellcheck
Warner Losh [Wed, 28 Jul 2021 19:42:29 +0000 (13:42 -0600)]
genassym.sh: Fix two minor issues found by shellcheck

o Remove redunant $ in $(( )) expression.
o Quote arg passed to work so paths with spaces, etc will work.

MFC After: 2 weeks
Reviewed by: kib
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31335

2 years agovnic: add TODO list item for multicast filter support
Ed Maste [Wed, 28 Jul 2021 18:08:36 +0000 (14:08 -0400)]
vnic: add TODO list item for multicast filter support

PR: 223573

2 years agopowerpc: change mfpvr return type to uint32_t
Leandro Lupori [Wed, 28 Jul 2021 17:03:53 +0000 (14:03 -0300)]
powerpc: change mfpvr return type to uint32_t

As the Processor Version Register (PVR) is a 32-bit PowerPC
register, change mfpvr() return type to match it and avoid
type casts on its callers.

Suggested by: jhibbits
Reviewed by: jhibbits, imp
Sponsored by: Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D31332

2 years agosocket: Implement SO_RERROR
Roy Marples [Wed, 28 Jul 2021 15:46:59 +0000 (08:46 -0700)]
socket: Implement SO_RERROR

SO_RERROR indicates that receive buffer overflows should be handled as
errors. Historically receive buffer overflows have been ignored and
programs could not tell if they missed messages or messages had been
truncated because of overflows. Since programs historically do not
expect to get receive overflow errors, this behavior is not the
default.

This is really really important for programs that use route(4) to keep
in sync with the system. If we loose a message then we need to reload
the full system state, otherwise the behaviour from that point is
undefined and can lead to chasing bogus bug reports.

Reviewed by: philip (network), kbowling (transport), gbe (manpages)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D26652

2 years agoAdd zfskeys rc.d script for auto-loading encryption keys
Eirik Øverby [Wed, 28 Jul 2021 16:11:35 +0000 (16:11 +0000)]
Add zfskeys rc.d script for auto-loading encryption keys

ZFS in 13 supports encryption, but for the use case where keys are
available in plaintext on disk there is no mechanism for automatically
loading keys on startup.

This script will, by default, look for any dataset with encryption and
keylocation prefixed with file://. It will attempt to unlock, timing
out after 10 seconds for each dataset found.
User can optionally specify explicitly which datasets to attempt to
unlock.

Also supports (optionally by force) unmounting filesystems and unloading
associated keys.

Sponsored by: Modirum
Differential Revision: https://reviews.freebsd.org/D30015

2 years agoLinuxKPI: add read_poll_timeout()
Bjoern A. Zeeb [Thu, 1 Jul 2021 13:29:49 +0000 (13:29 +0000)]
LinuxKPI: add read_poll_timeout()

Add an implementation of read_poll_timeout() and the atomic variant
which I did at some point last year for rtw88 and now updated based
on feedback.

MFC after: 10 days
Reviewed by: hsealsky
Differential Revision: https://reviews.freebsd.org/D30980

2 years agoxen: introduce xen_has_percpu_evtchn()
Julien Grall [Sat, 10 Oct 2015 19:40:06 +0000 (20:40 +0100)]
xen: introduce xen_has_percpu_evtchn()

xen_vector_callback_enabled is x86 specific and availability of
per-cpu event channel delivery differs on other architectures.

Introduce a new helper to check if there's support for per-cpu event
channel injection.

Submitted by: Elliott Mitchell <ehem+freebsd@m5p.com>
Reviewed by: royger
Differential Revision: https://reviews.freebsd.org/D29402

2 years agoxen/control: print warning on call of xctrl_suspend()
Julien Grall [Tue, 14 Jan 2014 01:41:15 +0000 (01:41 +0000)]
xen/control: print warning on call of xctrl_suspend()

Presently suspend/resume and migration aren't supported on Xen/ARM.  As
such this shouldn't ever occur.

This likely applies to future Xen architectures (RISC-V) and
xctrl_suspend() needs dependency on intr_machdep.h fixed.

Submitted by: Elliott Mitchell <ehem+freebsd@m5p.com>
Reviewed by: royger
Differential Revision: https://reviews.freebsd.org/D29599

2 years agoxen/grant_table: cleanup max_nr_grant_frames()
Elliott Mitchell [Sat, 10 Apr 2021 06:12:25 +0000 (23:12 -0700)]
xen/grant_table: cleanup max_nr_grant_frames()

This is no more or less than returning the smaller of two values.  Since
this is what min() does, use that to shrink max_nr_grant_frames() down
to the single line.

Reviewed by: royger
Differential Revision: https://reviews.freebsd.org/D29840

2 years agoxen/control: introduce xen_pv_shutdown_handler()
Julien Grall [Fri, 4 Apr 2014 23:52:05 +0000 (00:52 +0100)]
xen/control: introduce xen_pv_shutdown_handler()

While x86 only register PV shutdown handler for PV guests. ARM guests
are always using HVM and requires the PV shutdown handler.

Submitted by: Elliott Mitchell <ehem+freebsd@m5p.com>
Reviewed by: royger
Differential Revision: https://reviews.freebsd.org/D29406

2 years agoxen: introduce xen_pv_disks_disabled()
Julien Grall [Fri, 16 Oct 2015 18:18:21 +0000 (19:18 +0100)]
xen: introduce xen_pv_disks_disabled()

ARM guest is considered as HVM in Freebsd but they only support PV disk
(no emulation available).

Submitted by: Elliott Mitchell <ehem+freebsd@m5p.com>
Reviewed by: royger
Differential Revision: https://reviews.freebsd.org/D29403

2 years agoxen/netfront: introduce xen_pv_nics_disabled()
Julien Grall [Fri, 16 Oct 2015 18:26:35 +0000 (19:26 +0100)]
xen/netfront: introduce xen_pv_nics_disabled()

ARM guest is considered as HVM but it only supports PV nics (no
emulation available).

Submitted by: Elliott Mitchell <ehem+freebsd@m5p.com>
Reviewed by: royger
Differential Revision: https://reviews.freebsd.org/D29405

2 years agoxen/xen-os: move inclusion of machine/xen-os.h later
Elliott Mitchell [Sat, 17 Apr 2021 01:49:25 +0000 (18:49 -0700)]
xen/xen-os: move inclusion of machine/xen-os.h later

Several of x86 enable/disable functions depend upon the xen*domain()
functions.  As such the xen*domain() functions need to be declared
before machine/xen-os.h.

Officially declare direct inclusion of machine/xen/xen-os.h verboten as
such will break these functions/macros.  Remove one such soon to be
broken inclusion.

Reviewed by: royger
Differential Revision: https://reviews.freebsd.org/D29811

2 years agoxen/xenpv: remove low memory limit for non-x86
Elliott Mitchell [Tue, 6 Apr 2021 09:28:38 +0000 (11:28 +0200)]
xen/xenpv: remove low memory limit for non-x86

For embedded devices reserved addresses will be known in advance.  More
recently added devices will also likely be correctly updated.  As a
result using any available address is reasonable on non-x86.

Reviewed by: royger
Differential Revision: https://reviews.freebsd.org/D29304

2 years agoxen/intr: use __func__ instead of function names
Elliott Mitchell [Tue, 6 Apr 2021 13:46:46 +0000 (15:46 +0200)]
xen/intr: use __func__ instead of function names

Functions tend to get renamed and unless the developer is careful
often debugging messages are missed. As such using func is far
superior.  Replace several instances of hard-coded function names.

Reviewed by: royger
Differential revision: https://reviews.freebsd.org/D29499

2 years agoxen/timer: make xen timer optional
Julien Grall [Tue, 14 Jan 2014 01:41:14 +0000 (17:41 -0800)]
xen/timer: make xen timer optional

The timer is not used on ARM.

Submitted by: Elliott Mitchell <ehem+freebsd@m5p.com>
Reviewed by: royger
Differential Revision: https://reviews.freebsd.org/D29041

2 years agoxen/intr: use struct xenisrc * as xen_intr_handle_t
Elliott Mitchell [Tue, 6 Apr 2021 08:30:49 +0000 (10:30 +0200)]
xen/intr: use struct xenisrc * as xen_intr_handle_t

Since xen_intr_handle_t is meant to be an opaque handle and the only
use is retrieving the associated struct xenisrc *, directly use it as
the opaque handler.

Also add a wrapper function for converting the other direction.  If some
other value becomes appropriate in the future, these two functions will
be the only spots needing modification.

Reviewed by: mhorne, royger
Differential Revision: https://reviews.freebsd.org/D29500

2 years agoxen/control: gate x86 specific code in the preprocessor
Elliott Mitchell [Tue, 6 Apr 2021 08:18:47 +0000 (10:18 +0200)]
xen/control: gate x86 specific code in the preprocessor

Commit 152265223048 was implemented strictly for x86.  Unfortunately
one of the pieces was mixed into a common area breaking other
architectures. For now disable these bits on !x86, this should be
cleaned up later.

Fixes: 152265223048 ('xen: fix dropping bitmap IPIs during resume')
Reviewed by: royger
Differential Revision: https://reviews.freebsd.org/D29306

2 years agoxen/xen-os: don't let anyone else defining __XEN_INTERFACE_VERSION__
Julien Grall [Fri, 16 Oct 2015 18:59:45 +0000 (11:59 -0700)]
xen/xen-os: don't let anyone else defining __XEN_INTERFACE_VERSION__

FreeBSD should always use the same version across the source. If not
it's a call for problem.

Submitted by: Elliott Mitchell <ehem+freebsd@m5p.com>
Reviewed by: royger
Differential Revision: https://reviews.freebsd.org/D29407

2 years agoxen: create VM_MEMATTR_XEN for Xen memory mappings
Elliott Mitchell [Tue, 6 Apr 2021 07:59:30 +0000 (09:59 +0200)]
xen: create VM_MEMATTR_XEN for Xen memory mappings

The requirements for pages shared with Xen/other VMs may vary from
architecture to architecture.  As such create a macro which various
architectures can use.

Remove a use of PAT_WRITE_BACK in xenstore.c.  This is a x86-ism which
shouldn't have been present in a common area.

Original idea: Julien Grall <julien@xen.org>, 2014-01-14 06:44:08
Approach suggested by: royger
Reviewed by: royger, mhorne
Differential Revision: https://reviews.freebsd.org/D29351

2 years agoxen: move x86/xen/xenpv.c to dev/xen/bus/xenpv.c
Julien Grall [Tue, 14 Jan 2014 01:41:10 +0000 (17:41 -0800)]
xen: move x86/xen/xenpv.c to dev/xen/bus/xenpv.c

Minor changes are necessary to make this processor-independent, but
moving the file out of x86 and into common is the first step (so
others don't add /more/ x86-isms).

Submitted by: Elliott Mitchell <ehem+freebsd@m5p.com>
Reviewed by: royger
Differential Revision: https://reviews.freebsd.org/D29042

2 years agoAdd macros for arm64 special reg op and CR values
Andrew Turner [Wed, 28 Jul 2021 13:01:14 +0000 (15:01 +0200)]
Add macros for arm64 special reg op and CR values

Use these to simplify the definition of the user_regs array.

Reviewed by: imp, markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31333

2 years agopf: Validate user string nul-termination before copying
Mark Johnston [Wed, 28 Jul 2021 14:16:42 +0000 (10:16 -0400)]
pf: Validate user string nul-termination before copying

Some pf ioctl handlers use strlcpy() to copy strings when converting
from user structures to their in-kernel representations.  strlcpy()
ensures that the destination will be nul-terminated, but it assumes that
the source is nul-terminated.  In particular, it returns the full length
of the source string, so if the source is not nul-terminated, strlcpy()
will keep scanning until it finds a nul byte, and it may encounter an
unmapped page first.  Add a helper to validate user strings before
copying.

There are also places where we look up a ruleset using a user-provided
anchor string.  In some ioctl handlers we were already nul-terminating
the string, avoiding the same problem, but in other places we were not.
Fix those by nul-terminating as well.  Aside from being consistent,
anchors have a maximum length of MAXPATHLEN - 1 so calling strnlen()
might not be so desirable.

Reported by: syzbot+35a1549b4663e9483dd1@syzkaller.appspotmail.com
Reviewed by: kp
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31169

2 years agopf: Initialize arrays before copying out to userland
Mark Johnston [Wed, 28 Jul 2021 14:16:25 +0000 (10:16 -0400)]
pf: Initialize arrays before copying out to userland

A number of pf ioctls populate an array of structures and copy it out.
They have the following structures:
- caller specifies the size of its output buffer
- ioctl handler allocates a kernel buffer of the same size
- ioctl handler populates the buffer, possibly leaving some items
  initialized if the caller provided more space than needed
- ioctl handler copies the entire buffer out to userland

Thus, if more space was provided than is required, we end up copying out
uninitialized kernel memory.  Simply zero the buffer at allocation time
to prevent this.

Reported by: KMSAN
Reviewed by: kp
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31313

2 years agoLinuxKPI: add fsleep()
Bjoern A. Zeeb [Tue, 27 Jul 2021 15:22:02 +0000 (15:22 +0000)]
LinuxKPI: add fsleep()

Add fsleep() function now required by rtw88.  This seems to be
making a decision depending on time to sleep on how to sleep.
Given our compat framework already is lenient on how long to sleep,
this is a cut down version.

MFC after: 10 days
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D31322

2 years agoLinuxKPI: dmi.h do not rely on implicit includes
Bjoern A. Zeeb [Wed, 28 Jul 2021 13:28:48 +0000 (13:28 +0000)]
LinuxKPI: dmi.h do not rely on implicit includes

Add sys/types.h to dmi.h and do not rely on other files to include
all needed headers in Linux land.  I ran into compile problems with
rtw88 otherwise.

MFC after: 3 days

2 years agopf: fix ABI breakage
Kristof Provost [Wed, 28 Jul 2021 09:24:44 +0000 (11:24 +0200)]
pf: fix ABI breakage

The introduction of synproxy support changed the size of struct
pf_status, which in turn broke the userspace ABI.

Revert the relevant change. More work is needed on the synproxy code to
keep and expose the counters, but in the mean time this restores the
ABI.

PR:             257469
MFC after:      3 days
Sponsored by:   Modirum MDPay

2 years agomlx5/mlx4: Bump driver version to 3.7
Hans Petter Selasky [Wed, 16 Jun 2021 13:02:03 +0000 (15:02 +0200)]
mlx5/mlx4: Bump driver version to 3.7

While at it only output driver version to dmesg(8) when hardware is present.

Differential Revision: https://reviews.freebsd.org/D29100
MFC after: 1 week
Reviewed by: kib and markj
Sponsored by: NVIDIA Networking

2 years agobooti: Enable loading the kernel image to any address aligned to 2 MB
Michal Meloun [Fri, 9 Jul 2021 17:33:36 +0000 (19:33 +0200)]
booti: Enable loading the kernel image to any address aligned to 2 MB

We've supported this for a long time, plus most u-boot setups quietly expect
it. Otherwise they fail with different levels of memory overwrites.
MFC after: 2 weeks

2 years agoibcore: Kernel space update based on Linux 5.7-rc1.
Hans Petter Selasky [Wed, 16 Jun 2021 13:02:00 +0000 (15:02 +0200)]
ibcore: Kernel space update based on Linux 5.7-rc1.

Overview:

This is the first stage of a RDMA stack upgrade introducing kernel
changes only based on Linux 5.7-rc1.

This patch is based on about four main areas of work:
- Update of the IB uobjects system:
  - The memory holding so-called AH, CQ, PD, SRQ and UCONTEXT objects
    is now managed by ibcore. This also require some changes in the
    kernel verbs API. The updated verbs changes are typically about
    initialize and deinitialize objects, and remove allocation and
    free of memory.

- Update of the uverbs IOCTL framework:
  - The parsing and handling of user-space commands has been
    completely refactored to integrate with the updated IB uobjects
    system.

- Various changes and updates to the generic uverbs interfaces in
  device drivers including the new uAPI surface.

- The mlx5_ib_devx.c in mlx5ib and related mlx5 core changes.

Dependencies:

- The mlx4ib driver code has been updated with the minimum changes
needed.

- The mlx5ib driver code has been updated with the minimum changes
needed including DV support.

Compatibility:

- All user-space facing APIs are backwards compatible after this
  change.

- All kernel-space facing RDMA APIs are backwards compatible after
  this change, with exception of ib_create_ah() and ib_destroy_ah()
  which takes a new flag.

- The "ib_device_ops" structure exist, but only contains the driver ID
  and some structure sizes.

Differences from Linux:

- Infiniband drivers must use the INIT_IB_DEVICE_OPS() macro to set
  the sizes needed for allocating various IB objects, when adding
  IB device instances.

Security:

- PRIV_NET_RAW is needed to use raw ethernet transmit features.
- PRIV_DRIVER is needed to use other privileged operations.

Based on upstream Linux, Torvalds (5.7-rc1):
8632e9b5645bbc2331d21d892b0d6961c1a08429

MFC after: 1 week
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D31149
Sponsored by: NVIDIA Networking

2 years agoRegen
Konstantin Belousov [Tue, 27 Jul 2021 22:00:18 +0000 (01:00 +0300)]
Regen

2 years agoRevert most of ce42e793100b460f597e4c85ec0da12e274f9394
Konstantin Belousov [Mon, 19 Jul 2021 15:40:38 +0000 (18:40 +0300)]
Revert most of ce42e793100b460f597e4c85ec0da12e274f9394

to restore ABI compatibility for pre-10.x binaries.

It restores _umtx_lock() and _umtx_unlock() syscalls, and UMTX_OP_LOCK/
UMTX_OP_UNLOCK umtx_op(2) operations. UMUTEX_ERROR_CHECK flag is left
out for now, I do not think it makes a difference.

PR: 218571
Reviewed by: brooks (previous version)
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D31220

2 years agoFix the spelling of '*/' in the vnic driver
Andrew Turner [Tue, 27 Jul 2021 19:43:08 +0000 (19:43 +0000)]
Fix the spelling of '*/' in the vnic driver

Sponsored by: The FreeBSD Foundation

2 years agoTeach the arm64 kernel to identify the Arm AEM
Andrew Turner [Tue, 27 Jul 2021 19:28:33 +0000 (19:28 +0000)]
Teach the arm64 kernel to identify the Arm AEM

The Arm Architecture Envelope Model is a simulator that models the
architecture rather than any specific implementation. Add its part ID
macro and add it to the list of Arm CPUs we can decode.

Sponsored by: The FreeBSD Foundation

2 years agovnic: add TODO list item for non-promisc mode
Ed Maste [Tue, 27 Jul 2021 21:51:21 +0000 (17:51 -0400)]
vnic: add TODO list item for non-promisc mode

Also drop ARM64TODO comments; this is an issue with this specific
driver, not a general arm64 issue.

PR: 223575

2 years agoRemove opensolaris_atomic.S dependency.
Alexander Motin [Tue, 27 Jul 2021 23:50:52 +0000 (19:50 -0400)]
Remove opensolaris_atomic.S dependency.

This file is no longer there, so this broke static zfs build.

MFC after: 1 week

2 years agoRegen src.conf.5 after 5f946c76c0cc
Ed Maste [Tue, 27 Jul 2021 21:28:32 +0000 (17:28 -0400)]
Regen src.conf.5 after 5f946c76c0cc

2 years agoUpdate WITHOUT_KERNEL_SYMBOLS description
Ed Maste [Tue, 27 Jul 2021 21:18:41 +0000 (17:18 -0400)]
Update WITHOUT_KERNEL_SYMBOLS description

We have installed kernel debug data under /usr/lib/debug/ for some time
now, so the suggestion to set WITHOUT_KERNEL_SYMBOLS for small root
partitions is no longer valid.

Also call them "debug symbol files" rather than just "symbol files",
since they contain much more than just symbols.  The kernel also
includes (some) symbols, regardless of the setting of this knob.

MFC after: 1 week

2 years agoRevert "Cirrus-CI: Temporarily skip package build + test"
Ed Maste [Mon, 26 Jul 2021 15:49:15 +0000 (11:49 -0400)]
Revert "Cirrus-CI: Temporarily skip package build + test"

This reverts commit 2bfba2a04b05524d72a6190164aa5aaa1d29e337.

As of commit 4e224e4be7c3 Makefile.inc1 works with old and new pkg.

PR: 257422
Sponsored by: The FreeBSD Foundation

2 years agopkgbase: accommodate pkg < 1.17
Ed Maste [Tue, 27 Jul 2021 16:44:45 +0000 (12:44 -0400)]
pkgbase: accommodate pkg < 1.17

6cafdee71d2b adapted the pkgbase build for 1.17, but broke Cirrus-CI's
use of PKG_FORMAT=tar (the quarterly package set still has pkg 1.16).
Because of this I disabled the pkgbase build and test in 2bfba2a04b05.

Now, check `pkg --version` and use the old logic for < 1.17.

To be reverted once we no longer encounter pkg 1.16 in Cirrus-CI (i.e.,
via GCP cloud images) to avoid keeping this extra complexity around.

PR: 257422
Reviewed by: manu
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31324

2 years agoftpd: delete dead code
Alan Somers [Tue, 27 Jul 2021 18:14:00 +0000 (12:14 -0600)]
ftpd: delete dead code

Delete code killed by SVN r13139 in 1996.  Little chance that it would
still compile today.

PR: 257317
Reported by: Alan Shearer <sakison@gmail.com>
MFC after: 2 weeks
Sponsored by: Axcient

2 years agoamd64: rework AP startup
Konstantin Belousov [Sat, 10 Jul 2021 19:38:42 +0000 (22:38 +0300)]
amd64: rework AP startup

Stop using temporal page table with 1:1 mapping of low 1G populated over
the whole VA.  Use 1:1 mapping of low 4G temporarily installed in the
normal kernel page table.

The features are:
- now there is one less step for startup asm to perform
- the startup code still needs to be at lower 1G because CPU starts in
  real mode. But everything else can be located anywhere in low 4G
  because it is accessed by non-paged 32bit protected mode.  Note that
  kernel page table root page is at low 4G, as well as the kernel itself.
- the page table pages can be allocated by normal allocator, there is
  no need to carve them from the phys_avail segments at very early time.
  The allocation of the page for startup code still requires some magic.
  Pages are freed after APs are ignited.
- la57 startup for APs is less tricky, we directly load the final page
  table and do not need to tweak the paging mode.

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D31121

2 years agolinuxkpi: remove global atomic counter of the task allocations
Konstantin Belousov [Thu, 20 May 2021 15:28:20 +0000 (18:28 +0300)]
linuxkpi: remove global atomic counter of the task allocations

Use thread_reap_barrier() to ensure that no threads are kept in the
zombies list which could have the linuxkpi task allocated.

Also fix order of initialization and teardown for current task
allocation hooks and resources. Register current task allocator after
zones are initialized. Deregister allocator before cycling over threads
and zeroing task pointer.

Reviewed by: hselasky, markj
Sponsored by: Mellanox Technologies/NVidia Networking
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D30468

2 years agonullfs: provide custom null_rename bypass
Konstantin Belousov [Sat, 24 Jul 2021 15:05:58 +0000 (18:05 +0300)]
nullfs: provide custom null_rename bypass

fdvp and fvp vnodes are not locked, and race with reclaim cannot be handled
by the generic bypass routine.

Reported and tested by: pho
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D31310

2 years agonull_rename: some style
Konstantin Belousov [Sat, 24 Jul 2021 14:46:51 +0000 (17:46 +0300)]
null_rename: some style

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D31310

2 years agofifofs: fifo vnode might be relocked before VOP_OPEN() is called
Konstantin Belousov [Thu, 22 Jul 2021 10:27:43 +0000 (13:27 +0300)]
fifofs: fifo vnode might be relocked before VOP_OPEN() is called

Handle it in fifo_close by checking for v_fifoinfo == NULL

Reported and tested by: pho
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D31310