From nobody Sun Dec 14 17:58:40 2025 Received: from mail-24418.protonmail.ch (mail-24418.protonmail.ch [109.224.244.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 5313B1B85F8 for ; Wed, 10 Dec 2025 17:30:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=109.224.244.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765387809; cv=none; b=MD+Hw3NJIC+3NMzxDPptUIYQ7bzA2LhoY29xYNazwEcZg0k84aSRnxqsU0xd5X1a4SED3MvknmY9RIlPBRMokwDBUca+1gXPzBIiUW3uyMgS9pknX6eGAtc9iks7yQXGX62Vp0LDBwPRJY264wfrBFhVAfu/BXVyU9JVSObcP98= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765387809; c=relaxed/simple; bh=mdgk9M23toUSSdVjaABscn4nritKLnqb4cFgULxtoho=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Vnf5Qi7gHCRKfKMHj8W2ILzkeSZCEdCNpIcvMCMzifgUIlB/p1zwIU02Un37HbCSrG8r6mkWtFbW5pp55Ofo8PA0Y1X39KU1O0eNPOS9bAwhb+HdhSYiJ7YJrQyYrRJoEg9YeDhBoF1GpC7r9AnUlOdmxPntLymWurkIYFWU07g= 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=D++RtEx8; arc=none smtp.client-ip=109.224.244.18 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="D++RtEx8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail3; t=1765387800; x=1765647000; bh=aRRLcM1Q5eZzMoX1A6R6c/uTaz4KswX3LOgQlrenxtQ=; 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=D++RtEx8YI6ICA3eBD3PJbYjhNIvQlw/kkgxz/laOTL+VV7i8fByW6XqzDHZA7gyH 6Sw3FLW5SsMjfct+msBgJYZ3FxpHiqxK7lI1nH2FuZUbS895S3vJDOG+UiZEgMDUEQ gcN3+noLDoGNj3Brdb3V2ix2SQZi57eaq9yysXdDwJ7CWPE0SyA9PMiQPkK2BrHqiM /aylWbuuRIdU8v7ordUvXAovxGZ6PuYzjuIN8AB89LmJM7EkK0ONyP4jDEpensgMAa CIUpfsBlaqVKvUXZAMIkTkQUbNJF+AQGlpKwwfSkeeSL7VjcTUbVlvoPFn+MaWtVu1 KIhgPIwTJ70cA== Date: Wed, 10 Dec 2025 17:29:57 +0000 To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" From: Maciej Wieczor-Retman Cc: m.wieczorretman@pm.me, Maciej Wieczor-Retman , Andrey Konovalov , linux-kernel@vger.kernel.org Subject: [PATCH v7 11/15] x86: Minimal SLAB alignment Message-ID: <740bd4f4dbf4ce17e4bbbd3f3624bea2d24d72d3.1765386422.git.m.wieczorretman@pm.me> In-Reply-To: References: Feedback-ID: 164464600:user:proton X-Pm-Message-ID: 563efb56bca302dfdf8fb3c0c4c2289211e8d00c 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 8 byte minimal SLAB alignment interferes with KASAN's granularity of 16 bytes. It causes a lot of out-of-bounds errors for unaligned 8 byte allocations. Compared to a kernel with KASAN disabled, the memory footprint increases because all kmalloc-8 allocations now are realized as kmalloc-16, which has twice the object size. But more meaningfully, when compared to a kernel with generic KASAN enabled, there is no difference. Because of redzones in generic KASAN, kmalloc-8' and kmalloc-16' object size is the same (48 bytes). So changing the minimal SLAB alignment of the tag-based mode doesn't have any negative impact when compared to the other software KASAN mode. Adjust x86 minimal SLAB alignment to match KASAN granularity size. Signed-off-by: Maciej Wieczor-Retman Reviewed-by: Andrey Konovalov --- Changelog v6: - Add Andrey's Reviewed-by tag. Changelog v4: - Extend the patch message with some more context and impact information. Changelog v3: - Fix typo in patch message 4 -> 16. - Change define location to arch/x86/include/asm/cache.c. arch/x86/include/asm/cache.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h index 69404eae9983..3232583b5487 100644 --- a/arch/x86/include/asm/cache.h +++ b/arch/x86/include/asm/cache.h @@ -21,4 +21,8 @@ #endif #endif =20 +#ifdef CONFIG_KASAN_SW_TAGS +#define ARCH_SLAB_MINALIGN (1ULL << KASAN_SHADOW_SCALE_SHIFT) +#endif + #endif /* _ASM_X86_CACHE_H */ --=20 2.52.0