]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agouma: Fix handling of reserves in zone_import()
Mark Johnston [Mon, 1 Nov 2021 13:27:52 +0000 (09:27 -0400)]
uma: Fix handling of reserves in zone_import()

Kegs with no items reserved have uk_reserve = 0.  So the check
keg->uk_reserve >= dom->ud_free_items will be true once all slabs are
depleted.  Then, rather than go and allocate a fresh slab, we return to
the cache layer.

The intent was to do this only when the keg actually has a reserve, so
modify the check to verify this first.  Another approach would be to
make uk_reserve signed and set it to -1 until uma_zone_reserve() is
called, but this requires a few casts elsewhere.

Fixes: 1b2dcc8c54a8 ("uma: Avoid depleting keg reserves when filling a bucket")
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 7585c5db25b700d19baebd7afd7a1b2e03c29cda)

2 years agouma: Improve M_USE_RESERVE handling in keg_fetch_slab()
Mark Johnston [Mon, 1 Nov 2021 13:27:35 +0000 (09:27 -0400)]
uma: Improve M_USE_RESERVE handling in keg_fetch_slab()

M_USE_RESERVE is used in a couple of places in the VM to avoid unbounded
recursion when the direct map is not available, as is the case on 32-bit
platforms or when certain kernel sanitizers (KASAN and KMSAN) are
enabled.  For example, to allocate KVA, the kernel might allocate a
kernel map entry, which might require a new slab, which requires KVA.

For these zones, we use uma_prealloc() to populate a reserve of items,
and then in certain serialized contexts M_USE_RESERVE can be used to
guarantee a successful allocation.  uma_prealloc() allocates the
requested number of items, distributing them evenly among NUMA domains.
Thus, in a first-touch zone, to satisfy an M_USE_RESERVE allocation we
might have to check the slab lists of other domains than the current one
to provide the semantics expected by consumers.

So, try harder to find an item if M_USE_RESERVE is specified and the keg
doesn't have anything for current (first-touch) domain.  Specifically,
fall back to a round-robin slab allocation.  This change fixes boot-time
panics on NUMA systems with KASAN or KMSAN enabled.[1]

Alternately we could have uma_prealloc() allocate the requested number
of items for each domain, but for some existing consumers this would be
quite wasteful.  In general I think keg_fetch_slab() should try harder
to find free slabs in other domains before trying to allocate fresh
ones, but let's limit this to M_USE_RESERVE for now.

Also fix a separate problem that I noticed: in a non-round-robin slab
allocation with M_WAITOK, rather than sleeping after a failed slab
allocation we simply try again.  Call vm_wait_domain() before retrying.

Reported by: mjg, tuexen [1]
Reviewed by: alc
Sponsored by: The FreeBSD Foundation

(cherry picked from commit fab343a7168a2f033073bb5f65b5af17d9092c6f)

2 years agomodule(9): Document that evhand can be NULL
Felix Johnson [Thu, 11 Nov 2021 06:28:45 +0000 (01:28 -0500)]
module(9): Document that evhand can be NULL

PR: 192250
Reported by: ngie

(cherry picked from commit c5e0492ae81e4b0d7946ccfbedb434a9c4071256)

2 years agonfscl: Use NFSMNTP_DELEGISSUED in two more functions
Rick Macklem [Sat, 30 Oct 2021 03:35:02 +0000 (20:35 -0700)]
nfscl: Use NFSMNTP_DELEGISSUED in two more functions

Commit 5e5ca4c8fc53 added a NFSMNTP_DELEGISSUED flag to indicate when
a delegation has been issued to the mount.  For the common case
where an NFSv4 server is not issuing delegations, this flag
can be checked to avoid acquisition of the NFSCLSTATEMUTEX.

This patch adds checks for NFSMNTP_DELEGISSUED being set
to two more functions.

This change appears to be performance neutral for a small number
of opens, but should reduce lock contention for a large number of opens
for the common case where server is not issuing delegations.

(cherry picked from commit dc6dd769de63c4eceb8899205a5d780d9f278fd2)

2 years agonfscl: Fix race between Lookup and Setattr of size
Rick Macklem [Sat, 30 Oct 2021 23:35:02 +0000 (16:35 -0700)]
nfscl: Fix race between Lookup and Setattr of size

PR#259071 provides a test program that fails for the NFS client.
Testing with it, there appears to be a race between Lookup
and VOPs like Setattr-of-size, where Lookup ends up loading
stale attributes (including what might be the wrong file size)
into the NFS vnode's attribute cache.

The race occurs when the modifying VOP (which holds a lock
on the vnode), blocks the acquisition of the vnode in Lookup,
after the RPC (with now potentially stale attributes).

Here's what seems to happen:
Child                                Parent

does stat(), which does
VOP_LOOKUP(), doing the Lookup
RPC with the directory vnode
locked, acquiring file attributes
valid at this point in time

blocks waiting for locked file       does ftruncate(), which
vnode                                does VOP_SETATTR() of Size,
                                     changing the file's size
                                     while holding an exclusive
                                     lock on the file's vnode
                                     releases the vnode lock
acquires file vnode and fills in
now stale attributes including
the old wrong Size
                                     does a read() which returns
                                     wrong data size

This patch fixes the problem by saving a timestamp in the NFS vnode
in the VOPs that modify the file (Setattr-of-size, Allocate).
Then lookup/readdirplus compares that timestamp with the time just
before starting the RPC after it has acquired the file's vnode.
If the modifying RPC occurred during the Lookup, the attributes
in the RPC reply are discarded, since they might be stale.

With this patch the test program works as expected.

Note that the test program does not fail on a July stable/12,
although this race is in the NFS client code.  I suspect a
fairly recent change to the name caching code exposed this
bug.

PR: 259071

(cherry picked from commit 2be417843a04f25e631e99d5188eb2652b13d80d)

2 years agonfscl: Add setting n_localmodtime to the Write RPC code
Rick Macklem [Sun, 31 Oct 2021 00:08:28 +0000 (17:08 -0700)]
nfscl: Add setting n_localmodtime to the Write RPC code

Similar to commit 2be417843a, I believe there could be a race between
the NFS client VOP_LOOKUP() and file Writing that could result in stale
file attributes being loaded into the NFS vnode by VOP_LOOKUP().

I have not been able to reproduce a failure due to this race, but
I believe that there are two possibilities:

The Lookup RPC happens while VOP_WRITE() is being executed and loads
stale file attributes after VOP_WRITE() returns when it has already
completed the Write/Commit RPC(s).
--> For this case, setting the local modify timestamp at the end of
  VOP_WRITE() should ensure that stale file attributes are not loaded.

The Lookup RPC occurs after VOP_WRITE() has returned, while
asynchronous Write/Commit RPCs are in progress and then is
blocked by the vnode held by VOP_OPEN/VOP_CLOSE/VOP_FSYNC which
will flush writes via ncl_flush() or ncl_vinvalbuf(), clearing the
NMODIFIED flag (which indicates Writes-in-progress). The VOP_LOOKUP()
then acquires the NFS vnode lock and fills in stale file attributes.
 --> Setting the local modify timestamp in ncl_flsuh() and ncl_vinvalbuf()
   when they clear NMODIFIED should ensure that stale file attributes
   are not loaded.

This patch does the above.

PR: 259071

(cherry picked from commit 50dcff0816e5e4aa94f51ce27da5121e49902996)

2 years agonfscl: Do pNFS layout return_on_close synchronously
Rick Macklem [Sun, 31 Oct 2021 23:31:31 +0000 (16:31 -0700)]
nfscl: Do pNFS layout return_on_close synchronously

For pNFS servers that specify that Layouts are to be returned
upon close, they may expect that LayoutReturn to happen before
the associated Close.

This patch modifies the NFSv4.1/4.2 pNFS client so that this
is done.  This only affects a pNFS mount against a non-FreeBSD
NFSv4.1/4.2 server that specifies return_on_close in LayoutGet
replies.

Found during a recent IETF NFSv4 working group testing event.

(cherry picked from commit d5d2ce1c8550a41e7374893ccd864c172461221f)

2 years agopf tests: test NAT-ed ICMP errors
Kristof Provost [Tue, 19 Oct 2021 11:52:21 +0000 (13:52 +0200)]
pf tests: test NAT-ed ICMP errors

Ensure that the ICMP error is returned with the correct
source and destination addresses.

MFC after: 3 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D32572

(cherry picked from commit 30276ef12cbb47cdd302741096262041be30ec11)

2 years agopf: ensure we have the correct source/destination IP address in ICMP errors
Luiz Otavio O Souza [Tue, 19 Oct 2021 11:37:54 +0000 (13:37 +0200)]
pf: ensure we have the correct source/destination IP address in ICMP errors

When we route-to a packet that later turns out to not fit in the
outbound interface MTU we generate an ICMP error.
However, if we've already changed those (i.e. we've passed through a NAT
rule) we have to undo the transformation first.

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

(cherry picked from commit ab238f14544b2415561c4fed674ee360aa8b5860)

2 years agoRevert "files.arm64: fix sort order for aw_i2s.c"
Andriy Gapon [Sat, 13 Nov 2021 09:15:11 +0000 (11:15 +0200)]
Revert "files.arm64: fix sort order for aw_i2s.c"

This reverts commit 25fb4fb2518f53b9c986367932d7fa6b7b6697ec.

This MFC was done prematurely as aw_i2s is not stable/13 yet.

Strangely, git cherry-pick did not complain when applying the diff,
although the line to be removed was not in the patched file.

2 years agofiles.arm64: fix sort order for aw_i2s.c
Andriy Gapon [Fri, 24 Sep 2021 17:26:07 +0000 (20:26 +0300)]
files.arm64: fix sort order for aw_i2s.c

(cherry picked from commit 24f567bb0e5060adb21bed24b00effec4f37f034)

2 years agogpioled: allow the driver to be disabled via fdt
Andriy Gapon [Fri, 25 Sep 2020 07:32:47 +0000 (10:32 +0300)]
gpioled: allow the driver to be disabled via fdt

(cherry picked from commit 832503063e32a449f8ed6ecf865d01e575559971)

2 years agodriver for MAX44009 I2C illuminance sensor
Andriy Gapon [Thu, 20 Aug 2020 08:11:31 +0000 (11:11 +0300)]
driver for MAX44009 I2C illuminance sensor

(cherry picked from commit ff6fe2983550aeab0852e982e7fe5ac4c672c205)

2 years agopcf8591: driver for adc/dac with i2c interface
Andriy Gapon [Mon, 17 Aug 2020 10:05:11 +0000 (13:05 +0300)]
pcf8591: driver for adc/dac with i2c interface

(cherry picked from commit a60b30469741392e66ec6fd21a8d5c4810a2d407)

2 years agohtu21: allow configuration via hints on FDT-based systems
Andriy Gapon [Thu, 4 Nov 2021 11:56:12 +0000 (13:56 +0200)]
htu21: allow configuration via hints on FDT-based systems

On-board devices should be configured via the FDT and overlays.
Hints are primarily useful for external and temporarily attached devices.
Adding hints is much easier and faster than writing and compiling
an overlay.

(cherry picked from commit a75159eabc90dc35af68c92f7d5eb72e087f6131)

2 years agohtu21: don't needlessly bother hardware when measurements are not needed
Andriy Gapon [Sat, 6 Nov 2021 16:47:32 +0000 (18:47 +0200)]
htu21: don't needlessly bother hardware when measurements are not needed

sysctl(8) first queries a sysctl to get a size of its value even if the
sysctl is of a fixed size, e.g. it has an integer type.
Only after that sysctl(8) queries an actual value of the sysctl.

Previosuly the driver would needlessly read a sensor in the first step.

(cherry picked from commit 43b031a371eb90c15c390c26202f5f58d09300ef)

2 years agosockstat(1): Update Synopsis section
Felix Johnson [Wed, 10 Nov 2021 20:22:06 +0000 (15:22 -0500)]
sockstat(1): Update Synopsis section

Update sockstat(1) manpage so the Synopsis section includes q (silent
mode) and the -j argument name is consistent.

PR: 256795
Reported by: Nick Reilly <nreilly@blackberry.com>

(cherry picked from commit 5504d8394289853e8c065e88a83fb464cb50d934)

2 years agoAdd some of Intel Alder Lake device IDs.
Alexander Motin [Sat, 6 Nov 2021 03:05:15 +0000 (23:05 -0400)]
Add some of Intel Alder Lake device IDs.

MFC after: 1 week

(cherry picked from commit dc238358f9f48ee4c983e2131656edb15636ab9e)

2 years agoigc: Use hardware routine for PHY reset
Peter Grehan [Mon, 1 Nov 2021 13:35:43 +0000 (23:35 +1000)]
igc: Use hardware routine for PHY reset

Summary:
The previously used software reset routine wasn't sufficient
to reset the PHY if the bootloader hadn't left the device in
an initialized state. This was seen with the onboard igc port
on an 11th-gen Intel NUC.

The software reset isn't used in the Linux driver so all related
code has been removed.

Tested on: Netgate 6100 onboard ports, a discrete PCIe I225-LM card,
and an 11th-gen Intel NUC.

Reported by: woodsb02
Tested by: woodsb02 (NUC)
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 561cd74b1704ab76a3286733fb43da53b6892ea4)

2 years agoigc: correctly update RCTL when changing multicast filters.
Peter Grehan [Mon, 11 Oct 2021 17:49:01 +0000 (03:49 +1000)]
igc: correctly update RCTL when changing multicast filters.

Fix clearing of bits in RCTL for the non-bpf/non-allmulti case.
Update RCTL after modifying the multicast filter registers as per
the Linux driver.

This fixes LACP on igc interfaces, where incoming LACP multicasti
control packets were being dropped.

Obtained from: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 5a3eb6207a353c3a18da8abcf00a2d75276dd29e)

2 years agoFactor out flags preserved during mbuf demote into a separate define.
Hans Petter Selasky [Thu, 4 Nov 2021 17:48:23 +0000 (18:48 +0100)]
Factor out flags preserved during mbuf demote into a separate define.

This define will later on be used by coming TLS RX hardware offload patches.

No functional change intended.

Reviewed by: jhb@
Sponsored by: NVIDIA Networking

(cherry picked from commit dd31400c3c2aa941d057e78296c193959a6d9ed3)

2 years agobeep(1): Initial version of utility to create terminal beep via soundcard.
Hans Petter Selasky [Tue, 26 Oct 2021 17:13:00 +0000 (19:13 +0200)]
beep(1): Initial version of utility to create terminal beep via soundcard.

Reviewed by: imp@, emaste@ and pstef@
Differential Revision: https://reviews.freebsd.org/D32672
Sponsored by: NVIDIA Networking

(cherry picked from commit 8abfbe5a79b19bb95430f574d970843607f5809c)

2 years agoLinuxKPI: Add sysctl(8) knob to control verbosity of WARN_ON's.
Hans Petter Selasky [Tue, 2 Nov 2021 15:52:46 +0000 (16:52 +0100)]
LinuxKPI: Add sysctl(8) knob to control verbosity of WARN_ON's.

The purpose of this change is to reduce the amount of dmesg(8) noise when
VT switching after a panic.

Submitted by: Greg V <greg@unrelenting.technology>
Differential Revision: https://reviews.freebsd.org/D30174
Sponsored by: NVIDIA Networking

(cherry picked from commit 2390a1441effaba0e3d0f2f447f448aaf20428f1)

2 years agoip_divert: calculate delayed checksum for IPv6 adress family
Andrey V. Elsukov [Tue, 2 Nov 2021 16:59:06 +0000 (19:59 +0300)]
ip_divert: calculate delayed checksum for IPv6 adress family

Before passing an IPv6 packet to application apply delayed checksum
calculation. Mbuf flags will be lost when divert listener will return a
packet back, so we will not be able to do delayed checksum calculation
later. Also an application will get a packet with correct checksum.

Reviewed by: donner
Differential Revision: https://reviews.freebsd.org/D32807

(cherry picked from commit 4a9e95286cacce5bf7cd193b43c4a461cf7d69b8)

2 years agoe1000: Fix a typo in a source code comment
Gordon Bergling [Sun, 7 Nov 2021 13:12:23 +0000 (14:12 +0100)]
e1000: Fix a typo in a source code comment

- s/overwritting/overwriting/

(cherry picked from commit e9c7c6f5a021a02c5af2fa446d31cf3756b58d62)

2 years agoefi(8): Fix a typo in a source code comment
Gordon Bergling [Sun, 7 Nov 2021 13:07:24 +0000 (14:07 +0100)]
efi(8): Fix a typo in a source code comment

- s/writting/writing/

(cherry picked from commit 2b0f6ad444c0ec82facf55c0ee4806c2ba217daa)

2 years agousb_audio: Fix a typo in a source code comment
Gordon Bergling [Sun, 7 Nov 2021 13:04:26 +0000 (14:04 +0100)]
usb_audio: Fix a typo in a source code comment

- s/maxium/maximum/

(cherry picked from commit 3d6ed119e3fe123b7e18adf8672c45ab81068527)

2 years agofind(1): Update date format reference and remove cvs(1) references
Felix Johnson [Mon, 8 Nov 2021 06:14:58 +0000 (01:14 -0500)]
find(1): Update date format reference and remove cvs(1) references

cvs(1) is not installed by default. Change the date format reference to
note that find(1) understands ISO8601 and RFC822 date formats. Also
remove references to cvs(1).

PR: 254894
Reported by: danielsh@apache.org

(cherry picked from commit 52dbe1a0f419b8d45b4beed56b90ff48bc12e14c)

2 years agortld: style adjustments
Konstantin Belousov [Sat, 6 Nov 2021 03:20:39 +0000 (05:20 +0200)]
rtld: style adjustments

(cherry picked from commit 74aec9618fd709513ef2d319598dd82801c29726)

2 years agortld: ignore fstatfs(2) errors when checking MNT_NOEXEC flag
Konstantin Belousov [Sat, 6 Nov 2021 03:06:34 +0000 (05:06 +0200)]
rtld: ignore fstatfs(2) errors when checking MNT_NOEXEC flag

(cherry picked from commit c5637b8be8a5b6aaf663a58b0027f7f924d78b04)

2 years agoImplementations of cexpl()
Steve Kargl [Fri, 5 Nov 2021 02:04:01 +0000 (04:04 +0200)]
Implementations of cexpl()

PR: 216862

(cherry picked from commit 046e2d5db1e8afd2d09ea28e5d2a7550535d4b77)

2 years agopowerd(8): Add rc.conf(5) to see also
Felix Johnson [Sun, 7 Nov 2021 02:39:23 +0000 (22:39 -0400)]
powerd(8): Add rc.conf(5) to see also

powerd_flags is mentioned in rc.conf(5) and can be set there and pass to
powerd.

PR: 258320
Reported by: Michael <michael.hmich@gmail.com>

(cherry picked from commit ec071430a7822997619fe6d99853d8f49ea10b20)

2 years agoscsi_cd: Improve TOC access validation
Mark Johnston [Wed, 3 Nov 2021 19:09:17 +0000 (15:09 -0400)]
scsi_cd: Improve TOC access validation

1. During CD probing, we read the TOC header to find the number of
   entries, then read the TOC itself.  The header determines the number
   of entries, which determines the amount of data to read from the
   device into the softc in the CD_STATE_MEDIA_TOC_FULL state.  We
   hard-code a limit of 99 tracks (plus one for the lead-out) in the
   softc, but were not validating that the size reported by the media
   would fit in this hard-coded limit.  Kernel memory corruption could
   occur if not.[1]  Add validation to check this, and refuse to cache
   the TOC if it would not fit.

2. The CDIOCPLAYTRACKS ioctl uses caller provided track numbers to index
   into the TOC, but we only validate the starting index.  Add
   validation of the ending index.

Also, raise the hard-coded limit from 100 tracks to 170, per a
suggestion from Ken.

Reported by: C Turt <ecturt@gmail.com> [1]
Reviewed by: ken, avg
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 6afabf00920fb8d41b8f013090f282c17c117efc)

2 years agonfscl: Add a missing delegation lock release
Rick Macklem [Tue, 26 Oct 2021 02:09:14 +0000 (19:09 -0700)]
nfscl: Add a missing delegation lock release

There was a case in nfscl_doiods() where the function would return
without releasing the delegation shared lock, if it was aquired by
the call to nfscl_getstateid().  This patch adds that release.

I have never observed a failure due to this missing release, so I
do not know if it ever happens in practice.  However, since the pNFS
client is not yet heavily used, it might be the case.

Found by code inspection during a recent NFSv4 IETF working group
testing event.

(cherry picked from commit 23024f004a4c5659bfcb0b08fac2211ae925ee58)

2 years agoarm: fix a typo in nvidia/drm2/tegra_bo.c
Mateusz Guzik [Mon, 25 Oct 2021 18:42:10 +0000 (18:42 +0000)]
arm: fix a typo in nvidia/drm2/tegra_bo.c

Unbreaks building TEGRA124

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

(cherry picked from commit e2493f4912cabd1d04be88fd17139a64bf2a2622)

2 years agortld: fix dangerous_ld_env calculation for ld_dynamic_weak
Konstantin Belousov [Sat, 6 Nov 2021 03:00:52 +0000 (05:00 +0200)]
rtld: fix dangerous_ld_env calculation for ld_dynamic_weak

(cherry picked from commit 8363963a8f3fc8226b1e3aa627e2fdd09688704e)

2 years agossh: move common Makefile boilerplate to a new ssh.mk
Ed Maste [Tue, 2 Nov 2021 18:48:33 +0000 (14:48 -0400)]
ssh: move common Makefile boilerplate to a new ssh.mk

This moves SSHDIR and ssh_namespace.h handling to a common location,
and will simplify future work such as adding U2F support (D32509).

Reviewed by: kevans
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32808

(cherry picked from commit 9d63429fa16352f58037ac2aa6ddc734b25e8331)

2 years agoopenssh: remove unnecessary $FreeBSD$ tags
Ed Maste [Wed, 8 Sep 2021 01:48:15 +0000 (21:48 -0400)]
openssh: remove unnecessary $FreeBSD$ tags

Diff reduction against upstream: remove $FreeBSD$ tags from files where
the tag itself is the only difference from upstream.

(cherry picked from commit 0e642632e64a8b8ca740ce3307abe116c990e0b6)

2 years agoopenssh: restore local change to gssapi include logic
Ed Maste [Thu, 2 Sep 2021 20:43:59 +0000 (16:43 -0400)]
openssh: restore local change to gssapi include logic

/usr/include/gssapi.h claims that it is deprecated, and gssapi/gssapi.h
should be used instead.  So, test HAVE_GSSAPI_GSSAPI_H first falling
back to HAVE_GSSAPI_H.

This will be submitted upstream.

Fixes: 6eac665c8126 ("openssh: diff reduction against...")
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31810

(cherry picked from commit 258f5f79bb36e3e6955e7fb149cd2f50265a9ea5)

2 years agoopenssh: diff reduction against upstream 7.9p1
Ed Maste [Thu, 2 Sep 2021 17:38:30 +0000 (13:38 -0400)]
openssh: diff reduction against upstream 7.9p1

Clean up whitespace and nonfunctional differences, and unused functions.

(cherry picked from commit 6eac665c8126af387a457ee8a08303c6607a6769)

2 years agoPartially revert ac76bc1145dd because it is no longer necessary
Dimitry Andric [Fri, 5 Nov 2021 21:26:16 +0000 (22:26 +0100)]
Partially revert ac76bc1145dd because it is no longer necessary

In ac76bc1145dd, I added a few volatiles to work around ctrig_test
failures with {inf,inf}. This is not necessary anymore now, since in
3b00222f156d we added -fp-exception-behavior=maytrap for clang >= 10 in
libm's Makefile. (The flag tells clang to use stricter floating point
semantics, which libm depends on.)

PR: 244732, 254911
Fixes: ac76bc1145dd

(cherry picked from commit e2157cd0000f6dbb6465d7a885f2dcfd4d3596cb)

2 years agostrip/objcopy: handle empty file as unknown
Ed Maste [Mon, 25 Oct 2021 21:25:26 +0000 (17:25 -0400)]
strip/objcopy: handle empty file as unknown

Previously strip reported a somewhat cryptic error for empty files:

    strip: elf_begin() failed: Invalid argument

Add a special case to treat empty files as with an unknown file format.
This is consistent with llvm-strip.  GNU strip produces no output which
does not seem like useful behaviour (but it does exit with status 1).

Reported by: andrew
Reviewed by: markj
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32648

(cherry picked from commit 179219ea046f46927d6478d43431e8b541703539)

2 years agoelftoolchain: stop leaving tempfiles on error
Chris Rees [Mon, 15 Feb 2021 11:37:06 +0000 (11:37 +0000)]
elftoolchain: stop leaving tempfiles on error

Temporary files were not cleaned up, resulting in $TMPDIR or even
the current directory becoming littered with ecp.* files.

This happened with error and even sometimes on success!

Approved by: dim
MFC after: 4 weeks
Accepted upstream: https://sourceforge.net/p/elftoolchain/code/3918/
Differential Revision: https://reviews.freebsd.org/D28651

(cherry picked from commit 5ac70383c8b32eeec80426e837960977971c7c2b)

2 years agofuser: restore functionality by fixing fsid type
Andriy Gapon [Mon, 1 Nov 2021 06:40:17 +0000 (08:40 +0200)]
fuser: restore functionality by fixing fsid type

Use types from sys/stat.h for the filesystem and inode numbers for extra
safety.

PR: 259504
Reported by: Markus Wild <freebsd-bugs@virtualtec.ch>
MFC after: 1 week

(cherry picked from commit e18fbe6f19ed106f035c7d2aaeade6eb55cc0b5a)

2 years agocosl(): fix polynomial approximation coefficients for ld128 version
Steve Kargl [Tue, 2 Nov 2021 08:54:10 +0000 (10:54 +0200)]
cosl(): fix polynomial approximation coefficients for ld128 version

PR: 218514

(cherry picked from commit 6d04e1422e70ca0a77552782c01c291f90716773)

2 years agovmci: Avoid relying on macro expansion to provide correct syntax
Mark Johnston [Wed, 3 Nov 2021 15:19:53 +0000 (11:19 -0400)]
vmci: Avoid relying on macro expansion to provide correct syntax

No functional change intended.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit c75c1d2df9b3839319f6b5e2fad0b757eebd9c55)

2 years agodate: Capitalize seconds string in synopses
Mateusz Piotrowski [Wed, 3 Nov 2021 11:59:49 +0000 (12:59 +0100)]
date: Capitalize seconds string in synopses

This makes it consistent with other date(1) implementations. Also, it
feels more consistent since hours and minutes are already represented as
HH and MM respectively.

MFC after: 3 days

(cherry picked from commit c537bf9d5903d0689321f83691341c93b5919172)

2 years agodate.1: Fix some style issues and examples
Mateusz Piotrowski [Wed, 3 Nov 2021 10:26:46 +0000 (11:26 +0100)]
date.1: Fix some style issues and examples

- Use Cm instead of Ar or Sq for command modifiers of the -v flag.
- Remove unnecessary "Ar ..." from the synopsis. It's not clear what it
  was referring to.
- Add missing arguments to the -f and -v flags.
- Stylize the dot before "ss" with Cm in the default format in the -f
  flag description.
- Set LC_ALL=C in the last example so that the output format of
  date(1) always matches the specified format of the -f flag not matter
  the locale.
- List the -f flag as optional in all usage lines in the synopsis.

MFC after: 3 days

(cherry picked from commit 00133d5c5e6aae01663eca40993abd5e6137425b)

2 years agodate: Clean up synopses
Mateusz Piotrowski [Wed, 3 Nov 2021 11:58:09 +0000 (12:58 +0100)]
date: Clean up synopses

MFC after: 3 days

(cherry picked from commit a12b16f48f747339ccae6dd80cc0c0c4ad5b7846)

2 years agodpv: Fix synopsis formatting & sort options
Mateusz Piotrowski [Tue, 2 Nov 2021 07:05:48 +0000 (08:05 +0100)]
dpv: Fix synopsis formatting & sort options

MFC after: 3 days

(cherry picked from commit a85aa7f9d3bfd26f5dc07f70cb7ba281bfc69f20)

2 years agodpv.1: Do not use mdoc macros for Bl width
Mateusz Piotrowski [Tue, 2 Nov 2021 07:17:19 +0000 (08:17 +0100)]
dpv.1: Do not use mdoc macros for Bl width

Macros do not expand there.

MFC after: 3 days

(cherry picked from commit 3693250e8a746053291849d8442f912336f0bf1b)

2 years agodpv.1: Fix an example
Mateusz Piotrowski [Tue, 2 Nov 2021 07:11:50 +0000 (08:11 +0100)]
dpv.1: Fix an example

dpv(1) requires a label to be specified.

MFC after: 3 days

(cherry picked from commit f7c7a6ac00f13e2d47d50844dd92071933c33a56)

2 years agortld: Do not install libmap.conf when installing the COMPAT32 version
Emmanuel Vadot [Wed, 13 Oct 2021 12:40:26 +0000 (14:40 +0200)]
rtld: Do not install libmap.conf when installing the COMPAT32 version

This has the effect of installing the same file twice at the same location
and confuse pkgbase as we add this file twice in the package config part.

MFC after:  1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG

(cherry picked from commit d0f0e0bd741af867582ceede8ac1b0aec90eae2d)

2 years agoFix a common typo in syctl descriptions
Gordon Bergling [Wed, 3 Nov 2021 19:49:24 +0000 (20:49 +0100)]
Fix a common typo in syctl descriptions

- s/maxiumum/maximum/

(cherry picked from commit c28e39c3d6d10a72800b7f49c23453fcc1bca8cc)

2 years agonetinet: Fix a common typo in source code comments
Gordon Bergling [Wed, 3 Nov 2021 15:21:49 +0000 (16:21 +0100)]
netinet: Fix a common typo in source code comments

- s/writting/writing/

(cherry picked from commit bb91496a85176cfc005cf141fe1262c9ad5507d4)

2 years agoocs_fs: Fix two typos in source code comments
Gordon Bergling [Wed, 3 Nov 2021 16:17:51 +0000 (17:17 +0100)]
ocs_fs: Fix two typos in source code comments

- s/maxium/maximum/
- s/maxiumum/maximum/

(cherry picked from commit 7b56cb0462c39cb190fc23e0e1190bdc89c163c8)

2 years agogjournal(8): Fix a typo in a source code comment
Gordon Bergling [Wed, 3 Nov 2021 16:14:00 +0000 (17:14 +0100)]
gjournal(8): Fix a typo in a source code comment

- s/writting/writing/

(cherry picked from commit 9d2e51884ef286bab94d48d062cf71f6a74a3f99)

2 years agong_pptpgre(4): Fix a typo in a source code comment
Gordon Bergling [Wed, 3 Nov 2021 16:15:59 +0000 (17:15 +0100)]
ng_pptpgre(4): Fix a typo in a source code comment

- s/mimimum/minimum/

(cherry picked from commit 40a57b00f9a76f32a271d258acec4075966eec32)

2 years agoixgbe(4): Fix a few typos in source code comments
Gordon Bergling [Wed, 3 Nov 2021 15:16:20 +0000 (16:16 +0100)]
ixgbe(4): Fix a few typos in source code comments

- s/Manageblility/Managebility/
- s/alows/allows/

Obtained from: NetBSD

(cherry picked from commit 8da5034954911ecad0ce1e55acd3b50797bc338a)

2 years agofexecve(2): allow O_PATH file descriptors opened without O_EXEC
Konstantin Belousov [Wed, 3 Nov 2021 12:51:06 +0000 (14:51 +0200)]
fexecve(2): allow O_PATH file descriptors opened without O_EXEC

(cherry picked from commit be10c0a910155709dc4e521db3349d50e0440018)

2 years agoprocfs_doprocfile(): simplify
Konstantin Belousov [Thu, 4 Nov 2021 03:58:06 +0000 (05:58 +0200)]
procfs_doprocfile(): simplify

(cherry picked from commit 15bd9fa3bea794054b4a5bd2f4bb71b0ba3aa3ba)

2 years agoproc_get_binpath(): provide syntaxically correct value for unused NDINIT arg
Konstantin Belousov [Thu, 4 Nov 2021 00:53:21 +0000 (02:53 +0200)]
proc_get_binpath(): provide syntaxically correct value for unused NDINIT arg

(cherry picked from commit 7ac82c96fe79a6a9dcf595ef4860ed75d3511414)

2 years agoproc_get_binpath(): return empty string instead of NULL
Konstantin Belousov [Wed, 3 Nov 2021 15:11:33 +0000 (17:11 +0200)]
proc_get_binpath(): return empty string instead of NULL

(cherry picked from commit 02de91d740235f186321d7d3e11d09737daba43e)

2 years agofexecve(2): restore the attempts to calculate the executable path
Konstantin Belousov [Wed, 3 Nov 2021 12:58:03 +0000 (14:58 +0200)]
fexecve(2): restore the attempts to calculate the executable path

(cherry picked from commit e4ce23b238a162f5d36afe8ef49dcd66901138a1)

2 years agoprocfs: return right hardlink from /proc/curproc/file
Konstantin Belousov [Fri, 29 Oct 2021 01:43:32 +0000 (04:43 +0300)]
procfs: return right hardlink from /proc/curproc/file

PR: 248184

(cherry picked from commit e5248548f95ff1c89667847e0d945dea38adeca7)

2 years agoExtract proc_get_binpath() from sysctl_kern_proc_pathname()
Konstantin Belousov [Fri, 29 Oct 2021 01:42:59 +0000 (04:42 +0300)]
Extract proc_get_binpath() from sysctl_kern_proc_pathname()

(cherry picked from commit f34fc6ba06a10e0f2a505ec0dd2f2fab2a79e53d)

2 years agosys/proc.h: put proc_add_orphan() into proper place
Konstantin Belousov [Fri, 29 Oct 2021 22:02:32 +0000 (01:02 +0300)]
sys/proc.h: put proc_add_orphan() into proper place

(cherry picked from commit b4c7d45c849071b31936fec6ec43f3d4df3ef3d8)

2 years agosysctl kern.proc.procname: report right hardlink name
Konstantin Belousov [Sat, 23 Oct 2021 19:01:37 +0000 (22:01 +0300)]
sysctl kern.proc.procname: report right hardlink name

PR: 248184

(cherry picked from commit ee92c8a842d61ffda8d111e1b0e398085c5bfb3a)

2 years agoexec: store parent directory and hardlink name of the binary in struct proc
Konstantin Belousov [Sat, 23 Oct 2021 18:44:22 +0000 (21:44 +0300)]
exec: store parent directory and hardlink name of the binary in struct proc

(cherry picked from commit 351d5f7fc5161ededeaa226ee3f21a438ee4a632)

2 years agoexec: provide right hardlink name in AT_EXECPATH
Konstantin Belousov [Sat, 23 Oct 2021 00:24:08 +0000 (03:24 +0300)]
exec: provide right hardlink name in AT_EXECPATH

PR: 248184

(cherry picked from commit 0c10648fbb758bb76fd29330b7fe1bc519252325)

2 years agoMake vn_fullpath_hardlink() externally callable
Konstantin Belousov [Sat, 23 Oct 2021 00:23:17 +0000 (03:23 +0300)]
Make vn_fullpath_hardlink() externally callable

(cherry picked from commit 9a0bee9f6a77a85e4dfb27c9a33d4e210d05b469)

2 years agostruct image_params: use bool type for boolean members
Konstantin Belousov [Sat, 23 Oct 2021 15:05:56 +0000 (18:05 +0300)]
struct image_params: use bool type for boolean members

(cherry picked from commit 15bf81f354a428723d7e9ea61ea215d4195aa050)

2 years agodo_execve(): switch boolean locals to use bool type
Konstantin Belousov [Sat, 23 Oct 2021 14:47:28 +0000 (17:47 +0300)]
do_execve(): switch boolean locals to use bool type

(cherry picked from commit 9d58243fbc4a1931aba618f8f5f6872779656c42)

2 years agokern_exec.c: style
Konstantin Belousov [Fri, 22 Oct 2021 23:49:30 +0000 (02:49 +0300)]
kern_exec.c: style

(cherry picked from commit 143dba3a914294c2f4de80a46ffd04cd8b25246f)

2 years agollvm BPF target: add missed source files
Dimitry Andric [Tue, 2 Nov 2021 16:49:34 +0000 (17:49 +0100)]
llvm BPF target: add missed source files

Otherwise, linking llvm binaries with this target enabled (which is not
the default) will fail with a number of undefined symbol errors:

  ld: error: undefined symbol: llvm::initializeBPFAdjustOptPass(llvm::PassRegistry&)
  ld: error: undefined symbol: llvm::initializeBPFCheckAndAdjustIRPass(llvm::PassRegistry&)
  ld: error: undefined symbol: llvm::createBPFCheckAndAdjustIR()
  ld: error: undefined symbol: llvm::createBPFAdjustOpt()
  ld: error: undefined symbol: llvm::BPFAdjustOptPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&)

Reported by: Michael Dexter <editor@callfortesting.org>

(cherry picked from commit d30dc78f798adebda488d2b8e21290268d2fb501)

2 years agopowerpc64le: stand fixes
Leandro Lupori [Wed, 20 Oct 2021 18:48:33 +0000 (15:48 -0300)]
powerpc64le: stand fixes

Fix boot1 and loader on PowerPC64 little-endian (LE).

Due to endian issues, boot1 couldn't find the UFS boot partition
and loader wasn't able to load the kernel. Most of the issues
happened because boot1 and loader were BE binaries trying to access
LE UFS partitions and because loader expects the kernel ELF image
to use the same endian as itself.

To fix these issues, boot1 and loader are now built as LE binaries
on PPC64LE. To support this, the functions that call OpenFirmware
were enhanced to correctly perform endian conversion on its input
and output arguments and to change the CPU into BE mode before
making the calls, as OpenFirmware always runs in BE. Besides that,
some other small fixes were needed.

Submitted by: bdragon (initial version)
Reviewed by: alfredo, jhibbits
Sponsored by: Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D32160

(cherry picked from commit f83288645cd9726c24ca67292fbc3abb4eb65a36)

2 years agopowerpc64: fix OFWFB with Radix MMU
Leandro Lupori [Thu, 14 Oct 2021 13:39:52 +0000 (10:39 -0300)]
powerpc64: fix OFWFB with Radix MMU

Current implementation of Radix MMU doesn't support mapping
arbitrary virtual addresses, such as the ones generated by
"direct mapping" I/O addresses. This caused the system to hang, when
early I/O addresses, such as those used by OpenFirmware Frame Buffer,
were remapped after the MMU was up.

To avoid having to modify mmu_radix_kenter_attr just to support this
use case, this change makes early I/O map use virtual addresses from
KVA area instead (similar to what mmu_radix_mapdev_attr does), as
these can be safely remapped later.

Reviewed by: alfredo (earlier version), jhibbits (in irc)
Sponsored by: Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D31232

(cherry picked from commit 76384bd10fdbb97be2803d969905f15a84255d6a)

2 years agoefirt(9): Correct efi_var_set definition in the manpage
Lakshman [Tue, 2 Nov 2021 07:17:38 +0000 (03:17 -0400)]
efirt(9): Correct efi_var_set definition in the manpage

PR: 257531

(cherry picked from commit 2fe85640b2a3bf5c377dd180e40cd3d6e1a4f1f4)

2 years agodevinfo(8): Remove cross-reference to pnpinfo(8)
Felix Johnson [Mon, 1 Nov 2021 16:29:12 +0000 (12:29 -0400)]
devinfo(8): Remove cross-reference to pnpinfo(8)

devinfo(8) manpage contains reference to pnpinfo(8) which existed at the
time. Remove it.

PR: 232587
Reported by: Graham Perrin <grahamperrin@gmail.com>

(cherry picked from commit dde6071adcf203b185c185289f687c2bd51532fb)

2 years agowpa: Fix WITHOUT_CRYPT build
Cy Schubert [Thu, 28 Oct 2021 23:55:48 +0000 (16:55 -0700)]
wpa: Fix WITHOUT_CRYPT build

PASN requires CRYPT and when built WITHOUT_CRYPT buildworld
fails. Only enable PASN when MK_CRYPT is enabled (default).

PR: 259517
Reported by: emaste
Fixes: c1d255d3ffdbe447de3ab875bf4e7d7accc5bfc5

(cherry picked from commit a30e8044aa4753858c189f3384dae2b2f25a150b)

2 years agowpa: Address CTRL-EVENT-SCAN-FAILED
Cy Schubert [Thu, 9 Sep 2021 00:20:52 +0000 (17:20 -0700)]
wpa: Address CTRL-EVENT-SCAN-FAILED

5fcdc19a8111 didn't fully resolve the issue. There remains a report
that an ifconfig wlan0 up by itself is insufficient. Ifconfig down
must precede it.

Reported by: Filipe da Silva Santos <contact _ shiori_com_br>
Fixes: 5fcdc19a8111

(cherry picked from commit d06d7eb09131edea666bf049d6c0c55672726f76)

2 years agowpa: Address CTRL-EVENT-SCAN-FAILED
Cy Schubert [Tue, 7 Sep 2021 01:48:39 +0000 (18:48 -0700)]
wpa: Address CTRL-EVENT-SCAN-FAILED

Some installations may experience CTRL-EVENT-SCAN-FAILED when
associating to an AP. Installations that specify
ifconfig_wlan0="WPA ... up" in rc.conf do not experience
the problem whereas those which specify ifconfig_wlan0="WPA" without
the "up" will experience CTRL-EVENT-SCAN_FAILED.

However those that specify "up" in ifconfig_wlan0 will be able to
reproduce this problem by service netif stop wlan0;
service netif start wlan0. Interestingly The service netif stop/start
problem is reproducible on the older wpa 2.9 as well.

Reported by: dhw
Reported by: "Oleg V. Nauman" <oleg _ theweb_org_ua>
Reported by: Filipe da Silva Santos <contact _ shiori_com_br>
Reported by: Jakob Alvermark <jakob _ alvermark_net>

(cherry picked from commit 5fcdc19a81115d975e238270754e28557a2fcfc5)

2 years agowpa: Enable RSN Preauthentication
Cy Schubert [Fri, 3 Sep 2021 13:14:59 +0000 (06:14 -0700)]
wpa: Enable RSN Preauthentication

RSN Preauthentication allows a station autnetnicate to an AP that
it is not associated with yet while associated with a different AP.
This allows athentication to multiple APs simulteneously.

Tested by: philip

(cherry picked from commit bd452dcbede69b1862c769f244948f94b86448b5)

2 years agowpa: Enable MBO
Cy Schubert [Fri, 3 Sep 2021 13:14:01 +0000 (06:14 -0700)]
wpa: Enable MBO

Enable WiFi 6 MBO (Multi Band Operation). MBO is a prereq to 802.11ax.

MBO allows the efficient use of multiple frequency bands (channels).

To facilitate MBO, WNM (Wireless Network Monitoring) is a prerequisite.
It is required to build.

Tested by: philip

(cherry picked from commit 3968b47cd974e503df303265f3be9ba5865499ab)

2 years agowpa: Import wpa_supplicant/hostapd commits up to b4f7506ff
Cy Schubert [Fri, 3 Sep 2021 13:07:19 +0000 (06:07 -0700)]
wpa: Import wpa_supplicant/hostapd commits up to b4f7506ff

Merge vendor commits 40c7ff83e74eabba5a7e2caefeea12372b2d3f9a,
efec8223892b3e677acb46eae84ec3534989971f, and
2f6c3ea9600b494d24cac5a38c1cea0ac192245e.

Tested by: philip

(cherry picked from commit c1d255d3ffdbe447de3ab875bf4e7d7accc5bfc5)

2 years agoUnmap shared page manually before doing vm_map_remove() on exit or exec
Konstantin Belousov [Wed, 20 Oct 2021 20:32:59 +0000 (23:32 +0300)]
Unmap shared page manually before doing vm_map_remove() on exit or exec

(cherry picked from commit 1c69690319c5bb7deae6ce1add6ea25bb40b3b91)

2 years agoamd64 pmap: adjust the empty pmap optimization in pmap_remove()
Konstantin Belousov [Wed, 20 Oct 2021 20:30:34 +0000 (23:30 +0300)]
amd64 pmap: adjust the empty pmap optimization in pmap_remove()

(cherry picked from commit 0b3bc7288984c17da00d9f8c29f116d56bf44d35)

2 years agoamd64 pmap: account for the top-level pages
Konstantin Belousov [Wed, 20 Oct 2021 01:03:43 +0000 (04:03 +0300)]
amd64 pmap: account for the top-level pages

(cherry picked from commit e93b5adb6bb83d487eaa4211ac26e116db748c63)

2 years agokern_tc.c: Scaling/large delta recalculation
Sebastian Huber [Thu, 28 Oct 2021 08:22:58 +0000 (10:22 +0200)]
kern_tc.c: Scaling/large delta recalculation

(cherry picked from commit ae750fbac72387c05c8e13623c2465b20497b4be)

2 years agoForce WITHOUT_OPENSSL_KTLS off when WITHOUT_OPENSSL
Ed Maste [Thu, 28 Oct 2021 21:07:34 +0000 (17:07 -0400)]
Force WITHOUT_OPENSSL_KTLS off when WITHOUT_OPENSSL

Discussed with: jhb
MFC after: 1 week
Reported by: Michael Dexter, Build Option Survey
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 6940d0e4703e72b8ea445541567d0ef64c2bb94b)

2 years agoiscsid: set max_recv_data_segment_length to what we advertise
Ed Maste [Thu, 21 Oct 2021 15:09:58 +0000 (11:09 -0400)]
iscsid: set max_recv_data_segment_length to what we advertise

Previously we updated the conection's conn_max_recv_data_segment_length
only when we received a response containing MaxRecvDataSegmentLength
from the target.  If the target did not send MaxRecvDataSegmentLength
then we left conn_max_recv_data_segment_length at the default (i.e.,
8192).  A target could then send more data than that defult (up to our
advertised maximum), and we would drop the connection.

RFC 7143 specifies that MaxRecvDataSegmentLength is Declarative, not
negotiated.  Just set conn_max_recv_data_segment_length to our
advertised value in login_negotiate().

PR: 259355
Reviewed by: mav
MFC after: 1 week
Fixes: a15fbc904a4d ("Alike to r312190 decouple iSCSI...")
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32605

(cherry picked from commit fc79cf4fea7221fa62d480648f05e30f7df73f92)

2 years agovm_page: Break reservations to handle noobj allocations
Mark Johnston [Thu, 21 Oct 2021 15:46:25 +0000 (11:46 -0400)]
vm_page: Break reservations to handle noobj allocations

vm_reserv_reclaim_*() will release pages to the default freepool, not
the direct freepool from which noobj allocations are drawn.  But if both
pools are empty, the noobj allocator variants must break reservations to
make progress.

Reported by: cy
Reviewed by: kib (previous version)
Fixes: b498f71bc56a ("vm_page: Add a new page allocator interface for unnamed pages")
Sponsored by: The FreeBSD Foundation

(cherry picked from commit d7acbe481d17ccb81c2b879b9731c83b018f3094)

2 years agoUse the vm_radix_init() helper when initializing pmaps
Mark Johnston [Wed, 20 Oct 2021 00:29:05 +0000 (20:29 -0400)]
Use the vm_radix_init() helper when initializing pmaps

No functional change intended.

Reviewed by: alc, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit ff93447d8ed61081adfe00a23a1e4c7bee479e53)

2 years agoamd64: Add comments to pmap_pinit_type()
Mark Johnston [Wed, 20 Oct 2021 00:29:18 +0000 (20:29 -0400)]
amd64: Add comments to pmap_pinit_type()

... explaining why we don't pass the pmap pointer to
pmap_alloc_pt_page().

Reported by: alc
Reviewed by: alc, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 34fac29e98313fb0bfba0503e2e19e352b452516)

2 years agoConvert consumers to vm_page_alloc_noobj_contig()
Mark Johnston [Wed, 20 Oct 2021 00:25:04 +0000 (20:25 -0400)]
Convert consumers to vm_page_alloc_noobj_contig()

Remove now-unneeded page zeroing.  No functional change intended.

Reviewed by: alc, hselasky, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 84c3922243a7b7fd510dcfb100aec59c878c57d0)

2 years agoIntroduce vm_page_alloc_noobj_contig()
Mark Johnston [Wed, 20 Oct 2021 00:24:21 +0000 (20:24 -0400)]
Introduce vm_page_alloc_noobj_contig()

This is the same as vm_page_alloc_noobj(), but allocates physically
contiguous runs of memory.  For now it is implemented in terms of
vm_page_alloc_contig(), with the difference that
vm_page_alloc_noobj_contig() implements VM_ALLOC_ZERO by zeroing the
page.

Reviewed by: alc, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 92db9f3bb7623883231214e74ec38788c3dffc6a)

2 years agoConvert vm_page_alloc() callers to use vm_page_alloc_noobj().
Mark Johnston [Wed, 20 Oct 2021 00:23:39 +0000 (20:23 -0400)]
Convert vm_page_alloc() callers to use vm_page_alloc_noobj().

Remove page zeroing code from consumers and stop specifying
VM_ALLOC_NOOBJ.  In a few places, also convert an allocation loop to
simply use VM_ALLOC_WAITOK.

Similarly, convert vm_page_alloc_domain() callers.

Note that callers are now responsible for assigning the pindex.

Reviewed by: alc, hselasky, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit a4667e09e6520dc2c4b0b988051f060fed695a91)

2 years agovm_page: Add a new page allocator interface for unnamed pages
Mark Johnston [Wed, 20 Oct 2021 00:22:12 +0000 (20:22 -0400)]
vm_page: Add a new page allocator interface for unnamed pages

The diff adds vm_page_alloc_noobj() and vm_page_alloc_noobj_domain().
These mostly correspond to vm_page_alloc() and vm_page_alloc_domain()
when no VM object is specified, with the exception that they handle
VM_ALLOC_ZERO by zeroing the page, rather than by preserving PG_ZERO.

This simplifies callers and will permit simplification of the
vm_page_alloc_domain() definition.

Since the new allocator variant is similar to vm_page_alloc_freelist(),
implement both of them using a common backend allocator function.  No
functional change intended.

Reviewed by: alc, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit b498f71bc56af0069d9a4685b8385ee613a00727)

2 years agoAdd a VM flag to prevent reclaim on a failed contig allocation
Ryan Stone [Fri, 29 Jan 2021 21:13:57 +0000 (16:13 -0500)]
Add a VM flag to prevent reclaim on a failed contig allocation

If a M_WAITOK contig alloc fails, the VM subsystem will try to
reclaim contiguous memory twice before actually failing the
request.  On a system with 64GB of RAM I've observed this take
400-500ms before it finally gives up, and I believe that this
will only be worse on systems with even more memory.

In certain contexts this delay is extremely harmful, so add a flag
that will skip reclaim for allocation requests to allow those
paths to opt-out of doing an expensive reclaim.

Sponsored by: Dell Inc
Differential Revision: https://reviews.freebsd.org/D28422
Reviewed by: markj, kib

(cherry picked from commit 660344ca44c63bfe4a16c3e57d0f6dbcbb5e083e)

2 years agovlapic: Schedule callouts on the local CPU
Mark Johnston [Wed, 20 Oct 2021 00:50:06 +0000 (20:50 -0400)]
vlapic: Schedule callouts on the local CPU

The virtual LAPIC driver uses callouts to implement the LAPIC timer.
Callouts are armed using callout_reset_sbt(), which currently puts
everything on CPU 0.  On systems running many bhyve VMs this results in
a large amount of contention for CPU 0's callout lock.

Modify vlapic to schedule callouts on the local CPU instead.  This
allows timer interrupts to be scheduled more evenly among CPUs where
bhyve is running.

Reviewed by: grehan, jhb
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 4c812fe61b7ce2f297a381950ff7bd87fd51f698)