Commit Graph

1171 Commits

Author SHA1 Message Date
Toomas Soome
e416eecbb9 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.
2020-10-22 20:02:02 +00:00
Michal Meloun
5b5438c6f3 Add 'netserver' command to EFI loader.
In some environments is difficult to access bootp/dhcp
configuration as "standard user". Add a command that allows to set
or display the URI of the network server used as "net:" device.
Currently only tftp and nfs protocols are supported.

Typical usage pattern is:
netserver tftp://192.168.168.1/path_to_obj_dir/arm.armv7/sys/GENERIC/
boot net:kernel

Reviewed by:	imp, kevans
MFC after:	4 weeks
Differential Revision: https://reviews.freebsd.org/D26736
2020-10-14 13:13:14 +00:00
Andrew Turner
b9aa4537b2 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.

Reported by:	imp
MFC after:	2 weeks
Sponsored by:	Innovate UK
2020-10-13 16:51:05 +00:00
Warner Losh
e694696956 Force __BMI__ experimental instructions off.
The OpenZFS code that uses the BMI instructions is broken. Forcibly
disable them to prevent their use. When enabled, the build breaks.
This fixes the build when compiled for a core with BMI instructions.
This is the same fix committed in r364777, for the same issue.

Submitted by: Jung-uk Kim
2020-10-13 04:37:57 +00:00
Warner Losh
df13933e33 Add back org.freebsd:zstd_compress to features_for_read
This list is the of features that are allowed on the whole pool,
not the list of features that are implemented.
2020-10-13 03:49:12 +00:00
Warner Losh
9257c69b1c Turn off zstd on aarch64
loader support for zstd and zfs doesn't work for aarch64. Disable it
to unbreak the build.
2020-10-13 02:36:16 +00:00
Warner Losh
2fec3ae896 Add zstd support to the boot loader.
Add support to the _STANDALONE environment enough bits of the kernel
that we can compile it. We still have a small zstd_shim.c since there
were 3 items that were a bit hard to nail down and may be cleaned up
in the future. These go hand in hand with a number of commits to
sys/sys in the past weeks, should this need be MFCd.

Discussed with: mmacy (in review and on IRC/Slack)
Reviewed by: freqlabs (on openzfs repo)
Differential Revision: https://reviews.freebsd.org/D26218
2020-10-12 22:19:07 +00:00
Alex Richardson
253e820a4d Link efi programs with -pie rather than -shared
This was causing build failures in CheriBSD where we were passing -pie
already by default.

Reviewed By:	andrew
Differential Revision: https://reviews.freebsd.org/D24787
2020-10-12 11:27:08 +00:00
Toomas Soome
c50f409c15 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

MFC after:	2 weeks
2020-10-12 09:34:50 +00:00
Gordon Bergling
812b09037d Fix a few mandoc issues
- whitespace at end of input line
- skipping paragraph macro: Pp at the end of Sh
- new sentence, new line
- consider using OS macro: Fx
- AUTHORS section without An macro
- skipping paragraph macro: Pp before Ss
2020-10-09 15:14:19 +00:00
Kyle Evans
546f18f3da lualoader: improve the design of the brand-/logo- mechanism
In the previous world order, any brand/logo was forced to pull in the
drawer and call drawer.add{Brand,Logo} with the name their brand/logo is
taking and a table describing it.

In the new world order, these files just need to return a table that maps
out graphics types to a table of the exact same format as what was
previously being passed back into the drawer. The appeal here is not needing
to grab a reference back to the drawer module and having a cleaner
data-driven looking format for these. The format has been renamed to 'gfx-*'
prefixes and each one can provide a logo and a brand.

drawer.addBrand/drawer.addLogo will remain in place until FreeBSD 13, as
there's no overhead to them and it's not yet worth the break in
compatibility with any pre-existing brands and logos.

Reviewed by:	freqlabs
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D24966
2020-10-04 22:41:43 +00:00
Mateusz Piotrowski
180db5ef22 Correct the documented size of kern.msgbufsize
The correct value is 96KB after r226090.

PR:		249971
Submitted by:	johannes@jo-t.de
MFC after:	3 days
2020-10-02 15:37:51 +00:00
Kyle Evans
94510c294d lualoader: clear up some luacheck warnings
- One (1) unused argument
- One (1) trailing whitespace
- Two (2) "non-standard global" (curenv, rewind)

tools/boot/lua-lint.sh is once again happy.
2020-10-01 14:20:36 +00:00
Warner Losh
6ab1ffcbfe 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.
2020-09-29 16:29:50 +00:00
Warner Losh
8f3b36103b Report the kernel console on the boot screen
Report what console the boot loader is telling the kernel to use:
	o Dual (Serial Primary)
	o Dual (Video Primary)
	o Serial
	o Video

This allows the user to interrupt the boot and tweak the cosnole, if
needed, in a trivial way. Useful for installs where the default
selected may not be quite what you want, or when you are running a
dual setup and need to toggle over to the other console being primary.
The 'c'/'C' keys will do the cycling through the consoles.  Note:
you'll still have to drop into the loader to set details about serial
consoles. And this doesn't change the console the loader is using.

Reviewed by: kevans@
MFC After: 3 days
Differential Revision: https://reviews.freebsd.org/D26573
2020-09-28 16:19:21 +00:00
Warner Losh
d53ed73590 Fix video on PCI heuristic
The video on PCI heuristic was broken. It was supposed to infer a
video device when the last element of the path was a PCI DEVICE PATH
node. However, the last node in the device path is an END node, so
this heuristic never fired.

This leads, among other things, to bhyve only producing output in the
serial connection once we leave the boot loader. This restores the
dual headed boot on bhyve + UEFI (as we did in 11.2), but will favor
serial in the absence of other config which may be a change from 11.2.

MFC After: 3 days
Differential Revision: https://reviews.freebsd.org/D26572
2020-09-28 06:00:39 +00:00
Toomas Soome
1dc762d4fb loader: fix non-zfs build
We can not include zfs headers while building without zfs.

Reported by:	Oscar Holmlund
2020-09-23 19:15:22 +00:00
Toomas Soome
867ae3c38d 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.

Reported by:	Alexander Leidinger
2020-09-23 08:22:14 +00:00
Warner Losh
a5ebda464e Work around cp breakage in current from last week
There was a small window cp was broken. Work around this by using :>
instead of cp /dev/null. Ideally, we'd keep the cp /dev/null in the
build as a regression test, but doing so breaks people that upgraded
during the cp breakage and this is simpler than bootstrapping a
working cp since there's no good __FreeBSD_version sign posts for
that.

Suggested by: lots of people
Too stubborn for his own good: imp
2020-09-23 01:04:25 +00:00
Brandon Bergren
b75abea4d0 [PowerPC64LE] Set up powerpc.powerpc64le architecture
This is the initial set up for PowerPC64LE.

The current plan is for this arch to remain experimental for FreeBSD 13.

This started as a weekend learning project for me and kinda snowballed from
there.

(More to follow momentarily.)

Reviewed by:	imp (earlier version), emaste
Sponsored by:	Tag1 Consulting, Inc.
Differential Revision:	https://reviews.freebsd.org/D26399
2020-09-22 23:49:30 +00:00
Brandon Bergren
0ebbda9718 Tweak ficl definition from r365724
I had overthought how to do the FICL_TRUE change. We do not need to
explicitly specify how big the 0 is before the cast to the correct size.

The same change was suggested by both imp@ and Gunther Nikl independently.

Tested on powerpc.

Reported by:	imp, Gunther Nikl
2020-09-22 23:27:09 +00:00
D Scott Phillips
987eabdc2a 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.

Reviewed by:	jhb
Approved by:	scottl (implicit)
MFC after:	1 week
Sponsored by:	Ampere Computing, Inc.
Differential Revision:	https://reviews.freebsd.org/D26365
2020-09-21 22:24:46 +00:00
Toomas Soome
e307eb94ae loader: zfs should support bootonce an nextboot
bootonce feature is temporary, one time boot, activated by
"bectl activate -t BE", "bectl activate -T BE" will reset the bootonce flag.

By default, the bootonce setting is reset on attempt to boot and the next
boot will use previously active BE.

By setting zfs_bootonce_activate="YES" in rc.conf, the bootonce BE will
be set permanently active.

bootonce dataset name is recorded in boot pool labels, bootenv area.

in case of nextboot, the nextboot_enable boolean variable is recorded in
freebsd:nvstore nvlist, also stored in boot pool label bootenv area.
On boot, the loader will process /boot/nextboot.conf if nextboot_enable
is "YES", and will set nextboot_enable to "NO", preventing /boot/nextboot.conf
processing on next boot.

bootonce and nextboot features are usable in both UEFI and BIOS boot.

To use bootonce/nextboot features, the boot loader needs to be updated on disk;
if loader.efi is stored on ESP, then ESP needs to be updated and
for BIOS boot, stage2 (zfsboot or gptzfsboot) needs to be updated
(gpart or other tools).

At this time, only lua loader is updated.

Sponsored by:	Netflix, Klara Inc.
Differential Revision:	https://reviews.freebsd.org/D25512
2020-09-21 09:01:10 +00:00
Brandon Bergren
1d2a0dce33 [PowerPC] Remove obsolete MK_LOADER_FORCE_LE
In D12421, the ability to compile stand/ in little-endian was added, with the
intention to extend loader.kboot to run in Petitboot.

However, no further work was done, as the kernel then gained self-execution
capabilities as Petitboot was taught to load FreeBSD kernels directly.

The FreeBSD installer on powerpc64 (on POWER8 and POWER9) uses
/boot/etc/kboot.conf instead of loader.

As this option does nothing but cause stand/ to be miscompiled and actively
causes confusion, remove it.

(I have a functioning petitboot loader in my local tree, however, it turned
out to be quite inconvient to use due to the current petitboot plugin design
so I put it on hold.)

Reviewed by:	emaste, imp, jhibbits
Sponsored by:	Tag1 Consulting, Inc.
Differential Revision:	https://reviews.freebsd.org/D26430
2020-09-15 04:22:28 +00:00
Brandon Bergren
9e4c35f867 stand/ficl 64-bit compatibility
Currently, the only thing that prevents a functioning 64-bit FICL build is
a few integer types that were intended to be fixed-width.

Changing them to C99 integer types allows building a functioning 64-bit
FICL.

While this isn't applicable to the default settings of any in-tree loaders,
it is necessary for a future Petitboot loader, due to the requirement that
it be compiled as a 64-bit program.

Reviewed by:	tsoome, imp (earlier revision)
Sponsored by:	Tag1 Consulting, Inc.
Differential Revision:	https://reviews.freebsd.org/D26364
2020-09-14 15:48:30 +00:00
Kyle Evans
ecebb3cc1d Only set WARNS if not defined
This would allow interested parties to do experimental runs with an
environment set appropriately to raise all the warnings throughout the
build; e.g. env WARNS=6 NO_WERROR=yes buildworld.

Not currently touching the numerous instances in ^/tools.

MFC after:	1 week
2020-09-11 13:28:37 +00:00
Andrew Turner
6215ed7c5c Ignore the .interp section in the arm64 EFI loader
When building the loader an unneeded .interp section may be added. Move
this to the unused section region so offsets of used sections don't
change.

Obtained from:	CheriBSD
Sponsored by:	Innovate UK
2020-09-10 14:13:49 +00:00
D Scott Phillips
d455cd5ac3 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

Submitted by:	bcran
Reviewed By:	imp, kevans, tsoome
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D21281
2020-09-09 16:35:51 +00:00
Brandon Bergren
3e91d8268f Fix 64-bit build of libofw.
Adjust a couple of printf() lines that deal with dumping out addresses
to cast to uintmax_t.

This allows building a 64-bit libofw for use in things like a future
Petitboot loader for PowerPC64, and other FDT platforms that require
a 64-bit loader binary and want to use forth.

Sponsored by:	Tag1 Consulting, Inc.
2020-09-08 23:22:11 +00:00
John Baldwin
67dc6bed1f Quiet int-to-pointer-cast warnings on i386 with GCC 9.
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D26200
2020-09-04 00:11:01 +00:00
Warner Losh
ff79e517d1 Update to today's date
Also, fix a whitespace botch
2020-09-01 07:56:28 +00:00
Warner Losh
4c570f6118 Add defines for OpenZFS variables
OZFS is the top of the OpenZFS tree (aka src/sys/contrib/openzfs).
ZFSOSSRC is the path to the OepnZFS sources
ZFSOSINC is the path to the OepnZFS includes

MFC After: 3 days
2020-09-01 07:54:14 +00:00
Warner Losh
2b6d38a1db Very preliminary loader.efi(8) man page 2020-09-01 07:54:09 +00:00
Warner Losh
a855700a04 Document boot1.efi
Crude man page for boo1.efi.
2020-09-01 07:46:27 +00:00
Simon J. Gerraty
ed19b7c525 zalloc_malloc:Free hexdump preceeding buffer when we detect overflow
Move hexdump from stand/common/misc.c to stand/libsa/hexdump.c
(svn cp)
Disable use of pager - causes linking issue for boot1
can be re-enabled by defining HEXDUMP_PAGER.

Reviewed by:	stevek, imp
MFC after:	1 week
Sponsored by:	Juniper Networks
Differential Revision: https://reviews.freebsd.org/D26235
2020-08-29 21:05:43 +00:00
Warner Losh
f9553770c0 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.
2020-08-28 17:36:14 +00:00
Warner Losh
b9c5b43263 Declare time()
Time is used and was accidentally brought in through header
pollution. Declare it in stand.h directly instead.
2020-08-28 05:40:02 +00:00
Matt Macy
962619075c ZFS: remove duplicate "com.datto:encryption" from loader 2020-08-27 21:37:35 +00:00
Toomas Soome
0fec8f03cf libsa: only skein_block.c is using SKEIN_LOOP
Only use SKEIN_LOOP while compiling skein_block.c
2020-08-26 17:52:32 +00:00
Matt Macy
3e1470776b ZFS: whitelist zstd and encryption in the loader
Please note that neither zstd nor encryption is
supported by the loader at this instant. This
change makes it safe to use those features in
one's root pool, but not in one's root dataset.
2020-08-25 23:26:52 +00:00
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