Commit Graph

1861 Commits

Author SHA1 Message Date
Simon Glass
2189d5f1e8 Move strtomhz() to vsprintf.h
At present this function sits in its own file but it does not really
justify it. There are similar string functions in vsprintf.h, so move it
there. Also add the missing function comment.

Use the vsprintf.h include file explicitly where needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2019-12-02 18:23:09 -05:00
Simon Glass
8bef79bf3c common: Move sorting functions to their own header file
These don't need to be in common.h so move them out into a new header.
Also add some missing comments.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2019-12-02 18:23:08 -05:00
Simon Glass
3db7110857 crc32: Use the crc.h header for crc functions
Drop inclusion of crc.h in common.h and use the correct header directly
instead.

With this we can drop the conflicting definition in fw_env.h and rely on
the crc.h header, which is already included.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2019-12-02 18:23:08 -05:00
Simon Glass
b2ea91ba57 crc: Fix code style with crc functions
Some of these have a space before the bracket. Drop it to fix the style.
Add some missing function comments while here.

Note that u32 and u8 cannot be used here since crc.h is included on the
host side.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2019-12-02 18:23:07 -05:00
Simon Glass
c3a4d1c3ee common: Drop linux/crc8.h
We have an existing U-Boot header for the one function that this defines.
Use that instead of the linux/ one. Move over the nice comment.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2019-12-02 18:23:07 -05:00
Simon Glass
840ef4d43b common: Move random-number functions into their own header
Create a new rand.h header file and move functions into it, to reduce
the size of common.h

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2019-12-02 18:23:07 -05:00
Heinrich Schuchardt
b7cdecfc19 efi_loader: default EFI_LOADER=n on ARM11
Some of the ARM11 boards have tight limits on the size of U-Boots. Hence
use EFI_LOADER=n as default on ARM11.

Set EFI_LOADER=y for the Raspberry Pi and Raspberry Pi Zero as these boards
have sufficient storage on the SD card.

Suggested-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-11-23 09:19:31 +01:00
Heinrich Schuchardt
38064ee04c efi_loader: enable EFI_LOADER on arm1136 and arm1176
With an implementation for allow_unaligned() available for arm1136 and
arm1176 UEFI can be supported on these architectures.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-11-19 12:10:22 +01:00
Heinrich Schuchardt
b20bb09b21 efi_loader: restrict EFI_LOADER to armv7 and armv8 on ARM
fatload USB was reported to fail on the Sheevaplug. Debugging showed that
this was caused by an incorrect unaligned write to memory in
path_to_uefi().

UEFI on ARM requires that unaligned memory access is enabled.

* ARMv5 does not support unaligned access at all.
* ARMv6 supports unaligned access when we clear the A flag and set the
  U flag.
* On ARMv7 unaligned access is possible when clearing the aligned flag,
  which we do in function allow_unaligned() (arch/arm/cpu/armv7/sctlr.S).
  For none of the other cpus in arch/arm/cpu/ we have implemented a
  similar function.
* ARMv8 allows unaligned access.

Let EFI_LOADER on ARM depend on SYS_CPU=armv7 or SYS_CPU=armv8.

Once we have implemented allow_unaligned() for other ARM CPUs we can add
these to Kconfig.

Reported-by: Gray Remlin <gryrmln@gmail.com>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-11-19 12:10:22 +01:00
Heinrich Schuchardt
246e601846 efi_loader: remove unused function efi_dp_from_dev()
Function efi_dp_from_dev() is not used anywhere. Remove it.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-11-19 12:10:22 +01:00
Tom Rini
fd8adc33b8 Add OP-TEE test swuit
Fix patman cc_file output
 Minor sandbox/pinctrl changes
 -----BEGIN PGP SIGNATURE-----
 
 iQFFBAABCgAvFiEEslwAIq+Gp8wWVbYnfxc6PpAIreYFAl3NiIMRHHNqZ0BjaHJv
 bWl1bS5vcmcACgkQfxc6PpAIreYC2gf8DE+un/xHxyRwxCdnWuDI4dhC0Reffp3z
 5cyYv10du8t5fAkqbNHVodx/nG+P339x3Dvz8+4wJaJXJH9tdm04q28uE/iG89T1
 yf6pHRmeyp8FoveeScMAtx7OFgyG2l93K/sqhEQQKvnNadMDXjJPcmixgU4igNha
 JaPb6n4Hd04tSHyDgfeYz6kXW5Bxlp37t0UwKHSLfYMk4CH0hsydRV4FDoGRFups
 HAhT43B8b2Ml1MfQG+jgcrLfwGCRr+a6PamzmR1KW/LxhiVLl+XU8hfCBXnO9CXy
 Em/aJasNA6Wl4GaXy46UjM6xeUL2irENU5NvW5F+gTJ31tuoj+Movg==
 =y/5J
 -----END PGP SIGNATURE-----

Merge tag 'dm-pull-14nov19' of git://git.denx.de/u-boot-dm

Add OP-TEE test swuit
Fix patman cc_file output
Minor sandbox/pinctrl changes
2019-11-17 21:15:23 -05:00
Heiko Stuebner
6ccb05eae0 image: fdt: copy possible optee nodes to a loaded devicetree
The loading convention for optee or any other tee on arm64 is as bl32
parameter to the trusted-firmware. So TF-A gets invoked with the TEE as
bl32 and main u-boot as bl33. Once it has done its startup TF-A jumps
into the bl32 for the TEE startup, returns to TF-A and then jumps to bl33.

All of them get passed a devicetree as parameter and all components often
get loaded from a FIT image.

OP-TEE will create additional nodes in that devicetree namely a firmware
node and possibly multiple reserved-memory nodes.

While this devicetree is used in main u-boot, in most cases it won't be
the one passed to the actual kernel. Instead most boot commands will load
a new devicetree from somewhere like mass storage of the network, so if
that happens u-boot should transfer the optee nodes to that new devicetree.

To make that happen introduce optee_copy_fdt_nodes() called from the dt
setup function in image-fdt which after checking for the optee presence
in the u-boot dt will make sure a optee node is present in the kernel dt
and transfer any reserved-memory regions it can find.

Signed-off-by: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
2019-11-14 07:09:34 -06:00
Heiko Stuebner
357d2ceba0 fdtdec: only create phandle if caller wants it in fdtdec_add_reserved_memory()
The phandlep pointer returning the phandle to the caller is optional
and if it is not set when calling fdtdec_add_reserved_memory() it is
highly likely that the caller is not interested in a phandle to the
created reserved-memory area and really just wants that area added.

So just don't create a phandle in that case.

Signed-off-by: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2019-11-14 07:09:34 -06:00
Heiko Stuebner
086336a225 fdtdec: protect against another NULL phandlep in fdtdec_add_reserved_memory()
The change adding fdtdec_add_reserved_memory() already protected the added
phandle against the phandlep being NULL - making the phandlep var optional.

But in the early code checking for an already existing carveout this check
was not done and thus the phandle assignment could run into trouble,
so add a check there as well, which makes the function still return
successfully if a matching region is found, even though no-one wants to
work with the phandle.

Fixes: c9222a08b3 ("fdtdec: Implement fdtdec_add_reserved_memory()")
Signed-off-by: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2019-11-14 07:09:34 -06:00
Heinrich Schuchardt
2e716b8e29 efi_selftest: enable all UEFI unit tests on the sandbox
As we can build relocation code for the sandbox now we should enable the
unit tests that had to be disabled up to now.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-11-12 23:13:54 +01:00
Heinrich Schuchardt
3b4847cbee efi_loader: support building UEFI binaries on sandbox
On the sandbox the UEFI binaries must match the host architectures.

Adjust the Makefiles. Provide the PE/COFF header and relocation files.

Allow building helloworld.efi on the sandbox.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-11-12 23:13:54 +01:00
Heinrich Schuchardt
7264e21fde efi_loader: call add_u_boot_and_runtime() on sandbox
On the sandbox we should mark the stack area as EFI runtime memory like we
do on any other architecture.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-11-12 23:13:54 +01:00
AKASHI Takahiro
89cb6a5dd6 efi_loader: disk: install file system protocol to a whole disk
Currently, a whole disk without any partitions is not associated
with EFI_SIMPLE_FILE_SYSTEM_PROTOCOL. So even if it houses some
file system, there is a chance that we may not be able to access
it, particularly, when accesses are to be attempted after searching
that protocol against a device handle.

With this patch, EFI_SIMPLE_FILE_SYSTEM_PROTOCOL is installed
to such a disk if part_get_info() shows there is no partition
table installed on it.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>

Only if no partition table exists, check for a file system on disk level.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-11-12 23:13:54 +01:00
Heinrich Schuchardt
cab6f06c14 efi_loader: fix efi_dp_from_name()
Correctly check the return value of efi_dp_from_file().
If we can determine device path for the file, should not depend on the
device path for the device being requested.
Provide a function description for efi_dp_from_name().

Reported-by: Coverity CID 273159, CID 273158
Fixes: 08c51fff30 ("efi_loader: device_path: check against file path length")
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-11-12 23:13:54 +01:00
Simon Glass
f0921f5098 fdt: Sync up to the latest libfdt
Bring over the fdt from this commit:

430419c (origin/master) tests: fix some python warnings

adding in the 'assumptions' series designed to reduce code size.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-11-04 18:15:32 -07:00
Simon Glass
0d76afc032 fdt: Add Kconfig options to control code size
For better or worse libfdt recent grew a lot of code that checks the
validity of the device tree in great detail. When using unsigned or
unverified data this makes things safer, but it does add to code size.

Add some controls to select the trade-off between safety and code size.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2019-11-04 18:15:32 -07:00
Tom Rini
24b77393a5 Pull request for UEFI sub-system for efi-2020-01-rc2
Provide a better user interface for setting UEFI variables.
 
 Bug fixes:
 - ext4 file system not discovered on UEFI block device
 - 'make tests' build error on 32bit systems
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEbcT5xx8ppvoGt20zxIHbvCwFGsQFAl25wUcACgkQxIHbvCwF
 GsQ16w/+IibWYFw2t6AdI8DLWOvlHR/PVAOrbF9cBi1vZPr4drEH6m1ymRWAKjRt
 E4u8siBiIs5yhD7laL09JK4p/veTnoHCVrCdli9iPhIJUFGKz9uuXh4ruZgRnGIn
 +j0ra0tkTRHeGX4bMtTpMVySQqIuLQ+2ZrMMnfKfnTTlLmhv436xUyBZ/CFl7k4J
 7sFj/FfjRCYpe7nfHTqUGidJtJG1cc+hw26c1YrfiKB6piVdH43myOB5sPDW24g3
 OPptJyUFqbQjjV6Eq0EOVJt103rVtXpQc0e4Oa/mDDkmrQZ1pUhXi3zhxmzMRDQu
 k+9gX0IoSNJcW+e7DrcQsx5SmOnlvoC4euCypzhWEWvES89ftAHIitEAz9oTs6Gc
 etwXFomvH797ZOoBztrja9XsfnLFHBQHaAiExqEVVFi/1nhDsYdj+xEDHjDU+cZx
 E3UcrRNXcfA2+oaXpNBguzAOrMPX8UbrR1kkaMDTuJfA32Pe7RLz3aMfXyx1rAOU
 t7GWSROOYtoNf5IU/Jha1F8231WRPJnWm1LQdzNLaGSmbG/H7vFgW4dpdxEyLn4m
 C0Goj0GzmBIQxRL+38sCOKLVxPEpGoU/GzonC9bU0O+UyN57rAiwn9ZbTa6ZvJqG
 /2tPoKiutJRueUH3IDWViMhyW/w0h0tj0BUiV5lAQ9X9vW4E1YQ=
 =f0m8
 -----END PGP SIGNATURE-----

Merge tag 'efi-2020-01-rc2' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi

Pull request for UEFI sub-system for efi-2020-01-rc2

Provide a better user interface for setting UEFI variables.

Bug fixes:
- ext4 file system not discovered on UEFI block device
- 'make tests' build error on 32bit systems
2019-11-01 09:37:02 -04:00
Tom Rini
bb1bb4bb5d Fix for patman with email addresses containing commas
Bootstage improvements for TPL, SPL
 Various sandbox and dm improvements and fixes
 -----BEGIN PGP SIGNATURE-----
 
 iQFFBAABCgAvFiEEslwAIq+Gp8wWVbYnfxc6PpAIreYFAl24zDoRHHNqZ0BjaHJv
 bWl1bS5vcmcACgkQfxc6PpAIreZRiwf+Mf7oG//zjiZcHaPP6KOFb1CjwqLSuiaI
 eCYB6GEZXuSpc8MjAw+baAfIw8MMFuaCfPsUQ5dDo391neK0sW9kkEsdcXnQBpB3
 GdJYcewLN1UuJZovriGobIisGc0GQHh8gmRcVGWSKoEt+gAQauRtVYBIUPuS3JG+
 ihZgYmVgICa+3tqavIbP2oZdXLuLAxR65mfiQHtiJwdCN3OOzyls2v0T0slQX9GV
 ln6EvTk8OMIudBmkB7YiTmJF7AB+3PH/uBaiYyTKO9gtjLhnmCFvG5HxJTRFOKvU
 F4oVWZJDEcqfZvYgWg8i5vgokMP41nzLfBr7j5ifUX1f3xwCHy/Tpw==
 =S4XI
 -----END PGP SIGNATURE-----

Merge tag 'dm-pull-29oct19' of git://git.denx.de/u-boot-dm

- Fix for patman with email addresses containing commas
- Bootstage improvements for TPL, SPL
- Various sandbox and dm improvements and fixes
2019-11-01 09:34:35 -04:00
Sam Protsenko
8f684b5a8b libavb: Fix build warnings after updating the lib
After updating libavb to most recent version from AOSP/master, two new
warnings appear:

Warning #1:

    lib/libavb/avb_cmdline.c: In function 'avb_append_options':
    lib/libavb/avb_cmdline.c:365:15: 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:374:8: warning: 'verity_mode' may be used
                                    uninitialized in this function
                                    [-Wmaybe-uninitialized]
       if (!cmdline_append_option(
            ^~~~~~~~~~~~~~~~~~~~~~
               slot_data, "androidboot.veritymode", verity_mode)) {
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Warning #2:

    lib/libavb/avb_slot_verify.c: In function 'avb_slot_verify':
    lib/libavb/avb_slot_verify.c:1349:23: warning: 'ret' may be used
                                          uninitialized in this function
                                          [-Wmaybe-uninitialized]
       AvbSlotVerifyResult ret;
                           ^~~

Fix those by providing default return values to affected functions.

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
2019-10-31 07:22:53 -04:00
Sam Protsenko
4d579a4394 libavb: Update libavb to current AOSP master
Update libavb to commit 5fbb42a189aa in AOSP/master, because new version
has support for super partition [1], which we need for implementing
Android dynamic partitions. All changes from previous patches for libavb
in U-Boot are accounted for in this commit:
  - commit ecc6f6bea6 ("libavb: Handle wrong hashtree_error_mode in
                          avb_append_options()")
  - commit 897a1d947e ("libavb: Update SPDX tag style")
  - commit d8f9d2af96 ("avb2.0: add Android Verified Boot 2.0 library")

Tested on X15:

    ## Android Verified Boot 2.0 version 1.1.0
    read_is_device_unlocked not supported yet
    read_rollback_index not supported yet
    read_is_device_unlocked not supported yet
    Verification passed successfully
    AVB verification OK.

Unit test passes:

    $ ./test/py/test.py --bd sandbox --build -k test_avb

      test/py/tests/test_android/test_avb.py ss..s.

[1] 49936b4c01

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
Reviewed-by: Eugeniu Rosca <rosca.eugeniu@gmail.com>
Acked-by: Igor Opaniuk <igor.opaniuk@gmail.com>
2019-10-31 07:22:53 -04:00
Marek Szyprowski
2ad98ab8f6 linux_compat: fix potential NULL pointer access
malloc_cache_aligned() might return zero, so fix potential NULL pointer
access if __GFP_ZERO flag is set.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Ralph Siemsen <ralph.siemsen@linaro.org>
2019-10-31 07:22:53 -04:00
Simon South
9b3fbb2b43 tiny-printf: Support vsnprintf()
Add a simple implementation of this function, to allow logging to be
enabled in the SPL or TPL for systems that rely on the tiny printf()
implementation.

To keep the code size small,

- The function is built only when logging is enabled, as it
  (currently) is not needed otherwise; and
- Like the existing implementation of snprintf(), its buffer-size
  parameter is ignored.

Signed-off-by: Simon South <simon@simonsouth.net>
2019-10-31 07:22:53 -04:00
Heinrich Schuchardt
eb5b63f369 lib: errno: sync error codes
Macro ERRNO_MSG() ignores the error number but we should still use the same
constants as in include/linux/errno.h.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-10-31 07:22:53 -04:00
Heinrich Schuchardt
02e8a8241b lib: errno: check for unsupported error number
If errno_str() is called with an unsupported error number, do not return a
random pointer but a reasonable text.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
2019-10-31 07:22:53 -04:00
Marek Vasut
80e7e7c2ab lib: time: Add microsecond timer
Add get_timer_us(), which is useful e.g. when we need higher
precision timestamps.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
[trini: Fixup arch/arm/mach-bcm283x/include/mach/timer.h]
Signed-off-by: Tom Rini <trini@konsulko.com>
2019-10-31 07:22:53 -04:00
Heinrich Schuchardt
e731af4893 efi_loader: correct includes in efi_variable.c
'make tests' on an 32bit ARM system leads to

In file included from ../lib/efi_loader/efi_variable.c:9:
../include/malloc.h:364:7: error: conflicting types for ‘memset’
 void* memset(void*, int, size_t);
       ^~~~~~
In file included from ../include/compiler.h:126,
                 from ../include/env.h:12,
                 from ../lib/efi_loader/efi_variable.c:8:
../include/linux/string.h:103:15:
note: previous declaration of ‘memset’ was here
 extern void * memset(void *,int,__kernel_size_t);
               ^~~~~~
In file included from ../lib/efi_loader/efi_variable.c:9:
../include/malloc.h:365:7: error: conflicting types for ‘memcpy’
 void* memcpy(void*, const void*, size_t);
       ^~~~~~
In file included from ../include/compiler.h:126,
                 from ../include/env.h:12,
                 from ../lib/efi_loader/efi_variable.c:8:
../include/linux/string.h:106:15:
note: previous declaration of ‘memcpy’ was here
 extern void * memcpy(void *,const void *,__kernel_size_t);
               ^~~~~~

Use common.h as first include as recommended by the U-Boot coding style
guide.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-10-30 17:49:41 +01:00
Jean-Jacques Hiblot
d60ae4c59d fdt: Fix alignment issue when reading 64-bits properties from fdt
The FDT specification [0] gives a requirement of aligning properties on
32-bits. Make sure that the compiler is aware of this constraint when
accessing 64-bits properties.

[0]: https://github.com/devicetree-org/devicetree-specification/blob/master/source/flattened-format.rst

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2019-10-27 13:01:53 -06:00
Simon Glass
831c161119 tiny-printf: Reorder code to support %p
With a bit of code reordering we can support %p using the existing code
for ulong.

Move the %p code up and adjust the logic accordingly.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-10-27 10:56:51 -06:00
Simon Glass
dee74e6cc4 tiny-printf: Add print_grouped_ull()
This function is used in the bootstage report which may be trigged in TPL
or TPL. Add a very basic implication of this function so that it builds.
There is no attempt to get the formatting right, since this would add too
much code size.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Stefan Roese <sr@denx.de>
2019-10-27 10:56:51 -06:00
Simon Glass
1c1c8a3a99 tiny-printf: Reduce size by removing ctype
The ctype array is brought into the image, adding 256 bytes, when it is
unlikely to be needed. The extra code for %p is only present when DEBUG
is defined, so let's drop ctype as well unless DEBUG is defined.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-10-27 10:56:41 -06:00
AKASHI Takahiro
867400677c efi_loader: disk: install FILE_SYSTEM_PROTOCOL only if available
In the current implementation, EFI_SIMPLEFILE_SYSTEM_PROTOCOL is always
installed to all the partitions even if some of them may house no file
system.

With this patch, that protocol will be installed only if any file system
exists.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-10-17 19:19:56 +02:00
AKASHI Takahiro
08c51fff30 efi_loader: device_path: check against file path length
device_path strcuture has 2 bytes of "length" field, and so
file path length should not exceed this limit, 65535.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-10-17 19:19:55 +02:00
Daniele Alessandrelli
0772a1f497 rsa: Return immediately if required-key verification fails
Currently, if image verification with a required key fails, rsa_verify()
code tries to find another key to verify the FIT image. This however, is
not the intended behavior as the documentation says that required keys
"must be verified for the image / configuration to be considered valid".

This patch fixes the issue by making rsa_verify() return immediately if
the verification of a required key fails.

Signed-off-by: Daniele Alessandrelli <daniele.alessandrelli@gmail.com>
2019-10-15 08:40:03 -06:00
Tom Rini
efea5a34bb Merge https://gitlab.denx.de/u-boot/custodians/u-boot-x86
- Rename existing FSP code to fsp1
- Add fsp2 directory in preparation to support FSP 2.0
- Various x86 platform codes update
- Various bug fixes and updates in dm core, sandbox and spl
2019-10-08 18:45:26 -04:00
Simon Glass
594d272cfd dm: core: Drop fdtdec_get_pci_addr()
This function ise effectively replaced by ofnode_read_pci_addr() which
works with flat tree. Delete it to avoid code duplication.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2019-10-08 13:57:47 +08:00
Simon Glass
27084c03d3 spl: Allow tiny printf() to be controlled in SPL and TPL
At present there is only one control for this and it is used for both SPL
and TPL. But SPL might have a lot more space than TPL so the extra cost of
a full printf() might be acceptable.

Split the option into two, providing separate SPL and TPL controls. The
TPL setting defaults to the same as SPL.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2019-10-08 13:57:45 +08:00
Simon Glass
9bb746d819 spl: Avoid checking for Ctrl-C in SPL with print_buffer()
We don't have a console in SPL so it doesn't make sense to check for
Ctrl-C when printing a memory dump. Skip this so that print_buffer() can
be used in SPL.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2019-10-08 13:51:02 +08:00
Patrick Wildt
f2d247df50 efi: device path for nvme
This allows our EFI API to create a device path node for NVMe
devices.  It adds the necessary device path struct, uses the
nvme namespace accessor to retrieve the id and eui64, and also
provides support for the device path text protocol.

Signed-off-by: Patrick Wildt <patrick@blueri.se>
Tested-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-10-06 16:02:37 +02:00
Heinrich Schuchardt
1b7313d91f efi_selftest: testing read-only variables
The UEFI spec has this sentence:
"Variables that have runtime access but that are not nonvolatile are
read-only data variables once ExitBootServices() is performed."

At least EDK2 therefore treats variable PlatformLangCodes only as read-only
at runtime. Nowhere do we make this variable read-only in U-Boot.

Do not use variable PlatformLangCodes for testing if the read only
attribute of variables is observed before ExitBootServices().

Fixes: 5a24239c95 ("efi_loader: selftest: enable APPEND_WRITE tests")
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-10-06 16:02:37 +02:00
Heinrich Schuchardt
c9dd62f9c2 efi_selftest: correct SetVariable() test
Errors should not only be announced as text but should also result in
EFI_ST_FAILURE being returned.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-10-06 16:02:37 +02:00
Heinrich Schuchardt
709292a63a efi_loader: appending to non-existent variable
Appending to a non-existent variable must result in an error of type
EFI_NOT_FOUND.

Fixes: 09c76b79a9db ("efi_loader: SetVariable() deleting variables")
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-10-06 16:02:36 +02:00
Simon Glass
e587886a61 dm: core: Correct low cell in ofnode_read_pci_addr()
This reads the low cell of the PCI address from the wrong cell. Fix it.
Also fix the function that this code came from.

Fixes: 9e51204527 (dm: core: Add operations on device tree references)
Fixes: 4ea5243a3a (fdt: fix fdtdec_get_pci_addr() for CONFIG_PHYS_64BIT)
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2019-10-03 21:10:11 +08:00
Heinrich Schuchardt
3545c66143 efi_loader: SetVariable() deleting variables
APPEND_WRITE with data length zero is allowable according to the UEFI
specification.

The EDK2 interpretation of no access attributes is attributes = 0. As
the UEFI specification is vague in this respect let's stick to EDK2 here.

Fixes: commit 6d2f27c5fd ("efi_loader: variable: support APPEND_WRITE")
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-23 22:53:25 +02:00
Heinrich Schuchardt
edb6b6842c efi_loader: SetVariable() fix illegal return
We always have to return via EFI_EXIT() from EFIAPI functions.

Coverity reported an unreachable line and a resource leak.

Fixes: commit 6d2f27c5fd ("efi_loader: variable: support APPEND_WRITE")
Reported-by: Coverity Scan CID 253575, CID 184095
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-23 22:53:25 +02:00
Heinrich Schuchardt
be09372a71 efi_loader: description efi_stri_coll()
Remove outdated TODO for efi_stri_coll(). efi_stri_coll() is already using
the Unicode capitalization table.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-23 22:53:25 +02:00
AKASHI Takahiro
f8062c963a lib: charset: add u16_str<n>cmp()
u16 version of strcmp(): u16_strncmp() works like u16_strcmp() but only
at most n characters (in u16) are compared.
This function will be used in my UEFI secure boot patch.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-20 20:09:19 +02:00
AKASHI Takahiro
5a24239c95 efi_loader: selftest: enable APPEND_WRITE tests
Now that APPEND_WRITE is supported,
the result check for the only existing test case should be changed to
'todo' to 'error', while two more test cases are added.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-20 20:09:19 +02:00
AKASHI Takahiro
6d2f27c5fd efi_loader: variable: support APPEND_WRITE
If EFI_VARIABLE_APPEND_WRITE is specified in attributes at
efi_set_variable(), specified data will be appended to the variable's
original value. Attributes other than APPEND_WRITE should not be
modified.

With this patch, APPEND_WRITE test in 'variables' selftest will pass.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
2019-09-20 20:09:18 +02:00
Heinrich Schuchardt
7dc10c933c efi_loader: incorrect return value form DisconnectController
DisconnectController() should never return EFI_NOT_FOUND.
If EFI_DRIVER_BINDING_PROTOCOL.Stop() fails, return EFI_DEVICE_ERROR.

If the driver handle does not expose the EFI_DRIVER_BINDING_PROTOCOL
return EFI_INVALID_PARAMETER.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-20 20:09:18 +02:00
AKASHI Takahiro
23ad52fff4 efi_loader: device_path: support Sandbox's "host" devices
Sandbox's "host" devices are currently described as UCLASS_ROOT udevice
with DEV_IF_HOST block device. As the current implementation of
efi_device_path doesn't support such a type, any "host" device
on sandbox cannot be seen as a distinct object.

For example,
  => host bind 0 /foo/disk.img

  => efi devices
  Scanning disk host0...
  Found 1 disks
  Device           Device Path
  ================ ====================
  0000000015c19970 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)
  0000000015c19d70 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)

  => efi dh
  Handle           Protocols
  ================ ====================
  0000000015c19970 Device Path, Device Path To Text, Device Path Utilities, Unicode Collation 2, HII String, HII Database, HII Config Routing
  0000000015c19ba0 Driver Binding
  0000000015c19c10 Simple Text Output
  0000000015c19c80 Simple Text Input, Simple Text Input Ex
  0000000015c19d70 Block IO, Device Path, Simple File System

As you can see here, efi_root (0x0000000015c19970) and host0 device
(0x0000000015c19d70) have the same representation of device path.

This is not only inconvenient, but also confusing since two different
efi objects are associated with the same device path and
efi_dp_find_obj() will possibly return a wrong result.

Solution:
Each "host" device should be given an additional device path node
of "vendor device path" to make it distinguishable.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-20 20:09:18 +02:00
Heinrich Schuchardt
8262578535 efi_loader: parameter checks EFI_FILE_PROTOCOL.SetInfo()
We do not support volume label changes. No parameter checks are needed
here.

When the info for as file is changed the buffer must always contain a file
name.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-11 21:51:38 +02:00
Heinrich Schuchardt
11335c0439 efi_loader: check parameters EFI_FILE_PROTOCOL.GetInfo()
Check the parameters of EFI_FILE_PROTOCOL.GetInfo() to avoid possible NULL
dereference.

Check the buffer size for EFI_FILE_SYSTEM_INFO.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-09 15:21:09 +02:00
Heinrich Schuchardt
632834ce6d efi_loader: volume name in EFI_FILE_PROTOCOL.GetInfo()
We cannot determine the volume name in U-Boot. Instead of providing a dummy
volume name in case of EFI_FILE_SYSTEM_INFO and EFI_UNSUPPORTED in case of
EFI_FILE_SYSTEM_VOLUME_LABEL consistently return an empty string.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-09 15:21:09 +02:00
Heinrich Schuchardt
e692ed1d56 efi_loader: EFI_FILE_PROTOCOL rev 2 stub
The UEFI specification requires to implement version 2 of the
EFI_FILE_PROTOCOL. Provide the missing functions as stubs.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-09 15:21:09 +02:00
Heinrich Schuchardt
9bb62fa63b efi_loader: file size checks
The file size has to be determined in multiple places. Factor out a common
function.

If on entry into EFI_FILE_PROTOCOL.Read() the current position is beyond
the end of the file, return EFI_DEVICE_ERROR.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-09 15:21:08 +02:00
Heinrich Schuchardt
83a74ad143 efi_loader: correct reading of directories
EFI_FILE_PROTOCOL.Read() is used both to read files and directories.

When reaching the end of a directory we always have to return buffer size
zero irrespective of the incoming buffer size. (The described scenario for
a Shim quirk cannot arise because every directory has at least '.' and '..'
as entries.)

Even when the buffer_size is too small multiple times we have to keep a
reference to our last read directory entry.

When we return to the start of the directory via SetPosition() we must
remove the reference to a previously kept directory entry.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-09 15:21:08 +02:00
Heinrich Schuchardt
87c4840610 efi_loader: eliminate inline function ascii2unicode()
ascii2unicode() can only convert characters 0x00-0x7f from UTF-8 to UTF-16.
Use utf8_utf16_strcpy() instead.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-09 15:21:08 +02:00
Heinrich Schuchardt
b0f1c728c8 efi_loader: EFI_FILE_PROTOCOL.Write() check args
Check the parameters passed to Write():

* cannot write to directories (UEFI SCT 2017, 5.7.3.5.15)
* cannot write to file opened read only (UEFI SCT 2017, 5.7.3.5.16)

Add missing comments.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-09 15:21:08 +02:00
Heinrich Schuchardt
fe1a81c1a4 doc: UEFI API documentation
Add some more files to the UEFI API documentation.

Correct some Sphinx comments.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-05 23:18:52 +02:00
Heinrich Schuchardt
cda9b35272 efi_loader: EFI_BLOCK_IO_PROTOCOL.Reset()
We cannot do anything in EFI_BLOCK_IO_PROTOCOL.Reset() but this does not
justify to return an error.

Let EFI_BLOCK_IO_PROTOCOL.Reset() return EFI_SUCCESS.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-05 23:18:51 +02:00
Heinrich Schuchardt
9d3f339881 efi_loader: use EFI_PRINT() instead of debug()
EFI_PRINT() offers indention of debug messages. Adjust the debug messages
of the BLOCK_IO_PROTOCOL.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-05 23:18:51 +02:00
Heinrich Schuchardt
f59f0825e8 efi_loader: parameter checks BLOCK_IO_PROTOCOL
Check parameters of ReadBlocks() and WriteBlocks().

If the buffer size is not a multiple of the block size, we have to return
EFI_BAD_BUFFER_SIZE.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-05 23:18:51 +02:00
Heinrich Schuchardt
03446987c5 efi_loader: do not set invalid screen mode
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetMode() should return EFI_UNDEFINED if a
screen mode is not available.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Alexander Graf <agraf@csgraf.de>
2019-09-05 23:18:51 +02:00
Heinrich Schuchardt
97ea0690f4 efi_loader: cursor positioning
When backspacing in column 0 do no set the column index to ULONG_MAX.
Ensure that the row number is not set to ULONG_MAX even if the row count is
advertised as 0.
Ignore control characters other the 0x08, 0x0a, 0x0d when updating the
column.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-05 23:18:51 +02:00
Heinrich Schuchardt
d41f99e179 efi_loader: correctly render UsbClass DP nodes as text
Correct the text representation of UsbClass device path nodes.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-05 23:18:51 +02:00
Heinrich Schuchardt
d0384d5160 efi_loader: correctly render CD-ROM device path nodes
Correct the name of the partition size component in struct
efi_device_path_cdrom_path.

Render entry, start, and size when converting a CD-ROM device path node to
text.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-05 23:18:51 +02:00
Heinrich Schuchardt
4411652aea efi_loader: correctly render MAC address device path nodes
If the interface type is greater 1 render all 32 bytes of the MAC address.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-05 23:18:51 +02:00
Heinrich Schuchardt
8254f8feb7 efi_loader: correct text conversion for vendor DP
Vendor device paths may contain data. When converting vendor device paths
to text this binary data has to be rendered.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-05 23:18:51 +02:00
Park, Aiden
b5b9eff26d efi_loader: Extract adding a conventional memory in separate routine
Adding a conventional memory region to the memory map may require ram_top
limitation and it can be also commonly used. Extract adding a conventional
memory to the memory map in a separate routine for generic use.

Signed-off-by: Aiden Park <aiden.park@intel.com>
Tested-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-05 23:18:51 +02:00
Heinrich Schuchardt
5b4746fd6b efi_loader: implement MCastIPtoMAC
Implement the MCastIPtoMAC service of the simple network protocol.
It converts an multicast IPv4 (or IPv6) address to a multicast Ethernet
address.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-05 23:18:51 +02:00
Heinrich Schuchardt
72a8f1685a efi_loader: fix status management in network stack
The network should start in status EfiSimpleNetworkStopped.

Add and correct status checks in the simple network protocol.

Correct the unit test:
* Shutdown() and Stop() during setup if needed
* invoke Shutdown() before Stop() when tearing down

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-05 23:18:51 +02:00
Heinrich Schuchardt
5947b49b09 efi_loader: EFI_SIMPLE_NETWORK.Transmit() fill header
Fill the media header in EFI_SIMPLE_NETWORK.Transmit().
Check that the buffer size is large enough for the header.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-05 23:18:51 +02:00
Heinrich Schuchardt
0c7adf4b5f efi_selftest: check EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT
Check that when the WaitForPacket event occurs
EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT is set.

Check the return value of Receive().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-05 23:18:51 +02:00
Heinrich Schuchardt
7f6d874d17 efi_loader: interrupts in simple network protocol
GetStatus() must clear the interrupt status.
Transmit() should set the TX interrupt.
Receive() should clear the RX interrupt.
Initialize() and Start() should clear the interrupt status.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-05 23:18:51 +02:00
Heinrich Schuchardt
53c701720c efi_selftest: use standalone UEFI program for exception
To fully demonstrate crash outputs for UEFI images provide a standalone
UEFI application that tries to invoke an illegal opcode.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-08-29 05:54:26 +02:00
Heinrich Schuchardt
ce9ad0313c efi_selftest: enable Exit() unit test on x86_64
Enable unit tests for StartImage() and Exit() unit tests on x86_64.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-08-29 05:54:26 +02:00
Lukas Auer
c4f603f723 fdtdec: make CONFIG_OF_PRIOR_STAGE available in SPL
The current preprocessor logic prevents CONFIG_OF_PRIOR_STAGE from being
used in U-Boot SPL. Change the logic to also make it available in U-Boot
SPL.

Signed-off-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
2019-08-26 16:07:42 +08:00
Heinrich Schuchardt
9f8932d055 efi_loader: do not call efi_runtime_detach twice
Commit 7f95104d91 ("efi_loader: detach runtime in ExitBootServices()")
added a call to efi_runtime_detach() to ExitBootServices() but did not
remove the call in SetVirtualAddressMap().

Remove the superfluous function call.

Correct a comment referring to efi_runtime_detach().

Fixes: 7f95104d91 ("efi_loader: detach runtime in ExitBootServices()")
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-08-15 20:33:10 +02:00
Heinrich Schuchardt
53e1d8fae8 efi_loader: parameter check in SetVirtualAddressMap
Check the parameters DescriptorSize and DescriptiorVersion of
SetVirtualAddressMap() as prescribed by the UEFI specification.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-08-15 20:33:10 +02:00
Heinrich Schuchardt
a6d37098bd efi_loader: EFI_PXE_BASE_CODE_PROTOCOL stub
U-Boot implements the EFI_PXE_BASE_CODE_PROTOCOL because GRUB uses the mode
information for booting via PXE. All function pointers in the protocol were
NULL up to now which will cause immediate crashes when the services of the
protocol are called.

Create function stubs for all services of the protocol returning
EFI_UNSUPPORTED.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-08-15 20:33:10 +02:00
Simon Glass
f3998fdc4d env: Rename environment.h to env_internal.h
This file contains lots of internal details about the environment. Most
code can include env.h instead, calling the functions there as needed.

Rename this file and add a comment at the top to indicate its internal
nature.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
[trini: Fixup apalis-tk1.c]
Signed-off-by: Tom Rini <trini@konsulko.com>
2019-08-11 19:27:31 -04:00
Simon Glass
e7dcf5645f env: Drop environment.h header file where not needed
This header file is now only used by files that access internal
environment features. Drop it from various places where it is not needed.

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2019-08-11 16:43:41 -04:00
Simon Glass
3f0d680745 env: Drop the ACTION typedef
Avoid using a typedef here which is unnecessary. Add an 'env_' prefix to
both the enum and its members to make it clear that these are related to
the environment.

Add an ENV prefix to these two flags so that it is clear what they relate
to. Also move them to env.h since they are part of the public API. Use an
enum rather than a #define to tie them together.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-08-11 16:43:41 -04:00
Simon Glass
25e51e90fe env: Drop _ENTRY
This typedef does not need to be defined in the search.h header since it
is only used in one file (hashtable.c). Remove it from the header and
change it to a struct.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-08-11 16:43:41 -04:00
Simon Glass
dd2408cac1 env: Drop the ENTRY typedef
U-Boot is not supposed to use typedef for structs anymore. Also this name
is the same as the ENTRY() macro used in assembler files, and 'entry'
itself is widely used in U-Boot (>8k matches).

Drop the typedef and rename the struct to env_entry to reduce confusion.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2019-08-11 16:43:41 -04:00
Simon Glass
7b51b576d6 env: Move env_get() to env.h
Move env_get() over to the new header file.

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2019-08-11 16:43:41 -04:00
Simon Glass
9fb625ce05 env: Move env_set() to env.h
Move env_set() over to the new header file.

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2019-08-11 16:43:41 -04:00
Simon Glass
9eef56dbe3 env: Move env_get_ulong() to env.h
Move env_get_ulong() over to the new header file.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2019-08-11 16:43:41 -04:00
Simon Glass
0c670fc148 common: Move gzip functions into a new gzip header
As part of the effort to remove things from common.h, create a new header
for the gzip functions. Move the function declarations to it and add
missing documentation.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
2019-08-11 16:43:41 -04:00
Heinrich Schuchardt
bb68957720 efi_selftest: sharpen ConvertPointer() test
Now that ConvertPointer() is implemented throw an error if the result is
incorrect.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-07-30 21:36:22 +02:00
Heinrich Schuchardt
7be56e864e efi_loader: implement ConvertPointer()
Implement the ConvertPointer() runtime service.

Suggested-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-07-30 21:36:22 +02:00
Heinrich Schuchardt
24e6722b8a efi_loader: definition of efi_virtual_address_map()
Use efi_uintn_t where the UEFI spec uses UINTN. Use efi_uintn_t also for
the result of the division of two efi_uintn_t.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-07-30 21:36:22 +02:00
Heinrich Schuchardt
c0a8a95263 efi_selftest: fix SetVirtualAddressMap unit test
We read the address map before assigning the memory for the pages that will
be mapped to virtual addresses. So these pages will overlap with the entry
for EFI_CONVENTIONAL_MEMORY. We have to ensure that every page is described
at most once in the map.

Remove EFI_CONVENTIONAL_MEMORY from the map that we pass to
SetVirtualAddressMap().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-07-30 21:36:22 +02:00
Heinrich Schuchardt
6f3badb67d efi_loader: re-enable GRUB workaround on 32bit ARM
GRUB on ARM 32bit prior to version 2.04 lacks proper handling of caches.
In U-Boot v2019.04 a workaround for this was inadvertently removed.

The workaround is currently also needed for booting on systems with caches
that cannot be managed via CP15 (e.g. with an i.MX6 CPU).

Re-enable the workaround and make it customizable.

Fixes: f69d63fae2 ("efi_loader: use efi_start_image() for bootefi")
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-07-30 21:36:22 +02:00
Heinrich Schuchardt
a1b633df55 lib: uuid: alignment error in gen_rand_uuid()
Packed structures like struct uuid are not aligned. GCC 9.1 therefore
throws an error when trying to compile gen_rand_uuid().

lib/uuid.c: In function ‘gen_rand_uuid’:
lib/uuid.c:244:2: error: converting a packed ‘struct uuid’ pointer
(alignment 1) to a ‘unsigned int’ pointer (alignment 4) may result in
an unaligned pointer value [-Werror=address-of-packed-member]
  244 |  unsigned int *ptr = (unsigned int *)&uuid;
      |  ^~~~~~~~

Generate the uuid in a properly aligned buffer.

The byte order of a random number should not matter. Do not call
cpu_to_be32() to change the byte order.

Reported-by: Ramon Fried <rfried.dev@gmail.com>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-07-29 09:32:13 -04:00