]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
20 months agokboot: copy EFI's bootinfo.c and adjust
Warner Losh [Tue, 6 Dec 2022 18:00:08 +0000 (11:00 -0700)]
kboot: copy EFI's bootinfo.c and adjust

Copy EFI's bootinfo.c and make minor adjustments for kboot's needs. Do
not connect this to the build just yet until other pieces are in place.

Sponsored by: Netflix

20 months agokboot: Mark the EFI specific parts of bootinfo.c
Warner Losh [Tue, 6 Dec 2022 17:55:58 +0000 (10:55 -0700)]
kboot: Mark the EFI specific parts of bootinfo.c

bootinfo.c is about to be shared with kboot since they create
substantially similar environments / metadata tagging / etc. Tag this
with #ifdef EFI for the moment until the proper abstracting out can
happen.

Sponsored by: Netflix

20 months agoudp: rearrange declarations in udp_var.h into user and _KERNEL halves
Gleb Smirnoff [Wed, 7 Dec 2022 17:55:38 +0000 (09:55 -0800)]
udp: rearrange declarations in udp_var.h into user and _KERNEL halves

Bring everything that belongs to _KERNEL into single block.  Move
sub-includes to its beginning.

20 months agoudp: destroy UDP and UDP-Lite inpcbinfos in single SYSUNINIT
Gleb Smirnoff [Wed, 7 Dec 2022 17:55:38 +0000 (09:55 -0800)]
udp: destroy UDP and UDP-Lite inpcbinfos in single SYSUNINIT

They are created in a single SYSINIT, there is no reason to destroy
them in separate functions.

20 months agotcp: use single locked callout per tcpcb for the TCP timers
Gleb Smirnoff [Wed, 7 Dec 2022 17:00:48 +0000 (09:00 -0800)]
tcp: use single locked callout per tcpcb for the TCP timers

Use only one callout structure per tcpcb that is responsible for handling
all five TCP timeouts.  Use locked version of callout, of course. The
callout function tcp_timer_enter() chooses soonest timer and executes it
with lock held.  Unless the timer reports that the tcpcb has been freed,
the callout is rescheduled for next soonest timer, if there is any.

With single callout per tcpcb on connection teardown we should be able
to fully stop the callout and immediately free it, avoiding use of
callout_async_drain().  There is one gotcha here: callout_stop() can
actually touch our memory when a rare race condition happens.  See
comment above tcp_timer_stop().  Synchronous stop of the callout makes
tcp_discardcb() the single entry point for tcpcb destructor, merging the
tcp_freecb() to the end of the function.

While here, also remove lots of lingering checks in the beginning of
TCP timer functions.  With a locked callout they are unnecessary.

While here, clean unused parts of timer KPI for the pluggable TCP stacks.

While here, remove TCPDEBUG from tcp_timer.c, as this allows for more
simplification of TCP timers.  The TCPDEBUG is scheduled for removal.

Move the DTrace probes in timers to the beginning of a function, where
a tcpcb is always existing.

Discussed with: rrs, tuexen, rscheff (the TCP part of the diff)
Reviewed by: hselasky, kib, mav (the callout part)
Differential revision: https://reviews.freebsd.org/D37321

20 months agotcp: remove tcp_timer_suspend()
Gleb Smirnoff [Wed, 7 Dec 2022 17:00:48 +0000 (09:00 -0800)]
tcp: remove tcp_timer_suspend()

It was a temporary code added together with RACK to fight against
TCP timer races.

20 months agotcp: embed inpcb into tcpcb
Gleb Smirnoff [Wed, 7 Dec 2022 17:00:48 +0000 (09:00 -0800)]
tcp: embed inpcb into tcpcb

For the TCP protocol inpcb storage specify allocation size that would
provide space to most of the data a TCP connection needs, embedding
into struct tcpcb several structures, that previously were allocated
separately.

The most import one is the inpcb itself.  With embedding we can provide
strong guarantee that with a valid TCP inpcb the tcpcb is always valid
and vice versa.  Also we reduce number of allocs/frees per connection.
The embedded inpcb is placed in the beginning of the struct tcpcb,
since in_pcballoc() requires that.  However, later we may want to move
it around for cache line efficiency, and this can be done with a little
effort.  The new intotcpcb() macro is ready for such move.

The congestion algorithm data, the TCP timers and osd(9) data are
also embedded into tcpcb, and temprorary struct tcpcb_mem goes away.
There was no extra allocation here, but we went through extra pointer
every time we accessed this data.

One interesting side effect is that now TCP data is allocated from
SMR-protected zone.  Potentially this allows the TCP stacks or other
TCP related modules to utilize that for their own synchronization.

Large part of the change was done with sed script:

s/tp->ccv->/tp->t_ccv./g
s/tp->ccv/\&tp->t_ccv/g
s/tp->cc_algo/tp->t_cc/g
s/tp->t_timers->tt_/tp->tt_/g
s/CCV\(ccv, osd\)/\&CCV(ccv, t_osd)/g

Dependency side effect is that code that needs to know struct tcpcb
should also know struct inpcb, that added several <netinet/in_pcb.h>.

Differential revision: https://reviews.freebsd.org/D37127

20 months agobsd-family-tree: FreeBSD 12.4 added
Maxim Konovalov [Wed, 7 Dec 2022 16:39:36 +0000 (16:39 +0000)]
bsd-family-tree: FreeBSD 12.4 added

20 months agoFix a typo in the binmisc option name
Doug Rabson [Wed, 7 Dec 2022 13:40:18 +0000 (13:40 +0000)]
Fix a typo in the binmisc option name

This should be spelt IMGACT_BINMISC to match the filename. The option
name does not appear outside of sys/conf and this module is typically
used via the kernel module imgact_binmisc.ko.

MFC After: 2 weeks

20 months agozfs: merge openzfs/zfs@59493b63c (master)
Martin Matuska [Wed, 7 Dec 2022 13:10:46 +0000 (14:10 +0100)]
zfs: merge openzfs/zfs@59493b63c (master)

Notable upstream pull request merges:
  #13782 Fix setting the large_block feature after receiving a snapshot
  #14157 FreeBSD: stop using buffer cache-only routines on sync
  #14172 zed: post a udev change event from spa_vdev_attach()
  #14181 zed: unclean disk attachment faults the vdev
  #14190 Bump checksum error counter before reporting to ZED
  #14196 Remove atomics from zh_refcount
  #14197 Don't leak packed recieved proprties
  #14198 Switch dnode stats to wmsums
  #14199 Remove few pointer dereferences in dbuf_read()
  #14200 Micro-optimize zrl_remove()
  #14204 Lua: Fix bad bitshift in lua_strx2number()
  #14212 Zstd fixes
  #14218 Avoid a null pointer dereference in zfs_mount() on FreeBSD
  #14235 nopwrites on dmu_sync-ed blocks can result in a panic
  #14236 zio can deadlock during device removal
  #14247 Micro-optimize fletcher4 calculations
  #14261 FreeBSD: zfs_register_callbacks() must implement error check
         correctly

Obtained from: OpenZFS
OpenZFS commit: 59493b63c18ea223857066218d6a58b67eb88159

20 months agoprotocols.5: Update the description of /etc/protocols
Gordon Bergling [Wed, 7 Dec 2022 11:31:44 +0000 (12:31 +0100)]
protocols.5: Update the description of /etc/protocols

The reference to the "DARPA Internet" seems not quite
up to date in 2022, so move that to the HISTORY section.

Mention RFC 2780 and RFC 5237.

Obtained from: NetBSD
MFC after: 3 days

20 months agostress2: Add list of problems found
Peter Holm [Wed, 7 Dec 2022 11:03:44 +0000 (12:03 +0100)]
stress2: Add list of problems found

20 months agogetservent.3: Mention the service.db
Gordon Bergling [Wed, 7 Dec 2022 09:26:13 +0000 (10:26 +0100)]
getservent.3: Mention the service.db

- reference /var/db/services.db
- reference services_mkdb(8)

Obtained from: NetBSD
MFC after: 3 days

20 months agoAdd some more local.*.mk includes
Simon J. Gerraty [Tue, 6 Dec 2022 18:49:54 +0000 (10:49 -0800)]
Add some more local.*.mk includes

These facilitate customizing the build with minimal churn.

Reviewed by: stevek
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D37592

20 months agoixl: silence runtime warning when PCI_IOV is not enabled
Andrew Gallatin [Tue, 6 Dec 2022 16:35:18 +0000 (11:35 -0500)]
ixl: silence runtime warning when PCI_IOV is not enabled

When PCI_IOV is not enabled, do not attempt to call
iflib_softirq_alloc_generic(...IFLIB_INTR_IOV), as it results
in boot-time warnings similar to:
taskqgroup_attach_cpu: qid not found for iov cpu=2
ixl2: taskqgroup_attach_cpu failed 22
Instead, make it conditional on PCI_IOV like the other
SR-IOV related code.

Reviewed by: erj
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37609

20 months agolinuxkpi: Fix style for dma_map_sgtable
Emmanuel Vadot [Tue, 6 Dec 2022 15:52:16 +0000 (16:52 +0100)]
linuxkpi: Fix style for dma_map_sgtable

Reported by: bz
Sponsored by: Beckhoff Automation GmbH & Co. KG

20 months agolinuxkpi: Fix return value of dma_map_sgtable
Austin Shafer [Tue, 6 Dec 2022 15:25:53 +0000 (16:25 +0100)]
linuxkpi: Fix return value of dma_map_sgtable

dma_map_sgtable internally uses the dma_map_sg_attrs helper. The problem is
that dma_map_sg_attrs returns the number of entries mapped, whereas
dma_map_sgtable returns nonzero on failure. This leads to dma_map_sgtable
returning non-zero-but-positive values which tricks other areas of the stack
into thinking nents is a valid pointer.

This checks if nents is valid and returns zero if so, updating the nents field
in sgt. This fixes PRIME render offload with nvidia-drm.

Fixes: 9202c95f47c2 ("linuxkpi: Add dma_{un,}map_sgtable")

20 months agobhyve: build SPCR ACPI table
Corvin Köhne [Wed, 30 Nov 2022 14:46:19 +0000 (15:46 +0100)]
bhyve: build SPCR ACPI table

OVMF ships some static ACPI tables. This worked in the past but won't
work in the future when we support devices like tpms. They require a TPM
ACPI table. So, we have to dynamically create ACPI tables depending on
the bhyve configuration.

Bhyve has much more information about the system than OVMF. Therefore,
it's easier for bhyve to build up some ACPI tables. For that reason, it
would be much better to use the ACPI tables provided by bhyve instead of
building some tables by OVMF.

At the moment, OVMF always creates a SPCR table. Maybe someone depends
on it. So, we have to build it by bhyve too before we can patch OVMF to
install the tables provided by bhyve.

Reviewed by: markj
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D37591

20 months agostress2: No need to run tests for 30 minutes
Peter Holm [Tue, 6 Dec 2022 09:32:49 +0000 (10:32 +0100)]
stress2: No need to run tests for 30 minutes

20 months agodma(8): add newaliases to mailer.conf
Baptiste Daroussin [Tue, 6 Dec 2022 07:30:19 +0000 (08:30 +0100)]
dma(8): add newaliases to mailer.conf

Reported by: karels
MFC After: 3 days

20 months agoRevert "newbus: Change attach failure behavior"
Warner Losh [Mon, 5 Dec 2022 23:57:58 +0000 (16:57 -0700)]
Revert "newbus: Change attach failure behavior"

This reverts commit 68c3f0302106643207dcdfe3b414810e245228e5. There are
some weird crashes when KVMs switch caused by this, so revert this
commit until they are sorted out.

Reported by: cy@
Sponsored by: Netflix

20 months agostand/zlib: Document the upstream issue behind NO_DEPRECATED_NON_PROTOTYPE
Warner Losh [Mon, 5 Dec 2022 23:55:04 +0000 (16:55 -0700)]
stand/zlib: Document the upstream issue behind NO_DEPRECATED_NON_PROTOTYPE

The zlib project has issue https://github.com/madler/zlib/issues/633 to
document its continued use of old K&R-style function definitions.

Suggested by: delphij@
Sponsored by: Netflix

20 months agostand: update prototypes for md_load and md_load64
Warner Losh [Mon, 5 Dec 2022 17:40:15 +0000 (10:40 -0700)]
stand: update prototypes for md_load and md_load64

These are declared as extern in a number of files (some with the wrong
return type). Centralize this in modinfo.h and remove a few extra stray
declarations as well that are no longer used. No functional change.

Note: I've not tried to cope with the bi_load() functions which are the
same logical thing. These will be handled separately.

Sponsored by: Netflix

20 months agoProvide more precise mount(8) failure message.
Kirk McKusick [Mon, 5 Dec 2022 22:47:24 +0000 (14:47 -0800)]
Provide more precise mount(8) failure message.

Suggested by: Xin LI
Reviewed by:  kib
PR:           19683
MFC after:    1 week

20 months agoMicro-optimize fletcher4 calculations
Richard Yao [Mon, 5 Dec 2022 19:00:34 +0000 (14:00 -0500)]
Micro-optimize fletcher4 calculations

When processing abds, we execute 1 `kfpu_begin()`/`kfpu_end()` pair on
every page in the abd. This is wasteful and slows down checksum
performance versus what the benchmark claimed. We correct this by moving
those calls to the init and fini functions.

Also, we always check the buffer length against 0 before calling the
non-scalar checksum functions. This means that we do not need to execute
the loop condition for the first loop iteration. That allows us to
micro-optimize the checksum calculations by switching to do-while loops.

Note that we do not apply that micro-optimization to the scalar
implementation because there is no check in
`fletcher_4_incremental_native()`/`fletcher_4_incremental_byteswap()`
against 0 sized buffers being passed.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14247

20 months agoFreeBSD: zfs_register_callbacks() must implement error check correctly
Richard Yao [Mon, 5 Dec 2022 18:16:50 +0000 (13:16 -0500)]
FreeBSD: zfs_register_callbacks() must implement error check correctly

I read the following article and noticed a couple of ZFS bugs mentioned:

https://pvs-studio.com/en/blog/posts/cpp/0377/

I decided to search for them in the modern OpenZFS codebase and then
found one that matched the description of the first one:

V593 Consider reviewing the expression of the 'A = B != C' kind. The
expression is calculated as following: 'A = (B != C)'. zfs_vfsops.c 498

The consequence of this is that the error value is replaced with `1`
when there is an error. When there is no error, 0 is correctly passed.
This is a very minor issue that is unlikely to cause any real problems.

The incorrect error code would either be returned to the mount command
on a failure or any of `zfs receive`, `zfs recv`, `zfs rollback` or `zfs
upgrade`.

The second one has already been fixed.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Damian Szuberski <szuberskidamian@gmail.com>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14261

20 months agocxgbe: stop open-coding kref access
Mateusz Guzik [Mon, 5 Dec 2022 17:35:08 +0000 (17:35 +0000)]
cxgbe: stop open-coding kref access

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

20 months agobhyveload: open guest boot disk image O_RDWR
Robert Wing [Mon, 5 Dec 2022 17:22:45 +0000 (08:22 -0900)]
bhyveload: open guest boot disk image O_RDWR

When a boot environment has been booted via the bootonce feature,
userboot clears the bootonce value from an nvlist but fails to write the
updated nvlist back to disk.

The failure occurs because bhyveload opens the guest boot disk image
O_RDONLY, fix this by opening it O_RDWR.

Reviewed by: imp, markj, jhb
Differential Revision: https://reviews.freebsd.org/D37274

20 months agoconfig: remove LOCK_PROFILING_FAST
Robert Wing [Mon, 5 Dec 2022 17:03:52 +0000 (08:03 -0900)]
config: remove LOCK_PROFILING_FAST

This option lived a short life in 2007.

last used eea4f254fe8f66e4d58b9befe435010a2d485423

Reviewed by: mjg
Differential Revision: https://reviews.freebsd.org/D37600

20 months agoUPDATING: add notes on how to reenable sendmail
Baptiste Daroussin [Mon, 5 Dec 2022 16:26:31 +0000 (17:26 +0100)]
UPDATING: add notes on how to reenable sendmail

20 months agosendmail: revert to use use NONE
Baptiste Daroussin [Mon, 5 Dec 2022 16:20:22 +0000 (17:20 +0100)]
sendmail: revert to use use NONE

The NONE parameter has been deprecated for more than 20 years
but was never removed, its useful to simplify the sendmail
management.

This reverts commit 7cadc5263887374c50c3e3f500ef6fb7b7c3dd98.

20 months agoUPDATING: Fix typo
Warner Losh [Mon, 5 Dec 2022 15:36:50 +0000 (08:36 -0700)]
UPDATING: Fix typo

Noticed by: Gary Jennejohn
Sponsored by: Netflix

20 months agotree.h: Fix SP/TAB white-space issues, add () for clarity.
Poul-Henning Kamp [Mon, 5 Dec 2022 14:28:56 +0000 (14:28 +0000)]
tree.h: Fix SP/TAB white-space issues, add () for clarity.

20 months agoif_ovpn: extend notifications with a reason
Kristof Provost [Thu, 1 Dec 2022 15:20:24 +0000 (16:20 +0100)]
if_ovpn: extend notifications with a reason

Extend peer deleted notifications (which are the only type right now) to
include the reason the peer was deleted. This can be either because
userspace requested it, or because the peer timed out.

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

20 months agolm75: fix typo
Wojciech Macek [Mon, 5 Dec 2022 06:30:12 +0000 (07:30 +0100)]
lm75: fix typo

s/sesnor/sensor/

20 months agorpcgen: Unindent a line not guarded by if (mtflag).
John Baldwin [Mon, 5 Dec 2022 00:32:03 +0000 (16:32 -0800)]
rpcgen: Unindent a line not guarded by if (mtflag).

mtflag is used to add pthread mutex locking around operations to make
them thread-safe.  Setting the state to _SERVED is not conditional on
locking.

Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D37541

20 months agorpcgen: Don't free() a pointer after realloc().
John Baldwin [Mon, 5 Dec 2022 00:31:35 +0000 (16:31 -0800)]
rpcgen: Don't free() a pointer after realloc().

A successful realloc() already frees the old pointer.

Reported by: GCC -Wuse-after-free
Reviewed by: brooks, imp, emaste
Differential Revision: https://reviews.freebsd.org/D37540

20 months agoposixshm_test: Fix sign mismatches in ?: results.
John Baldwin [Mon, 5 Dec 2022 00:31:05 +0000 (16:31 -0800)]
posixshm_test: Fix sign mismatches in ?: results.

GCC 12's -Wsign-compare complains if the two alternative results of
the ?: operator are differently signed.  Cast the small, sub-page
off_t values to size_t to quiet the warning.

Reviewed by: imp, kib
Differential Revision: https://reviews.freebsd.org/D37539

20 months agofwcontrol: Disable -Wzero-length-bounds warnings.
John Baldwin [Mon, 5 Dec 2022 00:30:20 +0000 (16:30 -0800)]
fwcontrol: Disable -Wzero-length-bounds warnings.

firewire.h includes zero length arrays in unions that trigger this
warning.

Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D37538

20 months agobsd.sys.mk: Add NO_WZERO_LENGTH_BOUNDS helper variable.
John Baldwin [Mon, 5 Dec 2022 00:29:55 +0000 (16:29 -0800)]
bsd.sys.mk: Add NO_WZERO_LENGTH_BOUNDS helper variable.

This variable expands to -Wno-zero-length-bounds on GCC 10+.

Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D37537

20 months agonetmap tests: Reset ctx->nmctx to NULL in nmreq_parsing.
John Baldwin [Mon, 5 Dec 2022 00:29:25 +0000 (16:29 -0800)]
netmap tests: Reset ctx->nmctx to NULL in nmreq_parsing.

This avoids leaking a pointer to the on-stack test_nmctx which
triggers a -Wdangling-pointer warning from GCC.

Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D37536

20 months agoacpica: Quiet a -Wdangling-pointer warning in AcpiUtInitStackPtrTrace.
John Baldwin [Mon, 5 Dec 2022 00:28:59 +0000 (16:28 -0800)]
acpica: Quiet a -Wdangling-pointer warning in AcpiUtInitStackPtrTrace.

This function intentionally saves a pointer to an on-stack variable in
a global as a dubious way of reading the stack pointer.

Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D37535

20 months agopw: Don't return a pointer to an on-stack buffer from grp_set_passwd.
John Baldwin [Mon, 5 Dec 2022 00:28:22 +0000 (16:28 -0800)]
pw: Don't return a pointer to an on-stack buffer from grp_set_passwd.

Make 'line' static to move it to .bss instead as that pattern is used
elsewhere in pw(8) (e.g. the static buffer in pw_pwcrypt).

Reported by: GCC -Wdangling-pointer
Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D37534

20 months agolibsa: Disable -Wdangling-pointer for zfs.c.
John Baldwin [Mon, 5 Dec 2022 00:27:22 +0000 (16:27 -0800)]
libsa: Disable -Wdangling-pointer for zfs.c.

GCC 12 warns about a dangling pointer to 'objid' in
zfs_bootenv_initial().  However, this appears to be a false positive
as the pointer to 'objid' is only passed to zfs_lookup_dataset() but
not saved anywhere that outlives the lifetime of the
zfs_bootenv_initial() function.

Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D37533

20 months agobsd.sys.mk: Add NO_WDANGLING_POINTER helper variable.
John Baldwin [Mon, 5 Dec 2022 00:26:48 +0000 (16:26 -0800)]
bsd.sys.mk: Add NO_WDANGLING_POINTER helper variable.

This variable expands to -Wno-dangling-pointer on GCC 12+.

Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D37532

20 months agoExplicitly set CXXSTD to c++11 for old C++ code using std::auto_ptr<>.
John Baldwin [Wed, 30 Nov 2022 22:56:19 +0000 (14:56 -0800)]
Explicitly set CXXSTD to c++11 for old C++ code using std::auto_ptr<>.

GCC 12 defaults to C++17 which removes (not just deprecates)
std::auto_ptr<>.  Trying to use CXXSTD of c++03 doesn't work with
libc++ headers, but c++11 does.

Reviewed by: brooks, imp, emaste
Differential Revision: https://reviews.freebsd.org/D37531

20 months agonewbus: Change attach failure behavior
Warner Losh [Sun, 4 Dec 2022 23:22:43 +0000 (16:22 -0700)]
newbus: Change attach failure behavior

In the rare case that we succeed in probing, but fail to attach, flip
the default to be to disable the
device. hw.bus.disable_failed_devices=false is no required to restore
the old behavior. The old behavior dates form a time when dynamic
control of devices wasn't yet present (devctl didn't exist). Now that
one can retry probe/attach the device with devctl, the default doesn't
make sense: The more desirable behaivor is to have stable device numbers
when one has several instances of the same device in a system (common
for NICs or HBAs).

Reviewed by: jhb (verbal)
Sponsored by: Netflix

20 months agonewbus: Create a knob to disable devices that fail to attach.
Warner Losh [Sun, 4 Dec 2022 23:20:24 +0000 (16:20 -0700)]
newbus: Create a knob to disable devices that fail to attach.

Normally, when a device fails to attach, we tear down the newbus state
for that device so that future driver loads can try again (maybe with a
different driver, or maybe with a re-loaded and fixed kld).

Sometimes, however, it is desirable to have the device fail
permanantly. We do this by calling device_disable() on a failed
attached, as well as keeping the device in DS_ATTACHING forever. This
prevents retries on that device. This is enabled via
hw.bus.disable_failed_devices=1 in either a hint via the loader, or at
runtime with a sysctl setting. Setting from 1 -> 0 at runtime will not
affect previously disabled devices, however: they remain disabled.
They can be re-enabled manually with devctl enable, however.

Sponsored by: Netflix

Reviewed by: gallatin, hselasky, jhb
Differential Revision: https://reviews.freebsd.org/D37517

20 months agokboot: Add md_addr to metadata
Warner Losh [Sun, 4 Dec 2022 20:52:22 +0000 (13:52 -0700)]
kboot: Add md_addr to metadata

Save the address of where the metadata is loaded.

Sponsored by: Netflix

20 months agokboot: Use #define for DT_DIR
Warner Losh [Sun, 4 Dec 2022 20:25:54 +0000 (13:25 -0700)]
kboot: Use #define for DT_DIR

Sponsored by: Netflix

20 months agokboot: powerpc64 has no newfstat system call
Warner Losh [Sun, 4 Dec 2022 20:20:04 +0000 (13:20 -0700)]
kboot: powerpc64 has no newfstat system call

Powerpc doesn't have a newfstat system call. It does have a fstat call,
which we define properly if SYS_newfstat isn't defined.

Sponsored by: Netflix

20 months agokboot: Add aarch64 termios
Warner Losh [Sun, 4 Dec 2022 20:16:32 +0000 (13:16 -0700)]
kboot: Add aarch64 termios

Aarch64 has the generic termios interface, so use termios_gen.h

Sponsored by: Netflix

20 months agokboot: Add missing license to termios
Warner Losh [Sun, 4 Dec 2022 20:12:09 +0000 (13:12 -0700)]
kboot: Add missing license to termios

I neglected to include the proper license markings on these
files. Remedy that now.

Sponsored by: Netflix

20 months agolibdevdctl: update deprecated deprecation warning comment
Ed Maste [Tue, 29 Nov 2022 19:44:15 +0000 (14:44 -0500)]
libdevdctl: update deprecated deprecation warning comment

The comment indicated -Wno-deprecated-declarations was used to avoid
warnings about deprecated auto_ptr and various deprecated function
objects from <functional>.  libdevdctl (now) does not use auto_ptr,
so don't mention it in the comment.

Sponsored by: The FreeBSD Foundation

20 months agostand: aarch64 has different nlinks than amd64
Warner Losh [Sun, 4 Dec 2022 05:46:21 +0000 (22:46 -0700)]
stand: aarch64 has different nlinks than amd64

Some typedefs are system dependent, so move them into stat_arch.h where
they are used.  On amd64, nlinks is a int64_t, while on aarch64 it's an
int (or int32_t).

Sponsored by: Netflix

20 months agoUpdates to UFS/FFS superblock integrity checks when reading a superblock.
Kirk McKusick [Sun, 4 Dec 2022 05:33:09 +0000 (21:33 -0800)]
Updates to UFS/FFS superblock integrity checks when reading a superblock.

Minor optimization that makes semantics of check clearer.

Sponsored by: The FreeBSD Foundation

20 months agokboot: powerpc ldscript catchup
Warner Losh [Sun, 4 Dec 2022 04:41:05 +0000 (21:41 -0700)]
kboot: powerpc ldscript catchup

Catch up with the latest ldscript for powerpc. Make it match others in
the tree.

Sponsored by: Netflix

20 months agostand/efi: Break stlye rules a little for easier sharing
Warner Losh [Sun, 4 Dec 2022 00:23:25 +0000 (17:23 -0700)]
stand/efi: Break stlye rules a little for easier sharing

Break the style rules a little to allow easier sharing between efi and
kboot. This will allow the ifdefs to be fewer in number.

Sponsored by: Netflix

20 months agostand/efi: Better include order for sharing
Warner Losh [Sun, 4 Dec 2022 00:23:22 +0000 (17:23 -0700)]
stand/efi: Better include order for sharing

Have a better include order so this can more easily be shared between
EFI and kboot. Fewer ifdefs and the same (enough) include order as
before.

Sponsored by: Netflix

20 months agostand/efi: Remove redundant parenthesis
Warner Losh [Sun, 4 Dec 2022 00:23:20 +0000 (17:23 -0700)]
stand/efi: Remove redundant parenthesis

Style: Remove redundant parens.

Sponsored by: Netflix

20 months agostand/efi: Document the copy size trick
Warner Losh [Sun, 4 Dec 2022 00:23:16 +0000 (17:23 -0700)]
stand/efi: Document the copy size trick

We call bi_copymodules twice: once with 0 and once with the size of the
arena. We do this to find the size, it turns out. Document this.

Sponsored by: Netflix

20 months agokboot: Enable fewer things by default
Warner Losh [Sat, 3 Dec 2022 19:48:23 +0000 (12:48 -0700)]
kboot: Enable fewer things by default

We don't need NFS / network support by default, nor do we need gzip
support. Remove them for now.

Sponsored by: Netflix

20 months agokboot: Make dosfs support conditional
Warner Losh [Sat, 3 Dec 2022 19:48:19 +0000 (12:48 -0700)]
kboot: Make dosfs support conditional

Sponsored by: Netflix

20 months agokboot: Add readme
Warner Losh [Sat, 3 Dec 2022 19:48:16 +0000 (12:48 -0700)]
kboot: Add readme

Document how to test kboot and how to build a initrd.

Sponsored by: Netflix

20 months agokboot: Move archsw init earlier
Warner Losh [Sat, 3 Dec 2022 19:48:11 +0000 (12:48 -0700)]
kboot: Move archsw init earlier

Do archsw init first thing.

Sponsored by: Netflix

20 months agonetmap_update_config: update na->name to cope with reconfigurations
Vincenzo Maffione [Sat, 3 Dec 2022 18:12:04 +0000 (18:12 +0000)]
netmap_update_config: update na->name to cope with reconfigurations

MFC after: 1 week

20 months agoCTL: Allow userland supply tags via ioctl frontend.
Alexander Motin [Sat, 3 Dec 2022 17:05:05 +0000 (12:05 -0500)]
CTL: Allow userland supply tags via ioctl frontend.

Before this ioctl frontend always replaced tags with sequential ones.
It was done for ctladm, that can not keep track of global tag list.
But in case of virtio-scsi in bhyve we can pass provided tags as-is.
It should be on virtio-scsi initiator to provide us valid tags.  It
should allow proper task management, error reporting, etc.  In case
of several virtio-scsi devices, they should use different CTL ports
or initiator IDs to avoid conflicts, but this is expected by design.

PR: 267539

20 months agoMissed chunk of 0acc026dda9e.
Alexander Motin [Sat, 3 Dec 2022 16:26:22 +0000 (11:26 -0500)]
Missed chunk of 0acc026dda9e.

20 months agoCTL: Increase maximum SCSI tag size from 32 to 64 bits.
Alexander Motin [Sat, 3 Dec 2022 15:23:29 +0000 (10:23 -0500)]
CTL: Increase maximum SCSI tag size from 32 to 64 bits.

SAM-5 specification states maximum size of command identifier (tag),
defined by specific transports, should not be larger than 64 bits.
While most of supported transports use 32 bits or less, it was
reported that virtio-scsi uses 64 bits.  Truncation to 32 bits in
bhyve code caused false tag conflict errors reported and possibly
other issues.

This changes CTL ABI and HA protocol, so CTL_HA_VERSION is bumped.

While we make HA protocol incompatible, increase default maximum
number of ports in CTL from 256 to 1024, matching number of LUNs.
There are many reports from people who need many iSCSI targets with
only one LUN each.  Increased memory consumption should be less of
a problem these days.

PR: 267539

20 months agobhyve virtio-scsi: Fix residual reporting.
Alexander Motin [Sat, 3 Dec 2022 15:08:20 +0000 (10:08 -0500)]
bhyve virtio-scsi: Fix residual reporting.

CTL does not really use residual field and it always returned zero.
Use ext_data_filled instead.

MFC after: 2 weeks

20 months agozio can deadlock during device removal
George Wilson [Sat, 3 Dec 2022 01:46:29 +0000 (19:46 -0600)]
zio can deadlock during device removal

When doing a device removal on a pool with gang blocks, the zio pipeline
can deadlock when trying to free blocks from a device which is being
removed with a stack similar to this:

 0xffff8ab9a13a1740 UNINTERRUPTIBLE       4
                   __schedule+0x2e5
                   __schedule+0x2e5
                   schedule+0x33
                   schedule_preempt_disabled+0xe
                   __mutex_lock.isra.12+0x2a7
                   __mutex_lock.isra.12+0x2a7
                   __mutex_lock_slowpath+0x13
                   mutex_lock+0x2c
                   free_from_removing_vdev+0x61
                   metaslab_free_impl+0xd6
                   metaslab_free_dva+0x5e
                   metaslab_free+0x196
                   zio_free_sync+0xe4
                   zio_free_gang+0x38
                   zio_gang_tree_issue+0x42
                   zio_gang_tree_issue+0xa2
                   zio_gang_issue+0x6d
                   zio_execute+0x94
                   zio_execute+0x94
                   taskq_thread+0x23b
                   kthread+0x120
                   ret_from_fork+0x1f

Since there are gang blocks we have to read the gang members as part of
the free. This can be seen with a zio dependency tree that looks like
this:

sdb> echo 0xffff900c24f8a700 | zio -rc | zio
ADDRESS                       TYPE  STAGE            WAITER
0xffff900c24f8a700            NULL  CHECKSUM_VERIFY  0xffff900ddfd31740
0xffff900c24f8c920            FREE  GANG_ASSEMBLE    -
0xffff900d93d435a0            READ  DONE

In the illustration above we are processing frees but because of gang
block we have to read the constituents blocks. Once we finish the READ
in the zio pipeline we will execute the parent. In this case the parent
is a FREE but the zio taskq is a READ and we continue to process the
pipeline leading to the stack above. In the stack above, we are blocked
waiting for the svr_lock so as a result a READ interrupt taskq thread
is now consumed. Eventually, all of the READ taskq threads end up
blocked and we're unable to complete any read requests.

In zio_notify_parent there is an optimization to continue to use
the taskq thread to exectue the parent's pipeline. To resolve the
deadlock above, we only allow this optimization if the parent's
zio type matches the child which just completed.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Signed-off-by: George Wilson <gwilson@delphix.com>
External-issue: DLPX-80130
Closes #14236

20 months agonopwrites on dmu_sync-ed blocks can result in a panic
George Wilson [Sat, 3 Dec 2022 01:45:33 +0000 (19:45 -0600)]
nopwrites on dmu_sync-ed blocks can result in a panic

After a device has been removed, any nopwrites for blocks on that
indirect vdev should be ignored and a new block should be allocated. The
original code attempted to handle this but used the wrong block pointer
when checking for indirect vdevs and failed to check all DVAs.

This change corrects both of these issues and modifies the test case
to ensure that it properly tests nopwrites with device removal.

Reviewed-by: Prakash Surya <prakash.surya@delphix.com>
Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: George Wilson <gwilson@delphix.com>
Closes #14235

20 months agoZTS: test reported checksum errors for ZED
Rob Wing [Mon, 14 Nov 2022 07:57:53 +0000 (07:57 +0000)]
ZTS: test reported checksum errors for ZED

Test checksum error reporting to ZED via the call paths
vdev_raidz_io_done_unrecoverable() and zio_checksum_verify().

Sponsored-by: Seagate Technology LLC
Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Wing <rob.wing@klarasystems.com>
Closes #14190

20 months agoBump checksum error counter before reporting to ZED
Rob Wing [Mon, 14 Nov 2022 07:40:38 +0000 (07:40 +0000)]
Bump checksum error counter before reporting to ZED

The checksum error counter is incremented after reporting to ZED. This
leads ZED to receiving a checksum error report with 0 checksum errors.

To avoid this, bump the checksum error counter before reporting to ZED.

Sponsored-by: Seagate Technology LLC
Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Wing <rob.wing@klarasystems.com>
Closes #14190

20 months agoautoconf: add support for openEuler
Xinliang Liu [Sat, 3 Dec 2022 01:39:48 +0000 (09:39 +0800)]
autoconf: add support for openEuler

Add config support for openEuler, so that it set the right sysconfig
dir for openEuler.

And DEFAULT_INIT_SCRIPT is no longer needed since commit "2a34db1bd
Base init scripts for SYSV systems".

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Xinliang Liu <xinliang.liu@linaro.org>
Closes #14241

20 months agolibpmc: remove unused auto_ptr warning suppression
Ed Maste [Tue, 29 Nov 2022 19:41:08 +0000 (14:41 -0500)]
libpmc: remove unused auto_ptr warning suppression

libpmc used -Wno-deprecated-declarations to silence warnings about usage
of deprecated std::auto_ptr, but there is (now) now use of auto_ptr in
libpmc.

Reviewed by: mhorne
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37576

20 months agonetlink: fix non-multipath build
Alexander V. Chernikov [Fri, 2 Dec 2022 22:20:42 +0000 (22:20 +0000)]
netlink: fix non-multipath build

20 months agoRetire trpt(8).
Gleb Smirnoff [Fri, 2 Dec 2022 22:10:55 +0000 (14:10 -0800)]
Retire trpt(8).

trpt(8) was utility to pull TCP debugging data from the kernel
originating back from 4.2BSD.  It is not used nowadays by TCP
developers.  We have more powerful debugging facilities, e.g.
the Dtrace probing, the TCP black box logging and siftr.

Discussed with: rscheff, tuexen, rrs, jtl and others

20 months agoinpcb: allow to provide protocol specific pcb size
Gleb Smirnoff [Fri, 2 Dec 2022 22:10:55 +0000 (14:10 -0800)]
inpcb: allow to provide protocol specific pcb size

The protocol specific structure shall start with inpcb.

Differential revision: https://reviews.freebsd.org/D37126

20 months agonetlink: store user-provided rtm_protocol
Alexander V. Chernikov [Fri, 2 Dec 2022 19:26:34 +0000 (19:26 +0000)]
netlink: store user-provided rtm_protocol

Store user-supplied source protocol in the nexthops and nexthop groups.
Protocol specification help routing daemons like bird to quickly
identify self-originated routes after the crash or restart.

Example:
```
10.2.0.0/24 via 10.0.0.2 dev vtnet0 proto bird
10.3.0.0/24 proto bird
nexthop via 10.0.0.2 dev vtnet0 weight 3
nexthop via 10.0.0.3 dev vtnet0 weight 4
```

20 months agorouting: provide dedicated function for nhgrp creation and linking.
Alexander V. Chernikov [Fri, 2 Dec 2022 17:58:03 +0000 (17:58 +0000)]
routing: provide dedicated function for nhgrp creation and linking.

There is a need to store client metadata in nexthops and nexthop groups.
This metadata is immutable and participate in nhop/nhg comparison.

Nexthops KPI already supports its: nexthop creation pattern is
```
nhop_alloc()
nhop_set_...()
...
nhop_get_nhop()
```

This change provides a similar pattern for the nexthop groups.
Specifically, it adds nhgrp_alloc(), nhgrp_get_nhgrp() and
nhgrp_set_uidx().

MFC after: 2 weeks

20 months agokboot: Use unsigned long long.
Warner Losh [Fri, 2 Dec 2022 19:41:01 +0000 (12:41 -0700)]
kboot: Use unsigned long long.

For the 64-bit platforms, this is a nop. Currently kboot only supports
64-bit platforms, though. If we support 32-bit in the future, this will
become important.

Noticed by: rpokala
Sponsored by: Netflix

20 months agokboot: Enhance hostdisk
Warner Losh [Fri, 2 Dec 2022 18:28:08 +0000 (11:28 -0700)]
kboot: Enhance hostdisk

Added missing functionality to allow us to boot off of things like
/dev/nvme0n1p2 successfully. And to list all available devices and
partitions with 'lsdev'.

Sponsored by: Netflix

20 months agokboot: amd64 use /sys/firmware/memmap to find free memory
Warner Losh [Fri, 2 Dec 2022 18:10:42 +0000 (11:10 -0700)]
kboot: amd64 use /sys/firmware/memmap to find free memory

Use the system's firmware memory map to find a good place to put the
kernel that won't stomp on anything else. While this uses obstensibly MI
interfaces to get this data, arm64 doesn't have this, nor does
powerpc64, so place it here.

Sponsored by: Netflix

20 months agokboot: move to using devparse
Warner Losh [Fri, 2 Dec 2022 18:10:06 +0000 (11:10 -0700)]
kboot: move to using devparse

We can use devparse directly now. No need to invent a kboot_parsedev
that just does what devparse does now that we've refactored.

Sponsored by: Netflix

20 months agokboot: Create routines to read Linux tiny files
Warner Losh [Fri, 2 Dec 2022 18:05:58 +0000 (11:05 -0700)]
kboot: Create routines to read Linux tiny files

Most of the files in /sys/ and /proc/ are small with one value. Create
two routines to help us read the file and decode that value.

Sponsored by: Netflix

20 months agofull-test: Start of a full testing suite.
Warner Losh [Fri, 2 Dec 2022 17:47:32 +0000 (10:47 -0700)]
full-test: Start of a full testing suite.

full-test.sh aims to be a test suite generator for the boot loader. It
tries to grab artifacts from the web and then constructs minimal boot
environments from that as well as writing qemu-system-* using scripts
that facilitates testing all the ways we can boot... At least all the
ways that we an boot that qemu can emulate.

This is very much a work in progress, and likely could use a good
cleanup at some point.

Sponsored by: Netflix

20 months agoAdd test notes
Warner Losh [Fri, 2 Dec 2022 17:47:29 +0000 (10:47 -0700)]
Add test notes

Add notes on how to test things. This will likely need to be fleshed out
more in the future, but this is a good start.

Sponsored by: Netflix

20 months agodevd: Warn for deprecated 'kern' system type
Warner Losh [Fri, 2 Dec 2022 17:47:22 +0000 (10:47 -0700)]
devd: Warn for deprecated 'kern' system type

One year ago, I deprecated 'kern' in favor of 'kernel' for the system
name for some power events. I'm about to remove it from the kernel, but
realized there's been no warning generated for users. Preserve POLA by
converting on the fly here and issuing a warning for 14.x, and an fatal
error after we branch 15. Make compiling it an error on 16 to remove
the gross hack after we branch.

Sponsored by: Netflix
Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D37584

20 months agonewbus: Remove deprecated "kern" system name for resume events.
Warner Losh [Fri, 2 Dec 2022 17:47:01 +0000 (10:47 -0700)]
newbus: Remove deprecated "kern" system name for resume events.

The new "kernel" system name is the one that's documented and has
been generated for a year now. Remove the old one now that 14.0
is getting close.

Sponsored by: Netflix
Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D37582

20 months agoAllow any user to read the NFS stats, for example with nfsstat(1).
Alan Somers [Thu, 1 Dec 2022 21:08:01 +0000 (14:08 -0700)]
Allow any user to read the NFS stats, for example with nfsstat(1).

This was originally allowed by 3cea29603d3 (2011).  But it got broken by
693957f8861 (2016) and apparently nobody noticed.

MFC after: 1 week
Sponsored by: Axcient
Reviewed by: rmacklem, ken
Differential Revision: https://reviews.freebsd.org/D37589

20 months agoif_ovpn: remove peer limit
Kristof Provost [Mon, 28 Nov 2022 09:16:24 +0000 (10:16 +0100)]
if_ovpn: remove peer limit

Replace the fixed-sized array by an RB_TREE. This should both speed up
lookups and remove the 128 peer limit.

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

20 months agoheimdal: Fix bus fault when zero-length request received
Cy Schubert [Thu, 1 Dec 2022 00:11:18 +0000 (16:11 -0800)]
heimdal: Fix bus fault when zero-length request received

Zero length client requests result in a bus fault when attempting to
free malloc()ed pointers within the requests softc. Return an error
when the request is zero length.

PR: 268062
Reported by: Robert Morris <rtm@lcs.mit.edu>
MFC after: 3 days

20 months agoheimdal: Add additional checks for bad kadmind input
Cy Schubert [Wed, 30 Nov 2022 23:53:49 +0000 (15:53 -0800)]
heimdal: Add additional checks for bad kadmind input

Check return codes for bad input.

MFC after: 3 days

20 months agolinuxkpi: Introduce module_param() of type `bint`
Jean-Sébastien Pédron [Thu, 1 Dec 2022 14:03:00 +0000 (15:03 +0100)]
linuxkpi: Introduce module_param() of type `bint`

In Linux, this limits the accepted value to -1, 0 and 1.
In FreeBSD, this remains a signed integer with no specific constraints.

This change is a requirement to update our DRM drivers to Linux 5.12.

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

20 months agolinuxkpi: Add `PCIE_SPEED_{32,64}_0GT` PCI-E bus speed constants
Jean-Sébastien Pédron [Thu, 1 Dec 2022 14:00:54 +0000 (15:00 +0100)]
linuxkpi: Add `PCIE_SPEED_{32,64}_0GT` PCI-E bus speed constants

This change is a requirement to update our DRM drivers to Linux 5.12.

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

20 months agolinuxkpi: Add `cmpxchg64()` in <asm/atomic.h>
Jean-Sébastien Pédron [Thu, 1 Dec 2022 13:59:16 +0000 (14:59 +0100)]
linuxkpi: Add `cmpxchg64()` in <asm/atomic.h>

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

20 months agolinuxkpi: Add `seqcount_mutex_t` support in <linux/seqlock.h>
Jean-Sébastien Pédron [Thu, 1 Dec 2022 13:58:27 +0000 (14:58 +0100)]
linuxkpi: Add `seqcount_mutex_t` support in <linux/seqlock.h>

To achieve that, the header uses the C11 type generic selection keyboard
_Generic() because the macros are supposed to work with seqcount_t
and seqcount_mutex_t.

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

20 months agonet: add if_allocdescr() to permit updating iface description from the kernel
Alexander V. Chernikov [Wed, 30 Nov 2022 13:49:07 +0000 (13:49 +0000)]
net: add if_allocdescr() to permit updating iface description from the kernel

Reviewed by: kp,zlei
Differential Revision: https://reviews.freebsd.org/D37566
MFC after: 2 weeks

20 months agorx8803: Improve probing logic
Kornel Dulęba [Thu, 1 Dec 2022 05:41:41 +0000 (06:41 +0100)]
rx8803: Improve probing logic

Add a PNP macro in order to load this driver automatically.
While here check if the device is enabled in DT before probing it.

Reviewed by: wma
Sponsored by: Alstom
Obtained from: Semihalf
Differential Revision: https://reviews.freebsd.org/D37579