Commit graph

450 commits

Author SHA1 Message Date
Andrew Turner 9f44638ef2 stand/efi: Fix for binutils when targeting arm64
When linking with ld.bfd it complain with the following:

/usr/local/bin/aarch64-unknown-freebsd14.0-ld: start.o: relocation
 R_AARCH64_ABS32 against `__data_size' can not be used when making a
 shared object

Fix this by marking the __data_size with ABSOLUTE. This returns a
non-relocatable value which appears to be the same behaviour of lld.

Reviewed by:	imp
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45257
2024-05-22 08:17:26 +00:00
Warner Losh 2d425b634f loader: c_init returns 0 or 1
c_init returns 0 (success) or 1 (failure). Don't return other values.

Sponsored by:		Netflix
2024-05-19 22:05:42 -06:00
Warner Losh b3551da9cd efi_console: Use c99 initializers
Sponsored by:		Netflix
2024-05-19 22:05:42 -06:00
Warner Losh 75e5f5916e boot1.efi: Don't redundantly include devpath.c
devpath.c is on both the comand line and in libefi. This is redundant
and was a mistake in 4cf36aa101. It never should have been here. In
practice, this just means that the devpath.o from libefi.a goes unused.
This will cause problems with some upcoming changes (D44872) to enable
LTO to reduce the size of the binaries, so go ahead and make the change
now to reduce the changeset for that. No functional change indended.

Fixes:		4cf36aa101
Co-authored-by:	sobomax
Sponsored by:	Netflix
2024-05-07 08:53:50 -06:00
Warner Losh cfcf475a66 stand: Install gptboot.efi(8)
We need to include bsd.init.mk first when we have man pages in the boot
loader.

Sponsored by:		Netflix
2024-04-05 16:53:47 -06:00
Stephen J. Kiernan fe429e6794 stand/efi: Changes to efichar to allow it to be used in the kernel
Replace malloc/free with EFICHAR_MALLOC and EFICHAR_FREEE macros.

Obtained from:	Juniper Networks, Inc.
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D44541
2024-03-28 14:09:37 -04:00
Warner Losh 2425dbdff3 loader/efi: Small diff reduction
Make doing the boot once protocol more similar to copies of this code.

Sponsored by:		Netflix
Reviewed by:		manu
Differential Revision:	https://reviews.freebsd.org/D44007
2024-02-29 09:14:47 -07:00
Warner Losh f5f08e41aa loader/efi: Only include interpreter's linker script
For safety, only include the interpreter's linker script. Note that the
simple loader doesn't have one, but it's not an error to copy a ELF
section that does not exist. No functional change, however.

Sponsored by:		Netflix
Reviewed by:		tsoome, kevans
Differential Revision:	https://reviews.freebsd.org/D44064
2024-02-24 17:57:29 -07:00
Warner Losh 8ec8413faa loader/ficl: Rename the ficl compile set to X4th_compile_set
And upcoming change will need this set to be named this. Since it's only
used in the efi Makefile, and inside if ficl itself, the change should
be a nop.

Sponsored by:		Netflix
Reviewed by:		tsoome, kevans
Differential Revision:	https://reviews.freebsd.org/D44063
2024-02-24 17:57:21 -07:00
Warner Losh b4e85f760b loader/efi: Use unique linker set for lua
After the linker set cleanup in ldscripts, there's now only one place we
need to know the linkerset name, so go ahead and change the lua
interpreter augmentation linker set to be uniquely named.

Sponsored by:		Netflix
Reviewed by:		tsoome, kevans
Differential Revision:	https://reviews.freebsd.org/D44062
2024-02-24 17:57:13 -07:00
Warner Losh d024bc7ff5 loader/efi: Linker sets not needed.
We don't need linker sets listed as sections. They are explicitly
included in the objcopy we use to create the .efi file. This practice
was added in 2002 by peter@ in a6d81d83a2 to make ia64 builds
self-hosted. However, it was added back to the objcopy in 2010 by rpaulo
in 8df7a05edd for i386 EFI support, though the ldscript file then
retained them needlessly. The gcc/binutils bug having been fixed in the
interim. We've not needed them since then, but the redundancy didn't
matter.

Sponsored by:		Netflix
Reviewed by:		tsoome, kevans
Differential Revision:	https://reviews.freebsd.org/D44061
2024-02-24 17:57:04 -07:00
Warner Losh 5b3b9a5858 loader: Move ldscripts to match more standard practices
In the larger open source community, ld scripts are foo.ldscrpt rather
than ldscript.arch like we use here. This moves the EFI ldscripts.

Sponsored by:		Netflix
Reviewed by:		tsoome, kevans, emaste
Differential Revision:	https://reviews.freebsd.org/D44056
2024-02-24 17:56:14 -07:00
Warner Losh 3e15b01d69 libsa: Remove redundant sys/cdefs.h
Sponsored by:		Netflix
2024-02-22 09:31:57 -07:00
Warner Losh b2822c40f6 loader/efi: Make gcc friendlier by move md_dev
Move the extern struct devsw md_dev out of the function. gcc is happier
with this arrangemnt often. However, we really should move it to a
header file, but that requires a bit of a rework of md support and
config.

Sponsored by:		Netflix
Reviewed by:		manu, tsoome
Differential Revision:	https://reviews.freebsd.org/D44008
2024-02-21 08:51:34 -07:00
Warner Losh 32568e5f24 loader: Retire CTASSERT
The project is moving away from CTASSERT in favor of
_Static_assert. Cleanup the few instances in the loader proactively.

Sponsored by:		Netflix
Reviewed by:		manu, tsoome
Differential Revision:	https://reviews.freebsd.org/D44006
2024-02-21 08:51:34 -07:00
Simon J. Gerraty f616d61ab6 libsecureboot do not report expected unverified files
By default only report unverified files at severity VE_WANT
and above.  This inlcudes *.conf but not *.hints, *.cookie
or *.tgz which get VE_TRY as their severity.

If Verbose is set to 0, then VerifyFlags should default to 0 too.
Thus the combination of

	module_verbose=0
	VE_VEBOSE=0

is sufficient to make the loader almost totally silent.

When verify_prep has to find_manifest and it is verified ok
return VE_NOT_CHECKED to verify_file so that it can skip
repeating verify_fd

Also add better debugging output for is_verified and add_verify_status.

vectx handle compressed modules

When verifying a compressed module (.ko.gz or .ko.bz2)
stat() reports the size as -1 (unknown).
vectx_lseek needs to spot this during closing - and just read until
EOF is hit.

Note: because of the way libsa's open() works, verify_prep will see
the path to be verified as module.ko not module.ko.bz2 etc.  This is
actually ok, because we need a separate module.ko.bz2 entry so that
the package can be verified, and the hash for module.ko is of the
uncompressed file which is what vectx will see.

Re-work local.trust.mk so site.trust.mk need only set
VE_SIGN_URL_LIST (if using the mentioned signing server)

interp.c: restrict interactive input

Apply the same restrictions to interactive input as for
unverified conf and hints files.

Use version.veriexec when LOADER_VERIEXEC is yes

Reviewed by:	kevans
Sponsored by:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D43810
2024-02-12 14:35:01 -08:00
Warner Losh 064fa628ce loader: For EFI, if we don't have ConOut, try ConIn
Try ConIn if we don't have a ConOut variable. ConIn will contain HID
devices and/or serial devices. We currently just search for serial
devices and will use them instead of video with the current code. While
ConIn w/o ConOut is fairly common on laptops, is kinda rare on servers.
Some refinement may be needed in the future if servers come to
light. This is also minimal to allow possible integration into 13.3
release.

MFC After:		1 week
Sponsored by:		Netflix
Reviewed by:		dab, tsoome
Differential Revision:	https://reviews.freebsd.org/D43714
2024-02-04 14:09:48 -07:00
Warner Losh 784f925e50 loader: Font module is EFI dependent
The font module is part of the gfx_fb support. Since we share this file
between EFI and kboot, we only want to pass the font data to the kernel
when we're booting from EFI, not kboot.

Sponsored by:		Netflix
2024-02-02 14:01:04 -07:00
Warner Losh dcc20bced5 stand: Use modern function definitions
Use modern function definitions for functions with no args.

Sponsored by:		Netflix
2024-01-28 13:04:31 -07:00
Dag-Erling Smørgrav 7edbf69b79 stand: Add 1440p to the list of known resolutions.
MFC after:	1 week
Reviewed by:	manu, kevans, imp
Differential Revision:	https://reviews.freebsd.org/D43391
2024-01-23 15:20:27 +01:00
Jose Luis Duran ed76a9506a stand: Fix typo (triple S)
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/955
2023-12-27 20:24:31 -07:00
Kyle Evans e183039f08 loader: lua: assume late ACPI detection if the feature isn't enabled
While we're here, enable the feature in the places we detect ACPI.  This
lets us side-step the existing issues and provide a path forward for
folks upgrading from previous releases that haven't updated their ESP
yet.

Let's also fix core.setACPI: the hint already indicates that the
user's disabled it more consistently than loader.acpi_disabled_by_user.
Even more, the latter is wrong because we set it by default if we did
not detect ACPI.  The ACPI hint remains even when we're setting defaults
because ACPI loaded into the kernel will make some noise if it's not
hinted off, even when we didn't detect it.

imp notes that this will result in some relatively harmless noise on
platforms that don't support ACPI but aren't using the UEFI loader, as
we would enable the ACPI module for loading on them and then loader
would not be able to find it.  These are non-fatal, but should probably
be fixed by just declaring support for EARLY_ACPI in those loaders since
we know they won't have ACPI early on -- punting on this for the time
being, though, in favor of providing a safer upgrade path sooner.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D42727
2023-12-08 15:43:59 -06:00
Warner Losh 7c43148a97 stand: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by:		Netflix
2023-11-26 22:24:00 -07:00
Warner Losh 7a1bc422d1 stand/efi: Consolidate integer types
We have no need for 5 different copies of these.

Sponsored by:		Netflix
Reviewed by:		rcm, kevans, andrew
Differential Revision:	https://reviews.freebsd.org/D42699
2023-11-21 19:58:20 -07:00
Warner Losh e4789047ff stand/efi: Define ACPI_USE_SYSTEM_INTTYPES to be 1 instead of blank
To avoid a redefinition warning... This needs to be redone correctly,
but this gets amd64 building again...  My amd64 environment is polluted
with something that caues earlier failures which I ignored...

Fixes:		488bc7e9a7
Sponsored by:	Netflix
2023-11-21 11:38:46 -07:00
Warner Losh 488bc7e9a7 stand/efi: Request ACPI use the system inttypes
With the system inttypes, we build on all platforms again.

Suggested by:	andrew
Fixes:		0b01d45783
Sponsored by:	Netflix
2023-11-21 08:59:05 -07:00
R. Christian McDonald 0b01d45783 loader: fix EFI ACPI detection
lua was previously unable to determine ACPI presence because this
probing was postponed until the final loading and execution of the
kernel.

This patch resolves that by detecting ACPI early (similar to
the order of operations in the legacy i386 loader).

Reviewed by:	kevans
Approved by:	kp
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D42459
2023-11-20 14:03:59 -05:00
Mark Johnston b247ff70e8 stand: Rename LIBFDT to LIBSAFDT
Preemptively address a collision with LIBFDT (to be added in the future)
from src.libnames.mk, which gets included via bsd.progs.mk.  No
functional change intended.

Reviewed by:	imp
MFC after:	1 week
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D42486
2023-11-07 09:57:32 -05:00
Stephen J. Kiernan 2008043f38 loader: add target for dirdeps build
Update dependencies for the loader variations used for each
architecture.

Reviewed by:	sjg
Differential Revision:	https://reviews.freebsd.org/D39741
2023-11-02 19:35:08 -04:00
Stephen J. Kiernan e5b786625f dirdeps: Add missing dependency files
Some leaf directories were missing Makefile.depend files or needed
architecture-specific Makefile.depend.* files.
2023-10-29 17:08:29 -04:00
Gleb Smirnoff d13550f0c9 stand/loader.efi: fix regression with ignoring nvstore
To read/update the boot loader nvstore, we always need to call
zfs_attach_nvstore() regardless of whether we use bootonce key
in nvstore or the bootfs property of the pool.  The call was
unintentionally left in the block of code that is processed
only when bootonce key is present.

In particular this fixes broken 'nextboot -k'.

Reviewed by:		imp
Differential Revision:	https://reviews.freebsd.org/D41795
Fixes:			e3e2681d0e
2023-09-11 11:04:48 -07:00
Warner Losh 05248206f7 Remove $FreeBSD$: one-line bare tag
Remove /^\s*\$FreeBSD\$$\n/
2023-08-16 11:55:20 -06:00
Warner Losh fa9896e082 Remove $FreeBSD$: two-line nroff pattern
Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:10 -06:00
Warner Losh d0b2dbfa0e Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:03 -06:00
Warner Losh 1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Warner Losh 2a63c3be15 Remove $FreeBSD$: one-line .c comment pattern
Remove /^/[*/]\s*\$FreeBSD\$.*\n/
2023-08-16 11:54:29 -06:00
Warner Losh 42b388439b Remove $FreeBSD$: one-line .h pattern
Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:23 -06:00
Warner Losh b3e7694832 Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:16 -06:00
Jessica Clarke 106c9ff5ac stand: Export _start on arm like other architectures
By not exporting _start, we get various warnings of the form:

  ld: warning: cannot find entry symbol _start

Note that in practice these don't matter because we manually construct
our PE header and use objcopy -O binary, so the entry point is set to
whatever we put explicitly in the PE header, but we should still do the
right thing and silence these warnings.

This was found in CheriBSD, where bsd.prog.mk has similar logic to
bsd.lib.mk and sets -Wl,--(no-)fatal-warnings based on LD_FATAL_WARNINGS
(unlike FreeBSD which only does so in the latter).
2023-08-05 01:14:16 +01:00
VexedUXR 3bf9e84f08 Stand: Silence undefined symbols check command
No need to print this...

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/786
2023-07-01 11:16:58 -06:00
John Baldwin b9f56cabed efi loader: Move 'module' variable under #ifdef MODINFOMD_MODULEP.
This quiets a set but unused warning on platforms without this module
info such as aarch64.

Differential Revision:	https://reviews.freebsd.org/D40672
2023-06-27 10:19:32 -07:00
VexedUXR 780332f1c1 loader.efi: Remove redundant error message
efi_copy_init already prints an error message (with more information) if it fails.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/777
2023-06-26 16:57:31 -06:00
Alfonso Gregory 39ae24e3bf bug: efi_print_global only checks for the first 5 letters of "Driver"
As a result, it is only really checking for the word Drive, making
"Drive" appended to anything else considered for efi env.

Reviewed by:	imp, kevans
Pull Request:	https://github.com/freebsd/freebsd-src/pull/738
2023-06-22 22:31:58 -05:00
VexedUXR 6f6213ec90 Add comments for memory size
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/753
2023-06-12 08:57:20 -06:00
VexedUXR a8c1c0b727 Add boot1.efi to CLEANFILES
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/775
2023-06-12 08:41:22 -06:00
Gleb Smirnoff bbc64cf66c stand/boot1.efi: use the bootonce dataset as root dataset
Before this change we would only pass the bootonce dataset name
to the environment for the next loader, while actually reading
the next stage loader from the 'bootfs' dataset, not the bootonce
dataset.

Another problem fixed by this change is a boot from a configuration
when bootonce attribute is present, but 'bootfs' property is not set.

Reviewed by:		imp
Differential Revision:	https://reviews.freebsd.org/D40389
2023-06-08 11:14:45 -07:00
Gleb Smirnoff e3e2681d0e stand/loader.efi: read zfs bootonce attribute before checking currdev
First check if bootonce is configured and if it is, then change currdev
accordingly and after that do the sanity check.  This fixes boot in a
situation when ZFS pool doesn't have the "bootfs" property, but has
bootonce attribute set.  A strange, but legitimate case.

Reviewed by:		tsoome, imp
Differential Revision:	https://reviews.freebsd.org/D40388
2023-06-08 11:14:45 -07:00
Kyle Evans 9ed4ec4ae3 stand: libefi: avoid a null pointer deref in eficom
We don't keep comc_port around anymore if the console's not present, but
some things might still try to set one of the environment variables we
hook.  In particular, one need not even set efi_com_port/efi_com_speed
in loader.conf; loader may do it itself and induce the crash if ConOut
depicts an available uart.

Probably reported by:	dch
OK for now:	imp
2023-05-28 13:54:50 -05:00
Warner Losh 46927f6744 stand/efi/eficom: Free comc_port if we can't find the serial port
If we can't find the serial port, free comc_port and return early. The
serial port just isn't there.

Sponsored by:		Netflix
Reviewed by:		kevans
Differential Revision:	https://reviews.freebsd.org/D40223
2023-05-24 22:33:53 -06:00
Warner Losh e5d4e036f2 stand/efi/eficom: Make aarch64 compat code probe correctly
Make the compat code more correct by probing using the eficom console
structure, not the comconsole one.

Sponsored by:		Netflix
Reviewed by:		kevans
Differential Revision:	https://reviews.freebsd.org/D40222
2023-05-24 22:33:53 -06:00