[PATCH 3/4] dma: debug: poison DMA buffers with KASAN while owned by device

2024-09-10 Thread Ahmad Fatoum
Accessing a DMA buffer while owned by device is racy: The device may have not written any data yet and in the case it has written data, it may be hidden by stale cache lines caused by CPU's speculation in the meantime. Only after sync'ing the buffer to the CPU are caches, if any, invalidated, so th

[PATCH 4/4] dma: debug: detect repeated DMA sync using KASAN

2024-09-10 Thread Ahmad Fatoum
Now that we poison/unpoison DMA buffers as part of ownership transfer, it's possible for us to detect repeated sync's that are unnecessary at a granularity of cache lines, which was not possible with the initial approach in commit 1ad4b32702dd ("dma: debug: detect repeated DMA sync"). Such repeate

[PATCH 0/4] dma: debug: track DMA buffer ownership with KASAN

2024-09-10 Thread Ahmad Fatoum
There is litte we can do in software if a DMA master decides to corrupt memory that is owned by the CPU. What we could do, however, is to ensure that code doesn't access memory while not owned by the CPU. This is done by recording ownership information into the KASAN shadow memory. That way access

[PATCH 1/4] Revert "dma: debug: detect repeated DMA sync"

2024-09-10 Thread Ahmad Fatoum
It turns out this check is too restrictive. The DMA API doesn't require a 1:1 relation between mapping and sync. It's permissible to map a big chunk and then managing it as a number of buffers that are synced individually. This is currently the case with the Designware MAC driver and having this c

[PATCH 2/4] KASan: implement non-warning kasan_is_poisoned_shadow

2024-09-10 Thread Ahmad Fatoum
We export kasan_poison_shadow and kasan_unpoison_shadow for use by allocators, but provide no API to query whether a region is poisoned without triggering a stack trace. This can be useful however for more unconventional "allocators" like the DMA API debug code, which can use it to detect double p

[PATCH] ARM: errata: document errata workarounds

2024-09-10 Thread Ahmad Fatoum
Give all errata workaround functions a kernel-doc listing the title of the erratum and what CPUs it affects for documentation purposes. Signed-off-by: Ahmad Fatoum --- arch/arm/include/asm/errata.h | 83 +++ 1 file changed, 83 insertions(+) diff --git a/arch/arm/

[PATCH v2] sandbox: lds: fix "ELF has a LOAD segment with RWX permissions" warning

2024-09-10 Thread Ahmad Fatoum
With binutils 2.39+, the barebox build started emitting this warning. On platforms other than sandbox, we disable this warning by passing --no-warn-rwx to ld as we don't care for ELF attributes as they aren't used anyway. On sandbox, however, the ELF attributes matter, so disabling the warning co

[PATCH] lib: notifier: allow unregistering notifier in notifier_call_chain

2024-09-10 Thread Ahmad Fatoum
It's possible for Linux notifiers to be removed from within the notifier callback. Allow the same within barebox to avoid subtle bugs. Signed-off-by: Ahmad Fatoum --- lib/notifier.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/notifier.c b/lib/notifier.c index c55e

[PATCH 2/2] include: linux/math.h: sync with linux

2024-09-10 Thread Ahmad Fatoum
The header has evolved upstream since we last imported it. Sync it with Linux to make available some more functions for use in barebox. Signed-off-by: Ahmad Fatoum --- include/linux/math.h | 173 --- lib/math/Makefile| 1 + lib/math/int_pow.c | 3

[PATCH 1/2] lib: drop separate int_sqrt.h header

2024-09-10 Thread Ahmad Fatoum
Linux defines int_sqrt in linux/math.h and has the implementations in lib/math. We have both these locations, so move the existing code over to simplify future sync of math functions. Signed-off-by: Ahmad Fatoum --- commands/fbtest.c | 2 +- include/int_sqrt.h| 8 includ

[PATCH master] Kbuild: update gen_compile_commands.py

2024-09-10 Thread Ahmad Fatoum
With python 3.12, we now get following warning when running the script: SyntaxWarning: invalid escape sequence '\#' This and other minor issues have been fixed upstream since we first imported the script, so let's sync and import the content of following Linux v6.11-rc6 commits: 074075aea2

Re: [PATCH] include: linux/iopoll: fix uninitialized warning

2024-09-10 Thread Ahmad Fatoum
Hello Rouven, On 03.09.24 11:37, Rouven Czerwinski wrote: > In gcc 13.3 there is a warning that start may be used unitialized: > > include/linux/iopoll.h:42:21: warning: ‘start’ may be used uninitialized > [-Wmaybe-uninitialized] > 42 | is_timeout(start, ((timeout_us)