]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agoamd64: correct size of the SSE area in the xsave layout
Konstantin Belousov [Sun, 12 Dec 2021 02:49:50 +0000 (04:49 +0200)]
amd64: correct size of the SSE area in the xsave layout

(cherry picked from commit 73b357be92385cbb70ba19e7023a736af2c6b493)
(cherry picked from commit 7e45b72844768d7fd5c3c4d4e29f4e84b4bc0402)

Approved by: so
Errata: FreeBSD-EN-22:02.xsave

2 years ago12.3: update to -RELEASE
Glen Barber [Thu, 2 Dec 2021 00:08:38 +0000 (19:08 -0500)]
12.3: update to -RELEASE

- Switch releng/12.3 from RC2 to RELEASE.
- Add the anticipated 12.3-RELEASE date to UPDATING.
- Set a static __FreeBSD_version.

Approved by: re (implicit)
Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years agoopenssl: Fix detection of ARMv7 and ARM64 CPU features
Allan Jude [Fri, 19 Nov 2021 15:14:30 +0000 (15:14 +0000)]
openssl: Fix detection of ARMv7 and ARM64 CPU features

OpenSSL assumes the same value for AT_HWCAP=16 (Linux)
So it ends up calling elf_auxv_info() with AT_CANARY which
returns ENOENT, and all acceleration features are disabled.

With this, my ARM64 test machine runs the benchmark
`openssl speed -evp aes-256-gcm` nearly 20x faster
going from 100 MB/sec to 2000 MB/sec

It also improves sha256 from 300 MB/sec to 1800 MB/sec

This fix has been accepted but not yet merged upstream:
https://github.com/openssl/openssl/pull/17082

PR: 259937
Reviewed by: manu, imp
Approved by: re (gjb)
Relnotes: yes
Fixes: 88e852c0b5c872b1a ("OpenSSL: Merge OpenSSL 1.1.1j")
Sponsored by: Ampere Computing LLC
Sponsored by: Klara Inc.
Differential Revision: https://reviews.freebsd.org/D33060

(cherry picked from commit d9bb798725cfce9c72b80440659b48e8668eb10d)
(cherry picked from commit 0ed191d116f511c1e67338f05386d87aad53076f)

2 years agolibctf: Improve check for duplicate SOU definitions in ctf_add_type()
Mark Johnston [Mon, 4 Oct 2021 16:28:22 +0000 (12:28 -0400)]
libctf: Improve check for duplicate SOU definitions in ctf_add_type()

When copying a struct or union from one CTF container to another,
ctf_add_type() checks whether it matches an existing type in the
destination container.  It does so by looking for a type with the same
name and kind as the new type, and if one exists, it iterates over all
members of the source type and checks whether a member with matching
name and offset exists in the matched destination type.  This can
produce false positives, for example because member types are not
compared, but this is not expected to arise in practice.  If the match
fails, ctf_add_type() returns an error.

The procedure used for member comparison breaks down in the face of
anonymous struct and union members.  ctf_member_iter() visits each
member in the source definition and looks up the corresponding member in
the desination definition by name using ctf_member_info(), but this
function will descend into anonymous members and thus fail to match.
Fix the problem by introducing a custom comparison routine which does
not assume member names are unique.  This should also be faster for
types with many members; in the previous scheme, membcmp() would perform
a linear scan of the desination type's members to perform a lookup by
name.  The new routine steps through the members of both types in a
single loop.

Approved by: re (gjb)
PR: 258763
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 105fd928b0b5b35ab529e5f6914788dc49582901)
(cherry picked from commit 39545ce06ca8088aecc68b92c028b78bcae888a2)

2 years agoWhen copying types from one CTF container to another, ensure that we
Jonathan T. Looney [Tue, 17 Nov 2020 14:07:27 +0000 (14:07 +0000)]
When copying types from one CTF container to another, ensure that we
always copy intrinsic data types before copying bitfields which are
based on those types. This ensures the type ordering in the destination
CTF container matches the assumption made elsewhere in the CTF code
that instrinsic data types will always appear before bitfields based on
those types.

This resolves the following error message some users have seen after
r366908:
    "/usr/lib/dtrace/ipfw.d", line 121: failed to copy type of 'ip6p':
    Conflicting type is already defined

Reviewed by: markj
Approved by: re (gjb)
Sponsored by: Netflix

(cherry picked from commit 3cbb4cc200f8a0ad7ed08233425ea54524a21f1c)
(cherry picked from commit 4faff19d63053defffe707312c6208c2b1e934ef)

2 years agoMFC: rc.d/rctl: unbreak for distinct /usr filesystem
Eugene Grosbein [Sat, 20 Nov 2021 08:54:39 +0000 (15:54 +0700)]
MFC: rc.d/rctl: unbreak for distinct /usr filesystem

Both rctl and used xargs utility live in /usr/bin
so add REQUIRE: FILESYSTEMS

Approved by: re (gjb)
Reported by: Peter <pmc@citylink.dinoex.sub.org>

(cherry picked from commit 0c54fe172ad365e7e60d6249484a7579c18b7d2d)
(cherry picked from commit 92b40444d07aeef2bf4b20109f3f90ac343b90df)

2 years agolibarchive: cherry-pick bugfix from vendor
Martin Matuska [Wed, 17 Nov 2021 21:21:19 +0000 (22:21 +0100)]
libarchive: cherry-pick bugfix from vendor

Vendor commit message (ede459d2e):
  archive_write_disk_posix: fix writing fflags broken in 8a1bd5c

  The fixup list was erroneously assumed to be directories only.
  Only in the case of critical file flags modification (e.g.
  SF_IMMUTABLE on BSD systems), other file types (e.g. regular files
  or symbolic links) may be added to the fixup list. We still need to
  verify that we are writing to the correct file type, so compare the
  archive entry file type with the file type of the file to be
  modified.

Fixes vendor issue #1617:
  Immutable flag no longer preserved during tar extraction on FreeBSD

Approved by: re (gjb)
Reported by: markj
Libarchive commit: ede459d2ebb879f5eedb6f7abea203be0b334230

(cherry picked from commit 201d0ebee321fb1a5501e17a4f150aa211020c5c)
(cherry picked from commit f2b106ec4e5a8488883c58480cf576d18010d263)

2 years ago12.3: update to RC2
Glen Barber [Thu, 18 Nov 2021 00:04:36 +0000 (19:04 -0500)]
12.3: update to RC2

Approved by: re (implicit)
Sponsored by: Rubicon Communications, LLC ("Netgate")

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.

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

(cherry picked from commit 561cd74b1704ab76a3286733fb43da53b6892ea4)
(cherry picked from commit 267a39780ea8c89b7a89ca9e91dcfff02c69656f)

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.

Approved by: re  (gjb)
Obtained from: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 5a3eb6207a353c3a18da8abcf00a2d75276dd29e)
(cherry picked from commit 73e1138208a5888aaabfc44d8e48aa04554c9146)

2 years ago12.3: update DVD pkg configuration
Glen Barber [Fri, 12 Nov 2021 15:29:53 +0000 (10:29 -0500)]
12.3: update DVD pkg configuration

Use the release_3 package repository to populate the dvd1.iso
images.

Approved by: re (implicit)
Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years ago12.3: update to RC1
Glen Barber [Thu, 11 Nov 2021 00:01:38 +0000 (19:01 -0500)]
12.3: update to RC1

Approved by: re (implicit)
Sponsored by: Rubicon Communications, LLC ("Netgate")

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.

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

(cherry picked from commit 6afabf00920fb8d41b8f013090f282c17c117efc)
(cherry picked from commit f607b686f9a96745e337a8d045f0f51b599a245e)

2 years ago12.3: update to BETA3
Glen Barber [Thu, 4 Nov 2021 01:07:01 +0000 (21:07 -0400)]
12.3: update to BETA3

Approved by: re (implicit)
Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years agousb(4): Fix for use after free in combination with EVDEV_SUPPORT.
Hans Petter Selasky [Sun, 24 Oct 2021 11:38:04 +0000 (13:38 +0200)]
usb(4): Fix for use after free in combination with EVDEV_SUPPORT.

When EVDEV_SUPPORT was introduced, the USB transfers may be running
after the main FIFO is closed. In connection to this a race may appear
which can lead to use-after-free scenarios. Fix this for all FIFO
consumers by initializing and resetting the FIFO queues under the
lock used by the client. Then the client driver will see an empty
queue in all cases a race may appear.

Approved by: re@ (gjb)
Found by: pho@
Sponsored by: NVIDIA Networking

(cherry picked from commit aad0c65d6b37364d8ba92ecb8c85e004398a5194)
(cherry picked from commit bb9bee1ffbb27f903bfd2c11d681d331bea727ea)

2 years ago12.3: Update to BETA2
Glen Barber [Thu, 28 Oct 2021 00:00:45 +0000 (20:00 -0400)]
12.3: Update to BETA2

Approved by: re (implicit)
Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years agocmp: initialize limit to avoid stack garbage limits
Kyle Evans [Thu, 21 Oct 2021 16:30:55 +0000 (11:30 -0500)]
cmp: initialize limit to avoid stack garbage limits

Approved by: re (gjb)
Pointy hat: kevans
Fixes: 4e380e847460 ("cmp: add -n, --bytes to limit number of bytes [...]")
Sponsored by: Klara, Inc.

(cherry picked from commit f1f7f31366e5830f4f5b96c6394a0b91475744f4)
(cherry picked from commit aba2dc46dfa51cf9e1b1987ca4e91f703ae7e368)

2 years agocontrib/tzdata: correct DST in Palestine
Philip Paeps [Mon, 25 Oct 2021 01:09:08 +0000 (01:09 +0000)]
contrib/tzdata: correct DST in Palestine

Direct commit to stable/12.

Merge the corrected DST transition date from tzdata 2021e.  This
corrects future timestamps in Palestine.

Approved by: re (blanket)

(cherry picked from commit 89e293e5dcb42e1fd312aab79d045c3eaa017bb6)

2 years agocontrib/tzdata: correct DST in Fiji
Philip Paeps [Mon, 18 Oct 2021 06:19:42 +0000 (14:19 +0800)]
contrib/tzdata: correct DST in Fiji

Direct commit to stable/12.

Unfortunately, there is still no clear consensus on the tz mailing list
about some of the changes introduced by tzdata 2021b and later releases.
Pending consensus, only merge the recently announced DST transition date
for Fiji and corrections to commentary from tzdata 2021d.  This corrects
future timestamps in Fiji.

Approved by: re (gjb)

(cherry picked from commit 74a0f31dbbd0b32689d63d8c965c611bdfc4da2f)

2 years agoRevert "12.3: Makefile: add a newline to validate the git->svn exporter"
Glen Barber [Thu, 21 Oct 2021 23:08:30 +0000 (19:08 -0400)]
Revert "12.3: Makefile: add a newline to validate the git->svn exporter"

This reverts commit 51a3024ee71a1ffebed139a40a534cdb2284d888.

Approved by: re (implicit)
Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years ago12.3: Makefile: add a newline to validate the git->svn exporter
Glen Barber [Thu, 21 Oct 2021 22:47:31 +0000 (18:47 -0400)]
12.3: Makefile: add a newline to validate the git->svn exporter

Approved by: re (implicit)
Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years ago12.3: create releng/12.3 branch
Glen Barber [Thu, 21 Oct 2021 00:44:32 +0000 (20:44 -0400)]
12.3: create releng/12.3 branch

Update from PRERELEASE to BETA1
switch pkg(8) configuration to use 'quarterly'
Bump __FreeBSD_version

Approved by: re (implicit)
Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years agocxgbe(4): Stop but don't free netmap queues when netmap is switched off.
Navdeep Parhar [Thu, 3 Dec 2020 08:30:29 +0000 (08:30 +0000)]
cxgbe(4): Stop but don't free netmap queues when netmap is switched off.

It is common for freelists to be starving when a netmap application
stops.  Mailbox commands to free queues can hang in such a situation.
Avoid that by not freeing the queues when netmap is switched off.
Instead, use an alternate method to stop the queues without releasing
the context ids.  If netmap is enabled again later then the same queue
is reinitialized for use.  Move alloc_nm_rxq and txq to t4_netmap.c
while here.

Sponsored by: Chelsio Communications

(cherry picked from commit 8eba75ed68854188c01a2058fe1f826b3428dbfa)

2 years agocxgbe(4): Revert r367917.
Navdeep Parhar [Wed, 2 Dec 2020 20:54:03 +0000 (20:54 +0000)]
cxgbe(4): Revert r367917.

r367917 fixed the backpressure on the netmap rxq being stopped but that
doesn't help if some other netmap rxq is starved (because it is stopping
too although the driver doesn't know this yet) and blocks the pipeline.
An alternate fix that works in all cases will be checked in instead.

Sponsored by: Chelsio Communications

(cherry picked from commit f42f3b2955e5afa770275fd76b4f754fbd67bbeb)

2 years agocxgbe(4): Catch up with in-flight netmap rx before destroying queues.
Navdeep Parhar [Sat, 21 Nov 2020 03:27:32 +0000 (03:27 +0000)]
cxgbe(4): Catch up with in-flight netmap rx before destroying queues.

The netmap application using the driver is responsible for replenishing
the receive freelists and they may be totally depleted when the
application exits.  Packets in flight, if any, might block the pipeline
in case there aren't enough buffers left in the freelist.  Avoid this by
filling up the freelists with a driver allocated buffer.

Sponsored by: Chelsio Communications

(cherry picked from commit b3718e2d7ebfe7fc0bb57bd0906aacc28dd755b2)

2 years agoselsocket: handle sopoll() errors correctly
Brooks Davis [Wed, 20 Oct 2021 16:00:38 +0000 (17:00 +0100)]
selsocket: handle sopoll() errors correctly

Without this change, unmounting smbfs filesystems with an INVARIANTS
kernel would panic after 10e64782ed59727e8c9fe4a5c7e17f497903c8eb.

PR: 253079
Found by: markj
Reviewed by: markj, jhb
Obtained from: CheriBSD
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D32492

(cherry picked from commit 04c91ac48ad13ce0d1392cedbd69c2c0223d206f)

2 years agopf: Introduce pf_nvbool()
Kristof Provost [Wed, 13 Oct 2021 09:00:46 +0000 (11:00 +0200)]
pf: Introduce pf_nvbool()

Similar to the existing functions for strings and ints, this lets us
simplify some of the nvlist conversion code.

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

(cherry picked from commit 776df104fa54bb581e1fb88ac44af4fa7fd4052b)

2 years agosbuf(9): Microoptimize sbuf_put_byte()
Alexander Motin [Tue, 5 Oct 2021 18:42:47 +0000 (14:42 -0400)]
sbuf(9): Microoptimize sbuf_put_byte()

This function is actively used by sbuf_vprintf(), so this simple
inlining in half reduces time of kern.geom.confxml generation.

MFC after: 2 weeks
Sponsored by: iXsystem, Inc.

(cherry picked from commit 7835b2cb4a1ae57f403739a2f1076ec7188f18c9)

2 years agociss(4): Fix typo.
Alexander Motin [Sun, 19 Sep 2021 18:01:40 +0000 (14:01 -0400)]
ciss(4): Fix typo.

(cherry picked from commit 5f8cb13cfb0c91a4ec1a9648a3ae245b1dff36f6)

2 years agociss(4): Properly handle data underrun.
Alexander Motin [Sun, 19 Sep 2021 17:45:51 +0000 (13:45 -0400)]
ciss(4): Properly handle data underrun.

For SCSI data underrun is a part of normal life.  It should not be
reported as error.  This fixes MODE SENSE used by modern CAM.

MFC after: 1 month

(cherry picked from commit e8144a13e075ff13c1f162690c7f14dd3f0a4862)

2 years agoFix two typos in source code comments
Gordon Bergling [Sat, 16 Oct 2021 06:09:31 +0000 (08:09 +0200)]
Fix two typos in source code comments

- s/alocated/allocated/
- s/realocated/reallocated/

(cherry picked from commit 899a3b38f5172d70360396caeebb5b694638282e)

2 years agonfscl: Fix another deadlock related to the NFSv4 clientID lock
Rick Macklem [Wed, 13 Oct 2021 00:21:01 +0000 (17:21 -0700)]
nfscl: Fix another deadlock related to the NFSv4 clientID lock

Without this patch, it is possible to hang the NFSv4 client,
when a rename/remove is being done on a file where the client
holds a delegation, if pNFS is being used.  For a delegation
to be returned, dirty data blocks must be flushed to the NFSv4
server.  When pNFS is in use, a shared lock on the clientID
must be acquired while doing a write to the DS(s).
However, if rename/remove is doing the delegation return
an exclusive lock will be acquired on the clientID, preventing
the write to the DS(s) from acquiring a shared lock on the clientID.

This patch stops rename/remove from doing a delegation return
if pNFS is enabled.  Since doing delegation return in the same
compound as rename/remove is only an optimization, not doing
so should not cause problems.

This problem was detected during a recent NFSv4 interoperability
testing event held by the IETF working group.

(cherry picked from commit b82168e657d378ff86ea18c4f03b98aac9ee9bb3)

2 years agonfscl: Fix a deadlock related to the NFSv4 clientID lock
Rick Macklem [Tue, 12 Oct 2021 04:58:24 +0000 (21:58 -0700)]
nfscl: Fix a deadlock related to the NFSv4 clientID lock

Without this patch, it is possible for a process doing an NFSv4
Open/create of a file to block to allow another process
to acquire the exclusive lock on the clientID when holding
a shared lock on the clientID.  As such, both processes
deadlock, with one wanting the exclusive lock, while the
other holds the shared lock.  This deadlock is unlikely to occur
unless delegations are in use on the NFSv4 mount.

This patch fixes the problem by not deferring to the process
waiting for the exclusive lock when a shared lock (reference cnt)
is already held by the process.

This problem was detected during a recent NFSv4 interoperability
testing event held by the IETF working group.

(cherry picked from commit 120b20bdf49630cf2a7dbc5f93b9e985e1f4f198)

2 years agogeom_label: Fix the stable/12 build
Mark Johnston [Mon, 18 Oct 2021 13:16:47 +0000 (09:16 -0400)]
geom_label: Fix the stable/12 build

MAXPHYS is a constant here, use the right name.  This is a direct commit
to stable/12.

Fixes: 116a988f99cd ("geom_label: Add more validation for NTFS volume tasting")
Reported by: Jenkins

2 years agogeom_label: Add more validation for NTFS volume tasting
Mark Johnston [Mon, 4 Oct 2021 21:48:44 +0000 (17:48 -0400)]
geom_label: Add more validation for NTFS volume tasting

- Ensure that the computed MFT record size isn't negative or larger than
  maxphys before trying to read $Volume.
- Guard against truncated records in volume metadata.
- Ensure that the record length is large enough to contain the volume
  name.
- Verify that the (UTF-16-encoded) volume name's length is a multiple of
  two.

PR: 258833, 258914
Sponsored by: The FreeBSD Foundation

(cherry picked from commit f0a08fa9f532a58f5d7a4814d6eb7ddd49f368da)

2 years agounzip: Fix segmentation fault if a zip file contains buggy filename.
Yoshihiro Takahashi [Sun, 10 Oct 2021 11:49:19 +0000 (20:49 +0900)]
unzip: Fix segmentation fault if a zip file contains buggy filename.

PR:             259011
Reported by:    Robert Morris
Submitted by:   ak

(cherry picked from commit 2c614481fd5248c1685e713f67d40cf2d5fba494)

2 years agovmci: fix panic due to freeing unallocated resources
Mark Peek [Sat, 9 Oct 2021 21:21:16 +0000 (14:21 -0700)]
vmci: fix panic due to freeing unallocated resources

Summary:
An error mapping PCI resources results in a panic due to unallocated
resources being freed up. This change puts the appropriate checks in
place to prevent the panic.

PR: 252445
Reported by: Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>
Tested by: marcus
MFC after: 1 week
Sponsored by: VMware

Test Plan:
Along with user testing, also simulated error by inserting a ENXIO
return in vmci_map_bars().

Reviewed by: marcus
Subscribers: imp
Differential Revision: https://reviews.freebsd.org/D32016

(cherry picked from commit 0f14bcbe384091c729464cb770372aeb79061070)

2 years agong_ppp(4): Fix a typo in a comment
Gordon Bergling [Thu, 14 Oct 2021 13:30:32 +0000 (15:30 +0200)]
ng_ppp(4): Fix a typo in a comment

- s/delcared/declared/

(cherry picked from commit 0a8159d8ca85383ec84076396c0a457c6d3e08f9)

2 years agologin.conf.5: Mark passwordtime as implemented
Felix Johnson [Wed, 6 Oct 2021 20:47:02 +0000 (22:47 +0200)]
login.conf.5: Mark passwordtime as implemented

login.conf.5 listed passwordtime in RESERVED CAPABILITIES, which is a
section for capabilities not implemented in the base system. However,
passwordtime has been implemented in the base for several years now.

PR: 246099
Reported by: avg
Reviewed by: 0mp
MFC after: 3 days

(cherry picked from commit e7f8f3b95e1ff76765f1d2f4412b95f6ff5abe25)

2 years agopci_dw: fix outbound I/O window configuration
Marcin Wojtas [Tue, 6 Apr 2021 12:31:39 +0000 (14:31 +0200)]
pci_dw: fix outbound I/O window configuration

Use viewport "2" instead of "0" and change window type from MEM to IO.
Without these changes the MEM ATU window can be overwritten with the IO one.

Submitted by: Kornel Duleba <mindal@semihalf.com>
Obtained from: Semihalf
Sponsored by: Marvell
Differential revision: https://reviews.freebsd.org/D29516

(cherry picked from commit 57dbb3c25936f0d61fef152eb224ca86a73af0e9)

2 years agopci_dw: Trim ATU windows bigger than 4GB
Wojciech Macek [Fri, 9 Apr 2021 07:28:44 +0000 (09:28 +0200)]
pci_dw: Trim ATU windows bigger than 4GB

The size of the ATU MEM/IO windows is implicitly casted to uint32_t.
Because of that some window sizes were silently demoted to 0 and ignored.
Check the size if its too large, trim it to 4GB and print a warning message.

Submitted by: Kornel Duleba <mindal@semihalf.com>
Reviewed by: mw
Obtained from: Semihalf
Sponsored by: Marvell
Differential revision: https://reviews.freebsd.org/D29625

(cherry picked from commit 243000b19f8b4ab104b584b2d16bc6aa9131c9b5)

2 years agontp.conf.5: Fix typos
Elyes HAOUAS [Wed, 6 Oct 2021 05:38:06 +0000 (07:38 +0200)]
ntp.conf.5: Fix typos

"certian" --> "certain"
"compatability" --> "compatibility"
"noticable" --> "noticeable"
"limite" --> "limit"
"acutal" --> "actual"
"ba" --> "be"

MFC after: 1 week
Pull Request:   https://github.com/freebsd/freebsd-src/pull/550
Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
(cherry picked from commit da3278ded3b2647d26da26788bab8363e502a144)

2 years agoe1000: print EEPROM/NVM/OROM versions
Kevin Bowling [Wed, 6 Oct 2021 23:25:03 +0000 (16:25 -0700)]
e1000: print EEPROM/NVM/OROM versions

This is useful for diagnosing problems. In particular, the errata
sheets identify the EEPROM version for many fixes.

Reviewed by: gallatin
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D32333

(cherry picked from commit 293663f4da9e8b8aeb106ce3b73a8ed2aa2a8a90)

2 years agoe1000: Lock nvm print sysctl
Kevin Bowling [Wed, 6 Oct 2021 23:20:26 +0000 (16:20 -0700)]
e1000: Lock nvm print sysctl

Otherwise results in KASSERT with debug kernels because we rely on the
iflib CTX lock to implement the software serialization to the NVM model

Reviewed by: gallatin
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D32333

(cherry picked from commit 9b3e252e59c6e63594fb20e3f65188dab9e1eeff)

2 years agoixgbe: Update shared code catchup
Kevin Bowling [Thu, 7 Oct 2021 01:43:27 +0000 (18:43 -0700)]
ixgbe: Update shared code catchup

Leftovers from DPDK sync

Reviewed by: grehan
Obtained from: DPDK
MFC after: 5 days
Differential Revision: https://reviews.freebsd.org/D31621

(cherry picked from commit 3f66b96d8658f8721e6b1c6f035611bec44675b9)

2 years agosbin/mount_fusefs/mount_fusefs.8: Fix typos
Elyes HAOUAS [Fri, 8 Oct 2021 16:44:48 +0000 (18:44 +0200)]
sbin/mount_fusefs/mount_fusefs.8: Fix typos

"expicitly" --> "explicitly"
"uknown" --> "unknown"

Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
Pull Request: https://github.com/freebsd/freebsd-src/pull/552

(cherry picked from commit c8a45820e0d94892c1a632d49ccfddd8f559801e)

2 years agoOpenSSH: cherry-pick "need initgroups() before setresgid()"
Ed Maste [Tue, 12 Oct 2021 00:47:39 +0000 (20:47 -0400)]
OpenSSH: cherry-pick "need initgroups() before setresgid()"

From openssh-portable commits f3cbe43e28fe and bf944e3794ef, backported
to OpenSSH 7.9p1 on stable/13 [and stable/12].

Reviewed by: delphij
Security: CVE-2021-41617
Differential Revision: https://reviews.freebsd.org/D32460

(cherry picked from commit 172fa4aa7577915bf5ace5783251821d3774dc05)
(cherry picked from commit be74669a2f62915f84b844bb00dd2767c60539fe)

2 years agolibc: vDSO timekeeping: Add pvclock support
Adam Fenn [Sat, 7 Aug 2021 20:11:29 +0000 (13:11 -0700)]
libc: vDSO timekeeping: Add pvclock support

Add support for 'VDSO_TH_ALGO_X86_PVCLK'; add vDSO-based timekeeping for
devices that support the KVM/XEN paravirtual clock API.

Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Reviewed by: kib
Differential Revision:  https://reviews.freebsd.org/D31418

(cherry picked from commit a3d932dfef5edc9d1c947b02fb93a64d63a291cb)

2 years agopvclock: Add vDSO support
Adam Fenn [Sat, 7 Aug 2021 20:10:04 +0000 (13:10 -0700)]
pvclock: Add vDSO support

Add vDSO support for timekeeping devices that support the KVM/XEN
paravirtual clock API.

Also, expose, in the userspace-accessible '<machine/pvclock.h>',
definitions that will be needed by 'libc' to support
'VDSO_TH_ALGO_X86_PVCLK'.

Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D31418

(cherry picked from commit d4b2d3035a23d5dc468d41151487a8299bf45cdc)

2 years agokvm_clock: KVM paravirtual clock support
Adam Fenn [Wed, 4 Aug 2021 15:42:48 +0000 (08:42 -0700)]
kvm_clock: KVM paravirtual clock support

Add support for the KVM paravirtual clock device.

Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D29733

(cherry picked from commit 6c69c6bb4c7ffde48b130df707799d4eca21ca9f)

2 years agopvclock: Add 'struct pvclock' API
Adam Fenn [Sat, 7 Aug 2021 20:01:46 +0000 (13:01 -0700)]
pvclock: Add 'struct pvclock' API

Consolidate more hypervisor-agnostic functionality behind a new 'struct
pvclock' API.

This should also make it easier to subsequently add hypervisor-agnostic
vDSO timekeeping support.

Also, perform some clean-up:
    - Remove 'pvclock_get_last_cycles()'; do not allow external access
      to 'pvclock_last_systime' since this is not necessary.
    - Consolidate/simplify wall and system time reading codepaths.
    - Ensure correct ordering within wall and system time reading
      codepaths via 'atomic(9)' and 'rdtsc_ordered()' rather than via
      'rmb()'.
    - Remove some extra newlines.

Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D31418

(cherry picked from commit 0b3382b863f3195d88b99f94d5af7fe4a7b9726a)

2 years agox86: files: Make sys/x86/x86/pvclock.c optional
Adam Fenn [Wed, 4 Aug 2021 15:10:43 +0000 (08:10 -0700)]
x86: files: Make sys/x86/x86/pvclock.c optional

Make inclusion of `sys/x86/x86/pvclock.c` contingent on that of its
dependents.

Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D31417

(cherry picked from commit 346f5a0c483b7c159efd7c8faf4a18f3e3f77158)

2 years agox86: cpufunc: Add rdtsc_ordered()
Adam Fenn [Wed, 28 Jul 2021 17:12:00 +0000 (10:12 -0700)]
x86: cpufunc: Add rdtsc_ordered()

Add a variant of 'rdtsc()' that performs the ordered version of 'rdtsc'
appropriate for the invoking x86 variant.

Also, expose the 'lfence'-ed and 'mfence'-ed 'rdtsc()' variants needed
by 'rdtsc_ordered()' for general use.

Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D31416

(cherry picked from commit 652ae7b11485d9f991ea66a56aa79d4dd9cd1103)

2 years agox86: cpufunc: Add rdtscp_aux()
Adam Fenn [Mon, 26 Jul 2021 19:59:55 +0000 (12:59 -0700)]
x86: cpufunc: Add rdtscp_aux()

Add a variant of 'rdtscp()' that retains and returns the 'IA32_TSC_AUX'
value read by 'rdtscp'.

Sponsored By: Juniper Networks, Inc.
Sponsored By: Klara, Inc.
Reviewed by: markj, kib
Differential Revision: https://reviews.freebsd.org/D31415

(cherry picked from commit 908e277230ef1a80589f85687f5b422b0e863e79)

2 years agocontrib/bc, usr.bin/gh-bc: merge update to version 5.1.1
Stefan Eßer [Wed, 12 May 2021 05:49:19 +0000 (07:49 +0200)]
contrib/bc, usr.bin/gh-bc: merge update to version 5.1.1

This version of bc and dc is used by default on FreeBSD-13 and newer,
but remains optional on FreeBSD-12.x. It is enabled by building and
installing the world with WITH_GH_BC=yes defined in /etc/src.conf.

contrib/bc: update to version 4.0.2

Merge commit '2858419a0ee2b8f5827de72c00618bcd69ebc5fc'

This update fixes the initialization of "scale" to 20 if started with
-l and the initial statement leads to an error (e.g. contains a syntax
error). Scale was initialized to 0 in that case.

Another change is the support of job control in interactive mode with
line editing enabled. The control characters have been interpreted as
editing commands only, prior to this version.

(cherry picked from commit 8c39e25220bb88cd027d0c3b0fe86e52f6abd150)
(cherry picked from commit 3d5f931a771ce8937c0572a4fc11bf7a09323125)

usr.bin/gh-bc, contrib/bc: update to version 5.0.0

Merge commit 2f57ecae4b98e76e5d675563785a7e6c59c868c4

This is a new major release with a number of changes and extensions:

- Limited the number of temporary numbers and made the space for them
  static so that allocating more space for them cannot fail.
- Allowed integers with non-zero scale to be used with power, places,
  and shift operators.
- Added greatest common divisor and least common multiple to lib2.bc.
- Made bc and dc UTF-8 capable.
- Added the ability for users to have bc and dc quit on SIGINT.
- Added the ability for users to disable prompt and TTY mode by
  environment variables.
- Added the ability for users to redefine keywords.
- Added dc's modular exponentiation and divmod to bc.
- Added the ability to assign strings to variables and array elements
  and pass them to functions in bc.
- Added dc's asciify command and stream printing to bc.
- Added bitwise and, or, xor, left shift, right shift, reverse,
  left rotate, right rotate, and mod functions to lib2.bc.
- Added the functions s2u(x) and s2un(x,n), to lib2.bc.

MFC after: 1 week

(cherry picked from commit 44d4804d1945435745518cd09eb8ae6ab22ecef4)

vendor/bc: update to upstream version 5.0.2

(cherry picked from commit a60ef1802a36f2f2a5611564191440ea1c1e2f17)
(cherry picked from commit 662087dfd0668dee82ed20d00ced662aa3595059)

contrib/bc: remove files ommitted from the release

A number of files have been removed from the release distribution of
this bc implementation. They were mostly relevant for pre release
testing and benchmarking to identify regressions. The Markdown
sources of the man pages are only relevant for combinations of build
options not used in FreeBSD and need non-default conversion tools
(available as ports in FreeBSD).

All the omitted files can be found in the upstream git repository,
and they are fetched when building this software as a port. But they
have never been used in the FreeBSD base system.

(cherry picked from commit ea31d1a5c490193348e0b71fdda6d08a2c80a2eb)

Remove files that were checked in with wrong .gitattributes

These files will be added back in updated form, but are only relevant
for the Windows platform, anyway.

(cherry picked from commit d6c323eda215d05091f56d02a8274eb50c244a6f)

contrib/bc: merge version 5.1.0 from vendor branch

This version adds options and functions that allow to print numbers
in the open interval (-1 .. 1) with or without a leading 0 digit.

Additionally, an option has been added to prevent line wrap and
allows to print arbitrarily long results on a single line.

Merge commit '5d58a51571721190681c50d4bd3a1f45e6282d72'

(cherry picked from commit d43fa8ef534ac87a16843d45264f56cf11e0fcbc)

contrib/bc: update to version 5.1.1

Merge commit '6f49f5cdde1c62c4e5a743e895f3afe592b5c0e5'

(cherry picked from commit a30efc5ca7272e446abb71f0d72c76539f267bb6)

contrib/bc: temporarily disconnect the tests for 5.0.2

The tests that come with version 5.0.2 have been extended to cover the
line editing functions. It has been found that these tests generate
false negative results in FreeBSD, most likely due to an issue in the
pexpect functionality used.

These history tests are skipped on systems that do not have python and
py-pexpect installed (and thus are unlikely to cause CI test failures),
but in order to not cause irritating failures on systems were these
packages are in fact installed, I temporarily disconnect them.

I had planned to skip this version due to the issue with the history
tests, but some committer has asked me to go ahead since the currently
used version 5.0.0 contains a macro name that collides with a project
he is working on.

No MFC of this version is planned. A version 5.0.3 is expected to be
released soon, and that version will allow to reconnect the tests and
will be MFCed.

(cherry picked from commit f774652b0e837be415abd20935eae3466ea34a20)

Add back Windows only VCXProj files

(cherry picked from commit ded0d3d486eba766f613070de0ed12029a9a3816)

contrib/bc: re-enable tests after the import of version 5.1.0

The tests have been fixed to not write any data outside of the
temporary work directory provided by the test framework.

MFC after: 3 days

(cherry picked from commit b8d895faf47afb8f3b31055e2ec2db8d0df5db23)

Revert erroneous commit ded0d3d486eba

These files came from a prior commit to contrib/bc and seem to have
been placed in the top of the source tree by a failed git rebase.

Reported by: markj

(cherry picked from commit f902ca97bdbceccf62b4b02b0321af91ea398925)
(cherry picked from commit e84a97439b4bcc11e04837b2f130dfff4c755c5f)

2 years agomlx4en(4): Fix wrong mbuf cluster size in mlx4_en_debugnet_init()
Hans Petter Selasky [Tue, 5 Oct 2021 08:46:56 +0000 (10:46 +0200)]
mlx4en(4): Fix wrong mbuf cluster size in mlx4_en_debugnet_init()

This fixes an "invalid cluster size" panic when debugnet is activated.

panic()
m_getzone()
debugnet_mbuf_reinit()
debugnet_any_ifnet_update()
ifhwioctl()
ifioctl()

Submitted by: ae@
PR: 258923
Sponsored by: NVIDIA Networking

(cherry picked from commit 5a7de2b42caf6241e87b417a0521e9ab303989d7)

2 years agoObsoleteFiles.inc: stop removing pthread_mutexattr_get/setpshared.3
Konstantin Belousov [Sun, 10 Oct 2021 14:38:20 +0000 (17:38 +0300)]
ObsoleteFiles.inc: stop removing pthread_mutexattr_get/setpshared.3

(cherry picked from commit 24b51c7295db6b316250f0288aaf05660a81063e)

2 years agomlx5_en: fix use of CALLOUT_DIRECT
Konstantin Belousov [Wed, 8 Sep 2021 15:37:20 +0000 (18:37 +0300)]
mlx5_en: fix use of CALLOUT_DIRECT

(cherry picked from commit 0eb2dcd32ea6fb59661d709872e02ea6b3e7b9e2)

2 years agofusefs: fix intermittency in the dev_fuse_poll test
Alan Somers [Sat, 25 Sep 2021 16:16:20 +0000 (10:16 -0600)]
fusefs: fix intermittency in the dev_fuse_poll test

The DevFusePoll::access/select test would occasionally segfault.  The
cause was a file descriptor that was shared between two threads.  The
first thread would kill the second and close the file descriptor.  But
it was possible that the second would read the file descriptor before it
shut down.  That did not cause problems for kqueue, poll, or blocking
operation, but it triggered segfaults in select's macros.

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

(cherry picked from commit f44a448709d3b77508fd59ee28201ae1666387c2)

2 years agofusefs: Fix a bug during VOP_STRATEGY when the server changes file size
Alan Somers [Sun, 3 Oct 2021 17:51:14 +0000 (11:51 -0600)]
fusefs: Fix a bug during VOP_STRATEGY when the server changes file size

If the FUSE server tells the kernel that a file's size has changed, then
the kernel must invalidate any portion of that file in cache.  But the
kernel can't do that during VOP_STRATEGY, because the file's buffers are
already locked.  Instead, proceed with the write.

PR: 256937
Reported by: Agata <chogata@moosefs.pro>
Tested by: Agata <chogata@moosefs.pro>
Reviewed by: pfg
Differential Revision: https://reviews.freebsd.org/D32332

(cherry picked from commit 032a5bd55b3a003d3560435422a95f27f91685fe)

2 years agofusefs: fix a recurse-on-non-recursive lockmgr panic
Alan Somers [Sat, 2 Oct 2021 18:17:36 +0000 (12:17 -0600)]
fusefs: fix a recurse-on-non-recursive lockmgr panic

fuse_vnop_bmap needs to know the file's size in order to calculate the
optimum amount of readahead.  If the file's size is unknown, it must ask
the FUSE server.  But if the file's data was previously cached and the
server reports that its size has shrunk, fusefs must invalidate the
cached data.  That's not possible during VOP_BMAP because the buffer
object is already locked.

Fix the panic by not querying the FUSE server for the file's size during
VOP_BMAP if we don't need it.  That's also a a slight performance
optimization.

PR: 256937
Reported by: Agata <chogata@moosefs.pro>
Tested by: Agata <chogata@moosefs.pro>

(cherry picked from commit 7430017b9978cae054ed99e5160f739e5ca021d5)

2 years agofusefs: quiet some cache-related warnings
Alan Somers [Sun, 3 Oct 2021 16:59:04 +0000 (10:59 -0600)]
fusefs: quiet some cache-related warnings

If the FUSE server does something that would make our cache incoherent,
we should print a warning to the user.  However, we previously warned in
some situations when we shouldn't, such as if the file's size changed on
the server _after_ our own attribute cache had expired.  This change
suppresses the warning in cases like that.  It also moves the warning
logic to a single place within the code.

PR: 256936
Reported by: Agata <chogata@moosefs.pro>
Tested by: Agata <chogata@moosefs.pro>, jSML4ThWwBID69YC@protonmail.com

(cherry picked from commit 5d94aaacb5180798b2f698e33937f068386004eb)

2 years agoRPCBIND: skip ipv6 link local when request is not from link local address
David Bright [Mon, 4 Oct 2021 15:43:41 +0000 (08:43 -0700)]
RPCBIND: skip ipv6 link local when request is not from link local address

RPCINFO on macOS behaves different compared to other linux clients and
doesn't provide request address in rpcb structure of the
RPCBPROC_GETADDRLIST call which doesn't seem to be forbidden.

In this case RPCBIND uses RPC call's source address and picks a
closest corresponding local address. If there are no addresses in the
same subnet as the source address, return of RPCBIND may vary
depending on the order of addresses returned in getifaddrs. If a link
local precedes global address it may be returned even if the request
comes from neither a link local nor from link local in a different
scope, which will prevent services like nfs from working in tpc6
scenario on macOS clients. Issue can be seen only on FreeBSD rpcbind
port due to changes in workflow of addrmerge call.

Submitted by: Dmitry Ovsyannikov (Dmitry.Ovsyannikov@dell.com)
Sponsored by: Dell EMC

(cherry picked from commit d18c9a91979543adc182c7b28819691b64fda388)

2 years agoUpgrade ENA to v2.4.1
Marcin Wojtas [Fri, 23 Jul 2021 22:31:32 +0000 (15:31 -0700)]
Upgrade ENA to v2.4.1

Approved by: re

ena: Remove redundant declaration of ena_log_level.

GCC6 raises a -Wredundant-decl error due to duplicate declarations
in ena_fbsd_log.h and ena_plat.h.

Submitted by: jhb
Sponsored by: Chelsio Communications

(cherry picked from commit 8843787aa1bdbd10de6ba47a04489179ec2d2d3c)

ena: Avoid unnecessary mbuf collapses for LLQ condition

In case of Low-latency Queue, one small enough descriptor can be pushed
directly to the ENA hw, thus saving one fragment. Check for this
condition before performing collapse.

Submitted by: Artur Rojek <ar@semihalf.com>
Obtained from: Semihalf
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit c81f8c26115a64b9a97ecdb2a64e824dd839ee73)

ena: Trigger reset on ena_com_prepare_tx failure

All ena_com_prepare_tx errors other than ENA_COM_NO_MEM are fatal and
require device reset.

Submitted by: Artur Rojek <ar@semihalf.com>
Obtained from: Semihalf
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit 36130d2979d695dd439bc607feb00dcdb9a1937b)

ena: Prevent reset after device destruction

Check for ENA_FLAG_TRIGGER_RESET inside a locked context in order to
avoid potential race conditions with ena_destroy_device. This aligns the
reset task logic with the Linux driver.

Submitted by: Artur Rojek <ar@semihalf.com>
Obtained from: Semihalf
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit 433ab9b6987b42b3e5b25b8b5dc7e5178c7ef9bb)

ena: Add extra log messages

Stay aligned with the Linux driver by adding the following logs:
* inform the user about retrying queue creation
* warn on non-empty ena_tx_buffer.mbuf prior to ena_tx_map_mbuf

Submitted by: Artur Rojek <ar@semihalf.com>
Obtained from: Semihalf
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit 77160654a162b5faa8ad7a02e18d2bef2589f868)

ena: Add locking assertions

ENA silently assumed that ena_up, ena_down and ena_start_xmit routines
should be called within locked context. Driver's logic heavily assumes
on concurrent access to those routines, so for safety and better
documentation about this assumption, the locking assertions were added
to the above functions.

The assertion was added only for the main steps (skipping the helper
functions) which can be called from multiple places including the kernel
and the driver itself.

Submitted by: Artur Rojek <ar@semihalf.com>
Obtained from: Semihalf
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit cb98c439d66c303353a9f4abbbe9ddb51559c638)

ena: Move RSS logic into its own source files

Delegate RSS related functionality into separate .c/.h files in
preparation for the full RSS support.

While at it, reorder functions and remove prototypes for ones with
internal linkage.

Submitted by: Artur Rojek <ar@semihalf.com>
Obtained from: Semihalf
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit 986e7b9227668caf9620f207e3c1d708c87b634d)

ena: Disable meta descriptor caching for netmap

If LLQ is being used, `ena_tx_ctx.meta_valid` must stay enabled. This
fixes netmap support on latest generation ENA HW and aligns it with the
core driver behavior.

As netmap doesn't support any csum offloads, the
`adapter->disable_meta_caching` value can be simply passed to the HW.

Submitted by: Artur Rojek <ar@semihalf.com>
Obtained from: Semihalf
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit a831466830de6ab55fc03170290b313157196e81)

ena: Share ena_global_lock between driver instances

In order to use `ena_global_lock` in sysctl context, it must be kept
outside the driver instance's software context, as sysctls can be called
before attach and after detach, leading to lock use before sx_init and
after sx_destroy otherwise.
Solve this issue by turning `ena_global_lock` into a file scope
variable, shared between all instances of the driver and associated
sysctl context, and in turn initialized/destroyed in dedicated
SYSINIT/SYSUNINIT functions.
As a side effect, this change also fixes existing race in the reset
routine, when simultaneously accessing sysctl exposed properties.

Submitted by: Artur Rojek <ar@semihalf.com>
Obtained from: Semihalf
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit 07aff471c0de2de9a1dc5c7749c46b525bdd0201)

ena: Add missing statistics

Provide the following sysctl statistics in order to stay aligned with
the Linux driver:
* rx_ring.csum_good
* tx_ring.unmask_interrupt_num

Also rename the 'bad_csum' statistic name to 'csum_bad' for alignment.

Submitted by: Artur Rojek <ar@semihalf.com>
Obtained from: Semihalf
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit 223c8cb12e951c63807300a0cbdc4a1569520b4b)

ena: Implement full RSS reconfiguration

Bind RX/TX queues and MSI-X vectors to matching CPUs based on the RSS
bucket entries.

Introduce sysctls for the following RSS functionality:
- rss.indir_table:      indirection table mapping
- rss.indir_table_size: indirection table size
- rss.key:              RSS hash key (if Toeplitz used)

Said sysctls are only available when compiled without `option RSS`, as
kernel-side RSS support currently doesn't offer RSS reconfiguration.

Migrate the hash algorithm from CRC32 to Toeplitz and change the initial
hash value to 0x0 in order to match the standard Toeplitz implementation.
Provide helpers for hash key inversion required for HW operations.

Submitted by: Artur Rojek <ar@semihalf.com>
Obtained from: Semihalf
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit 6d1ef2abd330fac4057f092abbbdc28a568b4327)

ena: fix building in-kernel driver

When building ENA as compiled into the kernel, the driver would fail to
build. Resolve the problem by introducing the following changes:
1. Add missing `ena_rss.c` entry in `sys/conf/files`.
2. Prevent SYSCTL_ADD_INT from throwing an assert due to an extra
CTLTYPE_INT flag.

Fixes: 986e7b92276 ("ena: Move RSS logic into its own source files")
Fixes: 6d1ef2abd33 ("ena: Implement full RSS reconfiguration")
Submitted by: Artur Rojek <ar@semihalf.com>
Obtained from: Semihalf
Sponsored by: Amazon, Inc.
MFC after: 1 week

(cherry picked from commit a3f0d18237bdcf272461d3b4b682de384c572144)

ena: Update driver version to v2.4.1

Some of the changes in this release:
* Hardware RSS hash key reconfiguration and indirection table
reconfiguration support.
* Full kernel RSS support.
* Extra statistic counters.
* Netmap support for ENAv3.
* Locking assertions.
* Extra log messages.
* Reset handling fixes.

Submitted by: Michal Krawczyk <mk@semihalf.com>
Obtained from: Semihalf
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit 42c7760be3ea420668f625f2064ae347aa7e818e)

2 years agoUpgrade ENA to v2.4.0
Marcin Wojtas [Mon, 14 Jun 2021 08:57:45 +0000 (10:57 +0200)]
Upgrade ENA to v2.4.0

Approved by: re

ena: change ENA C++-style comment into C-style

According to man style(9), only C-style comments should be used.

Submitted by: Michal Krawczyk <mk@semihalf.com>
Obtained from: Semihalf
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit 438c9e3cf89403628ec237cfecdd0538f208087b)

ena: add support for the large LLQ headers in ENA

Default LLQ (Low-latency queue) maximum header size is 96 bytes and can
be too small for some types of packets - like IPv6 packets with multiple
extension. This can be fixed, by using large LLQ headers.

If the device supports larger LLQ headers, the user can activate this
feature by setting sysctl tunable 'hw.ena.force_large_llq_header' to '1'
in the /boot/loader.conf file.

In case the device isn't supporting this feature, the default value (96B)
will be used.

Submitted by: Michal Krawczyk <mk@semihalf.com>
Obtained from: Semihalf
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit beaadec9eaec8e6b266faff3b0880a141728fcef)

ena: remove surplus NULL checks when freeing ENA resources

Calling free on a NULL pointer is valid, as appropriate check is already
done internally:

/* free(NULL, ...) does nothing */
if (addr == NULL)
    return;

Submitted by: Artur Rojek <ar@semihalf.com>
Obtained from: Semihalf
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit ddec69e6a796283497ebada0569f34bd41bbdf37)

ena: hide sysctl nodes for unused ENA queues

IO queue related attributes are registered statically at driver attach
with the rest of the ENA specific sysctl nodes. However, the number of
queues can be changed at runtime via the `ena_sysctl_io_queues_nb`
request, leading to a potential exposure of attributes for non-existing
queues.

Introduce a new `ena_sysctl_update_queue_node_nb` function, which
updates the sysctl nodes after the number of queues is altered.
This happens by either registering or unregistering node specific oids,
based on a delta between the previous and current queue count.

NOTE: All unregistered oids must be registered again before the driver
detach, e.g. by another call to this function.

Submitted by: Artur Rojek <ar@semihalf.com>
Obtained from: Semihalf
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit 0e7d31f63b9db869c91228d8ed1e984bdee2b931)

Merge tag 'vendor/ena-com/2.4.0'

Update the driver in order not to break its compilation
and make use of the new ENA logging system

Migrate platform code to the new logging system provided by ena_com
layer.

Make ENA_INFO the new default log level.

Remove all explicit use of `device_printf`, all new logs requiring one
of the log macros to be used.

(cherry picked from commit 3fc5d816f8831d6fc2816ac97bd78dc486cd080c)

Update ENA driver man page

Bring the obsolete man page up to date:
* update diagnostic error messages
* add documentation of loader tunables
* document netmap support
* add a driver history section
* update the contact information

Submitted by: Artur Rojek <ar@semihalf.com>
Submitted by: Michal Krawczyk <mk@semihalf.com>
Obtained from: Semihalf
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit e34856a2c44a45512463aed0d1794f34258c66ee)

Update ENA version to v2.4.0

Some of the changes in this release:
* Large LLQ headers,
* Bug/stability fixes,
* Change of the README/Documentation.

Submitted by: Michal Krawczyk <mk@semihalf.com>
Obtained from: Semihalf
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit 93f0df457bf1d0e5f71839ab969c94d1f95813fb)

2 years agopci_user: call bus_translate_resource before BAR mmap
Marcin Wojtas [Tue, 6 Apr 2021 15:10:04 +0000 (17:10 +0200)]
pci_user: call bus_translate_resource before BAR mmap

On some armv8 machines it is possible that the mapping between CPU
and PCI bus BAR base addresses is not 1:1. In case a BAR is allocated
in kernel using bus_alloc_resource_any this translation is handled in
ofw_pci_activate_resource.

Do the same in pci_user.c by calling bus_translate_resource devmethod.
This fixes mmaping BARs to userspace on Marvell SoCs (Armada 7k8k/CN913x)
and possibly many other platforms.

Submitted by: Kornel Duleba <mindal@semihalf.com>
Reviewed by: kib
Obtained from: Semihalf
Sponsored by: Marvell
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D29604

(cherry picked from commit f2f1ab39c04088ce53287528549e652cf68cee09)

pci_user: fix build for 32-bit platforms

Commit: f2f1ab39c040 ("pci_user: call bus_translate_resource before BAR mmap")
broke build for 32-bit platforms due to rman_res_t and vm_paddr_t
incompatible types. Fix that.

(cherry picked from commit 9857e00a528bb230c8935ded5f118a7374bf808b)

2 years agoprometheus_sysctl_exporter(8): filter output using a regex
Robert Wing [Fri, 8 Oct 2021 01:00:27 +0000 (17:00 -0800)]
prometheus_sysctl_exporter(8): filter output using a regex

Add two options, -i and -e, for filtering prometheus metrics.

Each option takes a regular expression as an argument. The provided
regex will be tested against the prometheus metric name.

The -i option includes metrics matching the given regex.
The -e option excludes metrics matching the given regex.

Sponsored by:   Modirum MDPay
Sponsored by:   Klara Inc.
Reviewed by: 0mp, debdrup
Differential Revision: https://reviews.freebsd.org/D32269

(cherry picked from commit 8ff2b52241400f2b5c2287b91e6e12b97ffd5773)

2 years agoqlnxe: Fix typos in two error messages
Gordon Bergling [Sat, 2 Oct 2021 08:49:51 +0000 (10:49 +0200)]
qlnxe: Fix typos in two error messages

- s/erorr/error/

(cherry picked from commit 957d9ba0c3f908462915c9aed6900c50c8c76210)

2 years agoti(4): Fix a typo in an error message
Gordon Bergling [Sat, 2 Oct 2021 08:51:29 +0000 (10:51 +0200)]
ti(4): Fix a typo in an error message

- s/chanels/channels/

(cherry picked from commit 42dfad2ef12755d27e0e34656a2624f0dac2c502)

2 years agoe1000: Function prototype cleanup
Kevin Bowling [Wed, 6 Oct 2021 21:03:38 +0000 (14:03 -0700)]
e1000: Function prototype cleanup

Drop arguments of function prototypes since the file is mixed between
listing arg names and not.

No functional changes

Reviewed by: markj
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D32329

(cherry picked from commit 28ccd780a96fe49364072955636829cff1589cfb)

2 years agoar: provide error exit status upon failure
Ed Maste [Tue, 3 Aug 2021 18:30:06 +0000 (14:30 -0400)]
ar: provide error exit status upon failure

Previously ar and ranlib returned with exit status 0 (success) in the
case of a missing file or other error.  Update to use error handling
similar to that added by ELF Tool Chain after that project forked
FreeBSD's ar.

PR: PR257599 [exp-run]
Reported by: Shawn Webb, gehmehgeh (on HardenedBSD IRC)
Reviewed by: markj
Obtained from: elftoolchain
MFC after: 2 months
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31402

(cherry picked from commit 38911b3c2c7dbb9a097b44856472ebbbedde71fc)

2 years agofreebsd-update(8): Add -j flag to support jails
Faraz Vahedi [Fri, 1 Oct 2021 18:48:57 +0000 (13:48 -0500)]
freebsd-update(8): Add -j flag to support jails

Make freebsd-update(8) support jails by adding the -j flag which takes
a jail jid or name as an argument. This takes advantage of the recently
added -j support to freebsd-version(8) in order to get the version of
the installed userland.

Reviewed by: dteske, kevans
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D25711

(cherry picked from commit c76da1f01064b2b9a1903b30d4b4c444b85f8724)

2 years agofreebsd-version(1): Add -j flag to support jails
Faraz Vahedi [Fri, 1 Oct 2021 18:46:23 +0000 (13:46 -0500)]
freebsd-version(1): Add -j flag to support jails

Make freebsd-version(1) support jails by adding the -j flag which takes
a jail jid or name as an argument. As with other options, -j
flags stack and display in the order requested.

Reviewed by: bcr (manpages), kevans
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D25705

(cherry picked from commit f54b18fc4d72c566912b9a41601ed87a852960e7)

2 years agoloader: dev_net.c should use __func__ with printf
Toomas Soome [Fri, 24 Sep 2021 14:07:20 +0000 (17:07 +0300)]
loader: dev_net.c should use __func__ with printf

We have printf calls with function name hardwired to string,
sometimes wrong name. Use __func__ instead.

MFC after: 1 week

(cherry picked from commit 1a25c51e38a7c9f46ec195836233636616741f06)

2 years agolibsa: cstyle cleanup of dosfs.c
Toomas Soome [Thu, 19 Aug 2021 14:33:24 +0000 (17:33 +0300)]
libsa: cstyle cleanup of dosfs.c

No functional changes intended.

MFC after: 1 week

(cherry picked from commit 3ec0714d6db0060113f6cadac6f4e44640603e8f)

2 years agoloader: cstyle cleanup of userboot/devicename.c
Toomas Soome [Wed, 11 Aug 2021 07:07:28 +0000 (10:07 +0300)]
loader: cstyle cleanup of userboot/devicename.c

No functional changes intended.

MFC after: 1 week

(cherry picked from commit 5d5a6216645a6aefa8665c79bb761b754d74c067)

2 years agoloader: cstyle cleanup of libsa/lseek.c
Toomas Soome [Sun, 1 Aug 2021 07:07:32 +0000 (10:07 +0300)]
loader: cstyle cleanup of libsa/lseek.c

Clean up lseek.c, no functional changes intended. This is pre-patch
for open file list rewrite.

MFC after: 1 week

(cherry picked from commit bbb539b83ceced2d355893ead5987193737833fd)

2 years agoloader(8): fix path to be correct loader.4th.
Warner Losh [Wed, 14 Jul 2021 22:34:43 +0000 (16:34 -0600)]
loader(8): fix path to be correct loader.4th.

boot.4th was a thing for only a few months around FreeBSD 3.1. The
correct name has been loader.4th for a long time.

MFC After:    2 days
Sponsored by: Netflix

(cherry picked from commit 13c98cd06b80afd0d062211ee8f1bfeb8c6cb065)

2 years agoloader: update autoboot description and move to loader.conf.5
Daniel Gerzo [Mon, 12 Jul 2021 21:13:03 +0000 (15:13 -0600)]
loader: update autoboot description and move to loader.conf.5

Document "NO" special value for the autoboot_delay and move the
description to loader.conf.5.

imp reworked some of the wording from danger's patch.

PR: 85128

(cherry picked from commit 71f6aea4150c66784cbad42c1e1ff908d909c2ec)

2 years agoDisable PIE for MIPS BERI boot loader
Marcin Wojtas [Thu, 25 Feb 2021 05:41:35 +0000 (06:41 +0100)]
Disable PIE for MIPS BERI boot loader

MIPS BERI boot loader is built with -mno-abicalls and -fno-pic
so prevent adding PIE-related build flags.

Fix build after 9a227a2fd642 ("Enable PIE by default on 64-bit architectures")

Obtained from: Semihalf
Sponsored by: Stormshield

(cherry picked from commit 19cd12a32afe801dc5e753013993e15e924ceb39)

2 years agoDisable PIE for MIPS ubldr
Marcin Wojtas [Fri, 12 Feb 2021 15:41:49 +0000 (16:41 +0100)]
Disable PIE for MIPS ubldr

When performing buildworld for MIPS with PIE enabled, the build fails
with "position-independent code requires '-mabicalls'" message.
-mno-abicalls and -fno-pic flags are explicitly set in MIPS ubldr
makefile, so to work around this problem, set MK_PIE=no for MIPS
ubldr.

Submitted by: Dawid Gorecki <dgr@semihalf.com>
Reviewed by: emaste
Obtained from: Semihalf
Sponsored by: Stormshield
Differential Revision: https://reviews.freebsd.org/D28370

(cherry picked from commit cd992885bcdfb3c2c6b761f5c3bf1c86949acdc3)

2 years agoDisable PIE for powerpc bootloaders.
Marcin Wojtas [Tue, 23 Feb 2021 12:42:26 +0000 (13:42 +0100)]
Disable PIE for powerpc bootloaders.

Bootloaders for powerpc are not built as position independent
code. Since bsd.prog.mk is used for building, when PIE is enabled,
the PIE flags are added and that causes the build to fail.
Adding MK_PIE=no stops bsd.prog.mk from adding PIE specific flags.

Submitted by: Dawid Gorecki <dgr@semihalf.com>
Reviewed by: emaste
Obtained from: Semihalf
Sponsored by: Stormshield
Differential Revision: https://reviews.freebsd.org/D28893

(cherry picked from commit 3aa023643e9db78f4da314ff9bfb1643533c004f)

2 years agoFix date
Mateusz Piotrowski [Thu, 7 Jan 2021 20:15:26 +0000 (21:15 +0100)]
Fix date

It's 2021 already.

(cherry picked from commit 79eca6520e0a516a2c217d8c9faedb58ad5db204)

2 years agoLink efi programs with -pie rather than -shared
Alex Richardson [Mon, 12 Oct 2020 11:27:08 +0000 (11:27 +0000)]
Link efi programs with -pie rather than -shared

This was causing build failures in CheriBSD where we were passing -pie
already by default.

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

(cherry picked from commit 253e820a4db794c4c5e39e8e6d6bf2775f25d0cc)

2 years agoIgnore the .interp section in the arm64 EFI loader
Andrew Turner [Thu, 10 Sep 2020 14:13:49 +0000 (14:13 +0000)]
Ignore the .interp section in the arm64 EFI loader

When building the loader an unneeded .interp section may be added. Move
this to the unused section region so offsets of used sections don't
change.

Obtained from: CheriBSD
Sponsored by: Innovate UK

(cherry picked from commit 6215ed7c5c0e8cdd536123ec658a081748cfc85c)

2 years agoQuiet int-to-pointer-cast warnings on i386 with GCC 9.
John Baldwin [Fri, 4 Sep 2020 00:11:01 +0000 (00:11 +0000)]
Quiet int-to-pointer-cast warnings on i386 with GCC 9.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D26200

(cherry picked from commit 67dc6bed1fc62b740351713e7aa42fe1eae896b6)

2 years agoUpdate to today's date
Warner Losh [Tue, 1 Sep 2020 07:56:28 +0000 (07:56 +0000)]
Update to today's date

Also, fix a whitespace botch

(cherry picked from commit ff79e517d1547b8f05ef9cb6ac95616a8483a253)

2 years agoVery preliminary loader.efi(8) man page
Warner Losh [Tue, 1 Sep 2020 07:54:09 +0000 (07:54 +0000)]
Very preliminary loader.efi(8) man page

(cherry picked from commit 2b6d38a1db31967572042a0fe01d980475eb32f1)

2 years agostand: use portable ln -n instead of ln -h
Alex Richardson [Thu, 6 Aug 2020 20:46:18 +0000 (20:46 +0000)]
stand: use portable ln -n instead of ln -h

This fixes the build on Linux

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

(cherry picked from commit d8e1e85c42f989df0343e2130de542d553a691c9)

2 years agoLoader: explain the syntax of currdev
Allan Jude [Mon, 13 Jul 2020 02:09:21 +0000 (02:09 +0000)]
Loader: explain the syntax of currdev

The origin text was: "Syntax for devices is odd."
That is not very helpful.

PR: 199103

(cherry picked from commit 551d20f044f3fa5e4f59d6303f1a2a70c1bf2297)

2 years agoloader: implement GELI writes
Toomas Soome [Sat, 11 Jul 2020 06:51:42 +0000 (06:51 +0000)]
loader: implement GELI writes

Bug: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=247482

This patch is based on initial work from allanjude.

PR: 247482

(cherry picked from commit de776da3239ee3edc5f77bd0e48d0bb15262024b)

2 years agoloader: update zfsimpl.c from illumos review suggestions
Toomas Soome [Mon, 6 Jan 2020 19:35:22 +0000 (19:35 +0000)]
loader: update zfsimpl.c from illumos review suggestions

Add extra comments and update error handling.

(cherry picked from commit 653c3383c7287535e75a94563455b48f177bc803)

2 years agoloader: provide u> and xemit words if needed
Toomas Soome [Tue, 17 Sep 2019 18:05:33 +0000 (18:05 +0000)]
loader: provide u> and xemit words if needed

We have external interpreter (userboot.so) which may be lagging behind
with updates and may be missing u> xemit words.

(cherry picked from commit 68861a62f5363e6984ba96efe6463e882a9c4896)

2 years agoEFI loader: Don't free bcache for DEVT_DISK devs
Colin Percival [Thu, 30 Sep 2021 21:48:14 +0000 (14:48 -0700)]
EFI loader: Don't free bcache for DEVT_DISK devs

Booting on an EC2 c5.xlarge instance, this reduces the number of I/Os
performed from 609 to 432, reduces the total number of blocks read
from 61963 to 60797, and reduces the time spent in the loader by 39 ms.

Note that b4cb3fe0e39a allowed the bcache to be retained for most of
the boot process, but relies on mounting filesystems; this commit
allows the bcache to be retained at the start of the boot process,
before the root filesystem has been located.

Reviewed by: imp, tsoome
MFC after: 1 week
Sponsored by: https://www.patreon.com/cperciva
Differential Revision: https://reviews.freebsd.org/D32239

(cherry picked from commit ce73f768b76486b1562f207a6fc1cef87065418a)

2 years agopkgfs_open: follow symlinks
Simon J. Gerraty [Fri, 15 Jan 2021 01:33:05 +0000 (17:33 -0800)]
pkgfs_open: follow symlinks

Caller is not interested in symlinks follow them.
Throw an error if too many links encountered.

(cherry picked from commit b14cfecbf0ed04c841aa594dede3668b0a36344a)

2 years agostand/ficl 64-bit compatibility
Brandon Bergren [Mon, 14 Sep 2020 15:48:30 +0000 (15:48 +0000)]
stand/ficl 64-bit compatibility

Currently, the only thing that prevents a functioning 64-bit FICL build is
a few integer types that were intended to be fixed-width.

Changing them to C99 integer types allows building a functioning 64-bit
FICL.

While this isn't applicable to the default settings of any in-tree loaders,
it is necessary for a future Petitboot loader, due to the requirement that
it be compiled as a 64-bit program.

(cherry picked from commit 9e4c35f867aca020df8d01fb7371bf5ae1cc8a2d)
(cherry picked from commit 0ebbda971890c149c5028066fc5ed7ea72228d87)

2 years agoloader: cstyle cleanup
Toomas Soome [Sun, 19 Jul 2020 06:59:09 +0000 (06:59 +0000)]
loader: cstyle cleanup

No functional changes intended.

(cherry picked from commit 97dd57e66c32a9a74549822a599ca77e50c7ff82)

2 years agoloader: crc32 is provided by libsa
Toomas Soome [Wed, 4 Mar 2020 18:38:09 +0000 (18:38 +0000)]
loader: crc32 is provided by libsa

Seems like leftover from moving crc32.c to libsa.

(cherry picked from commit ca251958058fc5e7c9ed020655ed7e737043ba77)

2 years agoFix 64-bit build of libofw.
Brandon Bergren [Tue, 8 Sep 2020 23:22:11 +0000 (23:22 +0000)]
Fix 64-bit build of libofw.

Adjust a couple of printf() lines that deal with dumping out addresses
to cast to uintmax_t.

This allows building a 64-bit libofw for use in things like a future
Petitboot loader for PowerPC64, and other FDT platforms that require
a 64-bit loader binary and want to use forth.

Sponsored by: Tag1 Consulting, Inc.

(cherry picked from commit 3e91d8268ff7ad4ca543d720f66525e6f114fb12)

2 years agoloader.efi: remove extra extern ST
Warner Losh [Thu, 30 Sep 2021 02:07:13 +0000 (20:07 -0600)]
loader.efi: remove extra extern ST

The definition for 'ST' is in efilib.h, so we don't need extern ST here.

(cherry picked from commit 8ea95b2fbab8eb891c4191c1879199685951b1f6)