summaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* | efi_loader: efi_signal_event() fix comment typosHeinrich Schuchardt2020-12-311-2/+2
| | | | | | | | | | | | Add missing commas. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: avoid invalid freeHeinrich Schuchardt2020-12-311-1/+1
| | | | | | | | | | | | | | | | load_options passed from do_efibootmgr() to do_bootefi_exec() may contain invalid data from the stack which will lead to an invalid free(). Fixes: 0ad64007feb9 ("efi_loader: set load options in boot manager") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: escape key handlingHeinrich Schuchardt2020-12-311-0/+12
| | | | | | | | | | | | | | | | | | | | Up to now the escape key was not correctly detected in UEFI applications. We had to hit it twice for a single escape to be recognized. Use a 10 ms delay to detect if we are dealing with the escape key or an escape sequence. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: missing parentheses after ifHeinrich Schuchardt2020-12-311-1/+1
| | | | | | | | | | | | | | IS_ENABLED() contains parentheses. But we should still put extra parentheses around it in an if statement for readability. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: Extra checks while opening an OPTEE sessionIlias Apalodimas2020-12-311-5/+15
| | | | | | | | | | | | | | | | | | | | | | | | When opening an OP-TEE session we need to check the internal return value of OP-TEE call arguments as well the return code of the function itself. The code was also ignoring to close the OP-TEE session in case the shared memory registration failed. Fixes: f042e47e8fb43 ("efi_loader: Implement EFI variable handling via OP-TEE") Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: make variable store size customizableHeinrich Schuchardt2020-12-311-0/+14
| | | | | | | | | | | | | | | | | | | | | | Currently the size of the buffer to keep UEFI variables in memory is fixed at 16384 bytes. This size has proven to be too small for some use cases. Make the size of the memory buffer for UEFI variables customizable. Reported-by: Paulo Alcantara (SUSE) <pc@cjr.nz> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* | fdt: Use phandle to distinguish DT nodes with same nameAswath Govindraju2020-12-222-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While assigning the sequence number to subsystem instances by reading the aliases property, only DT nodes names are compared and not the complete path. This causes a problem when there are two DT nodes with same name but have different paths. In arch/arm/dts/k3-am65-main.dtsi there are two USB controllers with the same device tree node name but different path. When aliases are defined for these USB controllers then fdtdec_get_alias_seq() fails to pick the correct instance for a given index. fdt_path_offset() function is slow and this would effect the U-Boot startup. To avert the time penalty on all boards, apply this extra check only when required by using a config option. Fix it by comparing the phandles of DT nodes after the node names match, under a config option. Signed-off-by: Aswath Govindraju <a-govindraju@ti.com> Reviewed-by: Simon Glass <sjg@chromium.org> Fix whitespace error in Kconfig: Signed-off-by: Simon Glass <sjg@chromium.org>
* | sandbox: implement runtime system resetHeinrich Schuchardt2020-12-221-1/+2
| | | | | | | | | | | | | | | | Implement a reset function that we can call after ExitBootServices(), when all driver model devices are gone. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
* | x86: Simplify acpi_device_infer_name()Simon Glass2020-12-181-24/+3
| | | | | | | | | | | | | | There is no-longer any need to check if sequence numbers are valid, since this is ensured by driver model. Drop the unwanted logic. Signed-off-by: Simon Glass <sjg@chromium.org>
* | dm: Avoid accessing seq directlySimon Glass2020-12-181-2/+2
| | | | | | | | | | | | | | | | | | | | At present various drivers etc. access the device's 'seq' member directly. This makes it harder to change the meaning of that member. Change access to go through a function instead. The drivers/i2c/lpc32xx_i2c.c file is left unchanged for now. Signed-off-by: Simon Glass <sjg@chromium.org>
* | dm: treewide: Rename ..._platdata variables to just ..._platSimon Glass2020-12-133-7/+7
| | | | | | | | | | | | | | Try to maintain some consistency between these variables by using _plat as a suffix for them. Signed-off-by: Simon Glass <sjg@chromium.org>
* | dm: treewide: Rename dev_get_platdata() to dev_get_plat()Simon Glass2020-12-131-3/+3
| | | | | | | | | | | | Rename this to be consistent with the change from 'platdata'. Signed-off-by: Simon Glass <sjg@chromium.org>
* | dm: treewide: Rename 'platdata' variables to just 'plat'Simon Glass2020-12-135-21/+21
| | | | | | | | | | | | | | | | | | | | We use 'priv' for private data but often use 'platdata' for platform data. We can't really use 'pdata' since that is ambiguous (it could mean private or platform data). Rename some of the latter variables to end with 'plat' for consistency. Signed-off-by: Simon Glass <sjg@chromium.org>
* | dm: treewide: Rename auto_alloc_size members to be shorterSimon Glass2020-12-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | This construct is quite long-winded. In earlier days it made some sense since auto-allocation was a strange concept. But with driver model now used pretty universally, we can shorten this to 'auto'. This reduces verbosity and makes it easier to read. Coincidentally it also ensures that every declaration is on one line, thus making dtoc's job easier. Signed-off-by: Simon Glass <sjg@chromium.org>
* | efi_selftest: implement exception test for sandboxHeinrich Schuchardt2020-12-131-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Provide a unit test that causes an illegal instruction to occur. The test can be run with the following commands: => setenv efi_selftest exception => bootefi selftest This might be the output: Executing 'exception' EFI application triggers exception. Illegal instruction pc = 0x1444d016, pc_reloc = 0xffffaa078e8dd016 UEFI image [0x0000000000000000:0xffffffffffffffff] '/\selftest' UEFI image [0x000000001444b000:0x0000000014451fff] pc=0x2016 '/bug.efi' Resetting ... It would tell us that the exception was triggered by an instruction 0x2016 bytes after the load address of the binary with filename /bug.efi. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
* | efi_loader: link partition to block deviceHeinrich Schuchardt2020-12-101-0/+20
| | | | | | | | | | | | | | | | | | | | | | We provide a UEFI driver for block devices. When ConnectController() is called for a handle with the EFI_BLOCK_IO_PROTOCOL this driver creates the partitions. When DisconnectController() is called the handles for the partitions have to be deleted. This requires that the child controllers (partitions) open the EFI_BLOCK_IO_PROTOCOL of the controller (block IO device) with attribute EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: make efi_protocol_open() non-staticHeinrich Schuchardt2020-12-101-1/+1
| | | | | | | | | | | | Provide efi_protocol_open() as library function. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_selftest: test EFI_LOAD_FILE_PROTOCOLHeinrich Schuchardt2020-12-102-0/+478
| | | | | | | | | | | | | | A unit test is supplied to test the support for the EFI_LOAD_FILE_PROTOCOL and the EFI_LOAD_FILE2_PROTOCOL by the LoadImage() boot service. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_selftest: clean up MakefileHeinrich Schuchardt2020-12-101-8/+6
| | | | | | | | | | | | | | | | Bring all obj-y entries together. Sort *.o targets. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: support EFI_LOAD_FILE_PROTOCOLHeinrich Schuchardt2020-12-101-1/+48
| | | | | | | | | | | | | | Support loading images via the EFI_LOAD_FILE_PROTOCOL and EFI_LOAD_FILE2_PROTOCOL. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: carve out efi_load_image_from_file()Heinrich Schuchardt2020-12-101-9/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | efi_load_image_from_file() should read via either of: * EFI_SIMPLE_FILE_SYSTEM_PROTOCOL * EFI_LOAD_FILE_PROTOCOL * EFI_LOAD_FILE2_PROTOCOL To make the code readable carve out a function to load the image via the file system protocol. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: pass boot_policy to efi_load_image_from_pathHeinrich Schuchardt2020-12-101-7/+9
| | | | | | | | | | | | | | Implementing support for loading images via the EFI_LOAD_FILE_PROTOCOL requires the boot policy as input for efi_load_image_from_path(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: move EFI_LOAD_FILE2_PROTOCOL_GUIDHeinrich Schuchardt2020-12-103-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | The EFI_LOAD_FILE_PROTOCOL_GUID and EFI_LOAD_FILE2_PROTOCOL_GUID are needed to complement the implementation of the LoadFile() boot service. Remove a duplicate declaration of a variable for the EFI_LOAD_FILE2_PROTOCOL_GUID. Move the remaining declaration to efi_boottime.c. Add a variable for the EFI_LOAD_FILE_PROTOCOL_GUID. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: resequence functions in efi_boottime.cHeinrich Schuchardt2020-12-101-82/+82
| | | | | | | | | | | | | | | | For implementing support for the EFI_LOAD_FILE_PROTOCOL in the LoadImage() service we will have to call the LocateDevicePath() service. To avoid a forward declaration resequence the functions. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: remove EFI_HII_CONFIG_ROUTING_PROTOCOLHeinrich Schuchardt2020-12-103-7/+8
| | | | | | | | | | | | | | | | | | Our implementation of the EFI_HII_CONFIG_ROUTING_PROTOCOL is a mere stub, where all services return an error code. The protocol is neither needed for the EFI shell nor for the UEFI SCT. To reduce the code size remove it from the U-Boot binary. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: don't set EFI_RT_SUPPORTED_UPDATE_CAPSULEHeinrich Schuchardt2020-12-101-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | The EFI_RT_PROPERTIES_TABLE configuration table indicates which runtime services are available at runtime. Even if CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y, we neither support UpdateCapsule() nor QueryCapsuleCapabilities() at runtime. Thus we should not set the corresponding flags EFI_RT_SUPPORTED_UPDATE_CAPSULE and EFI_RT_SUPPORTED_QUERY_CAPSULE_CAPABILITIES in RuntimeServicesSupported. Fixes: 2bc27ca8a04a ("efi_loader: define UpdateCapsule api") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | fs: fat: create correct short namesHeinrich Schuchardt2020-12-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current function set_name() used to create short names has the following deficiencies resolved by this patch: * Long names (e.g. FOO.TXT) are stored even if a short name is enough. * Short names with spaces are created, e.g. "A ~1.TXT". * Short names with illegal characters are created, e.g. "FOO++BAR". * Debug output does not not consider that the short file name has no concluding '\0'. The solution for the following bug is split of into a separate patch: * Short file names must be unique. This patch only provides the loop over possible short file names. Fixes: c30a15e590c ("FAT: Add FAT write feature") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | env: Allow returning errors from hdelete_r()Simon Glass2020-12-041-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At present this function returns 1 on success and 0 on failure. But in the latter case it provides no indication of what went wrong. If an attempt is made to delete a non-existent variable, the caller may want to ignore this error. This happens when setting a non-existent variable to "", for example. Update the function to return 0 on success and a useful error code on failure. Add a function comment too. Make sure that env_set() does not return an error if it is deleting a variable that doesn't exist. We could update env_set() to return useful error numbers also, but that is beyond the scope of this change. Signed-off-by: Simon Glass <sjg@chromium.org> wip
* | efi_loader: add firmware management protocol for raw imageAKASHI Takahiro2020-12-034-58/+194
| | | | | | | | | | | | | | | | | | | | | | | | In this commit, a very simple firmware management protocol driver is implemented. It will take a binary image in a capsule file and apply the data using dfu backend storage drivers via dfu_write_by_alt() interface. So "dfu_alt_info" variable should be properly set to specify a device and location to be updated. Please read README.dfu. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
* | efi_loader: add firmware management protocol for FIT imageAKASHI Takahiro2020-12-034-1/+314
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In this commit, a very simple firmware management protocol driver is implemented. It will take a common FIT image firmware in a capsule file and apply the data using dfu backend storage drivers via update_fit() interface. So "dfu_alt_info" variable should be properly set to specify a device and location to be updated. Please read README.dfu. Fit image is a common file format for firmware update on U-Boot, and this protocol works neatly just as a wrapper for one. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
* | efi_loader: capsule: support firmware updateAKASHI Takahiro2020-12-033-12/+252
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | efi_loader: capsule: add capsule_on_disk supportAKASHI Takahiro2020-12-033-0/+528
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | efi_loader: define UpdateCapsule apiAKASHI Takahiro2020-12-035-54/+291
| | | | | | | | | | | | | | | | | | 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>
* | efi_loader: Introduce eventlog support for TCG2_PROTOCOLIlias Apalodimas2020-12-033-23/+551
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | tpm: use more than sha256 on pcr_extendIlias Apalodimas2020-12-031-5/+6
| | | | | | | | | | | | | | | | | | | | The current tpm2_pcr_extend is hardcoded using SHA256. Let's make the actual command to the TPM2 configurable so we can support a wider range of algorithms and keep the current command line as-is i.e limited to SHA256 only Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
* | efi_loader: replace printf by log in efi_uclass.cHeinrich Schuchardt2020-12-031-9/+9
|/ | | | | | | | | | Use logging functions instead of printf() and debug(). Change logging messages for uclass creation and destruction to log_debug(). Reported-by: Simon Glass <sjg@chromium.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
* charset: make u16_strnlen accessible at runtimeIlias Apalodimas2020-11-291-1/+2
| | | | | | | | | | | commit 1fabfeef506c ("efi_loader: parameter check in GetNextVariableName()") introduces a check using u16_strnlen(). This code is used on EFI runtime variables as well, so unless we mark it as runtime, the kernel will crash trying to access it. Fixes: 1fabfeef506c ("efi_loader: parameter check in GetNextVariableName()") Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: enable EFI_SET_TIME on sandbox and QEMU ARMHeinrich Schuchardt2020-11-291-0/+1
| | | | | | | Enable EFI_SET_TIME on the sandbox and QEMU ARM to ensure that we compile and test the relevant code. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: parameter check in GetNextVariableName()Heinrich Schuchardt2020-11-211-3/+8
| | | | | | | | | | | | If GetNextVariableName() is called with a non-existing combination of VariableName and VendorGuid, return EFI_INVALID_PARAMETER. If GetNextVariableName() is called with a string that is not zero terminated, return EFI_INVALID_PARAMETER. Reformat a line over 80 characters. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: tcg2 protocol updatesIlias Apalodimas2020-11-211-68/+92
| | | | | | | | | On pull reuqest https://lists.denx.de/pipermail/u-boot/2020-November/432735.html V4 of the patchset was sent instead of the v5. This is the v4->v5 missing diff Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* efi_selftest: provide unit test for the EFI_TCG2_PROTOCOLHeinrich Schuchardt2020-11-142-0/+76
| | | | | | Provide a minimal test for the EFI_TCG2_PROTOCOL. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: Add basic EFI_TCG2_PROTOCOL supportIlias Apalodimas2020-11-144-0/+549
| | | | | | | | | | | | | | 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>
* efi_loader: incorrect buffer size in efi_file_setinfo()Heinrich Schuchardt2020-11-141-1/+1
| | | | | | | | When copying a string with must allocate a byte for the terminating '\0' in the target buffer. Fixes: fbe4c7df0087 ("efi_loader: enable file SetInfo()") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: Add missing newline to log_{err,warning}Paulo Alcantara2020-11-141-2/+2
| | | | | | | | | | | | Add missing newline to log messages in efi_rng_register() otherwise something like below would be shown Scanning disk virtio-blk#31... Found 2 disks Missing RNG device for EFI_RNG_PROTOCOLNo EFI system partition Signed-off-by: Paulo Alcantara (SUSE) <pc@cjr.nz> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_selftest: keep devices in ExitBootServices()Heinrich Schuchardt2020-11-142-4/+12
| | | | | | | | When calling ExitBootServices during out unit tests we should not detach devices as we need console output for runtime tests. Fixes: 529441ca89b1 ("efi_loader: Disable devices before handing over control") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* tpm: Change response length of tpm2_get_capability()Ilias Apalodimas2020-11-091-2/+2
| | | | | | | | | | | For implementing the EFI_TCG2_PROTOCOL we need the count field returned by the TPM when reading capabilities via tpm2_get_capability(). Adjust the implementation of the 'tpm2 get_capability' command accordingly. Suggested-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_selftest: add tool to download dtbHeinrich Schuchardt2020-11-092-0/+220
| | | | | | | | | | | For validating the fixed up device tree we need a tool to need to save it to a file. dtbdump.efi copies the configuration table with the device tree to a file on the same partition from which dtbdump.efi was invoked. The file name can be entered on the console. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: non-volatile variable not deleted from fileHeinrich Schuchardt2020-11-091-0/+1
| | | | | | | | | | | | When deleting a non-volatile variable it was deleted from memory but the deletion was not persisted to the file system. SetVariable() may be called with attributes == 0 to delete a variable. To determine if the deletion shall be persisted we have to consider the non-volatile flag in the attributes of the deleted variable and not the value passed in the call parameter. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* Merge tag 'dm-pull5nov20' of git://git.denx.de/u-boot-dmTom Rini2020-11-061-2/+2
|\ | | | | | | | | | | | | patman status subcommand to collect tags from Patchwork patman showing email replies from Patchwork sandbox poweroff command minor fixes in binman, tests
| * binman: Call helper function binman_set_rom_offset() to fill offsetMichal Simek2020-11-051-2/+2
| | | | | | | | | | | | | | | | | | There is prepared function for filing rom_offset. That's why use it instead of copying content of it. Signed-off-by: Michal Simek <michal.simek@xilinx.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>