summaryrefslogtreecommitdiffstats
path: root/arch/sandbox
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'for-next/misc'Sascha Hauer2020-11-101-1/+0
|\
| * sandbox: remove MXS tools from hosttools_defconfigRoland Hieber2020-11-091-1/+0
| | | | | | | | | | | | | | | | | | CONFIG_MXS_HOSTTOOLS currently only builds the tools mxsimage and mxsboot, which are both only needed to create bootable images for the MXS platform, and are not really useful as stand-alone host tools. Signed-off-by: Roland Hieber <rhi@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | sandbox: fix link error when UBSAN is selected without ASANAhmad Fatoum2020-10-191-6/+1
|/ | | | | | | | | | | | | dc7f1fce6747 ("sandbox: fix SANDBOX_UNWIND dependency to be KASAN only") already restricted ARCH_HAS_STACK_DUMP to be dependent only on AddressSanitizer being available. This change got lost by an erroneous merge conflict resolution in 39bdcdfb814a ("Merge branch 'for-next/misc' into master"). Fix it up. Fixes: 39bdcdfb814a ("Merge branch 'for-next/misc' into master") Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/sandbox' into masterSascha Hauer2020-10-1417-184/+513
|\
| * sandbox: defconfig: enable new generic featuresAhmad Fatoum2020-10-131-2/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Recent commits have modified sandbox for easier support of many common features: - block devices - watchdogs - reset source - reboot mode - barebox state Enable those in defconfig along with some other useful options. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: dts: include state node by defaultAhmad Fatoum2020-10-133-50/+47
| | | | | | | | | | | | | | | | | | | | | | | | For testing barebox-state, it would be nice to have a state pre-configured out-of-the-box. Add one to sandbox.dts. Because the barebox message on an non-configured state can looks quite scary, add an init script that tells the user that all is well. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: add watchdog driverAhmad Fatoum2020-10-135-0/+117
| | | | | | | | | | | | | | | | Add SIGALRM based watchdog driver. This can reset barebox if stuck and plays nicely with $global.system.reset. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: dts: implement reboot modeAhmad Fatoum2020-10-131-1/+11
| | | | | | | | | | | | | | | | Having a default reboot mode in the device tree allows testing the functionality out of sandbox without prior setup. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: power: implement reset source supportAhmad Fatoum2020-10-132-1/+25
| | | | | | | | | | | | | | | | We can differentiate between POR and RST by explicitly storing RST as reset reason when we invoke the reset handler. Do so. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: poweroff: migrate to driver probed from device treeAhmad Fatoum2020-10-134-43/+66
| | | | | | | | | | | | | | | | | | | | Follow-up will extend the poweroff driver to support system reset source. Set the stage by renaming the driver to power (as it does reset as well) and make it probe from device tree, so it can point at the system reset source syscon via phandle. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: dts: define default environment nodeAhmad Fatoum2020-10-131-0/+20
| | | | | | | | | | | | | | | | | | Now that we can define a hostfile that's persistent over barebox resets, but does not rely on a hard coded filename, we can have an always-on environment node. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: hostfile: maintain created temp files over resetAhmad Fatoum2020-10-133-9/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | Currently, hostfils without a barebox,filename are assigned a new temporary file on every start. For use of a hostfile syscon for reboot mode or reset source, we will need to persist the changes over a regular reset. This can easily be done by passing through all automatically created temporary file with an explicit --image option on subsequent runs. Do so. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: hostfile: support anonymous hostfiles in device treeAhmad Fatoum2020-10-133-5/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | So far use of hostfile in the device tree required us to hard code a file name. If we instead create a temporary file on demand, we can support: - environment - barebox-state - syscon for reset source and reboot mode out of the box with no dependency on external files. Do the necessary, so a hostfile device tree node without a barebox,filename gets a temporary file generated with the appropriate size. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: hostfile: unify --image and direct device tree probeAhmad Fatoum2020-10-134-40/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 801b7cff0210 ("sandbox: hostfile: allow probing from device tree") added initial support for probing hostfiles out of a non-fixed up device tree. This was achieved by having the driver probe call linux_open if the device tree node doesn't contain a valid barebox,fd property. A mmap did not happen in that case and as such the node couldn't be used as a syscon. Fix this by unifying the binding for hostfiles added by --image and ones already in the device tree. Both will result in a device node with just a barebox,filename property. On pure init level, both kinds of hostfiles will be iterated through and filenames will be opened and mmaped. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: dts: retire skeleton.dtsiAhmad Fatoum2020-10-122-15/+14
| | | | | | | | | | | | | | | | | | Follow up commits will flesh out the sandbox.dts and make most of what's in the skeleton.dtsi redundant. Merge the .dtsi with the .dts to have all the code at one place. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: fix behavior with images >= 4G on 32-bitAhmad Fatoum2020-10-121-5/+7
| | | | | | | | | | | | | | | | | | hf->base may remain uninitialized if an image is > 4G, but sandbox barebox is compiled for 32-bit. Fix this. Reported-by: clang-analyzer-10 Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: compile in a fallback device treeAhmad Fatoum2020-10-124-26/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The sandbox architecture is device tree only and so far when no --dtb was passed, it created a basic one itself and used that. Instead of creating the default device tree in C, just build the dtb into barebox like we do on other platforms. When --dtb is specified, that device tree will be used instead. This results in functional change: Model and hostname are now more accurate. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * of: Add common device tree register functionSascha Hauer2020-10-121-4/+1
| | | | | | | | | | | | | | | | The different architectures duplicate some code around unflattening and registering the device tree. Add common functions to reduce this duplication. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | sandbox: add dummy memory-mapped I/O port regionAhmad Fatoum2020-10-012-1/+8
|/ | | | | | | | | | | | | | | Super I/O devices on x86 have their base usually located at one of two I/O ports. They are probed by writing a "passcode" to the I/O port and then a value is read back. When COMPILE_TESTing these drivers and running them on sandbox, this fails with a segfault because all I/O port access lead to zero page dereference on that architecture. Even without running barebox, static analyzers correctly flag these accesses as invoking undefined behavior. Adding a dummy I/O region solves both issues. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc' into masterSascha Hauer2020-09-2513-49/+220
|\
| * sandbox: unwind: fix indentationAhmad Fatoum2020-09-151-1/+1
| | | | | | | | | | | | | | Indentation was unintentionally doubled. Fix this. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: hostfile: support registering images as barebox block devicesAhmad Fatoum2020-09-154-26/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While we can mount file systems on cdevs in barebox, partition table parsing only works for block devices. Allow for --image=argument,blkdev to try to mount an image as block device. This will fail for files that aren't of a multiple of the 512 byte block size. Host OS block devices are suitable for use as barebox block devices always, so that's the default unless overridden with a ,cdev suffix. The initcall level has been changed to occur after fs initcall level. This is required, because we can't have automounts without / mounted. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: implement actual sandbox reset via exec(2)Ahmad Fatoum2020-09-156-11/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On Linux, /proc/self/exe is a symlink to the originally exec(2)d executable. We can exec that with the original argv to simulate a reset. This is useful for shorter development cycles on sandbox and in future, could be used to test barebox behavior around resets (e.g. reset reason can be passed through via libc environment). We leave the original hanging reset in place though, because: - Many boards have multiple reset providers and incoming patches will allow users to select a specific one. Having this on sandbox as well makes testing easier. - /proc/self/exe is Linux-specific and wouldn't work when being run on e.g. BSDs or macOS Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: implement simple, ^C-interruptible, restart handlerAhmad Fatoum2020-09-143-0/+19
| | | | | | | | | | | | | | | | | | | | Typing reset in sandbox results in hang() while the terminal is not cooked and ^C is ineffective. Only way to terminate barebox then is via kill. Reinstate cooked mode on reset, so ^C termination is possible. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: fix SANDBOX_UNWIND dependency to be KASAN onlyAhmad Fatoum2020-09-141-1/+1
| | | | | | | | | | | | | | | | | | gcc v9.3.0's libubsan does not export a __sanitizer_print_stack_trace symbol. Play it safe and avoid possible linker errors by having the optional SANDBOX_UNWIND depend only on CONFIG_KASAN. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: support escaping commas in --image filenamesAhmad Fatoum2020-09-141-4/+6
| | | | | | | | | | | | | | | | | | Some tools like afl-fuzz generate file names containing commas. Allow escaping the commas in the file names, so they can be passed to barebox. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: add_image: support mmaping block devices on 32-bit hostsAhmad Fatoum2020-09-146-8/+13
| | | | | | | | | | | | | | | | | | | | BLKGETSIZE64 writes 64-bit to the address pointed at by the ioctl argument. As hf->size is a 32-bit size_t on 32-bit systems, on such systems, the adjacent member might be corrupted. Fix this. Fixes: 8d6da6462b12 ("sandbox: add_image: mmap block devices") Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: hostfile: error out if file couldn't be openedAhmad Fatoum2020-09-141-0/+3
| | | | | | | | | | | | | | | | The file descriptor is mandatory for doing anything useful. Error out if we don't have one. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: add a minimal defconfig to build only the host toolsRoland Hieber2020-08-281-0/+7
| | | | | | | | | | | | | | | | For distro packaging, make it possible to build all host tools in one go (and a very minimal barebox image as an unimportant side artifact). Signed-off-by: Roland Hieber <rhi@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/kbuild' into masterSascha Hauer2020-09-251-4/+1
|\ \
| * | sandbox: add sandbox.dtb to always-yMasahiro Yamada2020-08-191-4/+1
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unlike Linux, Barebox does not support 'make dtbs_install'. There is no good reason to use dtb-y, which is not natively supported by the Barebox build system. Sandbox is the special architecture that compiles DTB as a separate file. Add .dtb to always-y directly. CONFIG_OFTREE is a bool option. Use a more Kbuild-ish style instead of ifeq ($(CONFIG_OFTREE),y). Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / sandbox: rename KASan to ASanSascha Hauer2020-09-214-8/+4
|/ | | | | | | | | sandbox really has ASan support, that is address sanitizer with the help of the userspace library libasan. In contrast KASan is used on real hardware where we have to implement our own support code. Rename sandbox KASan to ASan to not clash with upcoming KASan support. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2020-07-277-19/+57
|\
| * sandbox: reinstate cooked terminal mode on sanitizer-induced deathAhmad Fatoum2020-07-142-0/+10
| | | | | | | | | | | | | | | | | | | | If we exit due to AddressSanitizer error, we remain in raw mode, which is not best user experience. Currently every exit is an AddressSanitizer death due to leaks. We want to encourage users to always have ASan enabled, to catch more errors, thus call cookmode() on exit. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: add libc memory allocatorAhmad Fatoum2020-07-143-0/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While we typically want to reuse as much barebox functionality as possible in sandbox, using system malloc(3) instead can be very useful when using external memory integrity tools. This is even useful for AddressSanitizer, because the reports resulting from the memory poisoning API are less detailed than the built-in support for the libc malloc(3). Note that a barebox "heap" is still allocated upfront. It's only used for request_sdram_region now though. Whatever is allocated by means of malloc and memalign will be ina disjunct heap. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: os: common: fix compiler warning in add_image()Ahmad Fatoum2020-07-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GCC reports: ./arch/sandbox/os/common.c: In function ‘add_image’: ./arch/sandbox/os/common.c:271:6: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] This is because hf->base is an unsigned long long, with the upper 32 bit all-zeroes on 32-bit systems. The compiler doesn't see that though. Change the cast, so we no longer warn. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: include: <asm/types.h>: don't define INTERNAL_SIZE_TAhmad Fatoum2020-07-141-11/+2
| | | | | | | | | | | | | | | | | | The INTERNAL_SIZE_T default is size_t, which already is 64-bit on 64-bit platforms and 32-bit on 32-bit ones. We can thus drop the #define and go back to the minimal <asm/types.h>. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: specify sizeof(dma_addr_t) == sizeof(phys_addr_t) == 8 on 64BITAhmad Fatoum2020-07-143-7/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | sizeof(dma_addr_t) == 8 shouldn't introduce any functional change, because we can't have DMA on sandbox. For now it suppresses benign warnings about mismatched pointer and integer sizes when some headers are included. sizeof(phys_addr_t) == 8 was already the case on systems with __x86_64__. As CONFIG_64BIT now is set according to the bitness of the compiler, we can migrate this fully to Kconfig. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | sandbox: fix generation of broken binariesAhmad Fatoum2020-07-051-1/+5
|/ | | | | | | | | | | | | Code under arch/sandbox/os is meant to link against the libc primitives of the OS, not the barebox counterparts (e.g. for malloc). 54d47eb7e912 ("sandbox: support forcing 32-bit x86") broke this rendering the sandbox architecture unusable. Fix this. Reported-by: Peter Mamonov <pmamonov@gmail.com> Fixes: 54d47eb7e912 ("sandbox: support forcing 32-bit x86") Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/sandbox-compile-test'Sascha Hauer2020-06-118-14/+96
|\
| * sandbox: os: add_image: fix memory leakAhmad Fatoum2020-06-031-1/+1
| | | | | | | | | | | | | | | | devname is strdup'd few lines later, so remove the earlier strdup. The pointer isn't stored anywhere persistent in between. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: asm: implement <asm/atomic.h>Ahmad Fatoum2020-06-031-0/+2
| | | | | | | | | | | | | | | | | | For easier code-sharing, the UBIFS code still uses the Kernel's atomic accessors. Provide a sandbox <asm/atomic.h> header, so we can compile-test UBI under sandbox. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: select HAS_DMAAhmad Fatoum2020-06-031-0/+1
| | | | | | | | | | | | | | | | With the DMA stubs in place, we can indicate HAS_DMA in good conscience. Do so. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: asm: implement stub DMA functionsAhmad Fatoum2020-06-031-1/+52
| | | | | | | | | | | | | | | | For compile-testing drivers that use DMA operations under sandbox, we want stub implementations of these. Provide them. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: implement stub physical virtual translationAhmad Fatoum2020-06-031-0/+10
| | | | | | | | | | | | | | | | For compile-testing drivers that use DMA operations under sandbox, we want stub implementations of these. Provide them. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: <asm/io.h>: include bitio accessorsAhmad Fatoum2020-06-031-0/+1
| | | | | | | | | | | | | | | | | | ARM <asm/io.h> defines the U-Boot style setbits/clrbits helpers. Have sandbox follow suit to allow more drivers to be compile tested there. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: support forcing 32-bit x86Ahmad Fatoum2020-06-033-2/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | If gcc supports multiple architectures, barebox uses only the default when compiling for ARCH=sandbox, this is e.g. the case with compilers that generate both 32- and 64-bit x86 executables. There can be good reasons to force 32-bit though, e.g. to reduce memory consumption while fuzzing or to temporarily avoid 32-to-64-bit warnings, while running the static analyzer. Add an option for this. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: asm: bitsperlong.h: detect bitness according to 64BIT symbolAhmad Fatoum2020-06-031-10/+1
| | | | | | | | | | | | | | | | | | | | | | Now that we have an accurate CONFIG_64BIT describing sandbox bitness, we don't need to assume everything except __x86_64__ as 32-bit. This assumes that sizeof(long) == sizeof(void *), which is assumed anyway throughout the code base. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: define CONFIG_64BIT as appropriateAhmad Fatoum2020-06-031-0/+9
| | | | | | | | | | | | | | | | | | | | | | All 64-bit architectures are supposed to define CONFIG_64BIT to support the relevant 64-bit MMIO accessors. The sandbox architecture is a bit of a special case, because barebox uses the toolchain default and doesn't force a bitness. Add 64BIT as promptless symbol, which reflects the pointer size of the target platform. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2020-06-111-40/+2
|\ \ | |/ |/|