summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* 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 tag 'dm-pull-10jul20' of ↵WIP/10Jul2020-cTom Rini2020-07-1095-313/+1030
|\ | | | | | | | | | | | | | | https://gitlab.denx.de/u-boot/custodians/u-boot-dm of-platdata: better phandle and compatible-string support patman support for Python3 on Ubuntu 14.04 new checkpatch check to avoid #ifdefs
| * dtoc: add test for cd-gpiosWalter Lozano2020-07-092-0/+109
| | | | | | | | | | | | | | Add a test for dtoc taking into account the cd-gpios property. Signed-off-by: Walter Lozano <walter.lozano@collabora.com> Reviewed-by: Simon Glass <sjg@chromium.org>
| * dtoc: update dtb_platdata to support cd-gpiosWalter Lozano2020-07-092-7/+11
| | | | | | | | | | | | | | | | | | | | Currently dtoc does not support the property cd-gpios used to declare the gpios for card detect in mmc. This patch adds support to cd-gpios property. Signed-off-by: Walter Lozano <walter.lozano@collabora.com> Reviewed-by: Simon Glass <sjg@chromium.org>
| * arm: dts: include gpio nodes for card detectWalter Lozano2020-07-095-1/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Several MMC drivers use GPIO for card detection with cd-gpios property in the MMC node pointing to a GPIO node. However, as U-Boot tries to save space by keeping only required nodes using u-boot* properties, several devices tree result in having only in the MMC node but not the GPIO node associated to cd-gpios. This patch, fixes several ocurrence of this issue. Signed-off-by: Walter Lozano <walter.lozano@collabora.com> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Adam Ford <aford173@gmail.com> #da850-evm
| * dm: doc: update of-plat with new phandle supportWalter Lozano2020-07-091-8/+16
| | | | | | | | | | | | | | | | | | Update documentation to reflect the new phandle support when OF_PLATDATA is used. Now phandles are implemented as pointers to U_BOOT_DEVICE, which makes it possible to get a pointer to the actual device. Signed-off-by: Walter Lozano <walter.lozano@collabora.com> Reviewed-by: Simon Glass <sjg@chromium.org>
| * dtoc: extend dtoc to use struct driver_info when linking nodesWalter Lozano2020-07-0910-65/+100
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the current implementation, when dtoc parses a dtb to generate a struct platdata it converts the information related to linked nodes as pointers to struct platdata of destination nodes. By doing this, it makes difficult to get pointer to udevices created based on these information. This patch extends dtoc to use struct driver_info when populating information about linked nodes, which makes it easier to later get the devices created. In this context, reimplement functions like clk_get_by_index_platdata() which made use of the previous approach. Signed-off-by: Walter Lozano <walter.lozano@collabora.com> Reviewed-by: Simon Glass <sjg@chromium.org>
| * sandbox: Move section u_boot_list to make it RWWalter Lozano2020-07-091-1/+1
| | | | | | | | | | | | | | | | In order to be able to update data in u_boot_list, move this section to make it RW. Signed-off-by: Walter Lozano <walter.lozano@collabora.com> Reviewed-by: Simon Glass <sjg@chromium.org>
| * core: extend struct driver_info to point to deviceWalter Lozano2020-07-094-3/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently when creating an U_BOOT_DEVICE entry a struct driver_info is declared, which contains the data needed to instantiate the device. However, the actual device is created at runtime and there is no proper way to get the device based on its struct driver_info. This patch extends struct driver_info adding a pointer to udevice which is populated during the bind process, allowing to generate a set of functions to get the device based on its struct driver_info. Signed-off-by: Walter Lozano <walter.lozano@collabora.com> Reviewed-by: Simon Glass <sjg@chromium.org>
| * core: drop const for struct driver_infoWalter Lozano2020-07-093-3/+3
| | | | | | | | | | | | | | | | | | In order to prepare for a new support of phandle when OF_PLATDATA is used drop the const for struct driver_info as this struct will need to be updated on runtime. Signed-off-by: Walter Lozano <walter.lozano@collabora.com> Reviewed-by: Simon Glass <sjg@chromium.org>
| * dm: doc: update of-plat with the support for driver aliasesWalter Lozano2020-07-091-1/+13
| | | | | | | | | | | | | | | | Update the documentation with the support for driver aliases using U_BOOT_DRIVER_ALIAS. Signed-off-by: Walter Lozano <walter.lozano@collabora.com> Reviewed-by: Simon Glass <sjg@chromium.org>
| * dtoc: add option to disable warningsWalter Lozano2020-07-093-34/+85
| | | | | | | | | | | | | | | | | | | | | | | | As dtoc now performs checks for valid driver names, when running dtoc tests several warnings arise as these tests don't use valid driver names. This patch adds an option to disable those warning, which is only intended for running tests. Signed-off-by: Walter Lozano <walter.lozano@collabora.com> Reviewed-by: Simon Glass <sjg@chromium.org>
| * dtoc: add support to scan driversWalter Lozano2020-07-093-4/+145
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently dtoc scans dtbs to convert them to struct platdata and to generate U_BOOT_DEVICE entries. These entries need to be filled with the driver name, but at this moment the information used is the compatible name present in the dtb. This causes that only nodes with a compatible name that matches a driver name generate a working entry. In order to improve this behaviour, this patch adds to dtoc the capability of scan drivers source code to generate a list of valid driver names and aliases. This allows to generate U_BOOT_DEVICE entries using valid driver names and rise a warning in the case a name is not valid. Signed-off-by: Walter Lozano <walter.lozano@collabora.com> Reviewed-by: Simon Glass <sjg@chromium.org> Open files in utf-8 mode: Signed-off-by: Simon Glass <sjg@chromium.org>
| * core: add support for U_BOOT_DRIVER_ALIASWalter Lozano2020-07-0914-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently when using OF_PLATDATA the binding between devices and drivers is done trying to match the compatible string in the node with a driver name. However, usually a single driver supports multiple compatible strings which causes that only devices which its compatible string matches a driver name get bound. To overcome this issue, this patch adds the U_BOOT_DRIVER_ALIAS macro, which generates no code at all, but allows an easy way to declare driver name aliases. Thanks to this, dtoc could be improve to look for the driver name based on its alias when it populates the U_BOOT_DEVICE entry. Signed-off-by: Walter Lozano <walter.lozano@collabora.com> Reviewed-by: Simon Glass <sjg@chromium.org>
| * dtoc: add missing code commentsWalter Lozano2020-07-091-0/+3
| | | | | | | | | | | | | | | | Add missing information about internal class members in order to make the code easier to follow. Signed-off-by: Walter Lozano <walter.lozano@collabora.com> Reviewed-by: Simon Glass <sjg@chromium.org>
| * drivers: rename drivers to match compatible stringWalter Lozano2020-07-0945-120/+106
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When using OF_PLATDATA, the bind process between devices and drivers is performed trying to match compatible string with driver names. However driver names are not strictly defined, and also there are different names used when declaring a driver with U_BOOT_DRIVER, the name of the symbol used in the linker list and the used in the struct driver_info. In order to make things a bit more clear, rename the drivers names. This will also help for further OF_PLATDATA improvements, such as checking for valid driver names. Signed-off-by: Walter Lozano <walter.lozano@collabora.com> Reviewed-by: Simon Glass <sjg@chromium.org> Add a fix for sandbox of-platdata to avoid using an invalid ANSI colour: Signed-off-by: Simon Glass <sjg@chromium.org>
| * test/dm: fdtdec: Add tests for fdtdec_add_reserved_memory()Bin Meng2020-07-091-0/+69
| | | | | | | | | | | | | | | | This adds a test case to test the functionality of the fdtdec API fdtdec_add_reserved_memory(). Signed-off-by: Bin Meng <bin.meng@windriver.com> Reviewed-by: Simon Glass <sjg@chromium.org>
| * test/dm: fdtdec: Corect a typo in dm_test_fdtdec_set_carveout()Bin Meng2020-07-091-1/+1
| | | | | | | | | | | | | | It should be "writable". Signed-off-by: Bin Meng <bin.meng@windriver.com> Reviewed-by: Simon Glass <sjg@chromium.org>
| * test/dm: fdtdec: Add the missing gd declarationBin Meng2020-07-091-0/+2
| | | | | | | | | | | | | | Add DECLARE_GLOBAL_DATA_PTR since it is referenced in the test codes. Signed-off-by: Bin Meng <bin.meng@windriver.com> Reviewed-by: Simon Glass <sjg@chromium.org>
| * cmd: fdt: remove CMD_FDT_MAX_DUMPHeinrich Schuchardt2020-07-091-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When printing the device tree we want to get an output that can be used as input for the device tree compiler. This requires that we do not write bogus lines like pcie@10000000 { interrupt-map = * 0x4000127c [0x00000280]; For instance the QEMU virt device has a property interrupt-map with 640 bytes which exceeds CMD_FDT_MAX_DUMP=64. So lets do away with the artificial limitation to 64 bytes. As indicated in commit f0a29d43313c ("fdt: Limit printed hex in fdt print and list commands") if a device tree contains binary blobs, it may still be desirable to limit the output length. Provide environment variable fdt_max_dump for this purpose. Fixes: 5d927b428622 ("Kconfig: Drop CONFIG_CMD_FDT_MAX_DUMP") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
| * log: use BIT() instead of 1 <<Heinrich Schuchardt2020-07-092-14/+14
| | | | | | | | | | | | | | Use the BIT() macro when creating a bitmask for the logging fields. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
| * log: don't show function by defaultHeinrich Schuchardt2020-07-096-10/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | The name of the function emitting a log message may be of interest for a developer but is distracting for normal users. See the example below: try_load_entry() Booting: Debian Make the default format for log messages customizable. By default show only the message text. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>