]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agoficl: instead of pad, emit can use local variable
Toomas Soome [Tue, 1 Dec 2020 22:28:02 +0000 (22:28 +0000)]
ficl: instead of pad, emit can use local variable

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

(cherry picked from commit dba7640e44c5ec148a84b0d58c6c9a3c9e5147f3)

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

Some compilers are complaining about missing prototype.

PR: 251150

(cherry picked from commit fc7cf7241f89a3d3ccc20cb49c5bf61e154b7a1b)

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

cstyle cleanup only, no functional changes intended.

(cherry picked from commit 3e9f0f1d298f7f1e535831cdf697f5884a6d07dc)

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

correct small issues - misplaced comment and typos.

(cherry picked from commit 83a252c6a15d44cd574a9ef9ba37a77a3464296f)

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

No functional changes intended.

(cherry picked from commit 90b307a8975327b195e4549b9b0745bcc684f646)

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

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

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

(cherry picked from commit e416eecbb9f7a5275d1d059ae720adc24af4d337)

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

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

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

(cherry picked from commit b9aa4537b2155a0b0bb419ff05b8da206c02bfbd)

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

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

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

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

(cherry picked from commit c50f409c15ef818baf5ee49edd52f44b9d809dce)

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

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

(cherry picked from commit 6ab1ffcbfeaab180691d7c1b5b0003f224442fed)

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

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

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

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

(cherry picked from commit 867ae3c38d1aa97300bd35f457037b3f1a0a103f)

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

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

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

(cherry picked from commit f9553770c03e82abcae07397025797ef346fbdab)

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

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

(cherry picked from commit b9c5b432637c04d4a803170b2fab7c9df2ef787b)

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

Only use SKEIN_LOOP while compiling skein_block.c

(cherry picked from commit 0fec8f03cf996be5d4c9d770a7c47aae5e5aaee8)

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

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

(cherry picked from commit c7dd069c70d465298f14553d981bfe5e2ffd0459)

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

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

(cherry picked from commit 9060f2c3920dde41226cf52b925bc949815c7f01)

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

Tiny cleanup, no functional changes.

(cherry picked from commit 5949d13fabc43a728b2122277f44a6366e3b9270)

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

Allow env_discard() to be used outside environment.c

(cherry picked from commit 588f0a1e29a341878ad938bb9c239431cac107ae)

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

No functional changes.

(cherry picked from commit 16aabe28c6e71f05e3520eb9209658fe61e7c28b)

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

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

(cherry picked from commit 1a4b982e1e22dc0bbcddbff082ee16abb2874871)

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

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

(cherry picked from commit 771f100cebd8ada2bd764574386a71b5a5067f45)

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

Need to free nvlist before return from vdev_from_nvlist().

(cherry picked from commit 045f497cbc6cb67bc563d7f2378bf9535044bb2d)

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

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

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

(cherry picked from commit 12c470af750672c4847af20cc8e2a736aab7db78)

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

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

(cherry picked from commit b93b14dc756861d543249f3d04b80809055fdd61)

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

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

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

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

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

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

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

(cherry picked from commit aba2397e74a2eff55e2507c27ba31813d6b2a95e)

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

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

(cherry picked from commit c98740b5e252d1cefd6d33d93fc1015d16afc1b8)

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

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

(cherry picked from commit 6469d2b422960de4b1253cc63b11fa67f896604f)

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

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

(cherry picked from commit 467535dcfaa6be42efe0fe8be9582cafc5dfb812)

2 years agoloader: variable i is unused without MBR/GPT support built in
Toomas Soome [Tue, 16 Jun 2020 07:05:03 +0000 (07:05 +0000)]
loader: variable i is unused without MBR/GPT support built in

Because i is only used as index in for loop, declare it in for statement.

(cherry picked from commit f44c441ee680e1456fba0e8c52f93a49e6f6695b)

2 years agozfsboot: cstyle cleanup
Toomas Soome [Sun, 14 Jun 2020 20:57:24 +0000 (20:57 +0000)]
zfsboot: cstyle cleanup

No functional changes intended.

(cherry picked from commit dfdeb45425cf025ce32c517ec3f85a8dd9fdff54)

2 years agoAvoid using non-portable dd conv=osync option
Alex Richardson [Mon, 11 May 2020 08:40:33 +0000 (08:40 +0000)]
Avoid using non-portable dd conv=osync option

The same thing can be achieved using the bs=$SIZE and conv=sync options.
Unlike conv=osync, conv=sync is support on both Linux and macOS.

(cherry picked from commit 87c5e64c64e43be532cb703e96c0776309aab337)

2 years agoFix the EFI_DEBUG case, prio_str is only used when EFI_DEBUG is unset.
Andrew Turner [Tue, 5 May 2020 10:01:10 +0000 (10:01 +0000)]
Fix the EFI_DEBUG case, prio_str is only used when EFI_DEBUG is unset.

(cherry picked from commit 4495f3687484e93a55031c415459ca19b030404f)

2 years agoloader: use #elif defined() in stand.h
Toomas Soome [Sun, 29 Mar 2020 06:48:59 +0000 (06:48 +0000)]
loader: use #elif defined() in stand.h

Small cleanup.

(cherry picked from commit 5292d0a7f308907bd9c3b37d42d348a144d05978)

2 years agoloader: typo did slip into 359408
Toomas Soome [Sat, 28 Mar 2020 21:55:42 +0000 (21:55 +0000)]
loader: typo did slip into 359408

somehow r was lost from 'char'.

(cherry picked from commit 6c01b7102de4ef77fb886df410f70171f04b3fae)

2 years agoloader: strdup name strings from dataset walker
Toomas Soome [Sat, 28 Mar 2020 21:50:27 +0000 (21:50 +0000)]
loader: strdup name strings from dataset walker

The removal of zfs scratch buffer did miss the fact the dataset
lookup was picking up the names from zap list.

(cherry picked from commit 215597f05fc6cf9e218d26ef37063ec58451a259)

2 years agoloader: add knob to build with user malloc
Toomas Soome [Sat, 28 Mar 2020 21:47:44 +0000 (21:47 +0000)]
loader: add knob to build with user malloc

This option is intended to aid development, to allow building with user
malloc. The use case would be to build userboot & test with libc (or
other) malloc and use extra malloc debug features.

(cherry picked from commit c907ec9e16745e3dacd15982f71dea21a06de53c)

2 years agoloader: remove libsa/crc32.c and use version from zlib
Toomas Soome [Thu, 19 Mar 2020 21:05:11 +0000 (21:05 +0000)]
loader: remove libsa/crc32.c and use version from zlib

we have crc32(const void *, size_t) in libsa. Unfortunately zlib has
crc32(long, const unigned char *, unsigned) and we have conflict.

Since we do build libsa with zlib, we can use zlib version instead.

(cherry picked from commit 27bae6150a9fd352796b5ff775eb464a2cf6dac9)

2 years agoloader: replace zfs_alloc/zfs_free with malloc/free
Toomas Soome [Wed, 26 Feb 2020 18:12:12 +0000 (18:12 +0000)]
loader: replace zfs_alloc/zfs_free with malloc/free

Use common memory management.

(cherry picked from commit c1c4c81fd75a7d0c14011ea1cf6113ecdd80e16a)

2 years agoMove smbios.c to libsa.
Warner Losh [Thu, 20 Feb 2020 00:46:22 +0000 (00:46 +0000)]
Move smbios.c to libsa.

smbios used to be an i386 only kinda weird quirk to the x86
architecture. But UEFI picked it up, dusted it off and now it's many
other locations. Make it base technology by moving it to libsa and
fixing up the compliation. The code has issues with unaligned access
still, but that will be addressed in a followup commit.

(cherry picked from commit a64f0b83e5ee1c9f7ac5782a3d3f9f1c7b368e41)

2 years agoCreate ptov() function.
Warner Losh [Thu, 20 Feb 2020 00:46:16 +0000 (00:46 +0000)]
Create ptov() function.

Create a ptov() function. It's basically the same as the btx PTOV
macro, but works everywhere. smbios needs this to translate addresses,
but the translation differs between BIOS booting and EFI booting. Make
it a function so one smbios.o can be used everywhere. Provide
definitions for it in the two loaders affected.

(cherry picked from commit ed2a65769a5d04fcfc2acff3fa11d6b69394fd88)

2 years agofollowup on r357497: clean obsolete comment and use shift instead of multiplication
Toomas Soome [Wed, 5 Feb 2020 13:08:24 +0000 (13:08 +0000)]
followup on r357497: clean obsolete comment and use shift instead of multiplication

Based on illumos review feedback: leftover comment, but also
have consistent block size calculation and add missing else leg to if
statement.

(cherry picked from commit 380977d55797c67c052759a9789a4120bd12f792)

2 years agozfsboot: vdev_read_pad2 does allocate buffer with wrong size
Toomas Soome [Wed, 5 Feb 2020 11:02:00 +0000 (11:02 +0000)]
zfsboot: vdev_read_pad2 does allocate buffer with wrong size

vdev_read_pad2() does read VDEV_PAD_SIZE of data, and will copy size bytes
of it, hence, we need buffer of VDEV_PAD_SIZE bytes.

Issue introduced in r357497.

(cherry picked from commit 7503958e4cd57bcfc2b611594906b56c6645e5f4)

2 years agovdev_read_pad2: freeing wrong pointer
Toomas Soome [Wed, 5 Feb 2020 05:42:42 +0000 (05:42 +0000)]
vdev_read_pad2: freeing wrong pointer

Shoud free previously allocated tmp buffer instead. Issue introduced in
r357497.

(cherry picked from commit a1746b25837c2df4367eed7e8c3665e26e0dc6bb)

2 years agoloader: rewrite zfs reader zap code to use malloc
Toomas Soome [Tue, 4 Feb 2020 07:37:55 +0000 (07:37 +0000)]
loader: rewrite zfs reader zap code to use malloc

First step on removing zfs_alloc.

(cherry picked from commit 4d297e7035a4c3e367fd995767ceabaa75bec1ca)

2 years agoRemove comment. We're just going to the next node here.
Warner Losh [Thu, 28 Nov 2019 05:40:10 +0000 (05:40 +0000)]
Remove comment. We're just going to the next node here.

(cherry picked from commit 79cb1bf26f78a580a3cb639f3e45dcd8171be14d)

2 years agocstyle cleanup for i386_copy.c
Toomas Soome [Fri, 8 Nov 2019 12:19:03 +0000 (12:19 +0000)]
cstyle cleanup for i386_copy.c

No functional changes are intended.

(cherry picked from commit 1113c41fef7b1b0ff02d816908f553f4699d9bd1)

2 years agouserboot/test should use PRIx64 as one would expect from prefix 0x
Toomas Soome [Thu, 24 Oct 2019 07:49:33 +0000 (07:49 +0000)]
userboot/test should use PRIx64 as one would expect from prefix 0x

Test is printing decimal value after prefix 0x.

(cherry picked from commit 96b2f9c996c82941b58eceaafe55eb696e8a5a4d)

2 years agoRemove whole-disk vdev support from zfsboot
Patrick Kelsey [Sun, 17 Feb 2019 03:52:44 +0000 (03:52 +0000)]
Remove whole-disk vdev support from zfsboot

This is consistent with the removal of whole-disk vdev support from
libsa/zfs/zfs.c in r342151, and is part way to having the LBAs read
during probe be fully constrained by partition tables when present.

(cherry picked from commit 861729a32e1a723ecfd2c5ba009d108879aa661b)

2 years agoWait a maximum of 300 seconds for network send/recv in libsa
Rebecca Cran [Thu, 20 Dec 2018 19:27:46 +0000 (19:27 +0000)]
Wait a maximum of 300 seconds for network send/recv in libsa

The reason for this change is that currently, a send/recv
takes many hours to time out.
This is suboptimal in the bootloader because it means for example
that NFS will take hours to fail before allowing subsequent access
methods such as gzip to be tried.

Setting MAXWAIT to 300 seconds (5 minutes) still allows slow
connections of 1Mb to be used to download a 30MB kernel file.

(cherry picked from commit d5cee48f3e65662051e15c85e4fc1841d72977fe)

2 years agoNuke out buffer overflow safety marker code.
Maxim Sobolev [Fri, 23 Nov 2018 22:36:56 +0000 (22:36 +0000)]
Nuke out buffer overflow safety marker code.

It duplicates similar code in the malloc()/free() as well as having
potential of softening the handling in case error is detected down to a
mere warning as compared to hard panic in free().

(cherry picked from commit 6c81fe160cb922d35cc740e2fa8be1a9467d139f)

2 years agoloader: zfsimpl.c cstyle cleanup
Toomas Soome [Sun, 15 Dec 2019 14:09:49 +0000 (14:09 +0000)]
loader: zfsimpl.c cstyle cleanup

No functional changes intended.

(cherry picked from commit 2e6bb6553b04d80cf85c9728df6aa4dc66dc020a)

2 years agoReverted: loader: allow booting from pool with log device
Toomas Soome [Sun, 3 Nov 2019 21:36:29 +0000 (21:36 +0000)]
Reverted: loader: allow booting from pool with log device

Apparently people are using log with boot pool, so we can not just
error out there. Still we will need to investigate how to handle
log properly.

(cherry picked from commit f331eb7d346b5e6b33b7e180fc876bfd853ba6ef)
(cherry picked from commit ae3f74e7638b91bdc778fbaee9caeab917190a82)

2 years agoReverted: loader: use struct initializer in vdev_probe().
Toomas Soome [Sun, 10 Nov 2019 15:07:36 +0000 (15:07 +0000)]
Reverted: loader: use struct initializer in vdev_probe().

(cherry picked from commit e5d9d0794881cb6cef879304c35b6d00b499b444)
(cherry picked from commit c082b391b0e24ce69b33482cf77ff13bd1fefe29)

2 years agoReverted: Split out the loader efifb setup to a new function
Andrew Turner [Fri, 26 Feb 2021 11:47:34 +0000 (11:47 +0000)]
Reverted: Split out the loader efifb setup to a new function

(cherry picked from commit c8db60c0673d4bb7a3a3e2c043804e1ed1108c2f)
(cherry picked from commit 773fc43fb060149f8e59c183e5da79feaf118c8c)

2 years agoloader: tftp client should use server address from rootip
Toomas Soome [Mon, 2 Aug 2021 12:27:38 +0000 (15:27 +0300)]
loader: tftp client should use server address from rootip

servip is set from bootp bp_siaddr (if present) and rootip is
set immediately from servip in tha sane bootp code.

However, the common/dev_net.c does only set rootip (based on
url processing etc). Therefore, we should also use rootip in tftp
reader.

Fixes hung tftp based boot when bp_siaddr is not provided.

(cherry picked from commit 1b1bb6f178802a4522824e0268634a99cdbda098)

2 years agoloader: Don't reserve space for symbols twice.
Warner Losh [Mon, 12 Jul 2021 21:17:05 +0000 (15:17 -0600)]
loader: Don't reserve space for symbols twice.

The current code bumps lastaddr twice for the symbol table
location. However, the first bump is bogus and results in wasted
space. Remove it.

PR: 110995

(cherry picked from commit 297e9f364b5aa243572ee52b1faef9b3542c1c9e)

2 years agoloader: Fix dtb loading
Emmanuel Vadot [Mon, 5 Jul 2021 13:50:39 +0000 (15:50 +0200)]
loader: Fix dtb loading

When calling file_findfile with only a type it returns
the first file matching the type. But in fdt_apply_overlays we
then iterate on the next files and try loading them as dtb overlays.
Fix this by checking the type one more time.

Reported by: Mark Millard <marklmi@yahoo.com>

(cherry picked from commit b464c459eaf4e63a3abaaa1ecf51c9d6e9f7521e)

2 years agoUpdate the EFI timer to be called once a second
Andrew Turner [Wed, 12 May 2021 08:59:04 +0000 (08:59 +0000)]
Update the EFI timer to be called once a second

There is no need to call it evert 10ms when we need 1s granularity.
Update to update the time every second.

(cherry picked from commit 93f7be080f3ad0bd71190d87aa2043d714270206)

2 years agoLoader: support booting OS from memory disk (MD)
Yongbo Yao [Wed, 7 Apr 2021 18:33:22 +0000 (13:33 -0500)]
Loader: support booting OS from memory disk (MD)

Until now, the boot image can be embedded into the loader with
/sys/tools/embed_mfs.sh, and memory disk (MD) is already supported
in loader source. But due to memory disk (MD) driver isn't registered
to the loader yet, the boot image can't be boot from embedded memory
disk.

(cherry picked from commit 5984246f9626fbc3d356ee2d3b3cd159f6d0a7c2)

2 years agoReuse the amd64 loader relocation code on arm64
Andrew Turner [Sun, 17 Jan 2021 18:11:11 +0000 (18:11 +0000)]
Reuse the amd64 loader relocation code on arm64

There is no need to keep multiple copies of the relocation code. The
amd64 code works on arm64 with a few small changes to relocation types.

(cherry picked from commit f6f0b849fb2683feebf2416a793964be0bd05cc5)

2 years agoloader: Partial revert of 987eabdc2ae1
Emmanuel Vadot [Sun, 17 Jan 2021 16:41:25 +0000 (17:41 +0100)]
loader: Partial revert of 987eabdc2ae1

The arm relocation code doesn't not work and make loader not loading
dependancies.

Reported by: Dr. Rolf Jansen <freebsd-rj@obsigna.com>

(cherry picked from commit 0f2434ea000e02e6b1f7f40f489c346c64445242)

2 years agostand/reloc_elf: Handle relative relocations for arm{,64} and riscv
D Scott Phillips [Mon, 21 Sep 2020 22:24:46 +0000 (22:24 +0000)]
stand/reloc_elf: Handle relative relocations for arm{,64} and riscv

Extend the powerpc relative relocation handling from r240782 to a
handful of other architectures.  This is needed to properly read
dependency information from kernel modules.

(cherry picked from commit 987eabdc2ae1c0beba77e4d3b538155e81c7a7d5)

2 years agostand/efihttp: Work around a bug in edk2 http instance reconfiguration
D Scott Phillips [Wed, 9 Sep 2020 16:35:51 +0000 (16:35 +0000)]
stand/efihttp: Work around a bug in edk2 http instance reconfiguration

A bug in the EFI HTTP driver of TianoCore EDK2 causes memory
corruption when an http instance that uses tls is reconfigured,
leading to a crash.

Work around this by forcing a new http instance for each request
instead of reconfiguring the existing one.

The upstream bug report is https://bugzilla.tianocore.org/show_bug.cgi?id=1917

(cherry picked from commit d455cd5ac36f4c1ac76f04e2c2bb4bfb00fe8bcd)

2 years agoZFS: remove duplicate "com.datto:encryption" from loader
Matt Macy [Thu, 27 Aug 2020 21:37:35 +0000 (21:37 +0000)]
ZFS: remove duplicate "com.datto:encryption" from loader

(cherry picked from commit 962619075c531f333b51161b4ec011e1e987ad5a)

2 years agoFix stand/newvers.sh with zsh in sh mode
Alex Richardson [Wed, 12 Aug 2020 15:49:10 +0000 (15:49 +0000)]
Fix stand/newvers.sh with zsh in sh mode

When building on macOS with sh==zsh, newvers.sh was producing an
unterminated string literal due to \\n being turned as a newline. Fix this
by using a here document instead.

(cherry picked from commit cad2917baf6e8d90720f5bfb2463dfa7be35f568)

2 years agoFix compilation error for install.c in loader
Stephen J. Kiernan [Fri, 31 Jul 2020 16:08:25 +0000 (16:08 +0000)]
Fix compilation error for install.c in loader

Fix typo in interp_include() invocation (missing 'p')
Remove setting tftpip, as servip is used by the tftp code in libsa. There
is no separate tftpip global variable any more.

(cherry picked from commit fafe230db0cd8d96ac5f3f74643e0c71e949d623)

2 years agoloader: geli_dev_ioctl does return huge mediasize
Toomas Soome [Tue, 7 Jul 2020 12:24:40 +0000 (12:24 +0000)]
loader: geli_dev_ioctl does return huge mediasize

The DIOCGMEDIASIZE is calculated md->md_sectorsize * md->md_provsize, and
for boot disk, the md_sectorsize is 4k. However, the md_provsize is already
in units of bytes.

(cherry picked from commit 0d1a62068123df267e20530c86d2fc7a4e1aaa2e)

2 years agoAs with r352446 align blocks in boot1.efi
Andrew Turner [Tue, 5 May 2020 09:42:26 +0000 (09:42 +0000)]
As with r352446 align blocks in boot1.efi

We need to ensure the buffers are aligned before passing them to ReadBlocks.
Assume 512 bytes is enough for now.

(cherry picked from commit 3d5e12ebce94791aa0d6df3e81e7a8ac48ee4b51)

2 years agoBuild the arm64 loader with -ffixed-x18
Andrew Turner [Fri, 24 Apr 2020 10:03:11 +0000 (10:03 +0000)]
Build the arm64 loader with -ffixed-x18

This stops the compiler from using the x18 register. Some UEFI
implementations assume this will be preserved when calling the Boot
Services.

(cherry picked from commit a2e2311a40696e39eb24ff4a4d4c0968bba42c8c)

2 years agoloader: misaligned access of dos_partition structure
Toomas Soome [Thu, 19 Mar 2020 17:27:08 +0000 (17:27 +0000)]
loader: misaligned access of dos_partition structure

armv7 crash due to misligned access of dos_partition dp_start field.

Allocate and make copy of dos_partition array to make sure the data
is aligned.

(cherry picked from commit 87d8d5ea3dd0a8ad2c0468660805017d6d45d937)

2 years agoloader: alloc_pread() should set errno if malloc fails
Toomas Soome [Sun, 23 Feb 2020 15:21:15 +0000 (15:21 +0000)]
loader: alloc_pread() should set errno if malloc fails

We may want to find out why alloc_pread() failed.

(cherry picked from commit 91e697162c272aa81f375d3294e43cea97e8c4cd)

2 years agoefi_register_handles() is missing NULL pointer check
Toomas Soome [Thu, 20 Feb 2020 09:02:59 +0000 (09:02 +0000)]
efi_register_handles() is missing NULL pointer check

Add missing check of malloc() result.

(cherry picked from commit 4a82db5fe718a6b4abaf4de7f5d82563dc2f98df)

2 years agoinsert_zfs() is missing NULL pointer check
Toomas Soome [Thu, 20 Feb 2020 09:00:20 +0000 (09:00 +0000)]
insert_zfs() is missing NULL pointer check

Add missing check of malloc() result.

(cherry picked from commit 7afa0d95e212a612b2990c975082757c44c3b50f)

2 years agoefipart_inithandles() is missing NULL pointer check
Toomas Soome [Thu, 20 Feb 2020 08:56:56 +0000 (08:56 +0000)]
efipart_inithandles() is missing NULL pointer check

Add missing check of malloc() result.

(cherry picked from commit 79cbcdcf3ececdb45f02c528d00e53e9600a4f48)

2 years agoconnect_controllers() is missing NULL pointer check
Toomas Soome [Thu, 20 Feb 2020 08:55:18 +0000 (08:55 +0000)]
connect_controllers() is missing NULL pointer check

Add missing check of malloc() result.

(cherry picked from commit ef91a071ac534ed1293f624e4e205916da8f30a4)

2 years agoefihttp_fs_seek() is missing NULL pointer check
Toomas Soome [Thu, 20 Feb 2020 08:53:04 +0000 (08:53 +0000)]
efihttp_fs_seek() is missing NULL pointer check

Add missing check of malloc() result.

(cherry picked from commit 8abc11f65c828a58263e4b4a8eac70fdf7082792)

2 years agoefinet_dev_init() is missing NULL pointer check
Toomas Soome [Thu, 20 Feb 2020 08:48:34 +0000 (08:48 +0000)]
efinet_dev_init() is missing NULL pointer check

Add missing check of malloc() result.

(cherry picked from commit 860545e20b8f09881973b828863f55141fb2250e)

2 years agoIn gptboot, don't assume a partition number is a single digit, 1-9. GPT
Ian Lepore [Sun, 22 Dec 2019 22:33:22 +0000 (22:33 +0000)]
In gptboot, don't assume a partition number is a single digit, 1-9.  GPT
partitions can have 128 partitions, so parse contiguous digits and then
validate that the number is between 1-128 inclusive.

I'm not sure 128 is a hard limit in the GPT standard, but it's the common
number in use, and it's a better upper limit than 9.

(cherry picked from commit 42e08952bb84aa86dfdcc7b80c95b58e515bdce7)

2 years agoUse symbolic names for int13 calls
Warner Losh [Mon, 16 Dec 2019 21:52:12 +0000 (21:52 +0000)]
Use symbolic names for int13 calls

For all the INT13 calls, use symbolic names instead of magic numbers. This makes
it easier to understand what the code is doing w/o a trip to google to find what
these numbers mean.

(cherry picked from commit 7f5499972e115cafc861ec438cd7237422cd9b7c)

2 years agoloader.efi: print ImageBase so we know where we are
Toomas Soome [Fri, 6 Dec 2019 09:50:29 +0000 (09:50 +0000)]
loader.efi: print ImageBase so we know where we are

Output a bit of debugging aid.

(cherry picked from commit fed13eb3e8d6091dcfae45e7652835d519306abe)

2 years agoloader.efi: Default to serial if we don't have a ConOut variable
Emmanuel Vadot [Fri, 8 Nov 2019 20:08:44 +0000 (20:08 +0000)]
loader.efi: Default to serial if we don't have a ConOut variable

In the EFI implementation in U-Boot no ConOut efi variable is created,
this cause loader to fallback to TERM_EMU implementation which is very
very very slow (and uses the ConOut device in the system table anyway).
The UEFI spec aren't clear as if this variable needs to exists or not.

(cherry picked from commit 14fb9485a4dc9c8212bfae6c2049cb4930f4b8e5)

2 years agoloader: show APFS partition type name
Toomas Soome [Mon, 4 Nov 2019 12:20:19 +0000 (12:20 +0000)]
loader: show APFS partition type name

Add small visual aid in lsdev output.

(cherry picked from commit 124003d5870a2da22648cfd8d9a71fda4f0d64a7)

2 years agoloader: zfs.c is missing malloc checks, fix it
Toomas Soome [Sun, 3 Nov 2019 14:36:16 +0000 (14:36 +0000)]
loader: zfs.c is missing malloc checks, fix it

malloc() can return NULL, we need to check the return value.

(cherry picked from commit 21da9f14f6144429874a286bfe21a16cbb0dbabd)

2 years agoloader: should check malloc in zfs_dev_open
Toomas Soome [Sun, 3 Nov 2019 13:03:47 +0000 (13:03 +0000)]
loader: should check malloc in zfs_dev_open

malloc can return NULL.

(cherry picked from commit f4ed0045735d88aa681b4933072ff35a890a86a0)

2 years agoloader: userboot/test should accept more than one disk
Toomas Soome [Sun, 3 Nov 2019 09:14:29 +0000 (09:14 +0000)]
loader: userboot/test should accept more than one disk

allow to specify multiple -d options, test -d disk1 -d disk2 ..

(cherry picked from commit bcbb1e60a1c181310a7ce36af2c202fa789d03e5)

2 years agopthread_mutexattr(3): document each pthread_mutexattr_set/get* function
Konstantin Belousov [Fri, 1 Oct 2021 01:39:39 +0000 (04:39 +0300)]
pthread_mutexattr(3): document each pthread_mutexattr_set/get* function

(cherry picked from commit be6116fdfc4d292b77b3df7d4dda029d26a73d65)

2 years agolibthr(3): explain some internals of the locks implementation
Konstantin Belousov [Fri, 1 Oct 2021 01:17:02 +0000 (04:17 +0300)]
libthr(3): explain some internals of the locks implementation

(cherry picked from commit f5b9747075a9b489226e2a911f8a1597f4b9d072)

2 years agopthread_mutexattr(3): install pthread_mutexattr_get/setpshared links
Konstantin Belousov [Fri, 1 Oct 2021 00:53:44 +0000 (03:53 +0300)]
pthread_mutexattr(3): install pthread_mutexattr_get/setpshared links

(cherry picked from commit 6bda192013fc8e6c994098fe262f2a74f424cb57)

2 years agopthread_mutexattr(3): document pthread_mutexattr_set/getpshared
Konstantin Belousov [Fri, 1 Oct 2021 00:46:16 +0000 (03:46 +0300)]
pthread_mutexattr(3): document pthread_mutexattr_set/getpshared

(cherry picked from commit 0a6e5fc29b43778bd004f7754c730e41a9ce2675)

2 years agopthread_mutexattr(3): use .Fo/.Fc to avoid too long lines
Konstantin Belousov [Fri, 1 Oct 2021 00:40:19 +0000 (03:40 +0300)]
pthread_mutexattr(3): use .Fo/.Fc to avoid too long lines

(cherry picked from commit 9f3b6cdbe87cf92d4099f3f5ff8eff3030a8076b)

2 years agofusefs: don't panic if FUSE_GETATTR fails durint VOP_GETPAGES
Konstantin Belousov [Thu, 16 Sep 2021 23:53:58 +0000 (02:53 +0300)]
fusefs: don't panic if FUSE_GETATTR fails durint VOP_GETPAGES

During VOP_GETPAGES, fusefs needs to determine the file's length, which
could require a FUSE_GETATTR operation.  If that fails, it's better to
SIGBUS than panic.

Sponsored by: Axcient
Reviewed by:  markj, kib
Differential Revision: https://reviews.freebsd.org/D31994

(cherry picked from commit 4f917847c9037d9b76de188c03e13b81224431b2)

buffer pager: allow get_blksize method to return error

Reported and reviewed by: asomers
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D31998

(cherry picked from commit 197a4f29f39e6ae6215a6dbd28ef449d305e6d49)

2 years agoses: Guard the elm_type_names declaration by _KERNEL
Alan Somers [Mon, 30 Aug 2021 20:45:13 +0000 (14:45 -0600)]
ses: Guard the elm_type_names declaration by _KERNEL

Sponsored by: Axcient

(cherry picked from commit cc2d08d3880c2e726849ab2aa23b3d15f8aa3938)

2 years agoses: Correct spelling of "Temperature Sensor"
Alan Somers [Mon, 30 Aug 2021 19:59:32 +0000 (13:59 -0600)]
ses: Correct spelling of "Temperature Sensor"

According to SES 4 revision 2 table 71, it should be singular.

Sponsored by: Axcient

(cherry picked from commit 1fb52e4373e7f645d71059a6a403469f059044c8)

2 years agoperiodic: by default, skip 221.backup-gpart in jails
Alan Somers [Fri, 18 Jun 2021 14:33:08 +0000 (08:33 -0600)]
periodic: by default, skip 221.backup-gpart in jails

It can still be enabled as usual in /etc/periodic.conf

PR: 256253
Reported by: delphij
Submitted by: Miroslav Lachman <000.fbsd@quip.cz>

(cherry picked from commit fcf2227a557552e45646bbcf2422a98baab5c8a8)

2 years agovinvalbuf: do not panic if we were unable to flush dirty buffers
Konstantin Belousov [Sun, 30 May 2021 16:52:42 +0000 (19:52 +0300)]
vinvalbuf: do not panic if we were unable to flush dirty buffers

Return EBUSY instead and let caller to handle the issue.

For vgone()/vnode reclamation, caller first does vinvalbuf(V_SAVE),
which return EBUSY in case dirty buffers where not flushed. Then caller
calls vinvalbuf(0) due to non-zero return, which gets rid of all dirty
buffers without dependencies.

PR: 238565
Reviewed by: asomers, mckusick
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D30555

(cherry picked from commit 27006229f7a40a18a61a0e8fd270bc583326b690)

fusefs: reenable the WriteCluster.cluster_write_err test

The underlying panic was just fixed by
revision 27006229f7a40a18a61a0e8fd270bc583326b690

PR: 238565
(cherry picked from commit 425bbe9e64f7af6bdb30a099bd90a32885de1ab8)

2 years agogmultipath: make physpath distinct from the underlying providers'
Alan Somers [Thu, 22 Apr 2021 21:09:03 +0000 (15:09 -0600)]
gmultipath: make physpath distinct from the underlying providers'

zfsd uses a device's physical path attribute to automatically replace a
missing ZFS disk when a blank disk is inserted into the same physical
slot.  Currently gmultipath passes through its underlying providers'
physical path attribute.  That may cause zfsd to replace a missing
gmultipath provider with a newly arrived, single-path disk.  That would
be bad.

This commit fixes that problem by simply appending "/mp" to the
underlying providers' physical path, in a manner similar to what geli
already does.

Sponsored by: Axcient
Differential Revision: https://reviews.freebsd.org/D29941

(cherry picked from commit 420dbe763f15b076751443edfeeb4f676deb3c44)

2 years agodaemon: add some basic tests
Alan Somers [Wed, 17 Mar 2021 16:35:00 +0000 (10:35 -0600)]
daemon: add some basic tests

Sponsored by: Axcient
Differential Revision: https://reviews.freebsd.org/D29316

(cherry picked from commit 3b57d80c7aa924ed0fad565591f5292c2ac88da5)

2 years agoICMP checksum test: Fix for big endian
Charlie Root [Tue, 12 Jan 2021 01:56:12 +0000 (18:56 -0700)]
ICMP checksum test: Fix for big endian

The in_cksum tests originally tried to simulate a BE environment by
swapping the byte order of the input.  But that's overcomplicated, and
didn't actually work on real BE hardware.  The correct testing strategy
is just to test on the native endianness, and run the tests in both BE
and LE environments.

Submitted by: Renato Riolino <renato.riolino@eldorado.org.br>
Reviewed By: asomers
Differential Revision: https://reviews.freebsd.org/D23193

(cherry picked from commit 292808246db702b9194deb8938e40fd06914aea9)

2 years agoMFC uipc_shm: Fix kern.ipc.posix_shm_list for jails
Jamie Gritton [Wed, 29 Sep 2021 17:20:36 +0000 (10:20 -0700)]
MFC uipc_shm: Fix kern.ipc.posix_shm_list for jails

Fix error return of kern.ipc.posix_shm_list, which caused it (and thus
"posixshmcontrol ls") to fail for all jails that didn't happen to own
the last shm object in the list.

(cherry picked from commit 747a47261eee59b6e9c437cd2c1b3979df5c32ac)

2 years agoBackout 356693. The libsa malloc does provide necessary alignment and
Toomas Soome [Mon, 13 Jan 2020 20:02:27 +0000 (20:02 +0000)]
Backout 356693. The libsa malloc does provide necessary alignment and
memalign by 4 will reduce alignment for some platforms. Thanks for Ian for
pointing this out.

(cherry picked from commit aaeffe5b7064536dc7f4ea75a58125ec69d2706b)