]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
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)

2 years agoloader: we should support pools without features
Toomas Soome [Fri, 2 Apr 2021 23:40:51 +0000 (02:40 +0300)]
loader: we should support pools without features

nvlist_check_features_for_read() does return error when there
are no features for read.

(cherry picked from commit d36341f7b8ddc2457a1e9e4a721d27d2e66cb39a)

2 years agolibsa: Remove conflicting .global/.weak directive
Alex Richardson [Tue, 30 Mar 2021 13:52:31 +0000 (14:52 +0100)]
libsa: Remove conflicting .global/.weak directive

LLVM12 complains if you change the symbol binding:
`error: _longjmp changed binding to STB_GLOBAL`
In this case LLVM actually ignored the weak directive and used the
later .global, but GNU as would mark the symbol as weak.
None of the other architectures mark the libsa _setjmp as weak so
just drop this directive.

(cherry picked from commit 59b2caef0537661397caf2ce1398cf802cb864b4)

2 years agostand: Load INIT_ARRAY and FINI_ARRAY sections
Mark Johnston [Tue, 16 Mar 2021 19:01:41 +0000 (15:01 -0400)]
stand: Load INIT_ARRAY and FINI_ARRAY sections

This is required for preloading modules into a KASAN-configured kernel.

(cherry picked from commit 7b1b5aad95df671aba3192f1669a8d96da481939)

2 years agopxeboot(8): remove antiquated information
Guangyuan Yang [Mon, 15 Feb 2021 22:03:37 +0000 (22:03 +0000)]
pxeboot(8): remove antiquated information

While I was there:
- Fix some typos
- Fix an excessive argument "indent" reported by mandoc -Tlint
- Replace a dead link with the one suggested by
  https://www.uefi.org/uefi

(cherry picked from commit c90fb7acf099f1dc982f8d6087aa92809ae43727)

2 years agoefi loader: fix typos in a comment
Eric van Gyzen [Fri, 1 Jan 2021 17:38:39 +0000 (11:38 -0600)]
efi loader: fix typos in a comment

...mostly because it's a harmless way to try the shiny new git repo.

(cherry picked from commit 670d2ad820c7584e6592d2a6d748dda0758d2ec5)

2 years agoloader: allow loader to accept zfs feature com.delphix:bookmark_written
Toomas Soome [Tue, 15 Dec 2020 22:37:03 +0000 (22:37 +0000)]
loader: allow loader to accept zfs feature com.delphix:bookmark_written

We do not need to actually read bookmarks, just whitelist this feature.

(cherry picked from commit d3eae37553cd23d5ca8addc4818aec9d8a71ec81)

2 years agoloader: allow loader to accept zfs feature com.datto:bookmark_v2
Toomas Soome [Tue, 15 Dec 2020 21:48:35 +0000 (21:48 +0000)]
loader: allow loader to accept zfs feature com.datto:bookmark_v2

We do not need to actually read bookmarks, just whitelist this feature

(cherry picked from commit eba724f361693a52721b2626d800a7e117af67ac)

2 years agoloader: Print autoboot countdown immediately, not at 9
Jessica Clarke [Mon, 14 Dec 2020 00:46:24 +0000 (00:46 +0000)]
loader: Print autoboot countdown immediately, not at 9

For the first second otime and ntime are equal so no message gets
printed. Instead we should print the countdown right from the start,
although we do it at the end of the first iteration so that if a key has
already been pressed then the message is suppressed.

(cherry picked from commit c46f7610d4c5a57fdb2aac5fcbf66aa7124ec703)

2 years agoficl: make dump a bit friendlier
Toomas Soome [Tue, 1 Dec 2020 23:07:05 +0000 (23:07 +0000)]
ficl: make dump a bit friendlier

would be nice to have dump to output hex and ascii.

(cherry picked from commit cd56ababd3ceddec64395aac66fa49b08f0f06af)

2 years agoficl: instead of pad, emit can use local variable
Toomas Soome [Tue, 1 Dec 2020 22:28:02 +0000 (22:28 +0000)]
ficl: instead of pad, emit can use local variable

Pad in forth is used as "scratchpad" and internal implementations
should not use it. Ficl does not really follow this rule and this can fire back.
emit has no need to use pad, we can use local variable instead.

(cherry picked from commit dba7640e44c5ec148a84b0d58c6c9a3c9e5147f3)

2 years agozfsboot: add prototype for main()
Toomas Soome [Sun, 15 Nov 2020 14:04:27 +0000 (14:04 +0000)]
zfsboot: add prototype for main()

Some compilers are complaining about missing prototype.

PR: 251150

(cherry picked from commit fc7cf7241f89a3d3ccc20cb49c5bf61e154b7a1b)

2 years agoloader: cstyle cleanup of console.c
Toomas Soome [Sat, 14 Nov 2020 10:56:40 +0000 (10:56 +0000)]
loader: cstyle cleanup of console.c

cstyle cleanup only, no functional changes intended.

(cherry picked from commit 3e9f0f1d298f7f1e535831cdf697f5884a6d07dc)

2 years agoloader: cstyle cleanup of bootstrap.h did miss a bit
Toomas Soome [Sun, 8 Nov 2020 09:49:51 +0000 (09:49 +0000)]
loader: cstyle cleanup of bootstrap.h did miss a bit

correct small issues - misplaced comment and typos.

(cherry picked from commit 83a252c6a15d44cd574a9ef9ba37a77a3464296f)

2 years agoloader: cstyle cleanup of bootstrap.h
Toomas Soome [Sun, 8 Nov 2020 09:35:41 +0000 (09:35 +0000)]
loader: cstyle cleanup of bootstrap.h

No functional changes intended.

(cherry picked from commit 90b307a8975327b195e4549b9b0745bcc684f646)

2 years agoloader: revert r342161 and r342151
Toomas Soome [Thu, 22 Oct 2020 20:02:02 +0000 (20:02 +0000)]
loader: revert r342161 and r342151

We are using asize property from pool label and we do not depend
on partition data to find last two pool labels and to validate LBA for disk IO.

This does allow us to re-enable support for partitionless disk setups.

(cherry picked from commit e416eecbb9f7a5275d1d059ae720adc24af4d337)

2 years agoUse adrp in the arm64 efi loader
Andrew Turner [Tue, 13 Oct 2020 16:51:05 +0000 (16:51 +0000)]
Use adrp in the arm64 efi loader

On startup the arm64 efi loaders need to know PC-relative addresses.
Previously we used the adr instruction to find this address, however this
instruction is limited to +/- 1MiB.

Switch to adrp to find the 4k page the address is within and an add to
set the bottom 12 bits. This lets us address +/- 4GiB which should be
large enough for now.

(cherry picked from commit b9aa4537b2155a0b0bb419ff05b8da206c02bfbd)

2 years agoloader: edd_device_path_v3 is too small
Toomas Soome [Mon, 12 Oct 2020 09:34:50 +0000 (09:34 +0000)]
loader: edd_device_path_v3 is too small

The EDD v3[1], see table 13, page 33, does define device path as double
qword, that is, 16 bytes, we have only qword.

Also remove edd_device_path_v4 and edd_params_v4 because those are not used,
and there is no size difference in v3 versus v4.

[1] http://www.t13.org/documents/UploadedDocuments/docs2004/d1572r3-EDD3.pdf

(cherry picked from commit c50f409c15ef818baf5ee49edd52f44b9d809dce)

2 years agoImplement some time variables from kernel
Warner Losh [Tue, 29 Sep 2020 16:29:50 +0000 (16:29 +0000)]
Implement some time variables from kernel

OpenZFS will start using some of the kernel timekeeping bits
shortly. This implements the bare minimum of that which currently
is just the time_seconds variable.

(cherry picked from commit 6ab1ffcbfeaab180691d7c1b5b0003f224442fed)

2 years agoloader: zfs_probe_dev should pick first matching zfs pool
Toomas Soome [Wed, 23 Sep 2020 08:22:14 +0000 (08:22 +0000)]
loader: zfs_probe_dev should pick first matching zfs pool

During devswitch probe, we pick boot pool based on boot disk, if the boot
disk happens to have multiple pools in freebsd-zfs partitions, the current
code does pick last pool from boot disk as boot pool. While there is no
way at that stage to test, the more logical approach would be to pick
first matching pool.

This patch is assuming we do pass pool guid pointer with guid value 0,
this will help us to determine, if the guid value is already set or not.

The general suggestion would be not to share disk between different pools.

(cherry picked from commit 867ae3c38d1aa97300bd35f457037b3f1a0a103f)

2 years agoCreate CFLAGS_EARLY.file for boot loader.
Warner Losh [Fri, 28 Aug 2020 17:36:14 +0000 (17:36 +0000)]
Create CFLAGS_EARLY.file for boot loader.

Some external code requires a specific set of include paths to work
properly since it emulates the typical environment the code is used
in. Enable this by creating a CFLAGS_EARLY.file variable that can be
used to build this stack. Otherwise the include stack we build for
stand programs may get in the way. Code that uses this feature has to
tolerate the normal stack of inclues being last on the list (and
presumably unused), though.

Generally, it it should only be used for the specific include
directories. Defines and that sort of thing should be done in the
normal CFLAGS variable. There is a global CFLAGS_EARY hook as well for
everything in a Makefile.

(cherry picked from commit f9553770c03e82abcae07397025797ef346fbdab)

2 years agoDeclare time()
Warner Losh [Fri, 28 Aug 2020 05:40:02 +0000 (05:40 +0000)]
Declare time()

Time is used and was accidentally brought in through header
pollution. Declare it in stand.h directly instead.

(cherry picked from commit b9c5b432637c04d4a803170b2fab7c9df2ef787b)

2 years agolibsa: only skein_block.c is using SKEIN_LOOP
Toomas Soome [Wed, 26 Aug 2020 17:52:32 +0000 (17:52 +0000)]
libsa: only skein_block.c is using SKEIN_LOOP

Only use SKEIN_LOOP while compiling skein_block.c

(cherry picked from commit 0fec8f03cf996be5d4c9d770a7c47aae5e5aaee8)

2 years agoWhen we have a command returned by zfs_nextboot() that is longer
Gleb Smirnoff [Thu, 20 Aug 2020 20:31:47 +0000 (20:31 +0000)]
When we have a command returned by zfs_nextboot() that is longer
than command in the loader.conf, the latter needs to be nul terminated,
otherwise garbage trailer left from zfs_nextboot() will be passed to
parse_cmd() together with loader.conf command.

While here, reset cmd to empty string if read() returns error.

(cherry picked from commit c7dd069c70d465298f14553d981bfe5e2ffd0459)

2 years agolibsa: smbios: Parse the chassis type and export it as smbios.chassis.type
Emmanuel Vadot [Thu, 20 Aug 2020 12:50:49 +0000 (12:50 +0000)]
libsa: smbios: Parse the chassis type and export it as smbios.chassis.type

It can be useful to know what type of machine we are running on for desktop
related thing.
It also allow us to support all the DMI variable that linux driver can fetch.

(cherry picked from commit 9060f2c3920dde41226cf52b925bc949815c7f01)

2 years agolibsa: remove leftover whitespace
Toomas Soome [Wed, 19 Aug 2020 20:41:22 +0000 (20:41 +0000)]
libsa: remove leftover whitespace

Tiny cleanup, no functional changes.

(cherry picked from commit 5949d13fabc43a728b2122277f44a6366e3b9270)

2 years agolibsa: make env_discard() public
Toomas Soome [Wed, 19 Aug 2020 15:27:09 +0000 (15:27 +0000)]
libsa: make env_discard() public

Allow env_discard() to be used outside environment.c

(cherry picked from commit 588f0a1e29a341878ad938bb9c239431cac107ae)

2 years agolibsa: cstyle cleanup for environment.c
Toomas Soome [Wed, 19 Aug 2020 15:20:33 +0000 (15:20 +0000)]
libsa: cstyle cleanup for environment.c

No functional changes.

(cherry picked from commit 16aabe28c6e71f05e3520eb9209658fe61e7c28b)

2 years agoloader: setting vdev size based on label asize is not working
Toomas Soome [Thu, 9 Jul 2020 13:19:00 +0000 (13:19 +0000)]
loader: setting vdev size based on label asize is not working

Because we need to read asize from vdev_tree. We also need to consider
different vdev type difference.

(cherry picked from commit 1a4b982e1e22dc0bbcddbff082ee16abb2874871)

2 years agoloader: zfs reader does not need BOOT2 bits
Toomas Soome [Thu, 2 Jul 2020 07:15:48 +0000 (07:15 +0000)]
loader: zfs reader does not need BOOT2 bits

After switching zfsloader to use full libsa, we do not need
spa_get_primary() and spa_get_primary_vdev() any more.

(cherry picked from commit 771f100cebd8ada2bd764574386a71b5a5067f45)

2 years agoloader: potential memory leak and check return values
Toomas Soome [Thu, 2 Jul 2020 07:03:15 +0000 (07:03 +0000)]
loader: potential memory leak and check return values

Need to free nvlist before return from vdev_from_nvlist().

(cherry picked from commit 045f497cbc6cb67bc563d7f2378bf9535044bb2d)

2 years agoboot1.efi: use malloc family from libsa
Toomas Soome [Tue, 30 Jun 2020 21:48:58 +0000 (21:48 +0000)]
boot1.efi: use malloc family from libsa

The zfs reader development did reach to the point where linking boot1,
we will get errors about duplicate symbols Malloc, Free, Calloc.

We can just use libsa version, just as loader.efi does. The only concern is,
libsa zalloc is using fixed size heap region, I did pick 64MB as other
stage instances are using, but this size is likely not optimal. In any case,
with limited memory setups, we should boot loader.efi directly.

(cherry picked from commit 12c470af750672c4847af20cc8e2a736aab7db78)

2 years agoloader: can not read zfs pool with slog removed
Toomas Soome [Fri, 26 Jun 2020 21:21:35 +0000 (21:21 +0000)]
loader: can not read zfs pool with slog removed

The vdev_init() does check for "known" vdev types, the [log] device removal will create "hole"
device, but vdev_init() does not allow it.

(cherry picked from commit b93b14dc756861d543249f3d04b80809055fdd61)

2 years agoloader: create single zfs nextboot implementation
Toomas Soome [Sat, 20 Jun 2020 06:23:31 +0000 (06:23 +0000)]
loader: create single zfs nextboot implementation

We should have nextboot feature implemented in libsa zfs code.
To get there, I have created zfs_nextboot() implementation based on
two sources, our current simple textual string based approach with added
structured boot label PAD structure from OpenZFS.

Secondly, all nvlist details are moved to separate source file and
restructured a bit. This is done to provide base support to add nvlist
add/update feature in followup updates.

And finally, the zfsboot/gptzfsboot disk access functions are swapped to
use libi386 and libsa.

(cherry picked from commit 3830659e99640001c09d26dfc0e1bbd77d919a62)
(cherry picked from commit a137f7997efc8a34da75a7643c8fade4be67e82c)
(cherry picked from commit 4583682ec14cc63f063b6769b7706af1891b0934)

2 years agoloader: r362262 did miss the pathlen check
Toomas Soome [Wed, 17 Jun 2020 10:56:58 +0000 (10:56 +0000)]
loader: r362262 did miss the pathlen check

While we are checking the "/dev/" prefix, we can skip the paths shorter than
this prefix.

(cherry picked from commit aba2397e74a2eff55e2507c27ba31813d6b2a95e)

2 years agoloader: strings in nvlist are counted strings, not c-strings
Toomas Soome [Wed, 17 Jun 2020 10:41:01 +0000 (10:41 +0000)]
loader: strings in nvlist are counted strings, not c-strings

We need to fetch both string size and data, then handle the data.

(cherry picked from commit c98740b5e252d1cefd6d33d93fc1015d16afc1b8)

2 years agoboot2: need to expand tab output and mask getchar
Toomas Soome [Tue, 16 Jun 2020 20:35:00 +0000 (20:35 +0000)]
boot2: need to expand tab output and mask getchar

The BIOS ouput char function does not expand tab.
Mask getchar with 0xFF.

(cherry picked from commit 6469d2b422960de4b1253cc63b11fa67f896604f)

2 years agoloader: zfs_cmd.c does not really compile without libzfs.h
Toomas Soome [Tue, 16 Jun 2020 07:30:34 +0000 (07:30 +0000)]
loader: zfs_cmd.c does not really compile without libzfs.h

Having libzfs.h wrapped in LOADER_ZFS_SUPPORT check does not really make sense,
because we do need function declarations with C99.

(cherry picked from commit 467535dcfaa6be42efe0fe8be9582cafc5dfb812)