aboutsummaryrefslogtreecommitdiff
path: root/arch/sandbox/cpu
AgeCommit message (Collapse)Author
2024-07-15sandbox: Remove duplicate newlinesMarek Vasut
Drop all duplicate newlines. No functional change. Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
2024-07-03sandbox: cleanup linker scripts and sectionsIlias Apalodimas
commit 6e2228fb052b ("Merge patch series "Clean up arm linker scripts"") was cleaning up linker scripts for armv7 and v8 in a similar fashion. Several commits in the past -- e.g commit d0b5d9da5de2 ("arm: make _end compiler-generated") was moving symbols to be compiler generated. They were defined as c variables in its own section to force the compiler emit relative a reference. However, defining those in the linker script will do the same thing since [0]. So let's remove the special sections from the linker scripts, the variable definitions from sections.c, and define them as a symbols. It's worth noting that the linker was discarding the symbols in the older binary completely since the symbol definition had an extra _. - new binary $~ aarch64-linux-gnu-readelf -sW u-boot | grep efi_runtim 246: 000000000004acbe 13 FUNC LOCAL DEFAULT 14 vbe_req_efi_runtime_rand 3198: 0000000000318690 16 OBJECT LOCAL DEFAULT 29 efi_runtime_mmio 6359: 00000000000dedff 217 FUNC LOCAL DEFAULT 14 efi_runtime_relocate 7942: 00000000003074c0 136 OBJECT GLOBAL HIDDEN 29 efi_runtime_services 8869: 0000000000305e20 0 NOTYPE GLOBAL DEFAULT 27 __efi_runtime_rel_stop 9159: 0000000000305e20 0 NOTYPE GLOBAL DEFAULT 27 __efi_runtime_stop 9410: 0000000000305e20 0 NOTYPE GLOBAL DEFAULT 27 __efi_runtime_start 10137: 00000000005981bd 0 NOTYPE WEAK HIDDEN 33 efi_runtime.c.de5bed54 10470: 0000000000305e20 0 NOTYPE GLOBAL DEFAULT 27 __efi_runtime_rel_start - old binary $~ aarch64-linux-gnu-readelf -sW u-boot.old | grep efi_runtim 246: 000000000004acbe 13 FUNC LOCAL DEFAULT 14 vbe_req_efi_runtime_rand 3198: 0000000000318690 16 OBJECT LOCAL DEFAULT 29 efi_runtime_mmio 6359: 00000000000dedff 221 FUNC LOCAL DEFAULT 14 efi_runtime_relocate 7942: 00000000003074c0 136 OBJECT GLOBAL HIDDEN 29 efi_runtime_services 10135: 0000000000598320 0 NOTYPE WEAK HIDDEN 33 efi_runtime.c.de5bed54 $~ bloat-o-meter u-bool.old u-boot add/remove: 0/0 grow/shrink: 1/1 up/down: 7/-4 (3) Function old new delta efi_memory_init 343 350 +7 efi_runtime_relocate 221 217 -4 Total: Before=2009902, After=2009905, chg +0.00% [0] binutils commit 6b3b0ab89663 ("Make linker assigned symbol dynamic only for shared object") Tested-by: Heinrich Schuchardt <xypron.glpk@gmx.de> # sandbox_defconfig on amd64, arm64, riscv64 Reviewed-by: Simon Glass <sjg@chromium.org> Fixes: commit aac53d3d96a2 ("sandbox: Rename EFI runtime sections") Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-07-03sandbox: use sane access rights for filesHeinrich Schuchardt
When writing an executable, allowing other users to modify it introduces a security issue. Generally we should avoid giving other users write access to our files by default. Replace chmod(777) by chmod(755) and chmod(644). Fixes: 47f5fcfb4169 ("sandbox: Add os_jump_to_image() to run another executable") Fixes: d9165153caea ("sandbox: add flags for open() call") Fixes: 5c2859cdc302 ("sandbox: Allow reading/writing of RAM buffer") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Sean Anderson <seanga2@gmail.com>
2024-04-17sandbox: don't call os_close with invalid file descriptorHeinrich Schuchardt
If open() fails it returns -1. Calling close() with this value makes no sense. Return -EIO instead. Addresses-Coverity-ID: 185828 Improper use of negative value Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Fixes: 566bf3a8698 ("sandbox: Add a function to read a host file") Reviewed-by: Sean Anderson <seanga2@gmail.com>
2024-04-12sandbox: missing return value checks in eth-raw-osHeinrich Schuchardt
We should check the return value of fcntl(). Addresses-Coverity-ID: 131108 ("Unchecked return value from library") Addresses-Coverity-ID: 131109 ("Unchecked return value from library") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-01-11Merge patch series "net fixes prior lwip"Tom Rini
Maxim Uvarov <maxim.uvarov@linaro.org> says: Add small net fixes prior lwip patches.
2024-01-11sandbox: eth-raw-os: successful return code is 0Maxim Uvarov
all network drivers return 0 on the successful transmission. Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-12-21Merge patch series "Complete decoupling of bootm logic from commands"Tom Rini
Simon Glass <sjg@chromium.org> says: This series continues refactoring the bootm code to allow it to be used with CONFIG_COMMAND disabled. The OS-handling code is refactored and a new bootm_run() function is created to run through the bootm stages. This completes the work. A booti_go() function is created also, in case it proves useful, but at last for now standard boot does not use this. This is cmdd (part d of CMDLINE refactoring) It depends on dm/bootstda-working which depends on dm/cmdc-working
2023-12-21sandbox: bootm: Enable more bootm OS methodsSimon Glass
It is useful for sandbox to build as much code as possible. Enable support for booting various other operating systems. Add the missing cache functions. These operating systems do not actually boot on sandbox, of course. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-12-21sandbox: Audit config.h and common.h usageTom Rini
Remove and replace common.h and config.h in sandbox when it's not needed and add some explicit includes where needed. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Rini <trini@konsulko.com>
2023-11-20Merge tag 'v2024.01-rc3' into nextTom Rini
Prepare v2024.01-rc3
2023-11-16arch: sandbox: Add function to create temporary filesSean Anderson
When working with sparse data buffers that may be larger than the address space, it is convenient to work with files instead. Add a function to create temporary files of a certain size. Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-11-14sandbox: Close file after mmaping itSean Anderson
After opening pathname, we must close ifd once we are done with it. Fixes: b9274095c2c ("sandbox: Add a way to map a file into memory") Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-11-02sandbox: eliminate unused functions from binariesHeinrich Schuchardt
The sandbox should closely mimic other architectures. Place each function or data in a separate section and let the linker eliminate unused ones. This will reduce the binary size. In the linker script mark that u_boot_sandbox_getopt are to be kept. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Tom Rini <trini@konsulko.com>
2023-10-17test: spl: Add a test for the NET load methodSean Anderson
Add a test for loading U-Boot over TFTP. As with other sandbox net routines, we need to initialize our packets manually since things like net_set_ether and net_set_udp_header always use "our" addresses. We use BOOTP instead of DHCP, since DHCP has a tag/length-based format which is harder to parse. Our TFTP implementation doesn't define as many constants as I'd like, so I create some here. Note that the TFTP block size is one-based, but offsets are zero-based. In order to avoid address errors, we need to set up/define some additional address information settings. dram_init_banksize would be a good candidate for settig up bi_dram, but it gets called too late in board_init_r. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-10-17test: spl: Add functions to create imagesSean Anderson
This add some basic functions to create images, and a test for said functions. This is not intended to be a test of the image parsing functions, but rather a framework for creating minimal images for testing load methods. That said, it does do an OK job at finding bugs in the image parsing directly. Since we have two methods for loading/parsing FIT images, add LOAD_FIT_FULL as a separate CI run. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-10-17sandbox: Support -T in splSean Anderson
The test devicetree is only compiled for U-Boot proper. When accessing it in SPL we need to go up one directory. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-10-13sandbox: fix spl_board_initHeinrich Schuchardt
sandbox_spl_defconfig with CONFIG_SPL_UNIT_TEST=n fails to build. in function `spl_board_init': arch/sandbox/cpu/spl.c:134:(.text.spl_board_init+0x4a): undefined reference to `ut_run_list' Add the missing configuration check. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-10-06sandbox: Only read the state if we have a state fileSimon Glass
We should not read this unless requested. Make it conditional on the option being provided. Add some debugging to show the state being written. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-10-06sandbox: Move reading the RAM buffer into a better placeSimon Glass
This should not happen in the argument-parsing function. Move it to the main program. Add some debugging for reading/writing. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-10-06spl: Use SYS_MALLOC_F instead of SYS_MALLOC_F_LENSimon Glass
Use the new SPL/TPL/VPL_SYS_MALLOC_F symbols to determine whether the malloc pool exists. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Sean Anderson <sean.anderson@seco.com>
2023-08-31event: Convert existing spy records to simpleSimon Glass
Very few of the existing event-spy records use the arguments they are passed. Update them to use a simple spy instead, to simplify the code. Where an adaptor function is currently used, remove it where possible. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-25sandbox: Add a way to access persistent test filesSimon Glass
Some pytests create files in the persistent-data directory. It is useful to be able to access these files in C tests. Add a function which can locate a file given its leaf name, using the environment variable set up in test/py/conftest.py Signed-off-by: Simon Glass <sjg@chromium.org>
2023-07-14sandbox: Fix quiting when the LCD window is closedSimon Glass
With recent changes to how sandbox handles reset, closing the window currently just restarts sandbox. Use the correct sysreset type to tell it to shut down. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-06-21sandbox: Add a dummy dcache_status() functionEmanuele Ghidoli
This adds dcache_status() so that code using it can build without error on sandbox. This is required in preparation of adding cache handling into get_ram_size function. Signed-off-by: Emanuele Ghidoli <emanuele.ghidoli@toradex.com> Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-04-28sandbox: disable tracing before unmapping RAMPavel Skripkin
Currently doing 'reset' command in sandbox with tracing enabled causes SIGSEV ``` Hit any key to stop autoboot: 0 => => => reset resetting ... Segmentation fault (core dumped) ``` Tracing callback uses RAM buffer for storing tracing reports, but state_uninit() function unmaps whole RAM, which causes SIGSEV on umapped memory inside tracing subsystem. Fix it by disabling tracing before unmapping memory Signed-off-by: Pavel Skripkin <paskripkin@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org> Add missing check for CONFIG_TRACE: Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-28sandbox: fix return type of os_filesize()Heinrich Schuchardt
Given a file ../img of size 4294967296 with GPT partition table and partitions: => host bind 0 ../img => part list host 0 Disk host-0.blk not ready The cause is os_filesize() returning int. File sizes must use off_t. Correct all uses of os_filesize() too. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-04-28sandbox: mark sandbox_exit() as no return.Heinrich Schuchardt
Fix a -Wimplicit-fallthrough warning in sandbox_sysreset_request(). Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-04-27sandbox64: fix: return unsigned long in readq()Abdellatif El Khlifi
make readq return unsigned long readq should return 64-bit data Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-01-23sandbox: Allow SPI flash bootdevs to be disabled for testsSimon Glass
Most tests don't want these and they can create a lot of noise. Add a way to disable them. Use that in tests, with a flag provided to enable them for tests that need this feature. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23sandbox: Allow ethernet to be disabled at runtimeSimon Glass
For bootstd tests it is seldom useful to have ethernet enabled. Add a way to disable it, so that ethernet operations like tftpboot do nothing. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-12-23global: Migrate CONFIG_MALLOC_F_ADDR to CFGTom Rini
Perform a simple rename of CONFIG_MALLOC_F_ADDR to CFG_MALLOC_F_ADDR Signed-off-by: Tom Rini <trini@konsulko.com>
2022-12-21Merge tag 'v2023.01-rc4' into nextTom Rini
Prepare v2023.01-rc4 Signed-off-by: Tom Rini <trini@konsulko.com>
2022-12-05global: Move remaining CONFIG_SYS_SDRAM_* to CFG_SYS_SDRAM_*Tom Rini
The rest of the unmigrated CONFIG symbols in the CONFIG_SYS_SDRAM namespace do not easily transition to Kconfig. In many cases they likely should come from the device tree instead. Move these out of CONFIG namespace and in to CFG namespace. Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-12-05sandbox: fix sound driverHeinrich Schuchardt
In the callback function we have to use memcpy(). Otherwise we add the new samples on top of what is stored in the stream buffer. If we don't have enough data, zero out the rest of the stream buffer. Our sampling frequency is 48000. Let the batch size for the callback function be 960. If we play a multiple of 20 ms, this will always be a full batch. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-11-07test: Add a way to detect a test that breaks anotherSimon Glass
When running unit tests, some may have side effects which cause a subsequent test to break. This can sometimes be seen when using 'ut dm' or similar. Add a new argument which allows a particular (failing) test to be run immediately after a certain number of tests have run. This allows the test causing the failure to be determined. Update the documentation also. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-10-31vbe: Support reading the next SPL phase via VBESimon Glass
Add an SPL loader to obtain the next-phase binary from a FIT provided by the VBE driver. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-10-31sandbox: Support obtaining the next phase from an imageSimon Glass
At present sandbox runs the next phase from discrete executables, so for example u-boot-tpl runs u-boot-vpl to get to the next phase. In some cases the phases are all built into a single firmware image, as is done for real boards. Add support for this to sandbox. Make it higher priority so that it takes precedence over the existing method. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-10-31sandbox: Add a way to specify the sandbox executableSimon Glass
At present the sandbox executable is assumed to be arg[0] but this only works for a single jump (e.g. from SPL to U-Boot). Add a new arg to solve this issue, along with a detailed comment. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-10-31sandbox: Generalise SPL bootingSimon Glass
At present sandbox only supports jumping to a file, to get to the next U-Boot phase. We want to support other methods, so update the code to use an enum for the method. Also use the Use board_boot_order() to set the order, so we can add more options. Also add the MMC methods into the BOOT_DEVICE enum so that booting from MMC can be supported. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-10-31sandbox: Drop message about writing sandbox stateSimon Glass
This happens every time sandbox moves to the next phase so is not very interesting. Display the message only when debugging. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2022-10-31test: Support tests which can only be run manuallySimon Glass
At present we normally write tests either in Python or in C. But most Python tests end up doing a lot of checks which would be better done in C. Checks done in C are orders of magnitude faster and it is possible to get full access to U-Boot's internal workings, rather than just relying on the command line. The model is to have a Python test set up some things and then use C code (in a unit test) to check that they were done correctly. But we don't want those checks to happen as part of normal test running, since each C unit tests is dependent on the associate Python tests, so cannot run without it. To acheive this, add a new UT_TESTF_MANUAL flag to use with the C 'check' tests, so that they can be skipped by default when the 'ut' command is used. Require that tests have a name ending with '_norun', so that pytest knows to skip them. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-10-24sandbox: add SIGALRM-based watchdog deviceRasmus Villemoes
In order to test that U-Boot actually maintains the watchdog device(s) during long-running busy-loops, such as those where we wait for the user to stop autoboot, we need a watchdog device that actually does something during those loops; we cannot test that behaviour via the DM test framework. So introduce a relatively simple watchdog device which is simply based on calling the host OS' alarm() function; that has the nice property that a new call to alarm() simply sets a new deadline, and alarm(0) cancels any existing alarm. These properties are precisely what we need to implement start/reset/stop. We install our own handler so that we get a known message printed if and when the watchdog fires, and by just invoking that handler directly, we get expire_now for free. The actual calls to the various OS functions (alarm, signal, raise) need to be done in os.c, and since the driver code cannot get access to the values of SIGALRM or SIG_DFL (that would require including a host header, and that's only os.c which can do that), we cannot simply do trivial wrappers for signal() and raise(), but instead create specialized functions just for use by this driver. Apart from enabling this driver for sandbox{,64}_defconfig, also enable the wdt command which was useful for hand-testing this new driver (especially with running u-boot under strace). Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
2022-09-29sandbox: Support setting up the other FDT for testingSimon Glass
Provide a way to copy over the 'other' FDT when running tests. This loads it and allocates memory for the copy, if not done already, then does the copy. Avoid using U-Boot's malloc() pool for these copies, at least for now, since they are part of the test system. Tidy up the cpu.c header files while here. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-29sandbox: Support loading the other FDTSimon Glass
We need an 'other' FDT which is different from the control FDT, so we can check that the ofnode tests correctly handle them both. Add this to the build along with a way to read it into the sandbox state. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-29sandbox: Add a function to load a relative file pathSimon Glass
At present this implementation is specific to loading the test FDT. We plan to load others, so create a generic function to handle this. The path is now limited to 256 characters, to simplify the code. When there is an empty argv[0] (which should not happen), the function now just uses the path as is, with no prefix. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-25sandbox: unblock signal before calling execv()Heinrich Schuchardt
The following faulty behavior was observed. The sandbox configured with CONFIG_SANDBOX_CRASH_RESET=y was invoked with ./u-boot -T -S After executing `exception undefined' the sandbox reboots. When executing `exception undefined' the sandbox exits with SIGSEGV. The expected behavior is that the sandbox should reboot again. If we are relaunching the sandbox in a signal handler, we have to unblock the respective signal before calling execv(). See signal(7) man-page. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-09-24sandbox: Add function os_flush()Pali Rohár
It flushes stdout. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-09-02test: Allow running tests multiple timesSimon Glass
Some tests can have race conditions which are hard to detect on a single one. Add a way to run tests more than once, to help with this. Each individual test is run the requested number of times before moving to the next test. If any runs failed, a message is shown. This is most useful when running a single test, since running all tests multiple times can take a while. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-06-28sandbox: show error if the device-tree cannot be loadedHeinrich Schuchardt
U-Boot's printf() used before setting up U-Boot's serial driver does not create any output. Use os_printf() for error messages related to loading the device-tree. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>