aboutsummaryrefslogtreecommitdiff
path: root/lib/efi_loader/efi_setup.c
AgeCommit message (Collapse)AuthorFilesLines
2021-03-25efi: Add ESRT to the EFI system tableJose Marinho1-0/+6
The ESRT is initialised during efi_init_objlist after efi_initialize_system_table(). The ESRT is recreated from scratch at the following events: - successful UpdateCapsule; - FMP instance install. The code ensures that every ESRT entry has a unique fw_class value. Limitations: - The ESRT is not updated if an FMP instance is uninstalled; - the fields image_type and flags are in the current implementation left undefined. Setting these values will require a per-platform function that returns the image_type/flags as a function of the image fw_class. CC: Heinrich Schuchardt <xypron.glpk@gmx.de> CC: Sughosh Ganu <sughosh.ganu@linaro.org> CC: AKASHI Takahiro <takahiro.akashi@linaro.org> CC: Ilias Apalodimas <ilias.apalodimas@linaro.org> CC: Andre Przywara <andre.przywara@arm.com> CC: Alexander Graf <agraf@csgraf.de> CC: nd@arm.com Signed-off-by: Jose Marinho <jose.marinho@arm.com> Remove two EFI_CALL() indirections. Move ESRT GUID in efidebug's list of GUIDs. Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-01-29efi_loader: switch to non-secure mode laterHeinrich Schuchardt1-4/+0
Some ARMv7 boards using PSCI require to be in secure-mode when booted via 'bootz' or 'bootm'. During distro-boot 'bootefi bootmgr' is called to check if booting via UEFI is possible. With the change we change the switch from secure mode to non-secure mode is moved from the UEFI subsystem setup to just before calling StartImage(). Cc: Jernej Škrabec <jernej.skrabec@gmail.com> Reported by: Andre Przywara <andre.przywara@arm.com> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-12-31efi_loader: Remove unconditional installation of file2 protocol for initrdIlias Apalodimas1-5/+0
Up to now we install the EFI_LOAD_FILE2_PROTOCOL to load an initrd unconditionally. Although we correctly return various EFI exit codes depending on the file status (i.e EFI_NO_MEDIA, EFI_NOT_FOUND etc), the kernel loader only falls back to the cmdline interpreted initrd if the protocol is not installed. This creates a problem for EFI installers, since they won't be able to load their own initrd and start the installation. A following patch introduces a different logic where we search for an initrd path defined in an EFI variable named 'Initrd####'. If the bootmgr is used to launch the EFI payload, we'll will try to match the BootCurrent value and find the corresponding initrd (i.e Boot0000 -> Initrd0000 etc). If the file is found, we'll install the required protocol which the kernel's efi-stub can use and load our initrd. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-12-03efi_loader: capsule: support firmware updateAKASHI Takahiro1-0/+4
A capsule tagged with the guid, EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID, is handled as a firmware update object. What efi_update_capsule() basically does is to load any firmware management protocol (or fmp) drivers contained in a capsule, find out an appropriate fmp driver and then invoke its set_image() interface against each binary in a capsule. In this commit, however, loading drivers is not supported. The result of applying a capsule is set to be stored in "CapsuleXXXX" variable, but its implementation is deferred to a fmp driver. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
2020-12-03efi_loader: capsule: add capsule_on_disk supportAKASHI Takahiro1-0/+8
Capsule data can be loaded into the system either via UpdateCapsule runtime service or files on a file system (of boot device). The latter case is called "capsules on disk", and actual updates will take place at the next boot time. In this commit, we will support capsule on disk mechanism. Please note that U-Boot itself has no notion of "boot device" and all the capsule files to be executed will be detected only if they are located in a specific directory, \EFI\UpdateCapsule, on a device that is identified as a boot device by "BootXXXX" variables. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
2020-12-03efi_loader: define UpdateCapsule apiAKASHI Takahiro1-10/+54
In this commit, skeleton functions for capsule-related API's are added under CONFIG_EFI_UPDATE_CAPSULE configuration. Detailed implementation for a specific capsule type will be added in the succeeding patches. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
2020-12-03efi_loader: Introduce eventlog support for TCG2_PROTOCOLIlias Apalodimas1-6/+6
In the previous patches we only introduced a minimal subset of the EFI_TCG2_PROTOCOL protocol implementing GetCapability(). So let's continue adding features to it, introducing the GetEventLog() and HashLogExtendEvent() functions. In order to do that we first need to construct the eventlog in memory, specifically in EFI_BOOT_SERVICES_DATA memory and a configuration table from EFI_ACPI_MEMORY_NVS. U-Boot won't currently add any events to the log or measure any components, but will expose the necessary EFI APIs for applications to do so. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2020-11-14efi_loader: Add basic EFI_TCG2_PROTOCOL supportIlias Apalodimas1-0/+7
Since U-boot EFI implementation is getting richer it makes sense to add support for EFI_TCG2_PROTOCOL taking advantage of any hardware TPM available on the device. This is the initial implementation of the protocol which only adds support for GetCapability(). It's limited in the newer and safer TPMv2 devices. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Acked-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-09-27efi_loader: installation of EFI_RNG_PROTOCOLHeinrich Schuchardt1-0/+5
Having an EFI_RNG_PROTOCOL without a backing RNG device leads to failure to boot Linux 5.8. Only install the EFI_RNG_PROTOCOL if we have a RNG device. Reported-by: Scott K Logan <logans@cottsay.net> Cc: Neil Armstrong <narmstrong@baylibre.com> Cc: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-07-11efi_loader: OsIndicationsSupported, PlatformLangCodesHeinrich Schuchardt1-28/+31
UEFI variables OsIndicationsSupported, PlatformLangCodes should be read only. Avoid EFI_CALL() for SetVariable(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-07-03efi_loader: export initialization stateHeinrich Schuchardt1-1/+1
Export the UEFI sub-system initialization state. This will allow to treat the setting of UEFI variables during and after initialization differently. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-07-03efi_loader: change efi objects initialization orderAKASHI Takahiro1-3/+4
The simplest solution to revert the commit b32ac16f9a32 ("test/py: fix test_efi_secboot/conftest.py") is to move efi_console_register() forward before efi_disk_register(). Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-05-21efi_loader: initialize root node firstHeinrich Schuchardt1-5/+5
With commit 16ad946f41d3 ("efi_loader: change setup sequence") the detection of block device was moved to the start of the initialization sequence. In the case of virtio devices two handles with the same device path being created. The root node handle should be created before anything else. Reported-by: Ard Biesheuvel <ardb@kernel.org> Fixes: 16ad946f41d3 ("efi_loader: change setup sequence") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-05-04efi_loader: change setup sequenceHeinrich Schuchardt1-5/+5
If we want to restore variables from disk, we need to initialize block devices before variables. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-05-04efi_loader: correct comments for efi_status_tHeinrich Schuchardt1-1/+1
EFI_STATUS is unsigned (UINTN). Hence it cannot be negative. Correct comments for 'Return:'. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-04-16efi_loader: set up secure bootAKASHI Takahiro1-0/+38
The following variable is exported as UEFI specification defines: SignatureSupport: array of GUIDs representing the type of signatures supported by the platform firmware Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
2020-02-28efi_loader: Implement FileLoad2 for initramfs loadingIlias Apalodimas1-0/+5
Following kernel's proposal for an arch-agnostic initrd loading mechanism [1] let's implement the U-boot counterpart. This new approach has a number of advantages compared to what we did up to now. The file is loaded into memory only when requested limiting the area of TOCTOU attacks. Users will be allowed to place the initramfs file on any u-boot accessible partition instead of just the ESP one. Finally this is an attempt of a generic interface across architectures in the linux kernel so it makes sense to support that. The file location is intentionally only supported as a config option argument(CONFIG_EFI_INITRD_FILESPEC), in an effort to enhance security. Although U-boot is not responsible for verifying the integrity of the initramfs, we can enhance the offered security by only accepting a built-in option, which will be naturally verified by UEFI Secure Boot. This can easily change in the future if needed and configure that via ENV or UEFI variable. [1] https://lore.kernel.org/linux-efi/20200207202637.GA3464906@rani.riverdale.lan/T/#m4a25eb33112fab7a22faa0fd65d4d663209af32f Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-02-26efi_loader: implement EFI_RT_PROPERTIES_TABLEHeinrich Schuchardt1-4/+4
UEFI spec 2.8 errata A replaces the RuntimeServicesSupported variable defined in UEFI spec 2.8 by the configuration table EFI_RT_PROPERTIES_TABLE. So let's follow suit. Cc: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Tested-by: Ard Biesheuvel <ardb@kernel.org>
2019-07-06efi_loader: initialization of variable servicesHeinrich Schuchardt1-0/+5
Provide an initialization routine for variable services. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-06-14efi_loader: add RuntimeServicesSupported variableAKASHI Takahiro1-0/+5
This variable is defined in UEFI specification 2.8, section 8.1. Its value should be updated whenever we add any usable runtime services function. Currently we only support SetVirtualAddress() for all systems and ResetSystem() for some. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-05-07efi_loader: clean up UEFI sub-system initializationHeinrich Schuchardt1-0/+16
allow_unaligned(), switch_to_non_secure_mode(), and efi_init_obj_list() are called in sequence in multiple places. Move calls to allow_unaligned() and switch_to_non_secure_mode() to efi_init_obj_list(). Remove unused includes. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-05-02efi_loader: set OsIndicationsSupported at initAKASHI Takahiro1-0/+11
UEFI variables should be installed using well-defined API. Currently we don't support much, but the value of OsIndicationsSupported will be updated once some features are added in the future. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Add comments. Rename a variable. Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-04-12efi_loader: fix setting PlatformLangHeinrich Schuchardt1-15/+57
The UEFI variables PlatformLang and PlatformLangCodes specify the current firmware language and the list of all available languages. Currently their values are hard coded. With the patch a new configuration variable EFI_PLATFORM_LANG_CODES is provided. When initializing the UEFI subsystem this configuration variable is used to initialize PlatformLangCodes. The value of variable PlatformLang is read. If it is not set, the first language specified in EFI_PLATFORM_LANG_CODES is used to initialize PlatformLang. Suggested-by: Takahiro Akashi <takahiro.akashi@linaro.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-04-12efi_loader: move efi_save_gd() call to board_r.cHeinrich Schuchardt1-7/+0
The first functions of the UEFI sub-system are invoked before reaching the U-Boot shell, e.g. efi_set_bootdev(), efi_dp_from_name(), efi_dp_from_file(). We should be able to print out device paths for debugging purposes here. When printing device paths via printf("%pD\n", dp) this invokes functions defined as EFIAPI. So efi_save_gd() must be called beforehand. So let's move the efi_save_gd() call to function initr_reloc_global_data(() in board_r.c. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-04-07efi_loader: variables PlatformLang and PlatformLangCodesHeinrich Schuchardt1-0/+27
Since TianoCore EDK2 commit d65f2cea36d1 ("ShellPkg/CommandLib: Locate proper UnicodeCollation instance") in edk2 the UEFI Shell crashes if EFI variable PlatformLang is not defined. As this variable is anyway prescribed in the UEFI 2.7 spec let's define it to L"en-US". Use the same value for PlatformLangCodes that defines the list of all supported languages. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-02-13efi_loader: move efi_init_obj_list() to a new efi_setup.cAKASHI Takahiro1-0/+86
The function, efi_init_obj_list(), can be shared in different pseudo efi applications, like bootefi/bootmgr as well as my efishell. Moreover, it will be utilized to extend efi initialization, for example, my "removable disk support" patch and "capsule-on-disk support" patch in the future. So with this patch, it will be moved to a new file, efi_setup.c, under lib/efi_loader and exported, making no changes in functionality. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Remove lines deactivated by #if 1 #else Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>