summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)AuthorFilesLines
2022-02-15[TEMP]jh7100: remove "depends on DM_ETH || !NET" in EFI_LOADERTekkaman Ninja2-2/+23
This patch reverses some part of change in: commit eac6e0b7979440b889703196f383191c335e7599 Author: Simon Glass <sjg@chromium.org> Date: Fri Sep 24 18:30:17 2021 -0600 efi_loader: Drop code that doesn't work with driver model ... Since JH7100 ETH driver haven't supported DM yet.
2022-02-11efi_loader: fix dual signed image certificationIlias Apalodimas1-70/+18
The EFI spec allows for images to carry multiple signatures. Currently we don't adhere to the verification process for such images. The spec says: "Multiple signatures are allowed to exist in the binary's certificate table (as per PE/COFF Section "Attribute Certificate Table"). Only one hash or signature is required to be present in db in order to pass validation, so long as neither the SHA-256 hash of the binary nor any present signature is reflected in dbx." With our current implementation signing the image with two certificates and inserting both of them in db and one of them dbx doesn't always reject the image. The rejection depends on the order that the image was signed and the order the certificates are read (and checked) in db. While at it move the sha256 hash verification outside the signature checking loop, since it only needs to run once per image and get simplify the logic for authenticating an unsigned imahe using sha256 hashes. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2022-02-09acpi: Move MCFG implementation to common libMoritz Fischer2-0/+65
MCFG tables are used on multiple arches. Move to common ACPI lib. Cc: Simon Glass <sjg@chromium.org> Signed-off-by: Moritz Fischer <moritzf@google.com> Reviewed-by: Simon Glass <sjg@chromium.org> Use sizeof(*mcfg) instead of sizeof(*header) Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-05efi: Drop unnecessary calls to blk_find_device()Simon Glass1-12/+2
When we have the block descriptor we can simply access the device. Drop the unnecessary function call. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2022-02-05efi: Use device_get_uclass_id() where appropriateSimon Glass1-5/+5
Use this function rather than following the pointers, since it is there for this purpose. Add the uclass name to the debug call at the end of dp_fill() since it is quite useful. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2022-02-05efi_loader: add handle for UARTHeinrich Schuchardt1-27/+25
When loading an EFI binary via the UART we assign a UART device path to it. But we lack a handle with that device path. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-02-05efi_loader: fix text output for Uart() DP nodesHeinrich Schuchardt1-9/+19
The UEFI specification concerning Uart() device path nodes has been clarified: Parity and stop bits can either both use keywords or both use numbers but numbers and keywords should not be mixed. Let's go for keywords as this is what EDK II does. For illegal values fall back to numbers. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-02-05efi_loader: use %zu to print efi_uintn_t in FMP driverHeinrich Schuchardt1-2/+2
For printing an unsigned value we should use %u and not %d. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-02-05efi_loader: use %zu not %zd to print efi_uintn_tHeinrich Schuchardt1-3/+3
efi_uintnt_t is an unsigned type. We should avoid showing negative numbers. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-02-05efi_loader: fix device path to text protocolHeinrich Schuchardt1-4/+13
The printing of a file path node must properly handle: * odd length of the device path node * UTF-16 character only partially contained in device path node * buffer overflow due to very long file path Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-02-05lib: fix snprintf() for UTF-16 stringsHeinrich Schuchardt1-2/+12
snprintf() must return the required buffer length. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-02-05efi_selftest: merge FDT and RISC-V testsHeinrich Schuchardt3-135/+57
The test for the RISCV_EFI_BOOT_PROTOCOL retrieves the boot hart id via the protocol and compares it to the value of the boot hart id in the device tree. The boot hart id is already retrieved from the device tree in the FDT test. Merge the two tests to avoid code duplication. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-02-05efi_selftest: unit test for RISCV_EFI_BOOT_PROTOCOLSunil V L2-0/+120
Add a test for the RISCV_EFI_BOOT_PROTOCOL. Signed-off-by: Sunil V L <sunilvl@ventanamicro.com>
2022-02-03treewide: Use 16-bit Unicode stringsSimon Glass2-3/+3
At present we use wide characters for Unicode but this is not necessary. Change the code to use the 'u' literal instead. This helps to fix build warnings for sandbox on the Raspberry Pi. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2022-02-03efi: Use 16-bit unicode stringsSimon Glass31-250/+250
At present we use wide characters for unicode but this is not necessary. Change the code to use the 'u' literal instead. This helps to fix build warnings for sandbox on rpi. Signed-off-by: Simon Glass <sjg@chromium.org> Suggested-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2022-01-29Merge tag 'efi-2022-04-rc1-3' of ↵Tom Rini45-98/+219
https://source.denx.de/u-boot/custodians/u-boot-efi Pull request for efi-2022-04-rc1-3 Documentation: * update Nokia RX-51 documentation and move it to rst * describe boot switch settings for HiFive Unmatched board UEFI: * fix the checking of images hashes and signatures * provide the RISCV_EFI_BOOT_PROTOCOL
2022-01-29efi_loader: hash the image once before checking against db/dbxIlias Apalodimas1-1/+4
We don't have to recalculate the image hash every time we check against a new db/dbx entry. So let's add a flag forcing it to run once since we only support sha256 hashes Suggested-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-01-29efi_loader: correctly handle mixed hashes and signatures in dbIlias Apalodimas2-11/+46
A mix of signatures and hashes in db doesn't always work as intended. Currently if the digest algorithm is not explicitly set to sha256 we stop walking the security database and reject the image. That's problematic in case we find and try to check a signature before inspecting the sha256 hash. If the image is unsigned we will reject it even if the digest matches. Since we no longer reject the image on unknown algorithms add an explicit check and reject the image if any other hash algorithm apart from sha256 is detected on dbx. Suggested-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-01-29lib: allow printing RISC-V EFI Boot Protocol GUIDHeinrich Schuchardt1-0/+6
On RISC-V a new UEFI protocol has been introduced. Support printing its GUID using %pUs. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-01-29efi_loader: Enable RISCV_EFI_BOOT_PROTOCOL supportSunil V L4-0/+77
This adds support for new RISCV_EFI_BOOT_PROTOCOL to communicate the boot hart ID to bootloader/kernel on RISC-V UEFI platforms. The specification of the protocol is hosted at: https://github.com/riscv-non-isa/riscv-uefi Signed-off-by: Sunil V L <sunilvl@ventanamicro.com> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-01-29efi_loader: correct function comment styleHeinrich Schuchardt38-86/+86
Replace @return and @param. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-01-29rsa: adds rsa3072 algorithmJamin Lin1-0/+6
Add to support rsa 3072 bits algorithm in tools for image sign at host side and adds rsa 3072 bits verification in the image binary. Add test case in vboot for sha384 with rsa3072 algorithm testing. Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-01-27Merge tag 'dm-pull-26jan22' of ↵Tom Rini14-94/+471
https://source.denx.de/u-boot/custodians/u-boot-dm acpi refactoring to allow non-x86 use binman support for bintools (binary tools) minor tools improvements in preparation for FDT signing various minor fixes and improvements
2022-01-27lib/circbuf: Make circbuf selectable symbolLoic Poulain2-1/+10
It is currenly only used from usbtty driver but make it properly selectable via Kconfig symbol, for future usage. Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2022-01-26image: Return destination node for add_verify_data() methodSimon Glass2-3/+6
It is useful to know where the verification data was written. Update the API to return this. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-26rsa: Add debugging for failure casesSimon Glass1-3/+10
Add some more debugging to make it easier to see what is being tried and what fails. Fix a few comment styles while here. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-25acpi: Collect tables in the acpi_item listSimon Glass1-0/+5
At present this list is used to collect items within the DSDT and SSDT tables. It is useful for it to collect the whole tables as well, so there is a list of what was created and which write created each one. Refactor the code accordingly. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-25x86: Move acpi_get_rsdp_addr() ACPI tables to the writerSimon Glass1-0/+8
Move this over to use a writer file, moving the code from the x86 implementation. There is no need to store a separate variable since we can simply access the ACPI context. With this, the original monolithic x86 function for writing ACPI tables is gone. Note that QEMU has its own implementation. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-25x86: Move device-specific ACPI tables to a writer functionSimon Glass1-0/+12
Move this over to use a writer function, moving the code from the x86 implementation. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-25x86: acpi: Update acpi_fill_csrt() to use acpi_ctxSimon Glass1-7/+6
Update this function to the newer style, so we can avoid passing and returning an address through this function. Also move this function out of the x86 code so it can be used by other archs. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2022-01-25x86: Move CSRT table to a writer functionSimon Glass2-0/+51
Move this table over to use a writer function, moving the code from the x86 implementation. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-25x86: Move SSDT table to a writer functionSimon Glass2-0/+50
Move this table over to use a writer function, moving the code from the x86 implementation. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-25x86: Move DSDT table to a writer functionSimon Glass4-0/+65
Move this table over to use a writer function, moving the code from the x86 implementation. Add a pointer to the DSDT in struct acpi_ctx so we can reference it later. Disable this table for sandbox since we don't actually compile real ASL code. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-25x86: Move FACS table to a writer functionSimon Glass2-0/+34
Move this table over to use a writer function, moving the code from the x86 implementation. Add a pointer to the DSDT in struct acpi_ctx so we can reference it later. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-25x86: Move base tables to a writer functionSimon Glass4-76/+101
Use the new ACPI writer to write the base tables at the start of the area, moving this code from the x86 implementation. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-25x86: Use the ACPI table writerSimon Glass1-1/+3
Use the new ACPI writer to write the ACPI tables. At present this is all done in one monolithic function. Future work will split this out. Unfortunately the QFW write_acpi_tables() function conflicts with the 'writer' version, so disable that for sandbox. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-25x86: acpi: Split out context creation from base tablesSimon Glass3-15/+19
At present acpi_setup_base_tables() both sets up the ACPI context and writes out the base tables. We want to use an ACPI writer to write the base tables, so split this function into two, with acpi_setup_ctx() doing the context set, and acpi_setup_base_tables() just doing the base tables. Disable the writer's write_acpi_tables() function for now, to avoid build errors. It is enabled in a following patch. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-25acpi: Add a linker list for ACPI tablesSimon Glass1-0/+91
At present we call lots of functions to generate the required ACPI tables. It would be better to standardise these functions and allow them to be automatically collected and used when needed. Add a linker list to handle this. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-25acpi: Use finer-grained control of ACPI-table generationSimon Glass2-5/+5
Rather than keying everything off ACPIGEN, use the main GENERATE_ACPI_TABLE option to determine whether the core ACPI code is included. Make sure these option are not enabled in SPL/TPL since we never generate tables there. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-25efi: Correct address handling with ACPI tablesSimon Glass1-1/+4
The current EFI implementation confuses pointers and addresses. Normally we can get away with this but in the case of sandbox it causes failures. Despite the fact that efi_allocate_pages() returns a u64, it is actually a pointer, not an address. Add special handling to avoid a crash when running 'bootefi hello'. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-25efi: Correct call to write_acpi_tables()Simon Glass1-1/+1
This must be passed a ulong, not a u64. Fix it to avoid LTO warnings on sandbox. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-25x86: Move the acpi table to generic global_dataSimon Glass1-1/+1
Allow this to be used on any arch. Also convert to using macros so that we can check the CONFIG option in C code. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-25x86: Allow any arch to generate ACPI tablesSimon Glass1-0/+18
These have sadly found their way to ARM now. Allow any arch to support generating ACPI tables. Disable this for the tools build. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-22Merge tag 'efi-2022-04-rc1-2' of ↵Tom Rini15-61/+236
https://source.denx.de/u-boot/custodians/u-boot-efi Pull request for efi-2022-04-rc1-2 Documentation: * describe printf() format codes UEFI * enable more algorithms for UEFI image verification, e.g. SHA256-RSA2048 General * simplify printing short texts for GUIDs * provide a unit test for printing GUIDs
2022-01-19doc: replace @return by Return:Heinrich Schuchardt32-86/+86
Sphinx expects Return: and not @return to indicate a return value. find . -name '*.c' -exec \ sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \; find . -name '*.h' -exec \ sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \; Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-01-19lib/crypto: Enable more algorithms in cert verificationIlias Apalodimas1-19/+16
Right now the code explicitly limits us to sha1,256 hashes with RSA2048 encryption. But the limitation is artificial since U-Boot supports a wider range of algorithms. The internal image_get_[checksum|crypto]_algo() functions expect an argument in the format of <checksum>,<crypto>. So let's remove the size checking and create the needed string on the fly in order to support more hash/signing combinations. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2022-01-19efi_loader: printing TCG2 protocol GUIDHeinrich Schuchardt1-0/+4
We support the TCG2 protocol. Allow command efidebug to print it. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-01-19efi_selftest: implement printing GUIDsHeinrich Schuchardt2-4/+29
The ESRT test may try to print a GUID if an error occurs. Implement the %pU print code. Correct the ESRT test to use %pU instead of %pUl to avoid the output of character 'l'. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-01-19cmd: printenv: simplify printing GUIDsHeinrich Schuchardt1-0/+24
Use "%pS" to print text representations of GUIDs. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-01-19efi_loader: use %pUs for printing GUIDsHeinrich Schuchardt10-35/+35
For printing GUIDs with macro EFI_ENTRY use %pUs instead of %pUl to provide readable debug output. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>