summaryrefslogtreecommitdiffstats
path: root/arch/sandbox
Commit message (Collapse)AuthorAgeFilesLines
* sandbox: hostfile: fix UB-inducing shiftAhmad Fatoum2020-02-101-1/+1
| | | | | | | | | | | | | | | On 32-bit hosts, UBSan reports: ==================================================================== UBSAN: Undefined behaviour in ./arch/sandbox/board/hostfile.c:135:12 shift exponent 32 is too large for 32-bit type 'long unsigned int' ==================================================================== Fix this by using a unsigned long long for base. The upper 32-bit won't be set, but device tree fixups can now read them. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* sandbox: fix signed integer overflowAhmad Fatoum2020-02-101-1/+1
| | | | | | | | | | | | | | | On a 32-bit host system, UBSan reports: =============================================================== UBSAN: Undefined behaviour in ./arch/sandbox/os/common.c:115:32 signed integer overflow: 83598 * 1000000000 cannot be represented in type 'long int' =============================================================== Fix this. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* sandbox: add_image: mmap block devicesRobert Karszniewicz2019-10-281-0/+8
| | | | | | | | This makes it possible to mount block devices from the host machine, which have been passed as arguments to --image Signed-off-by: Robert Karszniewicz <r.karszniewicz@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* sandbox: add_image: output errno string on mmap failureRobert Karszniewicz2019-10-231-1/+1
| | | | | Signed-off-by: Robert Karszniewicz <r.karszniewicz@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* hwrng: dev-random: always use /dev/urandomAhmad Fatoum2019-10-232-7/+1
| | | | | | | | | | /dev/random can block long after boot time. It seems there's a consensus that /dev/urandom is safe to use except for very early boot, which isn't when barebox sandbox is usually run. To make the HWRNG more useful, always use /dev/urandom. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* lds: Add and use RO_DATA_SECTION macroSascha Hauer2019-10-141-5/+3
| | | | | | | | | 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>
* X86: lds: remove unnecessary alignmentsSascha Hauer2019-10-141-8/+0
| | | | | | | We do not seem to need all these alignments in the rodata sections, so remove them. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* lds: Move start/end address variables into definesSascha Hauer2019-10-141-12/+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>
* Merge branch 'for-next/sandbox'Sascha Hauer2019-09-1210-9/+112
|\
| * hwrng: add sandbox driver interface to host /dev/randomAhmad Fatoum2019-09-094-0/+39
| | | | | | | | | | | | | | | | | | | | Linux as well as other operating systems can provide /dev/random and /dev/urandom device to service userspace need for randomness. Add a driver to use /dev/random for blocking and /dev/urandom for non-blocking barebox random numbers. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: dts: add example for barebox, hostfile backed stateAhmad Fatoum2019-09-091-0/+50
| | | | | | | | | | | | | | | | | | | | Previous commit now allows probing barebox,hostfile to be probed from device tree. Add a barebox state node that shows how to use it. It's not included by default, same as barebox-libftdi-example.dtsi in the same directory. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: hostfile: allow probing from device treeAhmad Fatoum2019-09-093-4/+18
| | | | | | | | | | | | | | | | | | When testing things like barebox state in sandbox, it's nice to be able to refer to a partition on a hostfile by phandle. Support this by checking for reading the barebox,filename property. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: compile with symbol -fvisibility=hiddenAhmad Fatoum2019-08-281-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | barebox defines many symbols that are reserved for the C implementation. This collides with the libc, when building barebox for ARCH=sandbox. Specify -fvsibility-hidden, so libraries barebox is linked against don't inadvertently use barebox' functions. This fixes a heap corruption occurring when issuing fb0.enable=1 on my system, because X11 used strdup out of barebox, but free out of glibc[1]: binding file /lib/x86_64-linux-gnu/libX11.so.6 [0] to ./barebox [0]: normal symbol l `strdup' [GLIBC_2.2.5] [...] binding file /lib/x86_64-linux-gnu/libc.so.6 [0] to /lib/x86_64-linux-gnu/libc.so.6 [0]: normal symbol `free' [GLIBC_2.2.5] [1]: cf. CFLAGS +=-Dfree=barebox_free in arch/sandbox/Makefile Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: redefine optarg and optind to avoid collisionsAhmad Fatoum2019-08-281-1/+2
| | | | | | | | | | | | | | If we don't do this, the barebox main may fail to parse arguments. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: remove unused ARCH_LINUX Kconfig symbolAhmad Fatoum2019-08-281-3/+0
| | | | | | | | | | | | | | It's not referenced anywhere anymore, so drop it. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: include header to provide missing prototypeAhmad Fatoum2019-08-281-0/+1
| | | | | | | | | | | | | | | | sandbox_add_device lacks a prototype. Include the appropriate header to fix this. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | sandbox: support Address and UndefinedBehavior sanitizersAhmad Fatoum2019-09-092-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | For the hosted implementation, we just need to pass the appropriate options at compile and link time. No further arch-specific code needed. Because we define our own handlers in lib/ubsan.c, linking against libubsan isn't strictly required. We do it anyway on sandbox, so we can use the backtrace functionality within. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | sandbox: use sanitizer unwind for dump_stack if availableAhmad Fatoum2019-09-094-1/+19
| | | | | | | | | | | | | | | | The sanitize unwind looks pretty and is just a function call away if we are compiling with KASAN or UBSAN. Use it if available. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Kconfig: retire empty <asm/barebox.h>Ahmad Fatoum2019-08-301-1/+0
|/ | | | | | | With the latest changes, this file is empty on all archs. Drop it. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/sandbox'Sascha Hauer2019-07-125-5/+3
|\
| * sandbox: drop blank lines at EOFAntony Pavlov2019-07-112-2/+0
| | | | | | | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: eliminale no previous prototype for ‘sandbox_add_device’ warningAntony Pavlov2019-07-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | The patch fixes the following gcc-8.3.0 warning: arch/sandbox/board/devices.c:13:5: warning: no previous prototype for ‘sandbox_add_device’ [-Wmissing-prototypes] int sandbox_add_device(struct device_d *dev) ^~~~~~~~~~~~~~~~~~ Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: prevent segfault in tap_alloc()Antony Pavlov2019-07-112-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Tap network interface initialization in sandbox barebox leads to segfault under Debian Buster/Sid. The problem is that strcpy(dev, ifr.ifr_name) inside tap_alloc() tries to alter read-only data passed by tap_probe() and barebox receives SIGSEGV. Nobody uses network interface name returned by tap_alloc() so we can drop this strcpy(). Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Regenerate defconfig filesSascha Hauer2019-06-261-3/+1
|/ | | | | | | | | | | | | | | | Update defconfig files with the following script. for a in arch/*; do arch=$(basename $a) for c in $a/configs/*; do config=$(basename $c) export ARCH=$arch make $config && make savedefconfig && mv defconfig $c done done Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Shell: Handle aborting loops betterSascha Hauer2019-04-241-1/+1
| | | | | | | | | | | | | | | | | | It's easy to get stuck in an infinite loop in the hush shell: while true; do sleep 1; done The 'sleep' command will check for ctrl-c with the ctrlc() function. This will abort the sleep command. Hush then checks for ctrl-c again in the loop. The ctrl-c in the buffer has already been eaten by the sleep command, so the loop will continue. With this patch we remember the presence of a ctrl-c character in a variable instead of checking for a new character each time. The variable must be resetted explicitly by calling ctrlc_handled() which will be called by the shell in the outer loop. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2019-02-131-2/+0
|\
| * move umode_t typedef from asm/types.h to linux/types.hAntony Pavlov2019-01-181-2/+0
| | | | | | | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | devfs: Drop dev_lseek_default()Andrey Smirnov2019-01-291-1/+0
|/ | | | | | | | | | | | | | | | | | | | | Only the following cdevs do not declare an .lseek() operation: - Console devices in common/console.c - Firmware framework in common/firmware.c - JTAG driver in drivers/misc/jtag.c - UBI in drivers/mtd/ubi/barebox.c Of those four, first two are marked DEVFS_IS_CHARACTER_DEV and implement only .write() operation and the last two don't implement anything but .ioctl(). While there's probably no meaningful way to use lseek() against any of those devices, there doesn't seem to be any harm in allowing it either. Change devfs_lseek() to ignore absense of .lseek() callback and drop dev_lseek_default() and all references to it in the codebase. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* kconfig: include common Kconfig files from top-level KconfigAntony Pavlov2018-12-031-8/+0
| | | | | | | | | | | | | Based on this linux kernel commit: > commit 1572497cb0e6d2016078bc9d5a95786bb878389f > Author: Christoph Hellwig <hch@lst.de> > Date: Tue Jul 31 13:39:30 2018 +0200 > > kconfig: include common Kconfig files from top-level Kconfig Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: Introduce dev_set_name()Andrey Smirnov2018-10-181-1/+1
| | | | | | | | Introduce dev_set_name() in order to hide implementation details of setting device's name so it'd be easier to change it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* rename file_operations -> cdev_operationsSascha Hauer2018-04-061-1/+1
| | | | | | | | Linux also has struct file_operations which are something different. Rename our file_operations to cdev_operations which better matches what we have. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ratp: implement generic command supportAleksander Morgado2018-03-011-0/+5
| | | | | | | | | | | | | | | | | | | The RATP implementation now allows executing generic commands with a binary interface: binary requests are received and binary responses are returned. Each command can define its own RATP request contents (e.g. to specify command-specific options) as well as its own RATP response contents (if any data is to be returned). Each command is associated with a pair of numeric unique request and response IDs, and for easy reference these IDs are maintained in the common ratp_bb header. Modules may override generic implemented commands or include their own new ones (as long as the numeric IDs introduced are unique). Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/sandbox-libftdi'Sascha Hauer2018-02-087-3/+272
|\
| * sandbox: add i2c and spi libftdi1 bit-bang exampleAntony Pavlov2018-01-292-1/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make necessary changes in sandbox_defconfig: enable gpio, spi, i2c and led stuff. Usage: barebox$ make sandbox_defconfig barebox$ sed -i "s/# CONFIG_GPIO_LIBFTDI1.*$/CONFIG_GPIO_LIBFTDI1=y/" .config # edit arch/sandbox/dts/sandbox-libftdi-example.dtsi barebox$ echo '#include "sandbox-libftdi-example.dtsi"' >> arch/sandbox/dts/sandbox.dts barebox$ make barebox$ sudo ./barebox -d arch/sandbox/dts/sandbox.dtb Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: add gpio support with libftdi1Antony Pavlov2018-01-295-1/+175
| | | | | | | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: avoid symbol conflict for {open,read,close}dirAntony Pavlov2018-01-291-1/+3
| | | | | | | | | | | | | | This fixes libusb's /dev/bus/usb directory scan. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | sandbox: use 'poweroff' command for exitAntony Pavlov2018-01-254-19/+19
|/ | | | | | | | The 'poweroff' command is more appropriate for exit barebox than 'reset'. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* asm-generic: partially sync io.h with linux kernelOleksij Rempel2017-09-081-1/+2
| | | | | Signed-off-by: Oleksij Rempel <linux@rempel-privat.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* sandbox: new --stdinout option to enable a bidirectional consoleAleksander Morgado2017-06-061-11/+42
| | | | | | | | | In addition to allowing read-only and write-only consoles with --stdin and --stdout, we now allow bidirectional read/write consoles with FIFO files. This is e.g. to allow doing RATP over the FIFO based consoles. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* sandbox: Fix registering file/fifo consolesSascha Hauer2017-06-011-19/+19
| | | | | | | | barebox_register_console() uses xzalloc which requires the malloc pool to be initialized, so call it during the second option parsing when this is already done. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* sandbox: fix registering multiple consolesAleksander Morgado2017-06-013-7/+6
| | | | | | | | | | | | | | | | | | Consoles need to be registered with the "console" device name so that they are probed by the correct driver. The barebox_register_console() was already forcing this as it was overwriting the name that was being passed as argument, but it was failing to provide a unique id for each new console, so the underlying register_device() would just return an error when wanting to re-register a device with device name "console" and id 0. We remove the unused name parameter from barebox_register_console() as it is really nowhere used, and also specify DEVICE_ID_DYNAMIC as id, so that a new unique device id is given to each newly registered console device. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/ofpart'Sascha Hauer2017-04-071-4/+2
|\
| * treewide: Use of_property_write_string() where appropriateSascha Hauer2017-03-301-4/+2
| | | | | | | | | | | | | | Replace users which use of_set_property() to set a property to a string with of_property_write_string(). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | sandbox_defconfig: enable squashfs supportAntony Pavlov2017-04-061-0/+1
|/ | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2016-11-144-33/+1
|\
| * sandbox: eliminate sdl_init()Antony Pavlov2016-10-192-7/+1
| | | | | | | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * sandbox: drop unused header filesAntony Pavlov2016-10-122-26/+0
| | | | | | | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | arch: refresh defconfigsSascha Hauer2016-10-121-6/+0
|/ | | | | | | | | | | | | | | | | | | | | | The defconfig files are long untouched and a make xy_defconfig; make savedefconfig usually generates quite a different looking file. Refresh them to make it easier to generate patches against the configs using make xy_defconfig; make menuconfig; make savedefconfig This has been done with the following script. for a in arch/*; do arch=$(basename $a) for c in $a/configs/*; do config=$(basename $c) export ARCH=$arch make $config && make savedefconfig && mv defconfig $c done done Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* sandbox: Makefile: drop unused SUBARCH stuffAntony Pavlov2016-10-041-5/+0
| | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* rework remap_rangeSascha Hauer2015-11-031-13/+1
| | | | | | | | | | | | | | | | | | remap_range is for remapping regions with different cache attributes. It is implemented for ARM and PowerPC only, the other architectures only provide stubs. Currently the new cache attributes are passed in an architecture specific way and the attributes have to be retrieved by calls to mmu_get_pte_cached_flags() and mmu_get_pte_uncached_flags(). Make this simpler by providing architecture independent flags which can be directly passed to remap_range() Also provide a MAP_ARCH_DEFAULT flag and a arch_can_remap() function. The MAP_ARCH_DEFAULT defaults to whatever caching type the architecture has as default. the arch_can_remap() function returns true if the architecture can change the cache attributes, false otherwise. This allows the memtest code to better find out what it has to do. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>