[PATCH] ARM: io: avoid KASAN instrumentation of raw halfword I/O

Linus Walleij linusw at kernel.org
Sat May 23 15:11:36 PDT 2026


On Fri, May 22, 2026 at 11:20 PM Karl Mehltretter
<kmehltretter at gmail.com> wrote:

> Commit 421015713b30 ("ARM: 9017/2: Enable KASan for ARM") made KASAN
> instrument ARM C memory accesses. For CPUs before ARMv6, __raw_readw()
> and __raw_writew() are C volatile halfword accesses, so KASAN instruments
> them as normal memory accesses.
>
> That is not valid for MMIO. On the QEMU versatilepb machine with an
> ARM926EJ-S CPU and CONFIG_KASAN=y, PL011 probing traps while registering
> the UART:
>
>   Unable to handle kernel paging request at virtual address bd23e207
>   PC is at __asan_store2+0x2c/0x9c
>   LR is at pl011_register_port+0x4c/0x19c
>
> Keep the existing volatile halfword access, but move the pre-ARMv6
> definitions into __no_kasan_or_inline functions so raw MMIO halfword
> accesses are not instrumented by KASAN. The ARMv6-and-newer inline
> assembly path is unchanged.
>
> Fixes: 421015713b30 ("ARM: 9017/2: Enable KASan for ARM")
> Cc: stable at vger.kernel.org # v5.11+
> Assisted-by: Codex:gpt-5
> Signed-off-by: Karl Mehltretter <kmehltretter at gmail.com>

That makes sense.
Reviewed-by: Linus Walleij <linusw at kernel.org>

Please put this patch into Russell's patch tracker.

Yours,
Linus Walleij



More information about the linux-arm-kernel mailing list