Re: [PATCH] ARM: io: avoid KASAN instrumentation of raw halfword I/O
From: Linus Walleij
Date: Sat May 23 2026 - 18:12:07 EST
On Fri, May 22, 2026 at 11:20 PM Karl Mehltretter
<kmehltretter@xxxxxxxxx> 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@xxxxxxxxxxxxxxx # v5.11+
> Assisted-by: Codex:gpt-5
> Signed-off-by: Karl Mehltretter <kmehltretter@xxxxxxxxx>
That makes sense.
Reviewed-by: Linus Walleij <linusw@xxxxxxxxxx>
Please put this patch into Russell's patch tracker.
Yours,
Linus Walleij