Re: [PATCH v2] x86/Kconfig: Fix allyesconfig

From: Guenter Roeck
Date: Wed Apr 16 2025 - 20:42:23 EST


On 4/16/25 17:03, Andrew Morton wrote:
On Wed, 16 Apr 2025 16:05:59 -0700 Guenter Roeck <linux@xxxxxxxxxxxx> wrote:

64-bit allyesconfig builds fail with

x86_64-linux-ld: kernel image bigger than KERNEL_IMAGE_SIZE

Bisect points to commit 6f110a5e4f99 ("Disable SLUB_TINY for build
testing") as the responsible commit. Reverting that patch does indeed
fix the problem. Further analysis shows that disabling SLUB_TINY enables
KASAN, and that KASAN is responsible for the image size increase.

Solve the build problem by disabling KASAN for test builds.


Excluding KASAN from COMPILE_TEST builds is regrettable.

Can we address this some other way? One way might be to alter or
disable the KERNEL_IMAGE_SIZE check if COMPILE_TEST? That will be sad
for anyone who tries to boot a COMPILE_TEST kernel, but who the heck
does that?

As mentioned before, increasing KERNEL_IMAGE_SIZE did not help.
However, it turns out that this works:

diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
index ccdc45e5b759..647d4f47486d 100644
--- a/arch/x86/kernel/vmlinux.lds.S
+++ b/arch/x86/kernel/vmlinux.lds.S
@@ -468,8 +468,10 @@ SECTIONS
/*
* The ASSERT() sink to . is intentional, for binutils 2.14 compatibility:
*/
+#ifndef CONFIG_COMPILE_TEST
. = ASSERT((_end - LOAD_OFFSET <= KERNEL_IMAGE_SIZE),
"kernel image bigger than KERNEL_IMAGE_SIZE");
+#endif

I'll send v3.

Guenter