summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* TEST: binman_sym.h needs linux/compiler.hWIP/RFC-ltoTom Rini2021-03-031-0/+2
| | | | Signed-off-by: Tom Rini <trini@konsulko.com>
* arm: When using LTO do not use -ffunction-sections/-fdata-sectionsTom Rini2021-03-031-4/+9
| | | | | | | | When we enable LTO support, we will get our size optimization handled that way instead, so don't pass those flags. However, due to how we're using libgcc today we can't yet do that on aarch64. Signed-off-by: Tom Rini <trini@konsulko.com>
* LTO: Enable this by defaultTom Rini2021-03-031-1/+1
| | | | | | If an architecture supports this feature, enable it by default. Signed-off-by: Tom Rini <trini@konsulko.com>
* arch: ARM: make LTO availableMarek Behún2021-03-032-0/+3
| | | | | | Make LTO available for ARM architecture. Signed-off-by: Marek Behún <marek.behun@nic.cz>
* string: make memcpy() visible to fix LTO linking errorsMarek Behún2021-03-031-1/+2
| | | | | | | | | | | | | | | | | | | | It seems that sometimes (happening on ARM64, for example with turris_mox_defconfig) GCC, when linking with LTO, changes the name of lib/string.c's memcpy() function to memcpy.isra.0. This is a problem however when GCC for a code such as this: struct some_struct *info = get_some_struct(); struct some struct tmpinfo; tmpinfo = *info; emits a call to memcpy() by builtin behaviour, to copy *info to tmpinfo. This then results in the following linking error: .../lz4.c:93: undefined reference to `memcpy' .../uuid.c:206: more undefined references to `memcpy' follow Make memcpy() visible by using the __visible macro to avoid this error. Signed-off-by: Marek Behún <marek.behun@nic.cz>
* ARM: make gd a function for LTOMarek Behún2021-03-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | On ARM the gd pointer is stored in registers r9 / x18. For this the -ffixed-r9 / -ffixed-x18 flag when compiling, but using global register variables causes errors when building with LTO, and these errors are very difficult to overcome. Richard Biener says [1]: Note that global register vars shouldn't be used with LTO and if they are restricted to just a few compilation units the recommended fix is to build those CUs without -flto. We cannot do this for U-Boot since all CUs use -ffixed-reg flag. It seems that with LTO we could in fact store the gd pointer differently and gain performance or size benefit by allowing the compiler to use r9 / x18. But this would need more work. So for now, when building with LTO, go the clang way, and instead of declaring gd a global register variable we make it a function via macro. [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68384 Signed-off-by: Marek Behún <marek.behun@nic.cz>
* sandbox: build with LTOMarek Behún2021-03-034-0/+4
| | | | | | Build sandbox targets with LTO enabled. Signed-off-by: Marek Behún <marek.behun@nic.cz>
* arch: sandbox: make LTO availableMarek Behún2021-03-032-2/+3
| | | | | | Make LTO available for sandbox architecture. Signed-off-by: Marek Behún <marek.behun@nic.cz>
* build: support building with Link Time OptimizationsMarek Behún2021-03-036-1/+64
| | | | | | | Add plumbing for building U-Boot with Link Time Optimizations (gcc only). Signed-off-by: Marek Behún <marek.behun@nic.cz>
* binman: declare symbols externally visibleMarek Behún2021-03-032-2/+3
| | | | | | | | Use the `__visible` macro to declare binman symbols externally visible, so that when building with LTO the compiler does not optimize this data away. Signed-off-by: Marek Behún <marek.behun@nic.cz>
* efi_loader: fix warning when linking with LTOMarek Behún2021-03-031-2/+2
| | | | | | | | | | | | | | | | | | | | When linking with LTO, the compiler complains about type mismatch of variables `__efi_runtime_start`, `__efi_runtime_stop`, `__efi_runtime_rel_start` and `__efi_runtime_rel_stop`: include/efi_loader.h:218:21: warning: type of ‘__efi_runtime_start’ does not match original declaration [-Wlto-type-mismatch] 218 | extern unsigned int __efi_runtime_start, __efi_runtime_stop; | ^ arch/sandbox/lib/sections.c:7:6: note: ‘__efi_runtime_start’ was previously declared here 7 | char __efi_runtime_start[0] __attribute__((section(".__efi_runtime_start"))); | ^ Change the type to char[] in include/efi_loader.h. Signed-off-by: Marek Behún <marek.behun@nic.cz>
* linker_lists: declare entries and lists externally visibleMarek Behún2021-03-031-2/+4
| | | | | | | | | Use the `__visible` macro to declare entires and lists declared by ll_entry_declare() and ll_entry_declare_list() externally visible, so that when building with LTO the compiler does not optimize this data away. Signed-off-by: Marek Behún <marek.behun@nic.cz>
* sandbox: errno: avoid conflict with libc's errnoMarek Behún2021-03-032-2/+10
| | | | | | | | | | | | | | When building with LTO, the system libc's `errno` variable used in arch/sandbox/cpu/os.c conflicts with U-Boot's `errno` (defined in lib/errno.c) with the following error: .../ld: errno@@GLIBC_PRIVATE: TLS definition in /lib64/libc.so.6 section .tbss mismatches non-TLS reference in /tmp/u-boot.EQlEXz.ltrans0.ltrans.o To avoid this conflict use different asm label for this variable when CONFIG_SANDBOX is enabled. Signed-off-by: Marek Behún <marek.behun@nic.cz>
* build: use thin archives instead of incremental linkingMarek Behún2021-03-034-11/+9
| | | | | | | | | | | Using thin archives instead of incremental linking - saves disk space - works better with dead code elimination - prepares for potential LTO Linux does this for some time now, do this also in U-Boot. Signed-off-by: Marek Behún <marek.behun@nic.cz>
* regmap: fix a serious pointer casting bugMarek Behún2021-03-031-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is a serious bug in regmap_read() and regmap_write() functions where an uint pointer is cast to (void *) which is then cast to (u8 *), (u16 *), (u32 *) or (u64 *), depending on register width of the map. For example given a regmap with 16-bit register width the code int val = 0x12340000; regmap_read(map, 0, &val); only changes the lower 16 bits of val on little-endian machines. The upper 16 bits will remain 0x1234. Nobody noticed this probably because this bug can be triggered with regmap_write() only on big-endian architectures (which are not used by many people anymore), and on little endian this bug has consequences only if register width is 8 or 16 bits and also the memory place to which regmap_read() should store it's result has non-zero upper bits, which it seems doesn't happen anywhere in U-Boot normally. CI managed to trigger this bug in unit test of dm_test_devm_regmap_field when compiled for sandbox_defconfig using LTO. Fix this simply by taking into account that regmap_raw_read() and regmap_raw_write() behave as if the data given to these functions were in little-endian format, i.e. use cpu_to_le32() / le32_to_cpu(). In regmap_read() also zero out the space so that we don't get invalid result if regmap_raw_read() does not fill the whole object. Signed-off-by: Marek Behún <marek.behun@nic.cz>
* Merge branch '2021-03-03-assorted-improvements' into nextTom Rini2021-03-03174-623/+1481
|\ | | | | | | | | | | | | - Clean up reset_cpu() - Assorted arm cp15 cleanups - Assorted cleanups throughout the tree from Simon - TPM1 / TPM2 cleanups
| * tpm: Allow disabling platform hierarchy with TPM2Simon Glass2021-03-022-0/+48
| | | | | | | | | | | | | | | | | | With TPM2 we don't actually lock the TPM once verified boot is finished. Instead we disable the platform hierarchy which serves the same purpose. Add an implementation of this so we can safely boot into the kernel. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
| * tpm: Add TPM2 support for write_lockSimon Glass2021-03-023-1/+36
| | | | | | | | | | | | | | Implement this API function for TPM2. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
| * tpm: Add TPM2 support for read/write valuesSimon Glass2021-03-024-2/+127
| | | | | | | | | | | | | | Implement this API function for TPM2. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
| * tpm: Add an implementation of define_spaceSimon Glass2021-03-022-0/+65
| | | | | | | | | | | | | | | | Add support for this so that the TPM can be set up for use with Chromium OS verified boot. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
| * tpm: Reduce duplication in a few functionsSimon Glass2021-03-021-5/+8
| | | | | | | | | | | | | | | | Update tpm2_clear() and tpm2_pcr_extend() so that the command size is not repeated twice. Add a small comment to the latter. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
| * tpm: Add a basic API implementation for TPMv2Simon Glass2021-03-021-7/+77
| | | | | | | | | | | | | | | | | | Add support for TPMv2 versions of API functions. So far this is not complete as the standard is quite large, but it implements everything currently available for TPMv2 in U-Boot. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
| * tpm: Switch TPMv1 over to use the new APISimon Glass2021-03-0210-169/+168
| | | | | | | | | | | | | | | | | | | | | | | | Take over the plain 'tpm_...' functions for use by the new TPM API. Rename all the TPMv1 functions so they are called from the API. Update the TPMv1 functions so that they are called from the API. Change existing users to use the tpm1_ prefix so they don't need to go through the API, which might introduce uncertainty. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
| * tpm: Add an API that can support v1.2 and v2Simon Glass2021-03-022-0/+537
| | | | | | | | | | | | | | | | | | | | | | | | | | There are two different TPM standards. U-Boot supports both but each has its own set of functions. We really need a single TPM API that can call one or the other. This is not always possible as there are some differences between the two standards, but it is mostly possible. Add an API to handle this. So far it is not plumbed into the build and only supports TPMv1. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
| * tpm: Add debugging of request in tpm_sendrecv_command()Simon Glass2021-03-021-2/+8
| | | | | | | | | | | | | | | | | | | | The response is shown but not the request. Update the code to show both if debugging is enabled. Use a 'uint' type for size so it matches the register-word size on both 32- and 64-bit machines. Signed-off-by: Simon Glass <sjg@chromium.org>
| * tpm: Use logging in the uclassSimon Glass2021-03-021-3/+5
| | | | | | | | | | | | | | Update this to use log_debug() instead of the old debug(). Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
| * tpm: Don't include cr50 in TPL/SPLSimon Glass2021-03-022-3/+3
| | | | | | | | | | | | | | | | | | | | At present the security chip is not used in these U-Boot phases. Update the Makefile to exclude it. Fix a few logging statements while we are here. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
| * bootm: Fix duplicate debugging in bootm_process_cmdline()Simon Glass2021-03-021-1/+1
| | | | | | | | | | | | | | These two returns use the same string so are not distinguishable with LOG_ERROR_RETURN. Fix it. Signed-off-by: Simon Glass <sjg@chromium.org>
| * sandbox: Write out bloblist when exitingSimon Glass2021-03-021-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | Sandbox provides a way to write out its emulated memory on exit. This makes it possible to pass a bloblist from one phase (e.g. SPL) to the next. However the bloblist is not closed off, so the checksum is generally invalid. Fix this by finishing up the bloblist before writing the memory file. Signed-off-by: Simon Glass <sjg@chromium.org>
| * sandbox: Avoid using malloc() for system stateSimon Glass2021-03-025-30/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This state is not accessible to the running U-Boot but at present it is allocated in the emulated SDRAM. This doesn't seem very useful. Adjust it to allocate from the OS instead. The RAM buffer is currently not freed, but should be, so add that into state_uninit(). Update the comment for os_free() to indicate that NULL is a valid parameter value. Note that the strdup() in spl_board_load_image() is changed as well, since strdup() allocates memory in the RAM buffer. Signed-off-by: Simon Glass <sjg@chromium.org>
| * sandbox: Add os_realloc()Simon Glass2021-03-022-1/+59
| | | | | | | | | | | | | | | | | | We provide os_malloc() and os_free() but not os_realloc(). Add this, following the usual semantics. Also update os_malloc() to behave correctly when passed a zero size. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * s5p4418_nanopi2: Drop dead codeSimon Glass2021-03-022-146/+0
| | | | | | | | | | | | | | | | | | | | This code is still using the old command typedef. It was not noticed since this file is not currently built. It is using a non-existent option in the Makefile. Drop this file since it is not needed for correct operation. Signed-off-by: Simon Glass <sjg@chromium.org>
| * doc: Add a note about producing 'md.b' output using hexdumpSimon Glass2021-03-021-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | Comparing a hex dump on the U-Boot command line with the contents of a file on the host system is fairly easy and convenient to do manually if it is small. But the format used hexdump by default differs from that shown by U-Boot. Add a note about how to make them the same. (For large dumps, writing the data to the network with tftpput, or to a USB stick with ext4save is easiest.) Signed-off-by: Simon Glass <sjg@chromium.org>
| * doc: describe the md commandSimon Glass2021-03-023-1/+97
| | | | | | | | | | | | Provide a man-page for the md command. Signed-off-by: Simon Glass <sjg@chromium.org>
| * binman: Indicate how to make binman verboseSimon Glass2021-03-022-1/+4
| | | | | | | | | | | | | | | | Add notes about how to make binman produce verbose logging when building. Add a comment on how to do this. Signed-off-by: Simon Glass <sjg@chromium.org>
| * spl: Drop duplicate 'Jumping to U-Boot' messageSimon Glass2021-03-021-2/+1
| | | | | | | | | | | | | | | | | | This is printed twice but we only need one message, since there is very little processing in between them. Drop the second one, since all branches of the switch() already have output. Update the U-Boot message to include the phase being jumped to. Signed-off-by: Simon Glass <sjg@chromium.org>
| * arm: remove set_dacr/get_dacr functionsPatrick Delaunay2021-03-021-14/+0
| | | | | | | | | | | | | | | | Remove the unused function set_dacr/get_dacr Serie-cc: Ard Biesheuvel <ardb@kernel.org> Serie-cc: R Sricharan <r.sricharan@ti.com> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
| * arm: cp15: remove weak function arm_init_domainsPatrick Delaunay2021-03-023-10/+0
| | | | | | | | | | | | | | Remove the unused weak function arm_init_domains used to change the DACR value. Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
| * arm: omap2: remove arm_init_domainsPatrick Delaunay2021-03-021-17/+0
| | | | | | | | | | | | | | Remove the arm_init_domains and the DACR update, as it is now done in ARMv7 CP15 level. Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
| * arm: cp15: update DACR value to activate access controlPatrick Delaunay2021-03-021-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Update the initial value of Domain Access Control Register (DACR) and set by default the access permission to client (DACR_Dn_CLIENT = 1U) for each of the 16 domains and no more to all-supervisor (DACR_Dn_MANAGER = 3U). This patch allows to activate the domain checking in MMU against the permission bits in the translation tables and avoids prefetching issue on ARMv7 [1]. Today it was already done for OMAP2 architecture ./arch/arm/mach-omap2/omap-cache.c::arm_init_domains introduced by commit de63ac278cba ("ARM: mmu: Set domain permissions to client access") which fixes lot of speculative prefetch aborts seen on OMAP5 secure devices. [1] https://developer.arm.com/documentation/ddi0406/b/System-Level-Architecture/Virtual-Memory-System-Architecture--VMSA-/Memory-access-control/The-Execute-Never--XN--attribute-and-instruction-prefetching Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reported-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
| * arm: cosmetic: align TTB_SECT define valuePatrick Delaunay2021-03-021-1/+1
| | | | | | | | | | | | Align TTB_SECT define value with previous value. Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
| * arm: remove TTB_SECT_XN_MASK in DCACHE_WRITETHROUGHPatrick Delaunay2021-03-021-1/+1
| | | | | | | | | | | | | | | | The normal memory (other that DCACHE_OFF) should be executable by default, only the device memory (DCACHE_OFF) used for peripheral access should have the bit execute never (TTB_SECT_XN_MASK). Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
| * stm32mp: update the mmu configuration for SPL and prerelocPatrick Delaunay2021-03-021-10/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Overidde the weak function dram_bank_mmu_setup() to set the DDR (preloc case) or the SYSRAM (in SPL case) executable before to enable the MMU and configure DACR. This weak function is called in dcache_enable/mmu_setup. This patchs avoids a permission access issue when the DDR is marked executable (by calling mmu_set_region_dcache_behaviour with DCACHE_DEFAULT_OPTION) after MMU setup and domain access permission activation with DACR in dcache_enable. Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
| * stm32mp: update MMU config before the relocationPatrick Delaunay2021-03-021-4/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | Mark the top of ram, used for relocated U-Boot as a normal memory (cacheable and executable) to avoid permission access issue when U-Boot jumps to this relocated code. When MMU is activated in pre-reloc stage; only the beginning of DDR is marked executable. This patch avoids access issue when DACR is correctly managed. Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
| * reset: Remove addr parameter from reset_cpu()Harald Seiler2021-03-02134-142/+142
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Historically, the reset_cpu() function had an `addr` parameter which was meant to pass in an address of the reset vector location, where the CPU should reset to. This feature is no longer used anywhere in U-Boot as all reset_cpu() implementations now ignore the passed value. Generic code has been added which always calls reset_cpu() with `0` which means this feature can no longer be used easily anyway. Over time, many implementations seem to have "misunderstood" the existence of this parameter as a way to customize/parameterize the reset (e.g. COLD vs WARM resets). As this is not properly supported, the code will almost always not do what it is intended to (because all call-sites just call reset_cpu() with 0). To avoid confusion and to clean up the codebase from unused left-overs of the past, remove the `addr` parameter entirely. Code which intends to support different kinds of resets should be rewritten as a sysreset driver instead. This transformation was done with the following coccinelle patch: @@ expression argvalue; @@ - reset_cpu(argvalue) + reset_cpu() @@ identifier argname; type argtype; @@ - reset_cpu(argtype argname) + reset_cpu(void) { ... } Signed-off-by: Harald Seiler <hws@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
| * Revert "lpc32xx: cpu: add support for soft reset"Harald Seiler2021-03-021-16/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 576007aec9a4a5f4f3dd1f690fb26a8c05ceb75f. The parameter passed to reset_cpu() no longer holds a meaning as all call-sites now pass the value 0. Thus, branching on it is essentially dead code and will just confuse future readers. Revert soft-reset support and just always perform a hard-reset for now. This is a preparation for removal of the reset_cpu() parameter across the entire tree in a later patch. Fixes: 576007aec9a4 ("lpc32xx: cpu: add support for soft reset") Cc: Sylvain Lemieux <slemieux@tycoint.com> Signed-off-by: Harald Seiler <hws@denx.de>
| * board: ns3: Remove superfluous reset logicHarald Seiler2021-03-021-20/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current implementation of reset_cpu() in the ns3 board code does not archieve what it is supposed to (according to the comments), due to a number of reasons: 1. The argument to reset_cpu() is _not_ actually passed from the `reset` command, but is set to 0 in all call-sites (in this specific case, see arch/arm/lib/reset.c). Thus, performing different kinds of resets based on its value will not work as expected. 2. Contrary to its documentation, the passed argument is not interpreted, but a static `L3_RESET` define is used. The other comment properly notes that this will always perform a L3 reset, though. 3. The "parsing" of the static `L3_RESET` value is not even using the upper and lower nibble as stated in the comment, but uses the last two decimal digits of the value. This is currently one of the only implementations left in U-Boot, which make "use" of the value passed to reset_cpu(). As this is done under false assumption (the value does not have any meaning anymore), it makes sense to bring it into line with the rest and start ignoring the parameter. This is a preparation for removal of the reset_cpu() parameter across the entire tree in a later patch. Fixes: b5a152e7ca0b ("board: ns3: default reset type to L3") Cc: Bharat Gooty <bharat.gooty@broadcom.com> Cc: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com> Signed-off-by: Harald Seiler <hws@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
| * nds32: Remove dead reset_cpu() implementationHarald Seiler2021-03-021-22/+0
|/ | | | | | | | | | | | | | | | nds32 is one of the only architectures which still have a reset_cpu() implementation that makes use of the `addr` parameter. The rest of U-Boot now ignores it and passes 0 everywhere. It turns out that even here, reset_cpu() is no longer referenced anywhere; reset is either not implemented (e.g. ae3xx) or realized using a WDT (e.g. ag101). Remove this left-over implementation in preparation for the removal of the `addr` parameter in the entire tree. Cc: Rick Chen <rick@andestech.com> Signed-off-by: Harald Seiler <hws@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Rick Chen <rick@andestech.com>
* Prepare v2021.04-rc3v2021.04-rc3Tom Rini2021-03-011-1/+1
| | | | Signed-off-by: Tom Rini <trini@konsulko.com>
* log: convert pr_*() to loggingHeinrich Schuchardt2021-03-012-38/+48
| | | | | | | | | | | | In drivers we use a family of printing functions including pr_err() and pr_cont(). CONFIG_LOGLEVEL is used to control which of these lead to output via printf(). Our logging functions allow finer grained control of output. So replace printf() by the matching logging functions. The usage of CONFIG_LOGLEVEL remains unchanged. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>