Commit Graph

1131 Commits

Author SHA1 Message Date
Matt Macy
1ea0b9a5a9 Fix userboot after r364355
r364355 replaced init_zfs_bootenv with init_zfs_boot_options and
neglected to update userboot in the process.
2020-08-25 17:23:33 +00:00
Alex Richardson
0b862b0399 Avoid adding duplicates to SRCS/OBJS/SOBJS/POBJS
This is a change in preparation for stopping to use lorder.sh (D26044) and
instead assume that we have a linker newer than ~1990. Without lorder.sh
duplicates end up being passed to the linker when building .so files and this
can result in duplicate symbol definition errors.

There is one minor change: libcompiler_rt.a will no longer provide
gcc_personality_v0 and instead we now only have it in libgcc_eh.a/libgcc_s.so.
This matches GCC's behaviour.

Reviewed By:	emaste, cem
Differential Revision: https://reviews.freebsd.org/D26042
2020-08-24 09:20:33 +00:00
Gleb Smirnoff
c7dd069c70 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.

Reviewed by:	tsoome
2020-08-20 20:31:47 +00:00
Emmanuel Vadot
9060f2c392 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.

MFC after:	1 week
Sponsored by:	Sponsored-by: The FreeBSD Foundation
2020-08-20 12:50:49 +00:00
Toomas Soome
5949d13fab libsa: remove leftover whitespace
Tiny cleanup, no functional changes.
2020-08-19 20:41:22 +00:00
Toomas Soome
588f0a1e29 libsa: make env_discard() public
Allow env_discard() to be used outside environment.c
2020-08-19 15:27:09 +00:00
Toomas Soome
16aabe28c6 libsa: cstyle cleanup for environment.c
No functional changes.
2020-08-19 15:20:33 +00:00
Mariusz Zaborski
277f38abff zfs: add an option to the bootloader to rewind the ZFS checkpoint
The checkpoints are another way of keeping the state of ZFS.
During the rewind, the pool has to be exported.
This makes checkpoints unusable when using ZFS as root.
Add the option to rewind the ZFS checkpoint at the boot time.
If checkpoint exists, a new option for rewinding a checkpoint will appear in
the bootloader menu.
We fully support boot environments.
If the rewind option is selected, the boot loader will show a list of
boot environments that existed before the checkpoint.

Reviewed by:	tsoome, allanjude, kevans (ok with high-level overview)
Differential Revision:	https://reviews.freebsd.org/D24920
2020-08-18 19:48:04 +00:00
Alex Richardson
cad2917baf 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.

Reviewed By:	imp
Differential Revision: https://reviews.freebsd.org/D26036
2020-08-12 15:49:10 +00:00
Alex Richardson
1a18ab420b Allow overriding the tool used for stripping binaries
Since the make variable STRIP is already used for other purposes, this
uses STRIPBIN (which is also used for the same purpose by install(1).
This allows using LLVM objcopy to strip binaries instead of the in-tree
elftoolchain objcopy. We make use of this in CheriBSD since passing
binaries generated by our toolchain to elftoolchain strip sometimes results
in assertion failures.

This allows working around https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=248516
by specifying STRIPBIN=/path/to/llvm-strip

Obtained from:	CheriBSD
Reviewed By:	emaste, brooks
Differential Revision: https://reviews.freebsd.org/D25988
2020-08-11 16:46:27 +00:00
Alex Richardson
d8e1e85c42 stand: use portable ln -n instead of ln -h
This fixes the build on Linux

Differential Revision: https://reviews.freebsd.org/D24783
2020-08-06 20:46:18 +00:00
Stephen J. Kiernan
fafe230db0 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.

Obtained from:	Juniper Networks, Inc.
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D25897
2020-07-31 16:08:25 +00:00
Jessica Clarke
4f8212c8b2 loader: Avoid -Wpointer-to-int cast warnings for Arm and RISC-V
On RISC-V, Clang warns with:

    cast to smaller integer type 'unsigned int' from 'void (*)(void *)'

Instead, use %p as the standard format specifier for printing pointers.
Whilst Arm's pointer size is the same as unsigned, it's still cleaner to
use the right thing there too.

Reviewed by:	brooks (mentor), emaste
Approved by:	brooks (mentor), emaste
Differential Revision:	https://reviews.freebsd.org/D25718
2020-07-26 18:17:36 +00:00
Simon J. Gerraty
f2be828f97 Revert that! 2020-07-19 23:56:19 +00:00
Simon J. Gerraty
e17f5b1d30 Oops missed Makefile.config 2020-07-19 23:54:00 +00:00
Toomas Soome
97dd57e66c loader: cstyle cleanup
No functional changes intended.

Sponsored by:	Netflix, Klara Inc.
2020-07-19 06:59:09 +00:00
Mitchell Horne
5e697f5f22 Really fix cleandir after r362973
I made an attempt to fix this in r362978, but all it really did was
confine the issue to the $MACHINE_CPUARCH == "riscv" case. The real
problem is that LINKER_FEATURES is not defined here, so bsd.linker.mk
needs to be included.

This error with cleandir only occurs when META_MODE is disabled, which
explains why it was missed by both CI and myself.

Note that this effectively reverts r362978.

Reported by:	mjg
Reviewed by:	imp, kevans (in IRC)
2020-07-14 21:15:16 +00:00
Allan Jude
551d20f044 Loader: explain the syntax of currdev
The origin text was: "Syntax for devices is odd."
That is not very helpful.

PR:		199103
Reviewed by:	kevans, tsoome
Sponsored by:	Klara Inc.
Event:		July 2020 Bugathon
Differential Revision:	https://reviews.freebsd.org/D25629
2020-07-13 02:09:21 +00:00
Toomas Soome
de776da323 loader: implement GELI writes
Bug: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=247482

This patch is based on initial work from allanjude.

PR:		247482
Obtained from:	https://reviews.freebsd.org/D10236
Differential Revision:	https://reviews.freebsd.org/D25605
2020-07-11 06:51:42 +00:00
Warner Losh
71dcf98ddf Properly backout r362998
Correct a small mistake in r363060's backaout of r362998 by reverse-applying
r362998 by hand to loader.conf.

Differential Revision: https://reviews.freebsd.org/D25606
2020-07-10 00:24:06 +00:00
Scott Long
ffc568ba8b Revert r362998, r326999 while a better compatibility strategy is devised. 2020-07-09 22:38:36 +00:00
Toomas Soome
1a4b982e1e 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.

Reviewed by:	allanjude
Sponsored by:	Netflix, Klara Inc.
Differential Revision:	https://reviews.freebsd.org/D25586
2020-07-09 13:19:00 +00:00
Scott Long
13bf6002e5 Fix a example/docs typo from r362998, no functional change. 2020-07-07 20:42:35 +00:00
Scott Long
b302c2e5c9 Migrate the feature of excluding RAM pages to use "excludelist"
as its nomenclature.

MFC after:	1 week
2020-07-07 20:33:11 +00:00
Toomas Soome
0d1a620681 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.

Sponsored by:	Netflix, Klara Inc.
2020-07-07 12:24:40 +00:00
Mitchell Horne
4dfc952a8d Fix cleandir target post r362973
Reported by:	mmacy
2020-07-06 21:39:14 +00:00
Mitchell Horne
2192efc03b RISC-V boot1.efi and loader.efi support
This implementation doesn't have any major deviations from the other EFI
ports. I've copied the boilerplate from arm and arm64.

I've tested this with the following boot flows:
OpenSBI (M-mode) -> u-boot (S-mode) -> loader.efi -> FreeBSD
OpenSBI (M-mode) -> u-boot (S-mode) -> boot1.efi -> loader.efi -> FreeBSD

Due to the way that u-boot handles secondary CPUs, OpenSBI >= v0.7 is required,
as the HSM extension is needed to bring them up explicitly. Because of this,
using BBL as the SBI implementation will not be possible. Additionally, there
are a few recent u-boot changes that are required as well, all of which will be
present in the upcoming v2020.07 release.

Looks good:	emaste
Differential Revision:	https://reviews.freebsd.org/D25135
2020-07-06 18:19:42 +00:00
Toomas Soome
771f100ceb 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.

Sponsored by:	Netflix, Klara Inc.
2020-07-02 07:15:48 +00:00
Toomas Soome
045f497cbc loader: potential memory leak and check return values
Need to free nvlist before return from vdev_from_nvlist().

Sponsored by:	Netflix, Klara Inc.
2020-07-02 07:03:15 +00:00
Toomas Soome
12c470af75 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.

Sponsored by:	Netflix, Klara Inc.
2020-06-30 21:48:58 +00:00
Toomas Soome
b93b14dc75 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.

Obtained from: illumos
MFC after:	1 week
2020-06-26 21:21:35 +00:00
Kyle Evans
28e002cd3e stand: remove redundant declarations
These are picked out by the amd64-gcc6 build; time() is declared in <time.h>
and delay() is declared in <bootstrap.h>. These are the correct places for
these in stand/, so remove the duplicate declarations and make sure the
delay() consumer in libefi that depended on the extra delay() declaration
includes <bootstrap.h>.

MFC after:	1 week
2020-06-23 23:52:43 +00:00
Baptiste Daroussin
5b990a9463 Revert r362466
Such change should not have happen without prior discussion and review.

With hat:	transitioning core
2020-06-22 07:46:24 +00:00
Hans Petter Selasky
7747001b12 Improve wording to be more precise and clear.
No functional change intended.

s/Master Boot/Main Boot/ (also called MBR)

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2020-06-21 13:34:08 +00:00
Toomas Soome
4583682ec1 loader: libofw build is missing sys/list.h after r362431
Add another include path
2020-06-20 08:22:57 +00:00
Toomas Soome
a137f7997e loader: fix libofw build after r362431 2020-06-20 07:46:43 +00:00
Toomas Soome
3830659e99 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.

Sponsored by:	Netflix, Klara Inc.
Differential Revision:	https://reviews.freebsd.org/D25324
2020-06-20 06:23:31 +00:00
Kirk McKusick
34816cb9ae Move the pointers stored in the superblock into a separate
fs_summary_info structure. This change was originally done
by the CheriBSD project as they need larger pointers that
do not fit in the existing superblock.

This cleanup of the superblock eases the task of the commit
that immediately follows this one.

Suggested by: brooks
Reviewed by:  kib
PR:           246983
Sponsored by: Netflix
2020-06-19 01:02:53 +00:00
Toomas Soome
aba2397e74 loader: r362262 did miss the pathlen check
While we are checking the "/dev/" prefix, we can skip the paths shorter than
this prefix.

Sponsored by:	Netflix, Klara Inc.
2020-06-17 10:56:58 +00:00
Toomas Soome
c98740b5e2 loader: strings in nvlist are counted strings, not c-strings
We need to fetch both string size and data, then handle the data.

Reviewed by:	allanjude
Sponsored by:	Netflix, Klara Inc.
2020-06-17 10:41:01 +00:00
Toomas Soome
aeea57c709 loader: vidc_init should also erase the screen
Inject \e[J to erase the initial loader screen. We have two options,
find where out cursor is and use BIOS scroll for data from boot2 or erase the
display and start from origin. Erasing the screen is easier and we also
get the screen buffer initialized.

Sponsored by:	Netflix, Klara Inc.
2020-06-17 08:08:57 +00:00
Toomas Soome
6469d2b422 boot2: need to expand tab output and mask getchar
The BIOS ouput char function does not expand tab.
Mask getchar with 0xFF.

Sponsored by:	Netflix, Klara Inc.
2020-06-16 20:35:00 +00:00
Toomas Soome
467535dcfa 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.

Sponsored by:	Netflix, Klara Inc.
2020-06-16 07:30:34 +00:00
Toomas Soome
f44c441ee6 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.

Sponsored by:	Netflix, Klara Inc.
2020-06-16 07:05:03 +00:00
Toomas Soome
dfdeb45425 zfsboot: cstyle cleanup
No functional changes intended.

Sponsored by:	Netflix, Klara Inc.
2020-06-14 20:57:24 +00:00
Toomas Soome
7f3d93b55b loader.efi: update console after gfx mode change
The gfx mode change should be coordinated with console setup.
2020-06-14 10:13:40 +00:00
Simon J. Gerraty
005ff484b9 Minor cleanup of initialized variables
Sort the list and cleanup trailing white-space

Reviewed by:	stevek
MFC after:	1 week
2020-06-12 21:48:46 +00:00
Andrew Turner
0e281c4f0d Fix the efi serial console in the Arm models.
On some UEFI implementations the ConsOut EFI variable is not a device
path end type so we never move to the next node. Fix this by always
incrementing the device path node pointer, with a sanity check that
the node length is large enough so no two nodes overlap.

While here return failure on malloc failure rather than a NULL pointer
dereference.

Reviewed by:	tsoome, imp (previous version)
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D25202
2020-06-10 09:31:37 +00:00
Simon J. Gerraty
eff7aa697e loader: install allow for more complete device spec in url
Rework to simplify and impose sane url syntax.
That is we allow for file://[devname[:fstype]]/package

Reviewed by:	stevek
MFC after:	1 week
Sponsored by:	Juniper Networks
Differential Revision: https://reviews.freebsd.org//D25134
2020-06-08 18:13:38 +00:00
Kyle Evans
48260b4b53 lualoader: drop the filename and word "LUA" from errors
The filename is nearly always wrong since it's /boot/lua/loader.lua, which
is not useful for diagnostics. The actual errmsg will include a lua filename
if this is relevant.

Dropping "LUA" while we're here because that's almost universally
irrelevant to whatever error follows, unless the error states that it's
actually a lua problem.

Both of these are minor nits that just detract from identifying the
pertinent information.

MFC after:	3 days
2020-06-03 18:29:32 +00:00