summaryrefslogtreecommitdiffstats
path: root/arch/arm/lib32
Commit message (Collapse)AuthorAgeFilesLines
* ARM: io: read 32 bits at once for aligned I/O memcpy/memsetAhmad Fatoum2024-03-151-13/+54
| | | | | | | | | | | | | | | | | | | | The barebox arm32 implementation for I/O memcpy/memset uses single byte accesses exclusively. This is different from the barebox arm64 implementation, which accesses 64 bits at once if the buffer is aligned and the Linux arm32 implementation, which is the optimized assembly version that doesn't use single byte accesses for aligned buffers either. The current implementation is slower than need be and breaks code ported from Linux. e.g. the OMAP RNG driver uses memcpy_fromio and expects it to perform 32-bit accesses as any smaller access leads to a data abort on the hardware. In Linux this works, but in barebox it crashes. Avoid these issues by using 32-bit accesses if possible. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240313105631.686778-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: unwind: don't allocate while printing stack traceAhmad Fatoum2023-09-121-10/+10
| | | | | | | | | | | | | | | | Calling dump_stack() in response to failing assertions can be useful to pinpoint where things started going awry. This is also done in TLSF code, but dump_stack actually calls malloc, because it uses the logging functions instead of printing directly to console. To avoid circular dependencies and dump_stack() falsifying debugging results, let's use eprintf instead of pr_*: That way, the output still makes it to stderr, but it's no longer logged. This also removes the orange WARNING: prefix, but that can be added back if needed. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230911125619.2782229-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: set zero page accessible before copying ATAGs thereSascha Hauer2023-06-011-1/+6
| | | | | | | | | | | | We used skip setting up the zero page as faulting when the SDRAM starts at 0x0. One reason for doing that was that ATAGs will be copied there in that case. Call zero_page_access() if necessary to be able to set the zero page to faulting during barebox startup in the next step. Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230531103515.845714-1-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Subject: [PATCH 1/1] ARM:lib32: add architected timerRenaud Barbier2023-03-092-0/+19
| | | | | | | | | | In preparation for the introduction of the LS1021A support, add a specific timer support based on the LS1046A support so that delays can be used in the PBL. Signed-off-by: Renaud Barbier <renaud.barbier@ametek.com> Link: https://lore.barebox.org/BL0PR07MB566565603B9BFC2D40141142ECB79@BL0PR07MB5665.namprd07.prod.outlook.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: fix unwinding for XIP kernelsSascha Hauer2022-11-081-36/+80
| | | | | | | | | | | | | | | | | | | | | | | | Newer gcc versions generate a warning about accessing an array out of bounds: In function 'search_index', inlined from 'unwind_find_idx' at arch/arm/lib32/unwind.c:109: , inlined from 'unwind_frame' at arch/arm/lib32/unwind.c:248:8: arch/arm/lib32/unwind.c:86:32: warning: array subscript -1 is outside array bounds of 'struct unwind_idx[268435455]' [-Warray-bounds] 86 | } else if (addr >= last->addr) | ~~~~^~~~~~ arch/arm/lib32/unwind.c: In function 'unwind_frame': arch/arm/lib32/unwind.c:46:26: note: at offset -8 into object '__stop_unwind_idx' of size [0, 2147483647] 46 | extern struct unwind_idx __stop_unwind_idx[]; | ^~~~~~~~~~~~~~~~~ This was fixed by accident in the Kernel back in 2011 in de66a979012d ("ARM: 7187/1: fix unwinding for XIP kernels") . Adopt that commit for barebox. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20221107111419.722978-1-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: lds: define and use BAREBOX_RELOCATION_TABLEAhmad Fatoum2022-10-111-7/+1
| | | | | | | | | | The structure of the relocation table is one of the main differences between different architectures' linker scripts. Hoist it out for ARM into <asm/barebox.lds.h>. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20221010061122.2084009-8-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* lds: move OUTPUT_FORMAT/ARCH definition into headerAhmad Fatoum2022-10-111-2/+2
| | | | | | | | | | In order to allow us having architecture-indepenent linker scripts, move the definition for the format and the architecture into the new <asm/barebox.lds.h> header file. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20221010061122.2084009-7-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* lds: introduce <asm/barebox.lds.h>Ahmad Fatoum2022-10-111-1/+1
| | | | | | | | | | | | | | We have a separate linker script for each architecture and one more for PBL if supported. All linker scripts include <asm-generic/barebox.lds.h>. In future, we may want to use a linker script common to more than one architecture. Prepare for this by having each architecture define a <asm/barebox.lds.h>. Currently, these files contain little more than 1-2 #include directives, but this will change in later commits. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20221010061122.2084009-6-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: optee-early: Fix 'memcpy' implicit declarationAlexander Shiyan2022-06-101-0/+1
| | | | | | | | | | arch/arm/lib32/optee-early.c: In function 'start_optee_early': arch/arm/lib32/optee-early.c:26:2: error: implicit declaration of function 'memcpy' [-Werror=implicit-function-declaration] memcpy((void *)hdr->init_load_addr_lo, tee + sizeof(*hdr), hdr->init_size); Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com> Link: https://lore.barebox.org/20220610054051.4911-2-eagle.alexander923@gmail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: asm: setjmp: add missing .pop_sectionAhmad Fatoum2022-03-281-0/+1
| | | | | | | | | This fixes a mismatched .push_section. This had no effect, because the file ended after the follow-up .push_section. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.barebox.org/20220319074335.1313872-1-ahmad@a3f.at Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* arch: add SPDX-License-Identifier to all .c filesAhmad Fatoum2022-01-055-0/+10
| | | | | | | | | Record GPL-2.0-only as license for all files lacking an explicit license statement. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220103120539.1730644-11-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* arch: add SPDX-License-Identifier to all .S filesAhmad Fatoum2022-01-052-0/+4
| | | | | | | | | Record GPL-2.0-only as license for all files lacking an explicit license statement. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220103120539.1730644-10-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: add SPDX-License-Identifier for .gitignoreAhmad Fatoum2022-01-051-0/+2
| | | | | | | | | Makes the files not appear when searching for files that lack SPDX-License-Identifier. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220103120539.1730644-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: add SPDX-License-Identifier for Kbuild/KconfigAhmad Fatoum2022-01-051-0/+2
| | | | | | | | | | | | | | | To verify only Kconfig/Makefile is touched: git show --numstat --format=oneline HEAD | grep -v 'Kconfig\|Makefile' will print only arch/powerpc/Kbuild. To verify nothing unexpected is added: git show -U0 | grep '^-[^-]\|^+[^+]' | sort -u Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220103120539.1730644-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* blspec: Rework firmware loadSascha Hauer2021-06-283-1/+11
| | | | | | | | | | | | | | | | Applying overlays in blspec currently works in two steps. First of_firmware_load_overlay() is called which doesn't load an overlay, but instead loads firmware when one is needed by the overlay. This is done on the live tree, because that was needed to find the firmware manager. The second step is to call of_register_overlay() to apply the overlay to the kernel device tree when the fixups are executed. Instead of using a separate step to load the firmware, load the firmware as part of the of_fixups. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210624085223.14616-14-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fdt: Check blob size during unflatteningSascha Hauer2021-06-251-1/+1
| | | | | | | | | | | of_unflatten_dtb() doesn't check the size of the device tree blob passed to it. Add a size argument end add checks for the size. Some callers have no idea of the buffer size themselves, INT_MAX is passed in these cases. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210624085223.14616-4-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: module: Remove always false checkSascha Hauer2021-05-181-1/+1
| | | | | | | | | rel->r_offset < 0 is always false because r_offset is unsigned. Remove check. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210517185424.32145-13-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: asm: setjmp: implement coroutine dependency initjmp()Ahmad Fatoum2021-03-171-0/+8
| | | | | | | Implement initjmp() for use with the incoming bthread support. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* arm/lib: Replace license and copyright boilerplate by SPDX identifiersUwe Kleine-König2020-12-0716-155/+60
| | | | | | | | | Converts the files that licensecheck can determine to be licensed under GPL-2.0-only or GPL-2.0-or-later and also convert the copyright statements to SPDX. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: bootm: Add lower bound check of kernel in SDRAMAlexander Shiyan2020-10-281-2/+3
| | | | | | | | In get_kernel_addresses(), we add the lower bound check of kernel position. Kernel address cannot be lower than SDRAM start. Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* magicvar: Replace BAREBOX_MAGICVAR_NAMED with BAREBOX_MAGICVARSascha Hauer2020-10-021-2/+2
| | | | | | | | BAREBOX_MAGICVAR now generates a unique identifier automatically, so we can convert users of BAREBOX_MAGICVAR_NAMED to the simpler BAREBOX_MAGICVAR macro. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc' into masterSascha Hauer2020-09-251-5/+39
|\
| * bootm: Allow loading OP-TEE from FIT imageAlbert Schwarzkopf2020-09-181-5/+39
| | | | | | | | | | | | | | | | | | | | | | | | Currently, TEE binaries can only be loaded if CONFIG_BOOTM_FORCE_SIGNED_IMAGES is not set. No signature check is being performed on them. Allow loading OP-TEE from FIT images. Therefore, now it's possible to ensure that only trusted OP-TEE binaries will be loaded by using signed FIT images. Signed-off-by: Albert Schwarzkopf <a.schwarzkopf@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | ARM: Add KASan supportSascha Hauer2020-09-223-2/+9
|/ | | | | | | | | | | | | | This adds KASan support to the ARM architecture. What we are doing is: * Add __no_sanitize_address attribute to various lowlevel functions which do not run in a proper C environment * Add non-instrumented variants of memset/memcpy (prefixed with '__') * make original memcpy/memset weak symbols so strong definitions in lib/kasan/common.c can replace them * Use non-instrumented memcpy in early functions * call kasan_init() Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* arm: module: Allow modules outside of bl rangeDavid Dgien2020-07-014-0/+248
| | | | | | | | | | | | | | | | | | | | | | | | | | Unlike the Linux kernel, barebox does not have a dedicated heap for storing modules. Therefore, if the system memory configuration places the general heap further away than can be reached by a 'bl' instruction (24 bits of address, or 16 MiB), then the module relocations will fail due to being out of range. Allocate PLTs when loading modules so that jumps and calls whose targets are too far away for their relative offsets to be encoded in the instructions themselves can be bounced via veneers in the module's PLT. The modules will use slightly more memory, but after rounding up to page size, the actual memory footprint is usually the same. Adoption of Linux commits: 66e94ba3c8ea ARM: kernel: avoid brute force search on PLT generation 1031a7e674d1 ARM: kernel: sort relocation sections before allocating PLTs 05123fef0982 ARM: kernel: allocate PLT entries only for external symbols 35fa91eed817 ARM: kernel: merge core and init PLTs 7d485f647c1f ARM: 8220/1: allow modules outside of bl range Signed-off-by: David Dgien <dgienda125@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: remove references to CREDITSUwe Kleine-König2020-04-272-6/+0
| | | | | | | | The CREDITS file was removed from barebox in 2015 by commit 6570288f2d97 ("Remove the CREDITS file"). Remove references to it from several files. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: bootm: make sure we place the kernel in free memorySascha Hauer2020-03-231-1/+14
| | | | | | | | When placing the kernel image in memory make sure we do not place it too high, outside of the available memory, outside of the available memory. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: add optee early loading functionRouven Czerwinski2020-01-302-0/+40
| | | | | | | | | | | | | | | | | | | Add a OP-TEE early loading function which expects a pointer to a valid tee binary and the device tree. OP-TEE will then be started and barebox will continue to run in normal mode. The function start_optee_early should be used in a boards lowlevel.c file. Ensure that barebox has been relocated and a proper c environment has been setup beforehand. Depending on the OP-TEE configuration, the fdt will be modified. If the internal barebox device tree is passed, OP-TEE will overwrite barebox PBL memory during this modification. Copy the fdt to a save memory location beforehand to avoid a corruption of barebox PBL memory. This also moves the OP-TEE Kconfig symbols into a separate menu. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: import setjmp implementation from U-BootRouven Czerwinski2020-01-302-0/+38
| | | | | Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* optee: move optee_verify_header() to commonRouven Czerwinski2020-01-281-9/+3
| | | | | | | | Subsequent patches will use this to verify the header in the PBL, move it to common to make it potentially available for both. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: move into ARM32 specific optee kernel start into lib32 dirLucas Stach2019-12-022-0/+15
| | | | | | | | Otherwise it may also get built on a ARM64 config, which obviously fails. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* lds: Add and use RO_DATA_SECTION macroSascha Hauer2019-10-141-10/+4
| | | | | | | | | We have many different pointer arrays which we put into linker sections and each time there's one added we have to adjust all linker scripts. This adds a common RO_DATA_SECTION define and uses it for all architectures. This makes it easier to add a new linker array. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* lds: create and use BAREBOX_PCI_FIXUP macroSascha Hauer2019-10-141-14/+1
| | | | | | | No need to repeat the pci fixup sections in each linker script. Add a define for it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* lds: Move start/end address variables into definesSascha Hauer2019-10-141-19/+2
| | | | | | | | | | | For the older section defines we specify the start and end addresses outside the macro which means we have to repeat them in each linker script. Make the start/end addresses part of the define to simplify things. While at it, add a BAREBOX_ prefix to the INITCALLS and EXITCALLS macros for consistency to the other defines. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Acked-by: Sam Ravnborg <sam@ravnborg.org>
* barebox.lds: Remove unnecessary bracesSascha Hauer2019-10-141-2/+2
| | | | | | | The BAREBOX_CLK_TABLE and BAREBOX_DTB macros are defines that do not take a parameter, so we can remove the braces. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: Initial OP-TEE supportSascha Hauer2019-06-074-5/+89
| | | | | | | | | | | | | | | | | | | | | | | | | This adds initial support for OP-TEE, see https://www.op-tee.org/ barebox starts in secure mode as usual. When booting a kernel the bootm code also loads the optee_os binary. Instead of jumping into the kernel barebox jumps into the optee_os binary and puts the kernel execution address into the lr register. OP-TEE then jumps into the kernel in nonsecure mode. The optee_os binary is passed with the -t option to bootm or with global.bootm.tee. Optionally OP-TEE can be compiled into barebox using the builtin firmware feature. Enable the Kconfig option and place or link your tee binary as optee.bin into the firmware directory. The amount of SDRAM which is kept free for OP-TEE is configurable. This patch was tested on a i.MX6 Nitrogen6x board. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: Add missing includesSascha Hauer2019-03-181-0/+1
| | | | | | | | | Many files in the tree implement functions, but do not include the header files which provide the prototypes for these functions. This means conflicting prototypes remain undetected. Add the missing includes. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: semihosting: Fix function prototypeSascha Hauer2019-03-181-1/+1
| | | | | | lsee takes a loff_t pos argument and not a off_t argument. Fix. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: stack unwind: Print messages with pr_warningSascha Hauer2018-11-141-2/+2
| | | | | | | print stack traces with pr_err() rather than printf() to make sure they appear in the logs. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: unwind: Make locally used function staticSascha Hauer2018-10-231-1/+2
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: unwind: Provide prototypes for exported functionsSascha Hauer2018-10-231-0/+4
| | | | | | | | __aeabi_unwind_cpp_prx are provided to make the linker happy. To fix warnings about missing prototypes just provide a prototype in the same file. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: legacy Linux support: Make locally used functions staticSascha Hauer2018-10-231-3/+3
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/socfpga'Sascha Hauer2018-08-131-0/+7
|\
| * bootm: allow booting SoCFPGA prebootloader imageEnrico Jorns2018-08-081-0/+7
| | | | | | | | | | | | | | | | | | A prebootloader image might also contain a fully working barebox and allows to be booted second stage. Thus we add a handler here to give it a try. Signed-off-by: Enrico Jorns <ejo@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | pci: add quirk infrastructureLucas Stach2018-08-081-0/+12
|/ | | | | | | | | This is a cut down version of the Linux kernel PCI quirk infrastructure, which allows to register and execute some fixups before the driver is loaded. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/kill-oftree-f'Sascha Hauer2018-07-091-1/+14
|\ | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ARM: bootm: Add option boot using ATAGsSascha Hauer2018-06-111-5/+21
| | | | | | | | | | | | | | | | | | So far we can only force legacy boot using ATAGs by executing 'oftree -f'. Said command is going away as often this command is not safe to call. Add an alternative way using the global.bootm.boot_atag environment variable. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | bootm: Split bootm_load_devicetree into two functionsSascha Hauer2018-06-151-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | It is not always desired to get the devicetree from image data and load it to a SDRAM region at the same time. Sometimes it's enough to just load it to an allocated address (in case the user has no constraints where the devicetree should be placed. This patch splits bootm_load_devicetree into bootm_get_devicetree which returns a pointer to the allocated devicetree and bootm_load_devicetree which loads the devicetree to a specified region. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | ARM: bootm: drop usage of data->oftreeSascha Hauer2018-06-151-19/+24
|/ | | | | | | data->oftree can be replaced with a variable local to the arm code, so drop usage of data->oftree. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: aarch64: disable 32bit boot commandsSascha Hauer2018-04-043-0/+666
| | | | | | | | The 32bit boot support is full of legacy cruft. While it should be possible to merge the aarch64 support there, a fresh start looks more promising. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>