summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2020-06-29efi_loader: fix incorrect use of EFI_EXIT()Heinrich Schuchardt
efi_get_variable_common() does not use EFI_ENTRY(). So we should not use EFI_EXIT() either. Fixes: 767f6eeb01d3 ("efi_loader: variable: support variable authentication") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-06-24efi_loader: size of secure boot variablesHeinrich Schuchardt
The variables SetupMode, AuditMode, DeployedMode are explicitly defined as UINT8 in the UEFI specification. The type of SecureBoot is UINT8 in EDK2. Use variable name secure_boot instead of sec_boot for the value of the UEFI variable SecureBoot. Avoid abbreviations in function descriptions. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-06-24efi_loader: type of efi_secure_modeHeinrich Schuchardt
Variable efi_secure_mode is meant to hold a value of enum efi_secure_mode. So it should not be defined as int but as enum efi_secure_mode. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-06-15Merge tag 'efi-2020-07-rc5' of ↵Tom Rini
https://gitlab.denx.de/u-boot/custodians/u-boot-efi Pull request for UEFI sub-system for efi-2020-07-rc5 Use correct printf code in efi_image_parse(). Add random number generation to HTML documentation.
2020-06-15Revert "lib: Improve _parse_integer_fixup_radix base 16 detection"Sean Anderson
This reverts commit 0486497e2b5f4d36fa968a1a60fea358cbf70b65. The strtoul has well-defined semantics. It is defined by the C standard and POSIX. To quote the relevant section of the man pages, > If base is zero or 16, the string may then include a "0x" prefix, and the > number will be read in base 16; otherwise, a zero base is taken as 10 > (decimal) unless the next character is '0', in which case it is taken as > 8 (octal). Keeping these semantics is important for several reasons. First, it is very surprising for standard library functions to behave differently than usual. Every other implementation of strtoul has different semantics than the implementation in U-Boot at the moment. Second, it can result in very surprising results from small changes. For example, changing the string "1f" to "20" causes the parsed value to *decrease*. Forcing use of the "0x" prefix to specify hexidecimal numbers is a feature, not a bug. Lastly, this is slightly less performant, since the entire number is parsed twice. This fixes the str_simple_strtoul test failing with test/str_ut.c:29, run_strtoul(): expect_val == val: Expected 0x44b (1099), got 0x1099ab (1087915) test/str_ut.c:46, str_simple_strtoul(): 0 == run_strtoul(uts, str2, 0, 1099, 4): Expected 0x0 (0), got 0x1 (1) Signed-off-by: Sean Anderson <seanga2@gmail.com> CC: Michal Simek <michal.simek@xilinx.com> CC: Shiril Tichkule <shirilt@xilinx.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-06-15optee: fix copy of optee reserved-memory nodeEtienne Carriere
Fix the loop that parses FDT for a reserved memory node named "optee". Before this change, if at least one subnode was found in the reserved-memory node, the function endlessly looped since instruction continue returned back in the loop without updating variable subnode. This change fixes the issue by using a for loop. Fixes: 6ccb05eae01b ("image: fdt: copy possible optee nodes to a loaded devicetree") Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
2020-06-14efi_loader: printf code in efi_image_parse()Heinrich Schuchardt
For size_t we have to use %zu for printing not %lu. Fixes: 4540dabdcaca ("efi_loader: image_loader: support image authentication") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-06-08cmd: Correct the 'md.q' commandSimon Glass
This displays incorrect data at present due to a missing header file in display_options. Fix it. Fixes: 09140113108 ("command: Remove the cmd_tbl_t typedef") Signed-off-by: Simon Glass <sjg@chromium.org>
2020-06-05efi_loader: comments EFI_SIMPLE_TEXT_OUTPUT_PROTOCOLHeinrich Schuchardt
Provide missing comments for the functions implementing the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-06-05smbios: empty strings in smbios_add_string()Heinrich Schuchardt
smbios_add_string() cannot deal with empty strings. This leads to incorrect property values and invalid tables. E.g. for the pine64-lts_defconfig CONFIG_SMBIOS_MANUFACTURER="". Linux command dmidecode shows: Table 1: Manufacturer: sunxi Product Name: sunxi Table 3: Invalid entry length (2). DMI table is broken! Stop. Replace empty strings by "Unknown". Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-06-04Merge https://gitlab.denx.de/u-boot/custodians/u-boot-riscvTom Rini
- Fixes 7e249bc13aaf: ("riscv: Move all SMP related SBI calls to SBI_v01") Move sbi_probe_extension() out of CONFIG_SBI_V01. - SiFive FU540 support SPL.
2020-06-04lib: Makefile: build crc7.c when CONFIG_MMC_SPIPragnesh Patel
When build U-Boot SPL, meet an issue of undefined reference to 'crc7' for drivers/mmc/mmc_spi.c, so let's compile crc7.c when CONFIG_MMC_SPI selected. Signed-off-by: Pragnesh Patel <pragnesh.patel@sifive.com> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Acked-by: Jagan Teki <jagan@amarulasolutions.com>
2020-06-03Merge tag 'efi-2020-07-rc4' of ↵Tom Rini
https://gitlab.denx.de/u-boot/custodians/u-boot-efi Pull request for UEFI sub-system for efi-2020-07-rc4 This patch series addresses the following issues: * allow compiling with clang * add missing function descriptions to the HTML documentation * simplify the validation of UEFI images * validate load options in the UEFI boot manager In a preparatory patch a structure definition is moved.
2020-06-03efi_loader: signature: move efi_guid_cert_type_pkcs7 to efi_signature.cAKASHI Takahiro
The global variable, efi_guid_cert_type_pkcs7, will also be used in efi_image_loader.c in a succeeding patch so as to correctly handle a signature type of authenticode in signed image. Meanwhile, it is currently defined in efi_variable.c. Once some secure storage solution for UEFI variables is introduced, efi_variable.c may not always be compiled in. So move the definition to efi_signature.c as a common place. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-06-03efi_loader: simplify PE consistency checkHeinrich Schuchardt
Knowing that at least one section header follows the optional header we only need to check for the length of the 64bit header which is longer than the 32bit header. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-06-03efi_loader: function description cmp_pe_section()Heinrich Schuchardt
Rework the description of function cmp_pe_section(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-06-03efi_loader: function descriptions efi_image_loader.cHeinrich Schuchardt
We want to follow the Linux kernel style for function descriptions. Add missing parentheses after function names. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-06-03efi_loader: allow compiling with clangHeinrich Schuchardt
On ARM systems gd is stored in register r9 or x18. When compiling with clang gd is defined as a macro calling function gd_ptr(). So we can not make assignments to gd. In the UEFI sub-system we need to save gd when leaving to UEFI binaries and have to restore gd when reentering U-Boot. Define a new function set_gd() for setting gd and use it in the UEFI sub-system. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Tested-by: Tom Rini <trini@konsulko.com>
2020-06-03efi_loader: validate load optionHeinrich Schuchardt
For passing the optional data of the load option to the loaded imaged protocol we need its size. efi_deserialize_load_option() is changed to return the size of the optional data. As a by-product we get a partial validation of the load option. Checking the length of the device path remains to be implemented. Some Coverity defects identified the load options as user input because get_unaligned_le32() and get_unaligned_le16() is called. But non of these Coverity defects can be resolved without marking functions with Coverity specific tags. Reported-by: Coverity (CID 303760) Reported-by: Coverity (CID 303768) Reported-by: Coverity (CID 303776) Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-06-02kconfig: fix some typosMarcin Juszkiewicz
Signed-off-by: Marcin Juszkiewicz <marcin@juszkiewicz.com.pl>
2020-05-25cmd: zip: automatically pull in gzip()Michael Walle
Move the CONFIG_GZIP_COMPRESSED from a config.h macro to a Kconfig menu item. It is not selectable by a user because there is no reason to do so. Instead it will be automatically selected by the stuff which uses gzip(), like the zip command. Remove it from the config_whitelist.txt. Also remove CONFIG_GZIP_COMPRESS_DEF_SZ as this was never used on any board. The default seems to be sane, otherwise it should be added as a Kconfig option. Signed-off-by: Michael Walle <michael@walle.cc> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-05-22Merge tag 'efi-2020-07-rc3-2' of ↵Tom Rini
https://gitlab.denx.de/u-boot/custodians/u-boot-efi Pull request for UEFI sub-system for efi-2020-07-rc3 (2) Problems fixed with these patches are: * UEFI sub-system not working with virtio block devices * Missing SATA support in UEFI sub-system * A superfluous debug statement
2020-05-21efi_loader: check device path is not installed twiceHeinrich Schuchardt
Prior to corrective patches for virtio and SATA devices the same device path was installed on two different handles. This is not allowable. With this patch we will throw an error if this condition occurs for block devices. Update a comment for the installation of the simple file system protocol. Reported-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-05-21efi_loader: device path for SATA devicesHeinrich Schuchardt
Provide device path nodes for SATA devices. This avoids creation of two handles with the same device path indicating our root node. This is what the device paths for a SATA drive with four partitions could like: /VenHw(..)/Sata(0x0,0xffff,0x0) /VenHw(..)/Sata(0x0,0xffff,0x0)/HD(1,MBR,0x81ea591f,0x800,0x63ff830) /VenHw(..)/Sata(0x0,0xffff,0x0)/HD(2,MBR,0x81ea591f,0x6400800,0x9ff830) /VenHw(..)/Sata(0x0,0xffff,0x0)/HD(3,MBR,0x81ea591f,0x6e00800,0x16ef2ab0) /VenHw(..)/Sata(0x0,0xffff,0x0)/HD(4,MBR,0x81ea591f,0x1dcf3800,0x1dcedab0) Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-05-21efi_loader: device path for virtio block devicesHeinrich Schuchardt
The UEFI specification does not define a device sub-type for virtio. Let's use a vendor hardware node here. This avoids creation of two handles with the same device path indicating our root node. Reported-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-05-21efi_loader: initialize root node firstHeinrich Schuchardt
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-21efi_loader: Remove unnecessary debugPragnesh Patel
Remove unnecessary debug() from efi_set_variable_common(). native_name is NULL, so there is no meaning to print it. Signed-off-by: Pragnesh Patel <pragnesh.patel@sifive.com> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-05-20fdtdec: Add weak function to patch U-Boot DT right after fdtdec_setup()Marek Vasut
Add weak function which is called right after fdtdec_setup() configured the U-Boot DT. This permits board-specific adjustments to the U-Boot DT before U-Boot starts parsing the DT. This could be used e.g. to patch in various custom nodes or merge in DT fragments from prior-stage firmware. Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org> Cc: Simon Glass <sjg@chromium.org> Cc: Tom Rini <trini@konsulko.com>
2020-05-18common: Drop linux/bitops.h from common headerSimon Glass
Move this uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-18common: Drop linux/delay.h from common headerSimon Glass
Move this uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-18Fix some checkpatch warnings in calls to udelay()Simon Glass
Fix up some incorrect code style in calls to functions in the linux/time.h header, mostly udelay(). Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-18common: Drop linux/bug.h from common headerSimon Glass
Move this uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-18common: Drop asm_offsets.h from common headerSimon Glass
Move this uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-18common: Drop log.h from common headerSimon Glass
Move this header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-18command: Remove the cmd_tbl_t typedefSimon Glass
We should not use typedefs in U-Boot. They cannot be used as forward declarations which means that header files must include the full header to access them. Drop the typedef and rename the struct to remove the _s suffix which is now not useful. This requires quite a few header-file additions. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-18common: Drop init.h from common headerSimon Glass
Move this uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-18common: Drop image.h from common headerSimon Glass
Move this uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-18common: Drop bootstage.h from common headerSimon Glass
Move this fairly uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-18common: Drop part.h from common headerSimon Glass
Move this uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-18part: Drop disk_partition_t typedefSimon Glass
We should not be using typedefs and these make it harder to use forward declarations (to reduce header file inclusions). Drop the typedef. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-18common: Drop net.h from common headerSimon Glass
Move this header out of the common header. Network support is used in quite a few places but it still does not warrant blanket inclusion. Note that this net.h header itself has quite a lot in it. It could be split into the driver-mode support, functions, structures, checksumming, etc. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-18common: Drop uuid.h from common headerSimon Glass
Move this uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-17efi_loader: Implement EFI variable handling via OP-TEEIlias Apalodimas
In OP-TEE we can run EDK2's StandAloneMM on a secure partition. StandAloneMM is responsible for the UEFI variable support. In combination with OP-TEE and it's U-Boot supplicant, variables are authenticated/validated in secure world and stored on an RPMB partition. So let's add a new config option in U-Boot implementing the necessary calls to OP-TEE for the variable management. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Pipat Methavanitpong <pipat1010@gmail.com> Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-05-17efi_loader: round the memory area in efi_add_memory_map()Michael Walle
Virtually all callers of this function do the rounding on their own. Some do it right, some don't. Instead of doing this in each caller, do the rounding in efi_add_memory_map(). Change the size parameter to bytes instead of pages and remove aligning and size calculation in all callers. There is no more need to make the original efi_add_memory_map() (which takes pages as size) available outside the module. Thus rename it to efi_add_memory_map_pg() and make it static to prevent further misuse outside the module. Signed-off-by: Michael Walle <michael@walle.cc> Add missing comma in sunxi_display.c. Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-05-15lib: rsa: avoid overriding the object name when already specifiedJan Luebbe
If "object=" is specified in "keydir" when using the pkcs11 engine do not append another "object=<key-name-hint>". This makes it possible to use object names other than the key name hint. These two string identifiers are not necessarily equal. Signed-off-by: Jan Luebbe <jlu@pengutronix.de> Signed-off-by: Bastian Krause <bst@pengutronix.de> Reviewed-by: George McCollister <george.mccollister@gmail.com>
2020-05-15lib: rsa: Also check for presence of r-squared propertyJan Kiszka
Better than crashing later if it is missing. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2020-05-15rsa: don't use malloc.h in rsa-sign.cJonathan Gray
stdlib.h is the header for malloc since at least c89/c90. There is no system malloc.h on OpenBSD and trying to use malloc.h here falls back to the U-Boot malloc.h breaking the build of qemu_arm64. Fixes: 336d4615f8 ("dm: core: Create a new header file for 'compat' features") Signed-off-by: Jonathan Gray <jsg@jsg.id.au>
2020-05-15lib: Allow MD5 to be enabled in SPLSimon Glass
At present the MD5 option cannot be enabled by board configs since it has no Kconfig name. It is generally enabled, so long as FIT support is present. But not all boards use FIT, particularly in SPL Fix this and add an option for SPL as well. This allows board code to call md5() even if FIT support is not enabled. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-09charset: Add support for calculating bytes occupied by a u16 stringSughosh Ganu
The current code uses 'u16_strlen(x) + 1) * sizeof(u16)' in various places to calculate the number of bytes occupied by a u16 string. Let's introduce a wrapper around this. This wrapper is used on following patches Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-05-09efi_loader: variable: check a return value of uuid__str_to_bin()AKASHI Takahiro
The only error case is that a given UUID is in wrong format. So just return EFI_INVALID_PARAMETER here. Reported-by: Coverity (CID 300333) Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>