History log of /freebsd-current/stand/efi/loader/copy.c
Revision Date Author Comments
# 5360d017 29-May-2024 Ahmad Khalifa <ahmadkhalifa570@gmail.com>

loader: Fix G overflowing for G(4) on 32-bit builds

Prevent G(4) and over from overflowing for 32-bit builds.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1098


# 7c43148a 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

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


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# c16e08e5 11-May-2023 Warner Losh <imp@FreeBSD.org>

stand/efi: Retire i386 support

Remove the i386 ifdefs and files. It never worked.

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


# 95fa2e0a 02-Jan-2023 Robert Clausecker <fuz@fuz.su>

loader.efi: make sure kernel image is executable

The Windows Dev Kit 2023 (Volterra) has an UEFI implementation that maps
EfiLoaderData pages as non-executable. Map the kernel as EfiLoaderCode
to ensure that it can be executed.

With this change and another in review, FreeBSD boots to the mountroot
prompt if hw.pac.enable = 0 is set in loader.conf(5).

Reviewed by: andrew, imp, tsoome
Sponsored by: Berliner Linux User Group e.V.
Sponsored by: spline / FU-Berlin
Differential Revision: https://reviews.freebsd.org/D37931


# e30a0801 04-Sep-2022 Gordon Bergling <gbe@FreeBSD.org>

stand: Remove a double word in a source code comment

- s/the the/the/

MFC after: 3 days


# 9d70108a 21-Aug-2022 Warner Losh <imp@FreeBSD.org>

stand: Use bool for stage_offset_set

stage_offset_set is a boolean, convert it to a bool.

Sponsored by: Netflix


# a765ac11 30-Jun-2022 Ed Maste <emaste@FreeBSD.org>

Remove "All Rights Reserved" from Foundation copyrights

MFC after: 1 week
Sponsored by: The FreeBSD Foundation


# 305ef653 04-Nov-2021 Warner Losh <imp@FreeBSD.org>

efi: switch boot_services_gone to boot_services_active

Turn the presence or absence of boot services into a positive bool (and
change its type to bool). Move declaration to efi.h in the global
variables section.

Sponsored by: Netflix

Reviewed by: tsoome, kib
Differential Revision: https://reviews.freebsd.org/D31814


# b54eec83 26-Aug-2021 Konstantin Belousov <kib@FreeBSD.org>

efi loader: disallow user to configure staging area size less than default

We need to round it up to 2M, for instance. Having staging area too small
might cause the first resize to use negative size for memmove()/memcpy(),
which kills loader.

Tested by: Harry Schmalzbauer <freebsd@omnilan.de>
Sponsored by: The FreeBSD Foundation
MFC after: 1 week


# b8508069 26-Aug-2021 Konstantin Belousov <kib@FreeBSD.org>

Restore the definition of EFI_STAGING_SIZE

The definition can be overridden by users, and before f75caed644a5c it
was in MBs. Make the symbol' unit MB, to be compatible with users
customizations.

Reported and tested by: Harry Schmalzbauer <freebsd@omnilan.de>
Sponsored by: The FreeBSD Foundation
MFC after: 1 week


# 6032b6ba 09-Aug-2021 Konstantin Belousov <kib@FreeBSD.org>

amd64 UEFI loader: enable automatic disable of staging area copying

Discussed with: emaste
Sponsored by: The FreeBSD Foundation
MFC after: 1 month


# f75caed6 10-Jul-2021 Konstantin Belousov <kib@FreeBSD.org>

amd64 UEFI loader: stop copying staging area to 2M physical

On amd64, add a possibility to activate kernel with staging area in place.
Add 'copy_staging' command to control this. For now, by default the
old mode of copying kernel to 2M phys is retained. It is going to be
changed in several weeks.

On amd64, add some slop to the staging area to satisfy both requirements
of the kernel startup allocator, and to have space for minor staging data
increase after the final size is calculated. Add a new command
'staging_slop' to control its size.

Improve staging area resizing, in particular, reallocate it anew if
we cannot grow it neither down nor up.

Reviewed by: kevans, markj
Discussed with: emaste (the delivery plan)
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D31121


# 4d6047ed 17-Dec-2020 Warner Losh <imp@FreeBSD.org>

Drop EFI_STAGING_SIZE back down to 64M

vmware can't cope with anything larger than 64MB. Drop this back to
64MB everywhere but arm.

PR: 251866
MFC After: 1 week


# fd2ef8ef 25-Nov-2020 Maxim Sobolev <sobomax@FreeBSD.org>

Unobfuscate "KERNLOAD" parameter on amd64. This change lines-up amd64 with the
i386 and the rest of supported architectures by defining KERNLOAD in the
vmparam.h and getting rid of magic constant in the linker script, which albeit
documented via comment but isn't programmatically accessible at a compile time.

Use KERNLOAD to eliminate another (matching) magic constant 100 lines down
inside unremarkable TU "copy.c" 3 levels deep in the EFI loader tree.

Reviewed by: markj
Approved by: markj
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D27355


# 67dc6bed 03-Sep-2020 John Baldwin <jhb@FreeBSD.org>

Quiet int-to-pointer-cast warnings on i386 with GCC 9.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D26200


# 2192efc0 06-Jul-2020 Mitchell Horne <mhorne@FreeBSD.org>

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


# afc571b1 08-Mar-2020 Simon J. Gerraty <sjg@FreeBSD.org>

veloader use vectx API for kernel and modules

The vectx API, computes the hash for verifying a file as it is read.
This avoids the overhead of reading files twice - once to verify, then
again to load.

For doing an install via loader, avoiding the need to rewind
large files is critical.

This API is only used for modules, kernel and mdimage as these are the
biggest files read by the loader.
The reduction in boot time depends on how expensive the I/O is
on any given platform. On a fast VM we see 6% improvement.

For install via loader the first file to be verified is likely to be the
kernel, so some of the prep work (finding manifest etc) done by
verify_file() needs to be factored so it can be reused for
vectx_open().

For missing or unrecognized fingerprint entries, we fail
in vectx_open() unless verifying is disabled.

Otherwise fingerprint check happens in vectx_close() and
since this API is only used for files which must be verified
(VE_MUST) we panic if we get an incorrect hash.

Reviewed by: imp,tsoome
MFC after: 1 week
Sponsored by: Juniper Networks
Differential Revision: https://reviews.freebsd.org//D23827


# e6bb174c 27-Nov-2019 Andrew Turner <andrew@FreeBSD.org>

Support kernels larger than EFI_STAGING_SIZE in loader.efi

With a very large kernel or module the staging area may be too small to
hold it. When this is the case try to allocate more space before failing
in the efi copyin/copyout/readin functions.

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


# ec18da7c 17-Aug-2019 Tom Jones <thj@FreeBSD.org>

Reduce size of EFI_STAGING_SIZE to 32 on arm

Reduce the size of the EFI_STAGING area we allocate on arm to 32. On arm SBC
such as the NanoPi-NEOLTS the staging area allocation will fail on the 256MB
model with a staging size of 64.

Reviewed by: bcran, manu
Approved by: bz (mentor)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D21016


# 94e8f7c6 27-Jun-2019 Rebecca Cran <bcran@FreeBSD.org>

Increase EFI_STAGING_SIZE to 100MB on x64

To avoid failures when the large 18MB nvidia.ko module is being loaded,
increase EFI_STAGING_SIZE from 64MB to 100MB on x64 systems.
Leave the other platforms at 64MB.


# ce37b71e 05-Mar-2019 Rebecca Cran <bcran@FreeBSD.org>

Add retry loop around GetMemoryMap call to fix fragmentation bug

The call to BS->AllocatePages can cause the memory map to become framented,
causing BS->GetMemoryMap to return EFI_BUFFER_TOO_SMALL more than once. For
example this can happen on the MinnowBoard Turbot, causing the boot to stop
with an error. Avoid this by calling GetMemoryMap in a loop.

Reviewed by: imp, tsoome, kevans
Differential Revision: https://reviews.freebsd.org/D19341


# 0b600ec4 18-Aug-2018 John Baldwin <jhb@FreeBSD.org>

Fix casts between 64-bit physical addresses and pointers in EFI.

Compiling FreeBSD/i386 with modern GCC triggers warnings for various
places that convert 64-bit EFI_ADDRs to pointers and vice versa.
- Cast pointers to uintptr_t rather than to uint64_t when assigning
to a 64-bit integer.
- Cast 64-bit integers to uintptr_t before a cast to a pointer.

Reviewed by: kevans
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D16586


# ca987d46 14-Nov-2017 Warner Losh <imp@FreeBSD.org>

Move sys/boot to stand. Fix all references to new location

Sponsored by: Netflix