From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B1E72425CEE; Tue, 16 Jun 2026 16:28:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781627314; cv=none; b=tE1YM0UUQZ6L47t8HIRaOhGBS32SL5EgG8WoKjAB8Rm0rS7cdj02MgvwhQ2x7nOwyxvO/ECgYPfBLgvacCZBny2F4f1Zhhb/QIhJ0RuFaoxu7eAR7I+lgsm4cMLFlc5o8sPJN3RyJTNRWIVooMcjfnjdto9rw+kRxAdsr6UoI9I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781627314; c=relaxed/simple; bh=5cUbhv2qxHK80K7dkUacYYtbqG7sXOfswq4A4THRhlg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h2Gt9s4sR+wCkauAuaR5OM+vnfGP+/NXa3Kiq4LVUgsqYS9CIojowp2Drqyv5wF2DZRCHyVpDcZOy9VOiL5iyoPvwWNblnOtyoducSLwGG9fkwHvM2XXaIJ0SHXOYKAQW+Iy3pMP7SyGSXaN+riJrR0vBR2mHUM/FRM03pLna9Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=dQPQoPZ0; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="dQPQoPZ0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B651D1F000E9; Tue, 16 Jun 2026 16:28:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781627313; bh=8V5i+foK+BSnE1hECBqBughZYBDhK8NuhsO+hMIKWC8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=dQPQoPZ0E45n2ANWk5ZebuTEP5BYOuQwFi2OLh9wuTyk2ZZ4eV82lioFNC4v4dmXk XxCqMZYbhsiOKETkoGGaod1Pa4xh+W0sUpPyk0g4o17hEldVseFQg2hb+o1ZWIEozx FcIrB2IHZJuP8+y2rSrtYc4nXevBYEYlEoHS8+iA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Karl Mehltretter , Linus Walleij , Russell King Subject: [PATCH 6.12 154/261] ARM: 9474/1: io: avoid KASAN instrumentation of raw halfword I/O Date: Tue, 16 Jun 2026 20:29:52 +0530 Message-ID: <20260616145052.215603647@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145044.869532709@linuxfoundation.org> References: <20260616145044.869532709@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Karl Mehltretter commit d59ed803715a71fb9582e139d648ece8d66dc743 upstream. For CPUs before ARMv6, __raw_readw() and __raw_writew() are implemented as C volatile halfword accesses so the compiler can generate an access sequence that is safe for those machines. With KASAN enabled, those C accesses are instrumented as normal memory accesses. That is not valid for MMIO. On ARM926/VersatilePB with KASAN enabled, PL011 probing traps in __asan_store2() while registering the UART, because the instrumented writew() tries to check KASAN shadow for an MMIO address. Keep the existing volatile halfword access, but move the ARMv5 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@vger.kernel.org # v5.11+ Signed-off-by: Karl Mehltretter Reviewed-by: Linus Walleij Signed-off-by: Russell King Signed-off-by: Greg Kroah-Hartman --- arch/arm/include/asm/io.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) --- a/arch/arm/include/asm/io.h +++ b/arch/arm/include/asm/io.h @@ -56,8 +56,19 @@ void __raw_readsl(const volatile void __ * the bus. Rather than special-case the machine, just let the compiler * generate the access for CPUs prior to ARMv6. */ -#define __raw_readw(a) (__chk_io_ptr(a), *(volatile unsigned short __force *)(a)) -#define __raw_writew(v,a) ((void)(__chk_io_ptr(a), *(volatile unsigned short __force *)(a) = (v))) +#define __raw_writew __raw_writew +static __no_kasan_or_inline void __raw_writew(u16 val, volatile void __iomem *addr) +{ + __chk_io_ptr(addr); + *(volatile unsigned short __force *)addr = val; +} + +#define __raw_readw __raw_readw +static __no_kasan_or_inline u16 __raw_readw(const volatile void __iomem *addr) +{ + __chk_io_ptr(addr); + return *(const volatile unsigned short __force *)addr; +} #else /* * When running under a hypervisor, we want to avoid I/O accesses with