]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
17 months agovmm: fix set but not used warning
Robert Wing [Sun, 10 Apr 2022 18:30:19 +0000 (10:30 -0800)]
vmm: fix set but not used warning

(cherry picked from commit 5a17f489d5848085307e1d5fa7ca142694b4946b)

17 months agovmm: fix set but not used warning
Robert Wing [Sun, 10 Apr 2022 18:30:16 +0000 (10:30 -0800)]
vmm: fix set but not used warning

(cherry picked from commit 5241577a223d805282f726cb443a566aca653b9f)

17 months agovmm: fix set but not used warning
Robert Wing [Sun, 10 Apr 2022 18:30:14 +0000 (10:30 -0800)]
vmm: fix set but not used warning

(cherry picked from commit 3587bfa797cd66dce2e94ca93df5ce41def555df)

17 months agovmm: fix set but not used warnings
Robert Wing [Sun, 10 Apr 2022 18:30:11 +0000 (10:30 -0800)]
vmm: fix set but not used warnings

(cherry picked from commit 5c272efaba291f744191dca86f04418bfe90b222)

17 months agovmm: fix set but not used warnings
Robert Wing [Sun, 10 Apr 2022 18:30:08 +0000 (10:30 -0800)]
vmm: fix set but not used warnings

(cherry picked from commit f877977a034b41bedacdf507e79e4233b28a8bfc)

17 months agovmm: fix set but not used warning
Robert Wing [Sun, 10 Apr 2022 18:30:05 +0000 (10:30 -0800)]
vmm: fix set but not used warning

(cherry picked from commit 893a3dd697ef4ac0a432ca8ce8790661884eb1ea)

17 months agoFix a typo in previous commit.
John Baldwin [Fri, 8 Apr 2022 19:01:33 +0000 (12:01 -0700)]
Fix a typo in previous commit.

Reported by: npn
Pointy hat to: jhb
Fixes: 572edd3dae9f vmm: Re-quiet set but unused warnings.

(cherry picked from commit 6a33ecdc2f649234cc3160daec8c329f33860f45)

17 months agovmm amdvi: Move ctrl under #ifdef AMDVI_DEBUG_CMD.
John Baldwin [Fri, 8 Apr 2022 00:01:29 +0000 (17:01 -0700)]
vmm amdvi: Move ctrl under #ifdef AMDVI_DEBUG_CMD.

(cherry picked from commit a7d876f7010068d93f1d9b4bb62d1370c9a0798f)

17 months agovmm: Re-quiet set but unused warnings.
John Baldwin [Fri, 8 Apr 2022 00:01:29 +0000 (17:01 -0700)]
vmm: Re-quiet set but unused warnings.

__diagused is no longer used for KTR, so instead use #ifdef KTR or
expand KTR-only variables into their values in traces.

(cherry picked from commit 572edd3dae9fc3e67dfb1cb9ba023e8d3fe2a9bb)

17 months agovmm: fix "set but not used" warnings
Robert Wing [Tue, 1 Mar 2022 00:09:32 +0000 (15:09 -0900)]
vmm: fix "set but not used" warnings

(cherry picked from commit 2062ce996ddd39ba7a36c2caf8c898686d9cb2fe)

17 months agovmm: fix "set but not used" warnings
Robert Wing [Mon, 28 Feb 2022 23:55:37 +0000 (14:55 -0900)]
vmm: fix "set but not used" warnings

(cherry picked from commit 39d87a023567f633c6990ac7fcc3a20691a1efd6)

17 months agovmm: fix "set but not used" warnings
Robert Wing [Mon, 28 Feb 2022 23:46:08 +0000 (14:46 -0900)]
vmm: fix "set but not used" warnings

(cherry picked from commit 73505a10760c8b6f459b9c790bbf3a365f990a0b)

17 months agobhyve: Fix virtio-console legacy configuration parsing
Yan Ka Chiu [Fri, 6 May 2022 19:31:56 +0000 (15:31 -0400)]
bhyve: Fix virtio-console legacy configuration parsing

virtio-console is currently missing .pe_legacy_config, which prevents any
portN configuration from being parsed, and therefore no sockets will be
created.

Reviewed by: khng
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D35142

(cherry picked from commit 3cdfaefa4b88c928bfb62e7fb6c7f7742d81f31c)

17 months agoman pages: Fix typo
Christian Weisgerber [Wed, 6 Apr 2022 14:46:39 +0000 (16:46 +0200)]
man pages: Fix typo

s/the the/the/

Approved by: ygy (doc)

(cherry picked from commit 81d1214e8a9435aa7c09b622fa6916e89138dc5c)

17 months agobhyve: missing mutex initializations
Andy Fiddaman [Wed, 16 Mar 2022 03:50:36 +0000 (19:50 -0800)]
bhyve: missing mutex initializations

Explicitly initialize the mutex that a PCI virtio module passes back to
virtio.

It so happens that these mutexes were being initialized regardless, no
functional change intended.

Reviewed by:    chuck, jhb
Differential Revision:  https://reviews.freebsd.org/D34372

(cherry picked from commit f6f357efb1067b79678d8f348333ffdfec66ad20)

17 months agobhyve: plug memory leak in topology_parse()
Andy Fiddaman [Thu, 24 Feb 2022 17:36:41 +0000 (08:36 -0900)]
bhyve: plug memory leak in topology_parse()

Reviewed by:    jhb, rew
Differential Revision:  https://reviews.freebsd.org/D34301

(cherry picked from commit ad3da82996ffe8a7959fda4a84374b1907ebb116)

17 months agobhyve: Fix getaddrinfo() error handling
Mark Johnston [Tue, 8 Feb 2022 17:34:03 +0000 (12:34 -0500)]
bhyve: Fix getaddrinfo() error handling

- Use errx() since errno will not be set.
- Print the message returned by gai_strerror().

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 927aa5fefd4c69e72d44189a04fadf80e42d0ad8)

17 months agobhyve: clean up trailing whitespaces
Toomas Soome [Sun, 26 Dec 2021 07:52:38 +0000 (09:52 +0200)]
bhyve: clean up trailing whitespaces

Clean up trailing whitespaces. No functional changes.

Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D33681

(cherry picked from commit c2fa905cf6c1cf1938a0353679e3bd0b617ca179)

17 months agobhyve.8: Fix markup of the -G flag
Mateusz Piotrowski [Tue, 12 Oct 2021 14:06:52 +0000 (16:06 +0200)]
bhyve.8: Fix markup of the -G flag

(cherry picked from commit 775f6f459595c5373ab389a43bdf1a8467233f1a)

17 months agobhyve: Fix pci device node key in bhyve_config.5
Ka Ho Ng [Sun, 12 Sep 2021 20:31:19 +0000 (04:31 +0800)]
bhyve: Fix pci device node key in bhyve_config.5

PCI device node key in the manual page is wrong. It should be
pci.bus.slot.function.

MFC after: 3 days

(cherry picked from commit e31cc1d526dcdfcbe5666deb8b11decc5126a871)

17 months agobhyve: change a default address from ANY to localhost
Mariusz Zaborski [Thu, 19 Aug 2021 18:00:35 +0000 (20:00 +0200)]
bhyve: change a default address from ANY to localhost

Discussed with:     grehan, jhb

(cherry picked from commit 3a92927bb69f2d3fcd3dec4c909aab2191f4b848)

17 months agobhyve: enhance debug info for memory range clash
Robert Crowston [Sat, 10 Apr 2021 19:16:02 +0000 (20:16 +0100)]
bhyve: enhance debug info for memory range clash

Explain what the two clashing regions are.

Reivewed by: grehan, jhb
Differential Revision: https://reviews.freebsd.org/D29696
Pull Request: https://github.com/freebsd/freebsd-src/pull/463

(cherry picked from commit efec757b20425ac68171acc7f9cec8be750db688)

17 months agobhyve: Fix build when BHYVE_SNAPSHOT is set
Filipe da Silva Santos [Tue, 13 Sep 2022 06:30:41 +0000 (08:30 +0200)]
bhyve: Fix build when BHYVE_SNAPSHOT is set

Fixes: 9cc9abf409cc ("bhyve: create all vcpus on startup")
Sponsored by: Beckhoff Automation GmbH & Co. KG
X-MFC-With: 9cc9abf409cc

(cherry picked from commit 10c6af344108a8cfdc431b5b304de9c0fddcec47)

17 months agobhyve/snapshot: ..back to SOCK_STREAM
Robert Wing [Thu, 28 Apr 2022 15:43:01 +0000 (07:43 -0800)]
bhyve/snapshot: ..back to SOCK_STREAM

Now that nvlist_send()/nvlist_recv() are being used, ditch the datagram
socket.

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D34863

(cherry picked from commit 690b7ea081790eef2c890f63a4fe7e195cf51df0)

17 months agobhyve: use linker set for ipc commands
Robert Wing [Sun, 10 Apr 2022 02:46:00 +0000 (18:46 -0800)]
bhyve: use linker set for ipc commands

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

(cherry picked from commit c79331a42c308139828c1117f49224bb83617a53)

17 months agobhyve: sweep MAX_VMNAME
Robert Wing [Fri, 18 Mar 2022 05:55:52 +0000 (21:55 -0800)]
bhyve: sweep MAX_VMNAME

MAX_VMNAME is no longer used.

Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D34292

(cherry picked from commit 3ebe1109348f53f64b395293578416abedef4090)

17 months agobhyve/snapshot: limit snapshot filename to NAME_MAX
Robert Wing [Fri, 18 Mar 2022 05:51:31 +0000 (21:51 -0800)]
bhyve/snapshot: limit snapshot filename to NAME_MAX

NAME_MAX is a better fit since strcat_extension() constructs the
filename of the snapshot file.

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D34291

(cherry picked from commit 961e6a12efdbd48d92516beaf0772ff50008457d)

17 months agolibvmm: constify vm_get_name()
Robert Wing [Fri, 18 Mar 2022 05:26:54 +0000 (21:26 -0800)]
libvmm: constify vm_get_name()

Allows callers of vm_get_name() to retrieve the vm name without having
to allocate a buffer.

While in the vicinity, do minor cleanup in vm_snapshot_basic_metadata().

Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D34290

(cherry picked from commit 3efc45f34e13c63cb37a77a67fea39937004b75a)

17 months agobhyvectl: drop vm_get_name()
Robert Wing [Fri, 18 Mar 2022 05:22:43 +0000 (21:22 -0800)]
bhyvectl: drop vm_get_name()

Grab the vm name from bhyvectl's --vm flag instead.

Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D34399

(cherry picked from commit ee0ebaa42028aee9886e06b6b995c8b2389e89f4)

17 months agobhyve/snapshot: use a string for cmd element in the nvlist
Robert Wing [Tue, 15 Feb 2022 17:12:15 +0000 (08:12 -0900)]
bhyve/snapshot: use a string for cmd element in the nvlist

The nvlist for a checkpoint request will now look like:

    { cmd="checkpoint", suspend="true/false", filename="afilename" }

Reviewed by: jhb
Suggested by:   jhb
Differential Revision: https://reviews.freebsd.org/D34237

(cherry picked from commit 4379c1da56faa43ecc925e47707a2f51b488614e)

17 months agobhyve/snapshot: switch to nvlist for snapshot requests
Robert Wing [Wed, 9 Feb 2022 17:11:57 +0000 (08:11 -0900)]
bhyve/snapshot: switch to nvlist for snapshot requests

Switch to using an nvlist with nvlist_send()/nvlist_recv() to
communicate from bhyvectl(8) to bhyve(8).

The idea is that a bhyve process receives a command with with a set of
arguments. The nvlist here is structured to reflect that premise.

For example, to snapshot the vm, the expected nvlist looks like:

    { cmd=START_CHECKPOINT, filename="filename" }

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D33977

(cherry picked from commit edfb339d3868bbd36393efb2738287e170767784)

17 months agobhyve/snapshot: fix pthread_create() error check
Robert Wing [Wed, 19 Jan 2022 17:40:06 +0000 (08:40 -0900)]
bhyve/snapshot: fix pthread_create() error check

pthread_create() returns 0 on success or an error number on failure.

Reviewed by: khng, markj
Differential Revision: https://reviews.freebsd.org/D33930

(cherry picked from commit 51fbd894ddadd6a1bc4cb72de8ac4e92c013bd36)

17 months agobhyve/snapshot: split up mutex/cond initialization from socket creation
Robert Wing [Sat, 15 May 2021 19:58:21 +0000 (11:58 -0800)]
bhyve/snapshot: split up mutex/cond initialization from socket creation

Move initialization of the mutex/condition variables required by the
save/restore feature to their own function.

The unix domain socket that facilitates communication between bhyvectl
and bhyve doesn't rely on these variables in order to be functional.

Reviewed by:    markj
Differential Revision:  https://reviews.freebsd.org/D30281

(cherry picked from commit fdbc86cf79784f56fab8115f2d565962e1111b2e)

17 months agobhyve/snapshot: provide a way to send other messages/data to bhyve
Robert Wing [Wed, 3 Mar 2021 06:05:47 +0000 (21:05 -0900)]
bhyve/snapshot: provide a way to send other messages/data to bhyve

This is a step towards sending messages (other than suspend/checkpoint)
from bhyvectl to bhyve.

Introduce a new struct, ipc_message - this struct stores the type of
message and a union containing message specific structures for the type
of message being sent.

Reviewed by:    grehan
Differential Revision: https://reviews.freebsd.org/D30221

(cherry picked from commit d4870e3a7256704905655e997b37a866024c2894)

17 months agobhyve/snapshot: use SOCK_DGRAM instead of SOCK_STREAM
Robert Wing [Mon, 8 Mar 2021 00:23:29 +0000 (15:23 -0900)]
bhyve/snapshot: use SOCK_DGRAM instead of SOCK_STREAM

The save/restore feature uses a unix domain socket to send messages
from bhyvectl(8) to a bhyve(8) process. A datagram socket will suffice
for this.

An added benefit of using a datagram socket is simplified code. For
bhyve, the listen/accept calls are dropped; and for bhyvectl, the
connect() call is dropped.

EPRINTLN handles raw mode for bhyve(8), use it to print error messages.

Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D28983

(cherry picked from commit 38dfb0626fd35c64b2e2d5faae2c90e7981a3307)

17 months agobhyve/snapshot: rename and bump size of MAX_SNAPSHOT_VMNAME
Robert Wing [Sat, 27 Feb 2021 21:07:35 +0000 (12:07 -0900)]
bhyve/snapshot: rename and bump size of MAX_SNAPSHOT_VMNAME

MAX_SNAPSHOT_VMNAME is a macro used to set the size of a character
buffer that stores a filename or the path to a file - this file is used
by the save/restore feature.

Since the file doesn't have anything to do with a vm name, rename
MAX_SNAPSHOT_VMNAME to MAX_SNAPSHOT_FILENAME. Bump the size to PATH_MAX
while here.

Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D28879

(cherry picked from commit d656ce199d72f1aeeef1b2e28b4a284c968a8d03)

17 months agobhyvectl: reduce code duplication
Robert Wing [Sat, 27 Feb 2021 21:05:52 +0000 (12:05 -0900)]
bhyvectl: reduce code duplication

Combine send_start_checkpoint() and send_start_suspend() into a
single function named snapshot_request().

snapshot_request() is equivalent to send_start_checkpoint() and
send_start_suspend() except that it takes an additional argument. The
additional argument, enum ipc_opcode, is used to determine the type of
snapshot request being performed. Also, switch to using strlcpy instead
of strncpy.

Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D28878

(cherry picked from commit da9713917eb26b67bafc740384ccd44f7dff09f2)

17 months agobhyve/snapshot: rename checkpoint_opcodes to be more generic
Robert Wing [Sat, 27 Feb 2021 21:03:03 +0000 (12:03 -0900)]
bhyve/snapshot: rename checkpoint_opcodes to be more generic

Generalize the naming here since the domain socket that uses these codes
might be used for purposes other than the save/restore feature.

- rename checkpoint_opcodes to ipc_opcode

Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D28877

(cherry picked from commit b7fd9c4e5ebc69934205980d9f628ef8f21fb288)

17 months agobhyve/snapshot: drop mkdir when creating the unix domain socket
Robert Wing [Fri, 19 Feb 2021 02:48:40 +0000 (17:48 -0900)]
bhyve/snapshot: drop mkdir when creating the unix domain socket

Add /var/run/bhyve/ to BSD.var.dist so we don't have to call mkdir when
creating the unix domain socket for a given bhyve vm.

The path to the unix domain socket for a bhyve vm will now be
/var/run/bhyve/vmname instead of /var/run/bhyve/checkpoint/vmname

Move BHYVE_RUN_DIR from snapshot.c to snapshot.h so it can be shared
to bhyvectl(8).

Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D28783

(cherry picked from commit 5ce2d4a1c2922821b9940473213c0d75469755fc)

17 months agolibvmm: clean up vmmapi.h
Robert Wing [Fri, 29 Jan 2021 08:30:31 +0000 (23:30 -0900)]
libvmm: clean up vmmapi.h

struct checkpoint_op, enum checkpoint_opcodes, and
MAX_SNAPSHOT_VMNAME are not vmm specific, move them out of the vmmapi
header.

They are used for the save/restore functionality that bhyve(8)
provides and are better suited in usr.sbin/bhyve/snapshot.h

Since bhyvectl(8) requires these, the Makefile for bhyvectl has been
modified to include usr.sbin/bhyve/snapshot.h

Reviewed by:    kevans, grehan
Differential Revision:  https://reviews.freebsd.org/D28410

(cherry picked from commit 4f4065e0a220a57afa03420d4f8fa97dbcb5644c)

17 months agobhyve/ioapic: improve the tracking of IRR bit
Roger Pau Monné [Tue, 19 Jan 2021 11:52:28 +0000 (12:52 +0100)]
bhyve/ioapic: improve the tracking of IRR bit

One common method of EOI'ing an interrupt at the IO-APIC level is to
switch the pin to edge triggering mode and then back into level mode.
That would cause the IRR bit to be cleared and thus further interrupts
to be injected. FreeBSD does indeed use that method if the IO-APIC EOI
register is not supported.

The bhyve IO-APIC emulation code didn't clear the IRR bit when doing
that switch, and was also missing acknowledging the IRR state when
trying to inject an interrupt in vioapic_send_intr.

Reviewed by: grehan
Differential revision: https://reviews.freebsd.org/D28238

(cherry picked from commit 5ea878684f6cfff4ad05186346ff3a4828d980ca)

17 months agobhyve/ioapic: only account for asserted line in level mode
Roger Pau Monné [Tue, 19 Jan 2021 12:41:03 +0000 (13:41 +0100)]
bhyve/ioapic: only account for asserted line in level mode

After modifying a redirection entry only try to inject an interrupt if
the pin is in level mode, pins in edge mode shouldn't take into
account the line assert status as they are triggered by edge changes,
not the line status itself.

Reviewed by: grehan
Differential revision: https://reviews.freebsd.org/D28237

(cherry picked from commit d7d067698a38a3464a58eb34f68f63e529c45136)

17 months agobhyve/vioapic: remove an extra pin masked check
Roger Pau Monné [Tue, 19 Jan 2021 11:52:44 +0000 (12:52 +0100)]
bhyve/vioapic: remove an extra pin masked check

vioapic_send_intr does already check whether the pin is masked before
injecting the interrupt, there's no need to do it in vioapic_write
also.

No functional change intended.

Reviewed by: grehan
Differential revision: https://reviews.freebsd.org/D28236

(cherry picked from commit 49429cf9be7f43c37723175f90c56b29e29d1680)

17 months agozfs: merge openzfs/zfs@92e0d9d18 (zfs-2.1-release) into stable/13
Martin Matuska [Thu, 26 Jan 2023 16:50:13 +0000 (17:50 +0100)]
zfs: merge openzfs/zfs@92e0d9d18 (zfs-2.1-release) into stable/13

OpenZFS release 2.1.9

Notable upstream pull requeset merges:
  #12829 zfs diff -h/ZFS_DIFF_NO_MANGLE, diff cleanups
  #14181 zed: unclean disk attachment faults the vdev
  #14252 Activate filesystem features only in syncing context
  #14253 Allow reciever to override encryption property in case of replication
  #14254 Restrict visibility of per-dataset kstats inside FreeBSD jails
  #14255 Zero end of embedded block buffer in dump_write_embedded()
  #14261 FreeBSD: zfs_register_callbacks() must implement error check correctly
  #14264 Miscellaneous fixes
  #14272 Change ZEVENT_POOL_GUID to ZEVENT_POOL to display pool names
  #14287 FreeBSD: Remove stray debug printf
  #14288 Colorize zfs diff output
  #14291 FreeBSD: Fix potential boot panic with bad label
  #14328 FreeBSD: catch up to 1400077

Obtained from: OpenZFS
OpenZFS tag: zfs-2.1.9
OpenZFS commit: 92e0d9d183ce6752cd52f7277c8321d81df9ffee
Relnotes: yes

17 months agonetlink: allow netlink to be build in the kernel
Alexander V. Chernikov [Thu, 22 Dec 2022 14:51:36 +0000 (14:51 +0000)]
netlink: allow netlink to be build in the kernel

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

(cherry picked from commit c9313a0bad682351858e2e326cdb0f1d0bc2d1d8)

17 months agonetlink: fix standalone module build
Gleb Smirnoff [Tue, 4 Oct 2022 21:38:40 +0000 (14:38 -0700)]
netlink: fix standalone module build

(cherry picked from commit a87d2d1830933b81caaf30a67a4bef0a253ecd0b)

17 months agolinuxolator: add netlink support
Alexander V. Chernikov [Fri, 26 Aug 2022 14:34:15 +0000 (14:34 +0000)]
linuxolator: add netlink support

Add the glue code to support netlink in Linuxolator.
linux_common(4) now depends on netlink(4).

All netlink protocol constants are consistent with the Linux version.
However, certain OS-specific constants such as AF_INET6, interface
flags or default routing table id, are different between FreeBSD and
Linux. Thus, it may be needed to rewrite some message parts or even
rewrite the whole message, adding or removing some TLVs. The core
netlink implementation code provides efficient rewriting callbacks
 which Linuxolator now uses.

Reviewed by: dchagin
Differential Revision: https://reviews.freebsd.org/D36361
MFC after: 2 months

(cherry picked from commit 7c40e2d5f68516dd402073b28095ea5516fe3114)

17 months agogrowfs(7): conditionalize mention of adding dump device
Mike Karels [Mon, 23 Jan 2023 14:37:07 +0000 (08:37 -0600)]
growfs(7): conditionalize mention of adding dump device

The growfs_fstab script will add a new swap partition as a dump
device as well, but only if dumpdev is set to AUTO.

Reviewed by: pauamma
Differential Revision: https://reviews.freebsd.org/D38166

(cherry picked from commit 7d189f669836b81dbdeb7bc7178040a43ab9d1fe)

17 months agoath(4): Fix a sysctl description and a typo in a comment
Gordon Bergling [Thu, 19 Jan 2023 13:16:05 +0000 (14:16 +0100)]
ath(4): Fix a sysctl description and a typo in a comment

- s/delimeter/delimiter/

(cherry picked from commit e4b7980c5ca9c701242f3c395a042360db0ad7a7)

17 months agoMFC: MFV: xz 5.4.1.
Xin LI [Mon, 23 Jan 2023 00:49:43 +0000 (16:49 -0800)]
MFC: MFV: xz 5.4.1.

(cherry picked from commit 047153b416415605f127a3950e08c61f1910e9cb)

17 months agokgssapi: Increase timeout for kernel to gssd(8) upcalls
Rick Macklem [Wed, 11 Jan 2023 21:20:31 +0000 (13:20 -0800)]
kgssapi: Increase timeout for kernel to gssd(8) upcalls

It turns out that the underlying problem that caused
a Kerberized NFS mount with the "gssname" option to
fail was that the kernel upcall to the gssd(8) daemon
would time out prematurely after 25 seconds.  The
gss_acquire_cred() GSSAPI library call
takes about 27 seconds for the case where a desired_name
argument is specified.  A similarly long delay occurs
when the gss_init_sec_context() call is made and the
user principal's TGT has expired.

Once the upcall timed out, the kernel code assumed that
the gssd(8) daemon had died and closed the socket.
Ironically, closing the socket did cause the gssd(8)
daemon to terminate via a SIGPIPE signal.

This patch increases the timeout to 5 minutes.  Since
a timeout should only occur when the gssd(8) daemon
has died, a long timeout should be ok and seems to fix this
problem.

I still think that commit c33509d49a should remain in the
system, since it allows the mount to complete quickly
and not take nearly 30 seconds.

PR: 268823

(cherry picked from commit e3c26ce5cb410e4e58e131dfea7054e0bf11e3ca)

17 months agonfscl: Improve NFSv4 error message for NFSERR_WRONGSEC
Rick Macklem [Wed, 11 Jan 2023 21:28:44 +0000 (13:28 -0800)]
nfscl: Improve NFSv4 error message for NFSERR_WRONGSEC

The usual reason for an NFSv4 server replying NFSERR_WRONGSEC
to an operation is that a Kerberos credential is required.
This patch replaces a cryptic "err=10016" with a message
suggesting that a Kerberos TGT is probably needed.

(cherry picked from commit 39633fc1731c3feeed36aa452bbdfb7968a86383)

17 months agostand/mips: retire BERI boot loader
Warner Losh [Wed, 25 Jan 2023 18:31:00 +0000 (11:31 -0700)]
stand/mips: retire BERI boot loader

The folks that created the BERI boot loader no longer need it. They've
long since moved on to other research platforms. Since BERI loader
contains yet another copy of code that I've consolodated; and since it's
impossible to test this platform; and since there are no users, retire
it completely to ease future MFCs.

OK'd by: brooks@
Sponsored by: Netflix

This is a direct commit to stable/13

17 months agostand: updated MFC info.
Warner Losh [Wed, 25 Jan 2023 18:26:44 +0000 (11:26 -0700)]
stand: updated MFC info.

This is a direct commit to stable/13

17 months agostand/mips64: Make beri loader compile
Warner Losh [Wed, 25 Jan 2023 15:14:45 +0000 (08:14 -0700)]
stand/mips64: Make beri loader compile

The devdesc reorgs in main were done after mips was deleted. Make the
minimal changes to beri's devicename.c needed after that. I have no
ability to test this, however, so it builds with similar warnings to
before all my MFC changes.

This is a direct commit to stable/13

17 months agostand: update mips uboot to uboot reorg
Warner Losh [Wed, 25 Jan 2023 14:54:03 +0000 (07:54 -0700)]
stand: update mips uboot to uboot reorg

uboot reorg in main happened after the mips support was removed. Go
ahead and do the same reorg here. Move the mips files from mips/uboot to
uboot/arch/mips. Move mips/uboot/Makefile to
uboot/arch/mips/Makefile.inc and cut out the common lines. Split uboot
target into uboot and uboot.bin to better fit into reorg.

This is a direct commit to stable/13

17 months agostand/uboot: Remove -fPIC here
Warner Losh [Wed, 25 Jan 2023 15:03:08 +0000 (08:03 -0700)]
stand/uboot: Remove -fPIC here

When needed, -fPIC is added in defs.mk. While not in main, mips on
stable/13 can't tolerate it. Remove it here.

MFC After: now (it's a build issue)
Sponsored by: Netflix

(cherry picked from commit 4410e857965edef0e3be42ae323356ec08d2aaad)

17 months agopci_info: update to 2022-12-04
Baptiste Daroussin [Thu, 8 Dec 2022 15:07:54 +0000 (16:07 +0100)]
pci_info: update to 2022-12-04

(cherry picked from commit 07d1c4a919c0a7bdbf846e75e730d1c10c72eef6)

17 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

(cherry picked from commit d525abd2771692b8da01e23bc6f3333c7dd7f669)

17 months agoflua: chown(2) binding, fix bad copy/paste
Baptiste Daroussin [Fri, 25 Nov 2022 08:05:40 +0000 (09:05 +0100)]
flua: chown(2) binding, fix bad copy/paste

(cherry picked from commit 280f11f1be54370fcc289ee259a1b86637170ea1)

17 months agoflua: add a chown(2) binding
Baptiste Daroussin [Thu, 24 Nov 2022 08:16:05 +0000 (09:16 +0100)]
flua: add a chown(2) binding

The main difference with the chown in luaposix, is that it checks
and reports if a user or a group do exist when a string is passed
as arguments

Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D37479

(cherry picked from commit a1ab15abe2e2a1ed92cbad056df71afff7e8794e)

17 months agoumodem: ignore CDC_CM descriptor for baltech smartcard reader
Steffen Dirkwinkel [Fri, 4 Nov 2022 14:46:07 +0000 (15:46 +0100)]
umodem: ignore CDC_CM descriptor for baltech smartcard reader

The CDC_CM descriptor points to the wrong interface for serial port use.
Ignore it to use the CDC_UNION descriptor.

usbconfig dump (spec at: https://usb.org/sites/default/files/CDC1.2_WMC1.1_012011.zip):
ugen0.2: <Baltech AG Smartcard Reader> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (300mA)

  bLength = 0x0012
  bDescriptorType = 0x0001
  bcdUSB = 0x0200
  bDeviceClass = 0x0000  <Probed by interface class>
  bDeviceSubClass = 0x0000
  bDeviceProtocol = 0x0000
  bMaxPacketSize0 = 0x0040
  idVendor = 0x13ad
  idProduct = 0xf019
  bcdDevice = 0x0100
  iManufacturer = 0x0001  <Baltech AG>
  iProduct = 0x0002  <Smartcard Reader>
  iSerialNumber = 0x0003  <45031910>
  bNumConfigurations = 0x0001

 Configuration index 0

    bLength = 0x0009
    bDescriptorType = 0x0002
    wTotalLength = 0x0064
    bNumInterfaces = 0x0003
    bConfigurationValue = 0x0001
    iConfiguration = 0x0000  <no string>
    bmAttributes = 0x0080
    bMaxPower = 0x0096

    Interface 0
      bLength = 0x0009
      bDescriptorType = 0x0004
      bInterfaceNumber = 0x0000
      bAlternateSetting = 0x0000
      bNumEndpoints = 0x0001
      bInterfaceClass = 0x0003  <HID device>
      bInterfaceSubClass = 0x0000
      bInterfaceProtocol = 0x0000
      iInterface = 0x0000  <no string>

      Additional Descriptor

      bLength = 0x09
      bDescriptorType = 0x21
      bDescriptorSubType = 0x11
       RAW dump:
       0x00 | 0x09, 0x21, 0x11, 0x01, 0x00, 0x01, 0x22, 0xd0,
       0x08 | 0x00

     Endpoint 0
        bLength = 0x0007
        bDescriptorType = 0x0005
        bEndpointAddress = 0x0081  <IN>
        bmAttributes = 0x0003  <INTERRUPT>
        wMaxPacketSize = 0x0040
        bInterval = 0x0001
        bRefresh = 0x0000
        bSynchAddress = 0x0000

      Additional Descriptor

      bLength = 0x08
      bDescriptorType = 0x0b
      bDescriptorSubType = 0x01
       RAW dump:
       0x00 | 0x08, 0x0b, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00

    Interface 1
      bLength = 0x0009
      bDescriptorType = 0x0004
      bInterfaceNumber = 0x0001
      bAlternateSetting = 0x0000
      bNumEndpoints = 0x0001
      bInterfaceClass = 0x0002  <Communication device>
      bInterfaceSubClass = 0x0002
      bInterfaceProtocol = 0x0000
      iInterface = 0x0000  <no string>

      Additional Descriptor

      bLength = 0x05
      bDescriptorType = 0x24
      bDescriptorSubType = 0x00
       RAW dump:
       0x00 | 0x05, 0x24, 0x00, 0x10, 0x01

      Additional Descriptor

      bLength = 0x04
      bDescriptorType = 0x24
      bDescriptorSubType = 0x02
       RAW dump:
       0x00 | 0x04, 0x24, 0x02, 0x00

      Additional Descriptor

      bLength = 0x05
      bDescriptorType = 0x24
      bDescriptorSubType = 0x06
       RAW dump:
       0x00 | 0x05, 0x24, 0x06, 0x01, 0x02

      Additional Descriptor

      bLength = 0x05
      bDescriptorType = 0x24
      bDescriptorSubType = 0x01
       RAW dump:
       0x00 | 0x05, 0x24, 0x01, 0x00, 0x01

     Endpoint 0
        bLength = 0x0007
        bDescriptorType = 0x0005
        bEndpointAddress = 0x0085  <IN>
        bmAttributes = 0x0003  <INTERRUPT>
        wMaxPacketSize = 0x0008
        bInterval = 0x0010
        bRefresh = 0x0000
        bSynchAddress = 0x0000

    Interface 2
      bLength = 0x0009
      bDescriptorType = 0x0004
      bInterfaceNumber = 0x0002
      bAlternateSetting = 0x0000
      bNumEndpoints = 0x0002
      bInterfaceClass = 0x000a  <CDC-data>
      bInterfaceSubClass = 0x0000
      bInterfaceProtocol = 0x0000
      iInterface = 0x0000  <no string>

     Endpoint 0
        bLength = 0x0007
        bDescriptorType = 0x0005
        bEndpointAddress = 0x0086  <IN>
        bmAttributes = 0x0002  <BULK>
        wMaxPacketSize = 0x0040
        bInterval = 0x0000
        bRefresh = 0x0000
        bSynchAddress = 0x0000

     Endpoint 1
        bLength = 0x0007
        bDescriptorType = 0x0005
        bEndpointAddress = 0x0006  <OUT>
        bmAttributes = 0x0002  <BULK>
        wMaxPacketSize = 0x0040
        bInterval = 0x0000
        bRefresh = 0x0000
        bSynchAddress = 0x0000

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

(cherry picked from commit 8580e334b0757c8d55e51b8dc7fc4051521beedf)

17 months agoumodem: add quirk to ignore CDC_CM descriptor
Steffen Dirkwinkel [Tue, 17 Jan 2023 07:58:46 +0000 (08:58 +0100)]
umodem: add quirk to ignore CDC_CM descriptor

Some devices have CDC_CM descriptors that would point us to
the wrong interfaces. Add a quirk to ignore those (prefering the
CDC_UNION descriptor effectively)

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

(cherry picked from commit 73c3e8b1dee6cd42de32287ea8a57762b961d8ee)

17 months agostand: mfc notes
Warner Losh [Wed, 25 Jan 2023 04:19:48 +0000 (21:19 -0700)]
stand: mfc notes

MFCing stand is getting complicated. This file contains notes about
merging from 14, in summary:
o UFS changes have already been merged.
o The ZFS changes, on the whole, cannot be merged because OpenZFS
  versions are different.
o MIPS is still present in 13, so commits to tear down mips
  support.
o Some of the 14 GELI changes depend on crypto changes not yet merged.
o One change bumped the version to 14.x, and that shouldn't be merged.

The hashes listed should not be merged, unless something changes.

This is a direct commit to stable/13.

17 months agoRevert "mips: remove saf1761"
Warner Losh [Wed, 25 Jan 2023 04:00:23 +0000 (21:00 -0700)]
Revert "mips: remove saf1761"

Mips is still in stable/13, so this should not have been merged.

This reverts commit 622ab2c4834068312b6cd33fd7ac961f31240350.

Sponsored by: Netflix

17 months agoRevert "Bump the FreeBSD kernel version in kernel boot shim."
Warner Losh [Wed, 25 Jan 2023 03:56:41 +0000 (20:56 -0700)]
Revert "Bump the FreeBSD kernel version in kernel boot shim."

This should not have been merged.

This reverts commit 8cc2156f85bb5cd0c4bae6882b72b215281b1fc5.

Sponsored by: Netflix

17 months agoRevert "stand: remove mips support"
Warner Losh [Wed, 25 Jan 2023 03:54:38 +0000 (20:54 -0700)]
Revert "stand: remove mips support"

This change slipped through my checks, and should not have been merged.
mips is still supported in stable/13.

This reverts commit e006859bce01b2f10349a804cade3688f40557e3.

17 months agoTag zfs-2.1.9
Tony Hutter [Tue, 24 Jan 2023 23:41:54 +0000 (15:41 -0800)]
Tag zfs-2.1.9

META file and changelog updated.

Signed-off-by: Tony Hutter <hutter2@llnl.gov>
17 months agolinux 6.2 compat: zpl_set_acl arg2 is now struct dentry
Coleman Kane [Tue, 24 Jan 2023 19:20:50 +0000 (14:20 -0500)]
linux 6.2 compat:  zpl_set_acl arg2 is now struct dentry

Linux 6.2 changes the second argument of the set_acl operation to be a
"struct dentry *" rather than a "struct inode *". The inode* parameter
is still available as dentry->d_inode, so adjust the call to the _impl
function call to dereference and pass that pointer to it.

Also document that the get_acl -> get_inode_acl member name change from
commit 884a693 was an API change also introduced in Linux 6.2.

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Signed-off-by: Coleman Kane <ckane@colemankane.org>
Closes #14415

17 months agoRevert "ztest fails assertion in zio_write_gang_member_ready()"
Tony Hutter [Tue, 24 Jan 2023 23:31:09 +0000 (15:31 -0800)]
Revert "ztest fails assertion in zio_write_gang_member_ready()"

This reverts commit 0156253d29a303bdcca3e535958e754d8f086e33.

That commit was identified as causing IO errors on a user's
encrypted dataset:
https://github.com/openzfs/zfs/issues/14413

Signed-off-by: Tony Hutter <hutter2@llnl.gov>
17 months agobyteswap.h: Add a glibc/linux compatible byteswap.h
Warner Losh [Fri, 20 Jan 2023 23:33:37 +0000 (16:33 -0700)]
byteswap.h: Add a glibc/linux compatible byteswap.h

For endian.h to work instead of sys/endian.h, some software needs
byteswap.h available. It must define {__,}byteswap_{16,32,64}.
Included sys/_endian.h to get an appropriate __byteswap16, etc
and defines the new macros in terms of them. Enhance _endian.h
to allow it to be included from here too.

Sponsored by: Netflix
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D32051

(cherry picked from commit 1761b09bf42d2842e82c1ac614c23d31c4d4c0dc)

17 months agolinux: For better compatibility, provide compatible endian.h
Warner Losh [Fri, 20 Jan 2023 23:32:45 +0000 (16:32 -0700)]
linux: For better compatibility, provide compatible endian.h

Add endian.h. This includes sys/endian.h and then adds extra defines
that glibc defines with double underscores for our
_{BIG,BYTE,LITTLE,PDP}_ENDIAN macros. We also define __FLOAT_WORD_ORDER
to be the same as _BYTE_ENDIAN since FreeBSD doesn't currently define
this, and the default with glibc is exactly this for our platforms.
Move common parts of endian.h and sys/endian.h into sys/_endian.h
to limit namespace pollution from endian.h

All this gives us good compatibility with Linux. There may be one or two
upstreams that haven't integrated the patches I tried to send up.

There are some minor differences:
o The extra glibc macros are not defined. These are all
  controlled with either __ at the start, or only defined
  when glibc is being built. We also don't define macros
  that are used internally in glibc that would pollute
  the namespace.
o For complete compatibility, this change must also be
  paired with providing a glibc-compatible byteswap.h.

Sponsored by: Netflix
Reviewed by: mhorne, markj, jhb
Differential Revision: https://reviews.freebsd.org/D31962

(cherry picked from commit 30e0d2a51026830e5141ce3dd43854819bba910c)

17 months agoendian.h: Use the __bswap* versions
Warner Losh [Tue, 21 Sep 2021 04:02:35 +0000 (22:02 -0600)]
endian.h: Use the __bswap* versions

Make it possible to have all these macros work without bswap* being
defined. bswap* is part of the application namespace and applications
are free to redefine those functions.

Reviewed by: emaste,jhb,markj
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31964

(cherry picked from commit 44fb3c695f5e672ec00bdef0fa0f13793e6269a1)

17 months agoepoch: replace hand coded assertion
Brooks Davis [Fri, 20 Jan 2023 18:03:39 +0000 (18:03 +0000)]
epoch: replace hand coded assertion

The assertion is equivalent to kstack_contains() so use that rather
than spelling it out.

Suggested by: jhb
Reviewed by: jhb
MFC after: 1 week
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D38107

(cherry picked from commit fa1d803c0f652d72840a3c59139baf9d30792860)

17 months agoriscv: Fix thread0.td_kstack_pages init
Brooks Davis [Tue, 17 Jan 2023 16:36:15 +0000 (16:36 +0000)]
riscv: Fix thread0.td_kstack_pages init

Commit 0ef3ca7ae37c70e9dc83475dc2e68e98e1c2a418 initialized
thread0.td_kstack_pages to KSTACK_PAGES.  Due to the lack of an
include of opt_kstack_pages.h it used the fallback value of 4 from
machine/param.h.  This meant that increasing KSTACK_PAGES in the kernel
config resulted in a panic in _epoch_enter_preempt as the following
assertion was false during network stack setup:

MPASS((vm_offset_t)et >= td->td_kstack &&
    (vm_offset_t)et + sizeof(struct epoch_tracker) <=
    td->td_kstack + td->td_kstack_pages * PAGE_SIZE);

Switch to initializing with kstack_pages following other architectures.

Reviewed by: imp, markj
Sponsored by:   DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D38049

(cherry picked from commit b75062f23431fbabef1e7d665cae270b144f71b1)

17 months agoarm64: Fix thread0.td_kstack_pages init
Brooks Davis [Tue, 17 Jan 2023 16:35:08 +0000 (16:35 +0000)]
arm64: Fix thread0.td_kstack_pages init

Commit 86a994d6537d7b5e1efb1019e466d86a688fd570 initialized
thread0.td_kstack_pages to KSTACK_PAGES.  Due to the lack of an
include of opt_kstack_pages.h it used the fallback value of 4 from
machine/param.h.  This meant that increasing KSTACK_PAGES in the kernel
config resulted in a panic in _epoch_enter_preempt as the following
assertion was false during network stack setup:

        MPASS((vm_offset_t)et >= td->td_kstack &&
    (vm_offset_t)et + sizeof(struct epoch_tracker) <=
    td->td_kstack + td->td_kstack_pages * PAGE_SIZE);

Switch to initializing with kstack_pages following other architectures.

Reviewed by: imp, markj
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D38048

(cherry picked from commit e1b610f76caa09bbc3910477da878ea5078c6569)

17 months agostand: dev can't be NULL in default_prasedev
Warner Losh [Fri, 13 Jan 2023 22:44:23 +0000 (15:44 -0700)]
stand: dev can't be NULL in default_prasedev

We pass in the address of a variable to store this value always in the
only place that calls this function, so there is no need to test for NULL.

Sponsored by: Netflix
Notied by: tsoome in D38041

(cherry picked from commit 4883f347f6ed9a61f9789a3842077580250ebf44)

17 months agokboot: Use standard set_currdev
Warner Losh [Fri, 13 Jan 2023 21:21:16 +0000 (14:21 -0700)]
kboot: Use standard set_currdev

Use the standard set_currdev instead of the (now very old) copy of
setting currdev and loaddev directly. We do this only when we don't go
find the ZFS pool to boot from.

Sponsored by: Netflix
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D38012

(cherry picked from commit eb1795782cfc43523345f78737cc22277cea5056)

17 months agokboot: Add hostdisk override
Warner Losh [Fri, 13 Jan 2023 21:21:07 +0000 (14:21 -0700)]
kboot: Add hostdisk override

When hostdisk_override is set, all the /dev devices are hidden, and only
the files in that directory are used. This will allow filesystem testing
on FreeBSD without root, for example. Adjust the parse routine to not
require devices start with /dev (plus fix a leak for an error
condition). Add a match routine to allow the device name to be something
like "/home/user/testing/zfsfoo:" instead of strictly in /dev. Note:
since we need to look at all the devices in the system to probe for ZFS
zpools, you can't generally use a full path to get a 'virtual disk' at
this time.

Sponsored by: Netflix
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D38011

(cherry picked from commit b7ecfa195f46da4a08a0cb5b399c8bc69bff225a)

17 months agokboot: Fetch hostfs_root and bootdev from the environment
Warner Losh [Fri, 13 Jan 2023 21:20:56 +0000 (14:20 -0700)]
kboot: Fetch hostfs_root and bootdev from the environment

Fetch bootdev from the environment variable (so it should be set on the
command line). Default to 'zfs:' which will in the future look for the
first zpool that we can boot from. Prior versions of kboot would set
this from the second argument on the command line.

Fetch hostfs_root from the environment (defaulting to '/'). Prior
versions of kboot would set this from the first arg on the command line.

Sponsored by: Netflix
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D38010

(cherry picked from commit 4f3be6b8d94a388ce7ae239c785ea447d0adbf48)

17 months agokboot: Add ZFS support build glue
Warner Losh [Fri, 13 Jan 2023 21:20:48 +0000 (14:20 -0700)]
kboot: Add ZFS support build glue

Now that all the pieces are in place, allow kboot to be built with ZFS
support.

Sponsored by: Netflix
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D38009

(cherry picked from commit 42e37d8caf9da4628734f0c44c989583873b3ae6)

17 months agokboot: Add support for ZFS volumes
Warner Losh [Fri, 13 Jan 2023 21:20:40 +0000 (14:20 -0700)]
kboot: Add support for ZFS volumes

Add the zfs device and filesystem to config and write the hook we need
to probe zfs since there's not a generic mechanism in place to do that
when ZFS is configured.

Sponsored by: Netflix
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D38008

(cherry picked from commit f20ecce33a2a9a992fb267edf02edaa6eb9178b3)

17 months agokboot: Add ZFS support to hostdisk
Warner Losh [Fri, 13 Jan 2023 21:20:30 +0000 (14:20 -0700)]
kboot: Add ZFS support to hostdisk

Add helper function to walk through the disk drives we've found to look
for zpools. main.c will still need to call this because the loader
hasn't implemented a good way to 'taste' drives for zpools and/or GELI
partitions (mostly because there's no generic list of candidate
devices).

Sponsored by: Netflix
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D38007

(cherry picked from commit cc82c650a72fcdde255b023703a9b214a81254ec)

17 months agokboot: Rework hostdisk.c to allow easier ZFS support.
Warner Losh [Fri, 13 Jan 2023 21:20:09 +0000 (14:20 -0700)]
kboot: Rework hostdisk.c to allow easier ZFS support.

Keep a list of disks and partitions that we have. Keep track of the
sizes of the media and sector and use that to implement DIOCGMEDIASIZE
and DIOCGSECTORSIZE. Proivde a way to lookup disks by name.

Sponsored by: Netflix
Reviewed by: kevans (prior version)
Differential Revision: https://reviews.freebsd.org/D38013

(cherry picked from commit 1a13008e9874748958a3415a3d0c34b95acbf2e2)

17 months agostand/zfs: Fix memory leaking on error cases
Warner Losh [Fri, 13 Jan 2023 21:20:00 +0000 (14:20 -0700)]
stand/zfs: Fix memory leaking on error cases

Now that we return an allocated zfs_devdesc, we have to free it. These
frees were missing from the error cases. In addition, simplify the code
a bit for the out of memory case.

Sponsored by: Netflix
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D38006

(cherry picked from commit 5385c7e13b06cb42a28bbf8c0d910b0c2ffddec7)

17 months agostand/uboot: Explain why we test for NULL here
Warner Losh [Fri, 13 Jan 2023 21:19:47 +0000 (14:19 -0700)]
stand/uboot: Explain why we test for NULL here

Most parsedev routines assume that idev is non-null and can always be
set. Since we break from this pattern in uboot, explain why in a
comment. devparse was invented to put a lot of common code in one place
and to simplify the archsw.arch_getdev code and any dv_parsedev code
called. However, uboot couldn't use devparse at the time because its
device naming scheme slightly different parsing. So, we still use
uboot_parsedev directly from uboot_getdev where dev could be NULL. Add a
comment to this effect.

The match functionality added for ofw likely could be used to clean up
the multiple kludges that are here for uboot's device naming differences
with the normal boot loader. This work will wait for the future.

Sponsored by: Netflix
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D38042

(cherry picked from commit 5740057b4388f116717b9614cd54cf2c755e6e7d)

17 months agostand/ofw: dev can't be NULL here
Warner Losh [Fri, 13 Jan 2023 21:19:39 +0000 (14:19 -0700)]
stand/ofw: dev can't be NULL here

dev can't be NULL here. ofw_common_parsedev is always called via
devparse (indirectly through dv_parsedev() calls there which call it
with the args unchanged). In the past, ofw_getdev could call us with
NULL pointer for the parse-only case, but that's now all handled inside
of devparse for simplicity.

Sponsored by: Netflix
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D38041

(cherry picked from commit d38d8a4c4e9a3c4667307ac2163007ff193040b0)

17 months agostand: Separate base and cli parts of nvstore
Warner Losh [Fri, 13 Jan 2023 21:19:30 +0000 (14:19 -0700)]
stand: Separate base and cli parts of nvstore

zfs lives in libsa. However, it depends on nvstore (and other things)
that are in common. Fix part of this layering violation by splitting
nvstore into a libsa piece (which is the base implementation) and
keeping a much smaller common piece (to implement the nvstore
command). This just leaves zfs' knowledge of device names that's
specific to common and its calling platform specific init code to
resolve. Add a nvstore.h file for these two parts to communicate private
things and move the public nvstore api from bootstrap.h to stand.h.

Sponsored by: Netflix
Reviewed by: tsoome, kevans
Differential Revision: https://reviews.freebsd.org/D38043

(cherry picked from commit d1ea5017141ffecdb7ce97a3d97b27a6aabf8c4a)

17 months agostand: create common set_currdev
Warner Losh [Wed, 11 Jan 2023 22:14:28 +0000 (15:14 -0700)]
stand: create common set_currdev

Pull together the nearly identical copies of set_currdev in i386,
userboot and efi. Other boot loaders have variances that might be fine
to use the common routine, or not. Since they are harder to test for me,
and ofw and uboot do handle these setting differently, leave them be for
now.

Sponsored by: Netflix
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D38005

(cherry picked from commit ad70f2e22ef29f94bf5208b3a9a2389575330b06)

17 months agostand: Move dev_cleanup into libsa
Warner Losh [Wed, 11 Jan 2023 22:14:17 +0000 (15:14 -0700)]
stand: Move dev_cleanup into libsa

Since dev_cleanup() walks through all the devsw devices with dv_cleanup
rotuines, move it into libsa rather than having it in
'common'. Logically, it operates only on things that are in libsa, and
would never be different for different loaders: either people would call
it as is, or they'd do the loop themselves with 'special' things inline
between calls to cleanup (not that I think that will ever be needed
though).

Sponsored by: Netflix
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D38004

(cherry picked from commit bf020787d5f1b4a1274135b49309f7e9ef3955e1)

17 months agostand: Create common gen_setcurrdev and replace code
Warner Losh [Wed, 11 Jan 2023 22:14:02 +0000 (15:14 -0700)]
stand: Create common gen_setcurrdev and replace code

Replace 4 identical copies of *_setcurrdev with gen_setcurrdev to avoid
having to create a 5th copy. uboot_setcurrdev is actually different and
needs to remain separate (even though it's quite similar).

Sponsored by: Netflix
Reviewed by: fuz@fuz.su, kevans
Differential Revision: https://reviews.freebsd.org/D38003

(cherry picked from commit 1c1783d66bc81ebd0c1304b1f613a9403c073915)

17 months agostand/efi: Better variable name
Warner Losh [Sun, 8 Jan 2023 19:00:51 +0000 (12:00 -0700)]
stand/efi: Better variable name

sanity_check_currdev returns true if it found a kernel or a sane loader
config file. A better name for this would be 'bootable' rather than 'rv'
which connotes in other places an errno value or similar.

Sponsored by: Netflix

(cherry picked from commit 23ed2a38c200c93414de20d20f7508f621acecd1)

17 months agostand/zfs: Add a third argument to zfs_probe_dev: part_too
Warner Losh [Fri, 16 Dec 2022 23:19:51 +0000 (16:19 -0700)]
stand/zfs: Add a third argument to zfs_probe_dev: part_too

Pass in 'true' if you'd like to search this device's partitions or
'false' if you should just search the device. EFI and (in the future)
kboot have discrete partitions that aren't accessed via the full disk
device. Weird things happen if you try to search in these cases.

Sponsored by: Netflix

(cherry picked from commit 71bbe6fb709dcfbe36877fa53c928e2e6d881843)

17 months agokboot: use 128MB for the heap area, ZFS needs a lot of memory
Warner Losh [Fri, 23 Dec 2022 18:26:32 +0000 (11:26 -0700)]
kboot: use 128MB for the heap area, ZFS needs a lot of memory

ZFS uses a lot of memory. The old minimal allocations won't work when
ZFS support is added. Most environments this will be used (or will
liekly be used) have >> 256MB, 128MB should be safe everywhere and allow
examination of a fair number of ZFS pools to boot from.

Sponsored by: Netflix

(cherry picked from commit 4dd3e76881ad025170b0cfb5455680b3c89fe263)

17 months agokboot: Sort kexec_load alphabetically
Warner Losh [Sat, 7 Jan 2023 20:24:45 +0000 (13:24 -0700)]
kboot: Sort kexec_load alphabetically

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37968

(cherry picked from commit a0e4d18091a4fab66c4eb7c5dc731f78a2f9b0a3)

17 months agostand: Add macros for file types from stat
Warner Losh [Sat, 7 Jan 2023 20:23:05 +0000 (13:23 -0700)]
stand: Add macros for file types from stat

Add the familiar macros for file types for stat's st_mode
member. Prepend HOST_ to the start of these. Make sure all the values
match the linux nolibc and uapi headers. These values are the same as
native values since they appear to be required by POSIX. Define anyway
to allow the reader of the code to know that they are in the 'host (eg
Linux)' namespace rather than the 'loader' namespace.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37967

(cherry picked from commit 2f5f17b80c2d030196e05b12b15d544b363eb058)

17 months agokboot: Disks should be at least 16MB
Warner Losh [Tue, 13 Dec 2022 05:39:03 +0000 (22:39 -0700)]
kboot: Disks should be at least 16MB

Linux pre-boot environments will often have a number of psuedo disks
that are small, all smaller than a few MB. 16MB is a good cutoff since
it's big enough to filter these devices, yet small enough to allow a
super-minimal partition through (the smallest I've been able to make
that's useful lately is around 20MB).

Sponsored by: Netflix

(cherry picked from commit 0386255bee079922f00f37eeb4e9e3138b7666c1)

17 months agokboot: hostdisk.c update copyright notice
Warner Losh [Tue, 13 Dec 2022 05:37:35 +0000 (22:37 -0700)]
kboot: hostdisk.c update copyright notice

I've rewritten a substantial portion of this file, so add Netflix
copyright.

Sponsored by: Netflix

(cherry picked from commit 538b73578b9190af1b2fd57ca886c79b40aa1c17)

17 months agostand: Allow stand.h to be included in C++ programs
Warner Losh [Sat, 7 Jan 2023 01:39:09 +0000 (18:39 -0700)]
stand: Allow stand.h to be included in C++ programs

Allow stand.h to be included in C++ programs. This is little more than
using our stylized __BEGIN_DECL / __END_DECL around the entire
file. There's no run-time support for C++, so the C++ that can be used
is quite limited. It is enough for libunwind, though.

Sponsored by: Netflix
Reviewed by: jrtc27, kevans
Differential Revision: https://reviews.freebsd.org/D37946

(cherry picked from commit 5cf20707ba79b5c06b26381da0013c65004b53be)

17 months agostand: Add inttype.h
Warner Losh [Sat, 7 Jan 2023 01:37:56 +0000 (18:37 -0700)]
stand: Add inttype.h

libunwind files need inttype.h. It's safe so add it to the safe list.

Sponsored by: Netflix
Reviewed by: jrtc27, kevans
Differential Revision: https://reviews.freebsd.org/D37947

(cherry picked from commit 97e1430606f8387c03fe6e544005be8dab6a3364)