summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Merge tag 'efi-2020-10-rc1-3' of ↵WIP/13Jul2020Tom Rini2020-07-1328-1284/+1864
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://gitlab.denx.de/u-boot/custodians/u-boot-efi Pull request for UEFI sub-system for efi-2020-10-rc1 (3) Up to now UEFI variables where stored in U-Boot environment variables. Saving UEFI variables was not possible without saving the U-Boot environment variables. With this patch series file ubootefi.var in the EFI system partition is used for saving UEFI variables. Furthermore the UEFI variables are exposed for reading at runtime. Code corrections for UEFI secure boot are provided. A buffer overrun in the RSA library is fixed.
| * efi_selftest: adjust runtime test for variablesHeinrich Schuchardt2020-07-111-7/+6
| | | | | | | | | | | | | | As variable services are available at runtime we have to expect EFI_SUCCESS when calling the services. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: enable UEFI variables at runtimeHeinrich Schuchardt2020-07-113-5/+17
| | | | | | | | | | | | Enable UEFI variables at runtime. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: use memory based variable storageHeinrich Schuchardt2020-07-111-468/+94
| | | | | | | | | | | | | | | | | | Saving UEFI variable as encoded U-Boot environment variables does not allow implement run-time support. Use a memory buffer for storing UEFI variables. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: memory buffer for variablesHeinrich Schuchardt2020-07-113-0/+321
| | | | | | | | | | | | | | | | | | Saving UEFI variable as encoded U-Boot environment variables does not allow support at runtime. Provide functions to manage a memory buffer with UEFI variables. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: new function efi_memcpy_runtime()Heinrich Schuchardt2020-07-112-0/+22
| | | | | | | | | | | | Provide a memcpy() function that we can use at UEFI runtime. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: optional pointer for ConvertPointerHeinrich Schuchardt2020-07-112-0/+8
| | | | | | | | | | | | | | If the EFI_OPTIONAL_PTR is set in DebugDisposition, a NULL pointer does not constitute an invalid parameter. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: export efi_convert_pointer()Heinrich Schuchardt2020-07-112-5/+6
| | | | | | | | | | | | | | | | | | | | We need ConvertPointer() to adjust pointers when implementing runtime services within U-Boot. After ExitBootServices() gd is not available anymore. So we should not use EFI_ENTRY() and EFI_EXIT(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: UEFI variable persistenceHeinrich Schuchardt2020-07-115-1/+319
| | | | | | | | | | | | | | | | | | | | | | | | Persist non-volatile UEFI variables in a file on the EFI system partition. The file is written whenever a non-volatile UEFI variable is changed after initialization of the UEFI sub-system. The file is read during the UEFI sub-system initialization to restore non-volatile UEFI variables. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: secure boot flagHeinrich Schuchardt2020-07-111-6/+2
| | | | | | | | | | | | | | | | | | In audit mode the UEFI variable SecureBoot is set to zero but the efi_secure_boot flag is set to true. The efi_secure_boot flag should match the UEFIvariable SecureBoot. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: read-only AuditMode and DeployedModeHeinrich Schuchardt2020-07-111-9/+13
| | | | | | | | | | | | | | Set the read only property of the UEFI variables AuditMode and DeployedMode conforming to the UEFI specification. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: value of VendorKeysHeinrich Schuchardt2020-07-111-60/+15
| | | | | | | | | | | | | | | | | | | | According to the UEFI specification the variable VendorKeys is 1 if the "system is configured to use only vendor-provided keys". As we do not supply any vendor keys yet the variable VendorKeys must be zero. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: keep attributes in efi_set_variable_intHeinrich Schuchardt2020-07-111-12/+12
| | | | | | | | | | | | | | | | | | | | Do not change the value of parameter attributes in function efi_set_variable_int(). This allows to use it later. Do not use variable attr for different purposes but declare separate variables (attr and old_attr). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: simplify boot managerHeinrich Schuchardt2020-07-111-16/+12
| | | | | | | | | | | | | | | | | | Simplify the implementation of the UEFI boot manager: * avoid EFI_CALL for SetVariable() and GetVariable() * remove unnecessary type conversions Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: OsIndicationsSupported, PlatformLangCodesHeinrich Schuchardt2020-07-111-28/+31
| | | | | | | | | | | | | | | | | | UEFI variables OsIndicationsSupported, PlatformLangCodes should be read only. Avoid EFI_CALL() for SetVariable(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: separate UEFI variable API from implemementationHeinrich Schuchardt2020-07-114-79/+133
| | | | | | | | | | | | | | Separate the remaining UEFI variable API functions GetNextVariableName and QueryVariableInfo() from internal functions implementing them. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: display RO attribute in printenv -eHeinrich Schuchardt2020-07-111-8/+16
| | | | | | | | | | | | | | | | | | Let the 'printenv -e' command display the read only flag. If the variable is time authenticated write the time stamp. Avoid EFI_CALL() when calling SetVariable() and GetVariable(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: prepare for read only OP-TEE variablesHeinrich Schuchardt2020-07-116-181/+193
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We currently have two implementations of UEFI variables: * variables provided via an OP-TEE module * variables stored in the U-Boot environment Read only variables are up to now only implemented in the U-Boot environment implementation. Provide a common interface for both implementations that allows handling read-only variables. As variable access is limited to very few source files put variable related definitions into new include efi_variable.h instead of efi_loader. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * fs/fat: reduce data size for FAT_WRITEHeinrich Schuchardt2020-07-111-2/+7
| | | | | | | | | | | | | | | | Allocated tmpbuf_cluster dynamically to reduce the data size added by compiling with CONFIG_FAT_WRITE. Reported-by: Tom Rini <trini@konsulko.com> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: NULL dereference in efi_convert_pointerHeinrich Schuchardt2020-07-111-1/+2
| | | | | | | | | | | | Avoid a possible NULL pointer dereference in efi_convert_pointer(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: fix efi_get_child_controllers()Heinrich Schuchardt2020-07-111-4/+8
| | | | | | | | | | | | | | Don't call calloc(0, ..). Consider return value of efi_get_child_controllers(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: wrong printf format in efi_image_parseHeinrich Schuchardt2020-07-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 1b6c08548c85 ("efi_loader: image_loader: replace debug to EFI_PRINT") leads to a build warning on 32bit systems: lib/efi_loader/efi_image_loader.c: In function ‘efi_image_parse’: include/efi_loader.h:123:8: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 8 has type ‘size_t’ {aka ‘unsigned int’} [-Wformat=] Use %zu for printing size_t. Fixes: 1b6c08548c85 ("efi_loader: image_loader: replace debug to EFI_PRINT") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: cleanup for tee backed variablesIlias Apalodimas2020-07-111-5/+3
| | | | | | | | | | | | | | | | | | There's 2 variables in efi_get_next_variable_name() checking the size of the variable name. Let's get rid of the reduntant definition and simplitfy the code a bit. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * lib: rsa: export rsa_verify_with_pkey()AKASHI Takahiro2020-07-112-4/+7
| | | | | | | | | | | | | | | | | | This function will be used to implement public_key_verify_signature() in a later patch. rsa_verify() is not suitable here because calculation of message digest is not necessary. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * test: use virt-make-fs to build imageHeinrich Schuchardt2020-07-112-30/+4
| | | | | | | | | | | | Avoid sudo for test/py/tests/test_efi_secboot by using virt-make-fs. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * test/py: efi_secboot: add a test for verifying with digest of signed imageAKASHI Takahiro2020-07-112-0/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Signature database (db or dbx) may have not only certificates that contain a public key for RSA decryption, but also digests of signed images. In this test case, if database has an image's digest (EFI_CERT_SHA256_GUID) and if the value matches to a hash value calculated from image's binary, authentication should pass in case of db, and fail in case of dbx. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Use defined time stamps for sign-efi-sig-list. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * test/py: efi_secboot: add a test for multiple signaturesAKASHI Takahiro2020-07-112-1/+59
| | | | | | | | | | | | | | | | | | | | | | In this test case, an image is signed multiple times with different keys. If any of signatures contained is not verified, the whole authentication check should fail. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Provide a defined time stamp for dbx_hash1.auth. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * test/py: efi_secboot: add a test against certificate revocationAKASHI Takahiro2020-07-112-1/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Revocation database (dbx) may have not only certificates, but also message digests of certificates with revocation time (EFI_CERT_X509_SHA256_GUILD). In this test case, if the database has such a digest and if the value matches to a certificate that created a given image's signature, authentication should fail. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Set defined time stamp for dbx_hash.auth. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * test/py: efi_secboot: split "signed image" test case-1 into two casesAKASHI Takahiro2020-07-111-28/+38
| | | | | | | | | | | | | | | | | | | | Split the existing test case-1 into case1 and a new case-2: case-1 for non-SecureBoot mode; case-2 for SecureBoot mode. In addition, one corner case is added to case-2; a image is signed but a corresponding certificate is not yet installed in "db." Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
| * test/py: efi_secboot: more fixes against pylintAKASHI Takahiro2020-07-114-83/+79
| | | | | | | | | | | | | | More fixes against pylint warnings that autopep8 didn't handle in the previous commit. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
| * test/py: efi_secboot: apply autopep8AKASHI Takahiro2020-07-115-60/+67
| | | | | | | | | | | | | | | | Python's autopep8 can automatically correct some of warnings from pylint and rewrite the code in a pretty print format. So just do it. Suggested-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
| * efi_loader: image_loader: add digest-based verification for signed imageAKASHI Takahiro2020-07-113-75/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In case that a type of certificate in "db" or "dbx" is EFI_CERT_X509_SHA256_GUID, it is actually not a certificate which contains a public key for RSA decryption, but a digest of image to be loaded. If the value matches to a value calculated from a given binary image, it is granted for loading. With this patch, common digest check code, which used to be used for unsigned image verification, will be extracted from efi_signature_verify_with_sigdb() into efi_signature_lookup_digest(), and extra step for digest check will be added to efi_image_authenticate(). Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
| * efi_loader: image_loader: verification for all signatures should passAKASHI Takahiro2020-07-113-156/+198
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A signed image may have multiple signatures in - each WIN_CERTIFICATE in authenticode, and/or - each SignerInfo in pkcs7 SignedData (of WIN_CERTIFICATE) In the initial implementation of efi_image_authenticate(), the criteria of verification check for multiple signatures case is a bit ambiguous and it may cause inconsistent result. With this patch, we will make sure that verification check in efi_image_authenticate() should pass against all the signatures. The only exception would be - the case where a digest algorithm used in signature is not supported by U-Boot, or - the case where parsing some portion of authenticode has failed In those cases, we don't know how the signature be handled and should just ignore them. Please note that, due to this change, efi_signature_verify_with_sigdb()'s function prototype will be modified, taking "dbx" as well as "db" instead of outputing a "certificate." If "dbx" is null, the behavior would be the exact same as before. The function's name will be changed to efi_signature_verify() once current efi_signature_verify() has gone due to further improvement in intermediate certificates support. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
| * efi_loader: signature: make efi_hash_regions more genericAKASHI Takahiro2020-07-111-29/+17
| | | | | | | | | | | | | | There are a couple of occurrences of hash calculations in which a new efi_hash_regions will be commonly used. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
| * efi_loader: signature: fix a size check against revocation listAKASHI Takahiro2020-07-111-2/+3
| | | | | | | | | | | | | | | | Since the size check against an entry in efi_search_siglist() is incorrect, this function will never find out a to-be-matched certificate and its associated revocation time in the signature list. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
| * efi_loader: image_loader: retrieve authenticode only if it existsAKASHI Takahiro2020-07-111-8/+21
| | | | | | | | | | | | | | | | | | Since the certificate table, which is indexed by IMAGE_DIRECTORY_ENTRY_SECURITY and contains authenticode in PE image, doesn't always exist, we should make sure that we will retrieve its pointer only if it exists. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
| * efi_loader: image_loader: add a check against certificate type of authenticodeAKASHI Takahiro2020-07-111-12/+44
| | | | | | | | | | | | | | | | | | | | | | | | UEFI specification requires that we shall support three type of certificates of authenticode in PE image: WIN_CERT_TYPE_EFI_GUID with the guid, EFI_CERT_TYPE_PCKS7_GUID WIN_CERT_TYPE_PKCS_SIGNED_DATA WIN_CERT_TYPE_EFI_PKCS1_15 As EDK2 does, we will support the first two that are pkcs7 SignedData. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
| * lib/crypto: use qualified path for x509_parser.hHeinrich Schuchardt2020-07-111-1/+1
| | | | | | | | | | | | Use the path relative to /include for x509_parser.h in pkcs7_parser.h. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | Merge branch 'master' of https://gitlab.denx.de/u-boot/custodians/u-boot-spiWIP/11Jul2020Tom Rini2020-07-11101-7887/+107
|\ \ | | | | | | | | | | | | | | | | | | - Enable DM_SPI on siemens omap boards (Jagan) - Dropped some non-dm supported omap3 boards (Jagan) - Dropped non-dm code in omap3 spi driver (Jagan) - Dropped non-dm code in kirkwood spi driver (Bhargav)
| * | doc: driver-model: Update SPI migration statusJagan Teki2020-07-101-14/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All SPI drivers are converted to DM_SPI but 3 drivers still operate in nondm mode for SPL due to footprint constraints. Update the migration status for it. Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
| * | spi: kirkwood: Drop nondm codeBhargav Shah2020-07-103-130/+19
| | | | | | | | | | | | | | | | | | | | | | | | Drop the nondm code from kirkwood_spi.c since there is no board or any other code using for it. Signed-off-by: Bhargav Shah <bhargavshah1988@gmail.com> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
| * | mtd: spi-nor: Enable QE bit for ISSI flash in case of SFDPPragnesh Patel2020-07-091-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Enable QE bit for ISSI flash chips. QE enablement logic is similar to what Macronix has, so reuse the existing code itself. Signed-off-by: Pragnesh Patel <pragnesh.patel@sifive.com> Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
| * | spi: add support for all spi modes with soft spiJohannes Holland2020-07-091-11/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The spi bitbanging driver did not implement all spi modes properly. Add code to support all spi modes, honoring soft_spi_set_mode() and defaulting to spi mode 0. Previously, CPHA was implemented inversely (defaulting to CPHA=1) and CPOL=1 was hardcoded. Signed-off-by: Johannes Holland <johannes.holland@infineon.com> Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
| * | arm: Remove mx31pdk boardJagan Teki2020-07-098-409/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DM, OF_CONTROL, DM_SPI and other driver model migration deadlines are expired for this board. Remove it. Acked-by: Magnus Lilja <lilja.magnus@gmail.com> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
| * | spi: omap3: Drop nondm codeJagan Teki2020-07-092-143/+7
| | | | | | | | | | | | | | | | | | | | | Now all boards are using this omap3 spi driver in dm model, so drop the nondm code. Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
| * | db-88f6281-bp-nand: Enable DM_SPI/SPI_FLASHJagan Teki2020-07-091-2/+2
| | | | | | | | | | | | | | | | | | | | | Enable DM_SPI, DM_SPI_FLASH for db-88f6281-bp-nand board. Cc: Chris Packham <judge.packham@gmail.com> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
| * | arm: Remove pengwyn boardJagan Teki2020-07-0910-589/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | OF_CONTROL, DM_SPI and other driver model migration deadlines are expired for this board. Remove it. Cc: Lothar Felten <lothar.felten@gmail.com> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
| * | arm: Remove pepper boardJagan Teki2020-07-0910-562/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | OF_CONTROL, DM_SPI and other driver model migration deadlines are expired for this board. Remove it. Cc: Ash Charles <ash@gumstix.com> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
| * | arm: Remove bav335x boardJagan Teki2020-07-0912-1489/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | OF_CONTROL, DM_SPI and other driver model migration deadlines are expired for this board. Remove it. Cc: Gilles Gameiro <gilles@gigadevices.com> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
| * | arm: Remove cairo boardJagan Teki2020-07-098-703/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | OF_CONTROL, DM_SPI and other driver model migration deadlines are expired for this board. Drop it. Cc: Albert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>