aboutsummaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)AuthorFilesLines
2018-09-23efi_loader: Pass address to fs_read()Alexander Graf1-1/+4
The fs_read() function wants to get an address rather than the pointer to a buffer. So let's convert the passed buffer from pointer back a the address to make efi_loader on sandbox happier. Signed-off-by: Alexander Graf <agraf@suse.de> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-09-23efi_selftest: test for loaded image protocolHeinrich Schuchardt2-0/+109
Verify that the loaded image protocol is installed on the image handle. Verify that the loaded image protocol points to the system table. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-09-23efi_loader: pass system table in loaded image protocolHeinrich Schuchardt1-0/+1
The system table must be passed as a pointer in the loaded image protocol. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-09-23efi_selftest: memory leak testing manage protocolsHeinrich Schuchardt1-2/+19
Remove memory leak in efi_selftest_manageprotocols.c. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-09-18lib: bitrev: Sync with Linux kernel v4.17Bin Meng1-19/+9
Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-09-10Remove <inttypes.h> includes and PRI* usages in printf() entirelyMasahiro Yamada9-22/+12
In int-ll64.h, we always use the following typedefs: typedef unsigned int u32; typedef unsigned long uintptr_t; typedef unsigned long long u64; This does not need to match to the compiler's <inttypes.h>. Do not include it. The use of PRI* makes the code super-ugly. You can simply use "l" for printing uintptr_t, "ll" for u64, and no modifier for u32. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-09-10fdt: fix get_next_memory_node()Marek Vasut1-3/+1
The get_next_memory_node() always sets mem to -1 , which is incorrect, because then every iteration of memory bank parsing will start from the first memory bank instead of the previous one. On systems with 1 memory bank defined in DT and CONFIG_NR_DRAM_BANKS=4 , like ie. r8a77965-salvator-x , this will result in U-Boot incorrectly reporting four identical memory banks with the same memory configuration. Fix this by setting mem to startoffset value, which restores the behavior before the fixed patch was applied. Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Jens Wiklander <jens.wiklander@linaro.org> Cc: Simon Glass <sjg@chromium.org> Cc: Tom Rini <trini@konsulko.com> Fixes: 452bc121027d ("fdt: fix fdtdec_setup_memory_banksize()") Tested-by: Michal Simek <michal.simek@xilinx.com> [on ZynqMP}
2018-09-05lib/slre: remove superfluous assignmentHeinrich Schuchardt1-2/+0
It makes no sense to assign a value to 'res' if the next use of the variable is an assignment. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2018-08-31Make kmalloc'ed memory really DMA-safeMasahiro Yamada1-2/+3
In Linux, the memory returned by kmalloc() is DMA-capable. However, it is not true in U-Boot. At a glance, kmalloc() in U-Boot returns address aligned with ARCH_DMA_MINALIGN. However, it never pads the allocated memory. This half-way house is completely useless because calling kmalloc() and malloc() in this order causes a cache sharing problem. Change the implementation to call malloc_cache_aligned(), which allocates really DMA-capable memory. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-08-30efi: stub: Pass EFI system table address to U-Boot payloadBin Meng1-0/+4
This updates the EFI stub codes to pass UEFI BIOS's system table address to U-Boot payload so that U-Boot can utilize it. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-08-24libavb: Handle wrong hashtree_error_mode in avb_append_options()Ievgen Maliarenko1-0/+3
Exit with AVB_SLOT_VERIFY_RESULT_ERROR_INVALID_ARGUMENT when hashtree_error_mode value passed to avb_append_options() is unknown (not from AvbHashtreeErrorMode enum). Otherwise, default value is not handled in the switch(hashtree_error_mode), which causes below compile warning: lib/libavb/avb_cmdline.c: In function ‘avb_append_options’: lib/libavb/avb_cmdline.c:354:13: warning: ‘dm_verity_mode’ may be used uninitialized in this function [-Wmaybe-uninitialized] new_ret = avb_replace( ~~~~~~~~^~~~~~~~~~~~~~ slot_data->cmdline, "$(ANDROID_VERITY_MODE)", dm_verity_mode); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lib/libavb/avb_cmdline.c:363:8: warning: ‘verity_mode’ may be used uninitialized in this function [-Wmaybe-uninitialized] if (!cmdline_append_option( ^~~~~~~~~~~~~~~~~~~~~~ slot_data, "androidboot.veritymode", verity_mode)) { Signed-off-by: Ievgen Maliarenko <ievgen.maliarenko@globallogic.com> Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com> Reviewed-by: Igor Opaniuk <igor.opaniuk@linaro.org>
2018-08-21efi: Fix truncation of constant valueEugeniu Rosca1-4/+3
Starting with commit 867a6ac86dd8 ("efi: Add start-up library code"), sparse constantly complains about truncated constant value in efi.h: include/efi.h:176:35: warning: cast truncates bits from constant value (8000000000000000 becomes 0) This can get quite noisy, preventing real issues to be noticed: $ make defconfig *** Default configuration is based on 'sandbox_defconfig' $ make C=2 -j12 2>&1 | grep truncates | wc -l 441 After the patch is applied: $ make C=2 -j12 2>&1 | grep truncates | wc -l 0 $ sparse --version v0.5.2 Following the suggestion of Heinrich Schuchardt, instead of only fixing the root-cause, I replaced the whole enum of _SHIFT values by ULL defines. This matches both the UEFI 2.7 spec and the Linux kernel implementation. Some ELF size comparison before and after the patch (gcc 7.3.0): efi-x86_payload64_defconfig: text data bss dec hex filename 407174 29432 278676 715282 aea12 u-boot.old 407152 29464 278676 715292 aea1c u-boot.new -22 +32 0 +10 efi-x86_payload32_defconfig: text data bss dec hex filename 447075 30308 280076 757459 b8ed3 u-boot.old 447053 30340 280076 757469 b8edd u-boot.new -22 +32 0 +10 Fixes: 867a6ac86dd8 ("efi: Add start-up library code") Suggested-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-08-21efi_loader: EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.Reset()Heinrich Schuchardt1-8/+14
Implement the reset service of the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL. This should resolve the error reported by the SCT in Protocol/SimpleTextOut/BlackBoxTest/SimpleTextOutBBTestFunction_uefi.c:639 Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-08-20efi_selftest: correct block device unit testHeinrich Schuchardt1-1/+1
The UEFI specification mandates that the create flag is only used in conjunction with both the read and the write flag. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-08-20efi_loader: document runtime functionsHeinrich Schuchardt1-4/+149
Add comments for runtime service functions. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-08-20efi_loader: update runtime services table crc32Heinrich Schuchardt2-12/+15
The crc32 of the runtime services table must be updated after detaching. efi_update_table_header_crc32() must be __efi_runtime. So move it to efi_runtime.c Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-08-20lib: crc32: mark function crc32() as __efi_runtimeHeinrich Schuchardt1-12/+14
The function crc32() is needed by the EFI subsystem at runtime. So it has to be linked into the runtime section together with all dependencies. Eliminate empty defines local and ZEXPORT. Mark variables as static which are not exported. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-08-20efi_loader: avoid NULL dereference in efi_get_memory_map()Heinrich Schuchardt1-1/+3
We should only dereference parameter memory_map_size after checking that it is valid. Fixes: 8e835554b36b ("efi_loader: check parameters of GetMemoryMap") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-08-20efi_loader: fix a parameter check at CreateEvent()AKASHI Takahiro1-1/+2
The commit 21b3edfc9644 ("efi_loader: check parameters of CreateEvent") enforces a strict parameter check at CreateEvent(). On the other hand, UEFI specification version 2.7, section 7.1, says: The EVT_NOTIFY_WAIT and EVT_NOTIFY_SIGNAL flags are exclusive. If neither flag is specified, the caller does not require any notification concerning the event and the NotifyTpl, NotifyFunction, and NotifyContext parameters are ignored. So the check should be mitigated so as to comply with the specification. Without this patch, EDK2's Shell.efi won't be started. Fixes: 21b3edfc9644 ("efi_loader: check parameters of CreateEvent") Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-08-20efi_loader: relocate pointer to tablesHeinrich Schuchardt1-1/+8
When applying a virtual memory map we have to update the pointer to the list of configuration tables. Fixes: 4182a129ef73 ("efi_loader: allocate configuration table array") Reported-by: Mark Kettenis <mark.kettenis@xs4all.nl> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Tested-by: Mark Kettenis <kettenis@openbsd.org> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-08-20Revert "efi_loader: efi_allocate_pages is too restrictive"Stephen Warren1-1/+1
This reverts commit aa909462d01866354f4cd4534db5f571c2cf1fbb. This change caused "dhcp filename" to crash the system on p2371-2180 (Jetson TX1), for example when running test/py. Reverting this change isn't optimal, but at least restores TX1 to a working state. In the future, we should: a) Fix whatever problem causes the crash with this patch applied. This needs further discussion, so isn't something we can immediately do. b) Undo the revert; re-apply the original patch to efi_allocate_pages. Signed-off-by: Stephen Warren <swarren@nvidia.com> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-08-13rsa: Fix LibreSSL before v2.7.0Caliph Nomble1-6/+12
Fix LibreSSL compilation for versions before v2.7.0. Signed-off-by: Caliph Nomble <nomble@palism.com> Reviewed-by: Jonathan Gray <jsg@jsg.id.au>
2018-08-10smbios: fix checkstyle warningChristian Gmeiner1-0/+1
Fixes the following checkstyle warning: WARNING: Missing a blank line after declarations + int tmp = smbios_write_funcs[i]((ulong *)&addr, handle++); + max_struct_size = max(max_struct_size, tmp); Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-08-10smbios: fix checkstyle errorChristian Gmeiner1-1/+1
Fixes the following chechpatch -f error: ERROR: "(foo*)" should be "(foo *)" + strncpy((char*)t->uuid, serial_str, sizeof(t->uuid)); Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-07-30Merge tag 'signed-efi-next' of git://github.com/agraf/u-bootTom Rini18-135/+826
Patch queue for efi - 2018-07-25 Highlights this time: - Many small fixes to improve spec compatibility (found by SCT) - Almost enough to run with sandbox target - GetTime() improvements - Enable EFI_LOADER and HYP entry on ARMv7 with NONSEC=y
2018-07-26Merge git://git.denx.de/u-boot-dmTom Rini2-6/+16
2018-07-26fdt_support: make FDT_FIXUP_PARTITIONS depend on CMD_MTDPARTSMasahiro Yamada1-1/+1
fdt_fixup_mtdparts() calls mtdparts_init() and device_find(), which are defined in cmd/mtdparts.c The combination of FDT_FIXUP_PARTITIONS=y and CMD_MTDPARTS=n emits the following link error: common/fdt_support.c:903: undefined reference to `mtdparts_init' common/fdt_support.c:914: undefined reference to `device_find' Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-07-26fdt: fix fdtdec_setup_memory_banksize()Jens Wiklander1-5/+15
Prior to this patch is fdtdec_setup_memory_banksize() incorrectly ignoring the "status" field. This patch fixes that by testing the status with fdtdec_get_is_enabled() before using a memory node. Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-07-26initialize net_mode.if_typeAndrew Thomas1-0/+1
if_type is not correctly initialized Failure to initialize if_type means that grub2/efinet sends a bogus arp request. It therefore gets no response. On Raspberry Pi 3B+ this leads to a pause at: lan78xx_eth Waiting for PHY auto negotiation to complete....... done lan78xx_eth Waiting for PHY auto negotiation to complete....... done Signed-off-by: Andrew Thomas <andrew.thomas@oracle.com> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2018-07-25efi_selftest: unit test for GetTime()Heinrich Schuchardt2-0/+68
Provide a unit test for the GetTime() runtime service. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-07-25efi_selftest: support printing leading zeroesHeinrich Schuchardt1-11/+22
Allow specifying the precision when printing integers, e.g. efi_st_printf("%.4u-%.2u-%.2u\n", year, month, day); Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-07-25efi_loader: complete implementation of GetTime()Heinrich Schuchardt1-12/+41
Implement the missing parts of the GetTime() runtime service. Fill seconds. Fill daylight saving time flag correctly. Provide dummy values for capabilities. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-07-25efi_loader: remove unused efi_get_time_init()Heinrich Schuchardt1-5/+0
Remove unused function efi_get_time_init(). Initialization of the RTC has to be done in board bring up not in the EFI subsystem. There is no RTC device in the UEFI spec. The RTC is only accessed through the runtime services. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-07-25efi_selftest: unit test for CalculateCrc32()Heinrich Schuchardt2-0/+142
This unit test checks the CalculateCrc32 bootservice and checks the headers of the system table, the boot services tablle, and the runtime services table before and after ExitBootServices(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-07-25efi_selftest: check crc32 for InstallConfigurationTableHeinrich Schuchardt1-0/+43
InstallConfigurationTable() may change the number of installed configuration tables. Check the crc32 of the system table. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-07-25efi_loader: update crc32 in InstallConfigurationTableHeinrich Schuchardt1-0/+3
If the number of installed tables is changed in InstallConfigurationTable() update the crc32 of the system table. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-07-25efi_loader: correct signature of CalculateCrc32()Heinrich Schuchardt1-4/+4
Use const for the buffer. We are not changing the buffer. Use efi_uintn_t where prescribed by the UEFI spec. Prefer u32 over uint32_t. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-07-25efi_selftest: test InstallConfigurationTable()Heinrich Schuchardt2-0/+224
Provide a unit test for InstallConfigurationTable(). A table is installed, updated, removed. The table entry and the triggering of events is checked. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-07-25efi_loader: allocate configuration table arrayHeinrich Schuchardt1-20/+19
The system table contains a link to the list of configurations tables. These include the device tree, SMBIOS table, and the ACPI table. This array is currently statically linked. With the patch it is allocated as EFI_RUNTIME_SERVICES_DATA. Due to the structure of the system table we cannot work with a linked list here. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-07-25efi_loader: calculate crc32 for EFI tablesHeinrich Schuchardt1-4/+28
For the boot and runtime services tables and for the system table the crc32 has to be set in the header. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-07-25efi_loader: provide firmware revisionHeinrich Schuchardt2-2/+6
Provide a firmware revision in the system table using the Makefile variables VERSION and PATCHLEVEL, e.g. 0x20180700 for v2018.07. Correct the type of the firmware vendor. It is a u16* pointer. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-07-25efi_loader: correct headersize EFI tablesHeinrich Schuchardt2-3/+3
The headersize field has to be set to the size of the whole table including the header. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-07-25efi_loader: specify UEFI spec revisionHeinrich Schuchardt2-2/+4
Both in the boot and the runtime services tables we have to specify the UEFI spec revision. The same value is already used for the system table. So let's use a common constant. In the boot services table we have to provide the header signature. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-07-25efi_loader: clear screen has to reset cursor positionHeinrich Schuchardt1-0/+2
After clearing the screen the cursor position is row 0, column 0. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-07-25efi_loader: EFI_SIMPLE_TEXT_INPUT_PROTOCOL.Reset()Heinrich Schuchardt1-1/+6
Implement the reset service of the EFI_SIMPLE_TEXT_INPUT_PROTOCOL. This should resolve the error reported by the SCT in Protocol/SimpleTextIn/BlackBoxTest/SimpleTextInBBTestFunction.c:193 Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-07-25efi_loader: set revision in loaded image protocolHeinrich Schuchardt1-0/+1
The revision number has to be set in the loaded image protocol. The problem was detected by running the SCT in Protocol/LoadedImage/BlackBoxTest/LoadedImageBBTestMain.c:890 Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-07-25efi_driver: set DM_FLAG_NAME_ALLOCED flagHeinrich Schuchardt1-0/+2
Set the DM_FLAG_NAME_ALLOCED flag to avoid a memory leak when the block device is removed. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-07-25efi_selftest: test writing to fileHeinrich Schuchardt1-0/+70
Provide a unit test for writing to a FAT file system. Add some additional comments in block device unit test. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-07-25efi_loader: check map_key in ExitBootServicesHeinrich Schuchardt2-1/+11
The UEFI spec requires that the memory map key is checked in ExitBootServices(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-07-25efi_loader: check parameters of GetMemoryMapHeinrich Schuchardt1-10/+15
Check the parameters of boottime service GetMemoryMap(). Return EFI_INVALID_PARAMETER where required by the UEFI spec. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>