From nobody Sun Dec 14 17:58:00 2025 Received: from mail-24416.protonmail.ch (mail-24416.protonmail.ch [109.224.244.16]) (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 6F239261B62; Wed, 29 Oct 2025 19:07:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=109.224.244.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761764822; cv=none; b=HU+zVocHyBe0suTEsBjA3AX227xC27aiXXzy+dHVOjW5lfcRFjOOhhAlYJ2havpXhj3SKAC0JMl02uDM5XRDrAeYvYhhGF33Vuxaxy+bvDzoRLjgwB7w+du5Xevw90t7luTVKizIgTLzrzIaOG84tfe6gF8btMqWRfQn0SaLjdY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761764822; c=relaxed/simple; bh=mlxnBtQuW4/i3OKXh4jLeblYDHucd5W1OUn5HztEK4M=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MMzgpI112KCevo8BIDLWo1JSCyknjcmrmByKbQYrfShev97vYXf/MPjOIBR2ztbWURuxqqSTEf7J/uSgsu4vhPsL9pheaQFNFVbbJpmsmj/LQmrA4WNzvlHkNR8isBsHo1oJgw4rVxZnww50KgM+exdc4jG8ChRDv3dec1EkV7s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pm.me; spf=pass smtp.mailfrom=pm.me; dkim=pass (2048-bit key) header.d=pm.me header.i=@pm.me header.b=iIyqHUmB; arc=none smtp.client-ip=109.224.244.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pm.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pm.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pm.me header.i=@pm.me header.b="iIyqHUmB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail3; t=1761764817; x=1762024017; bh=UuVBFIvAqVGiw6UOZ0Oq2LH/B7F2B7f/ik0cOvmOtjs=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=iIyqHUmBQXJaUQMu+N0NZRSCH0kBx2A+c75BMIdYkjFaKskam7OT5Wjd61R/gx1Xx Xz0BfxOeql9L47SHvCAkTWD8CiJ+CjosWQrVJYXj5LffB0359mhzcZDTk3guLEc1CS P0af2k465IeYSTRHH9BfuN5/rtI1csCf0L/rvSxUQ5Cyw8uCyP7Mzz+OLabhBWwsGl FCjPJ3WdW+JAXcyt3iYl4ylBSBFjo6RMPXpCvPqMBk6x7qS2DVGrYDrO89F2AEEiVk 28Kvfp7z51eeM83L/GI9KF+c19L/vN8JB6k/tf/liftNpp/hj1PWfhGBSR5c0xS25r LMiCrEx6G6R2g== Date: Wed, 29 Oct 2025 19:06:49 +0000 To: xin@zytor.com, peterz@infradead.org, kaleshsingh@google.com, kbingham@kernel.org, akpm@linux-foundation.org, nathan@kernel.org, ryabinin.a.a@gmail.com, dave.hansen@linux.intel.com, bp@alien8.de, morbo@google.com, jeremy.linton@arm.com, smostafa@google.com, kees@kernel.org, baohua@kernel.org, vbabka@suse.cz, justinstitt@google.com, wangkefeng.wang@huawei.com, leitao@debian.org, jan.kiszka@siemens.com, fujita.tomonori@gmail.com, hpa@zytor.com, urezki@gmail.com, ubizjak@gmail.com, ada.coupriediaz@arm.com, nick.desaulniers+lkml@gmail.com, ojeda@kernel.org, brgerst@gmail.com, elver@google.com, pankaj.gupta@amd.com, glider@google.com, mark.rutland@arm.com, trintaeoitogc@gmail.com, jpoimboe@kernel.org, thuth@redhat.com, pasha.tatashin@soleen.com, dvyukov@google.com, jhubbard@nvidia.com, catalin.marinas@arm.com, yeoreum.yun@arm.com, mhocko@suse.com, lorenzo.stoakes@oracle.com, samuel.holland@sifive.com, vincenzo.frascino@arm.com, bigeasy@linutronix.de, surenb@google.com, ardb@kernel.org, Liam.Howlett@oracle.com, nicolas.schier@linux.dev, ziy@nvidia.com, kas@kernel.org, tglx@linutronix.de, mingo@redhat.com, broonie@kernel.org, corbet@lwn.net, andreyknvl@gmail.com, maciej.wieczor-retman@intel.com, david@redhat.com, maz@kernel.org, rppt@kernel.org, will@kernel.org, luto@kernel.org From: Maciej Wieczor-Retman Cc: kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org, linux-kbuild@vger.kernel.org, linux-mm@kvack.org, llvm@lists.linux.dev, linux-doc@vger.kernel.org, m.wieczorretman@pm.me Subject: [PATCH v6 05/18] kasan: Fix inline mode for x86 tag-based mode Message-ID: <8681ee6683b1c65a1d5d65f21c66e63378806ba0.1761763681.git.m.wieczorretman@pm.me> In-Reply-To: References: Feedback-ID: 164464600:user:proton X-Pm-Message-ID: 57ed454739a234eef863007c4125f42148d9fdbb Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Maciej Wieczor-Retman The LLVM compiler uses hwasan-instrument-with-calls parameter to setup inline or outline mode in tag-based KASAN. If zeroed, it means the instrumentation implementation will be pasted into each relevant location along with KASAN related constants during compilation. If set to one all function instrumentation will be done with function calls instead. The default hwasan-instrument-with-calls value for the x86 architecture in the compiler is "1", which is not true for other architectures. Because of this, enabling inline mode in software tag-based KASAN doesn't work on x86 as the kernel script doesn't zero out the parameter and always sets up the outline mode. Explicitly zero out hwasan-instrument-with-calls when enabling inline mode in tag-based KASAN. Signed-off-by: Maciej Wieczor-Retman Reviewed-by: Andrey Konovalov Reviewed-by: Alexander Potapenko --- Changelog v6: - Add Andrey's Reviewed-by tag. Changelog v3: - Add this patch to the series. scripts/Makefile.kasan | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/Makefile.kasan b/scripts/Makefile.kasan index 0ba2aac3b8dc..e485814df3e9 100644 --- a/scripts/Makefile.kasan +++ b/scripts/Makefile.kasan @@ -76,8 +76,11 @@ CFLAGS_KASAN :=3D -fsanitize=3Dkernel-hwaddress RUSTFLAGS_KASAN :=3D -Zsanitizer=3Dkernel-hwaddress \ -Zsanitizer-recover=3Dkernel-hwaddress =20 +# LLVM sets hwasan-instrument-with-calls to 1 on x86 by default. Set it to= 0 +# when inline mode is enabled. ifdef CONFIG_KASAN_INLINE kasan_params +=3D hwasan-mapping-offset=3D$(KASAN_SHADOW_OFFSET) + kasan_params +=3D hwasan-instrument-with-calls=3D0 else kasan_params +=3D hwasan-instrument-with-calls=3D1 endif --=20 2.51.0