x86/Kconfig: Fix allyesconfig
Subsystems (3)
PATCH v2 1/1 x86/Kconfig: Fix allyesconfig
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.
---
v2: Disable KASAN unconditionally for test builds
lib/Kconfig.kasan | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/Kconfig.kasan +1 -1
@@ -37,7 +37,7 @@ menuconfig KASAN (HAVE_ARCH_KASAN_SW_TAGS && CC_HAS_KASAN_SW_TAGS)) && \ CC_HAS_WORKING_NOSANITIZE_ADDRESS) || \ HAVE_ARCH_KASAN_HW_TAGS - depends on SYSFS && !SLUB_TINY + depends on SYSFS && !SLUB_TINY && !COMPILE_TEST select STACKDEPOT_ALWAYS_INIT help Enables KASAN (Kernel Address Sanitizer) - a dynamic memory safety
Signature · 1 line
2.45.2
Andrew Morton
maintainerQuoted 11 lines · On Wed, 16 Apr 2025 16:05:59 -0700 Guenter Roeck <[email protected]> wrote:
64-bit allyesconfig builds fail with
x86_64-linux-ld: kernel image bigger than
KERNEL_IMAGE_SIZEBisect points to commit
6f110a5e4f99("DisableSLUB_TINYfor build testing") as the responsible commit. Reverting that patch does indeed fix the problem. Further analysis shows that disablingSLUB_TINYenables 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?
Quoted 14 lines · Andrew Morton
Quoted 11 lines · On Wed, 16 Apr 2025 16:05:59 -0700 Guenter Roeck <[email protected]> wrote:
64-bit allyesconfig builds fail with
x86_64-linux-ld: kernel image bigger than
KERNEL_IMAGE_SIZEBisect points to commit
6f110a5e4f99("DisableSLUB_TINYfor build testing") as the responsible commit. Reverting that patch does indeed fix the problem. Further analysis shows that disablingSLUB_TINYenables KASAN, and that KASAN is responsible for the image size increase.Solve the build problem by disabling KASAN for test builds.
Quoted 6 lines
Excluding KASAN from
COMPILE_TESTbuilds is regrettable.Can we address this some other way? One way might be to alter or disable the
KERNEL_IMAGE_SIZEcheck ifCOMPILE_TEST? That will be sad for anyone who tries to boot aCOMPILE_TESTkernel, but who the heck does that?
I tried increasing the limit. It didn't work. With the RFC I sent earlier I made it dependent on allmodconfig, but Linus said I should just disable it for test builds (which was the cases anyway until commit 6f110a5e4f99).
Personally I don't have a preference either way. I can also do nothing and stop testing allyesconfig. That would help reducing the load on my testbed, so I would be all for it.
Guenter
Quoted 14 lines · Andrew Morton
Quoted 11 lines · On Wed, 16 Apr 2025 16:05:59 -0700 Guenter Roeck <[email protected]> wrote:
64-bit allyesconfig builds fail with
x86_64-linux-ld: kernel image bigger than
KERNEL_IMAGE_SIZEBisect points to commit
6f110a5e4f99("DisableSLUB_TINYfor build testing") as the responsible commit. Reverting that patch does indeed fix the problem. Further analysis shows that disablingSLUB_TINYenables KASAN, and that KASAN is responsible for the image size increase.Solve the build problem by disabling KASAN for test builds.
Quoted 6 lines
Excluding KASAN from
COMPILE_TESTbuilds is regrettable.Can we address this some other way? One way might be to alter or disable the
KERNEL_IMAGE_SIZEcheck ifCOMPILE_TEST? That will be sad for anyone who tries to boot aCOMPILE_TESTkernel, but who the heck does that?
As mentioned before, increasing KERNEL_IMAGE_SIZE did not help. However, it turns out that this works:
arch/x86/kernel/vmlinux.lds.S +2 -0
@@ -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
Andrew Morton
maintainerQuoted 22 lines · On Wed, 16 Apr 2025 17:17:00 -0700 Guenter Roeck <[email protected]> wrote:
Quoted 14 lines · Andrew Morton
Quoted 11 lines · On Wed, 16 Apr 2025 16:05:59 -0700 Guenter Roeck <[email protected]> wrote:
64-bit allyesconfig builds fail with
x86_64-linux-ld: kernel image bigger than
KERNEL_IMAGE_SIZEBisect points to commit
6f110a5e4f99("DisableSLUB_TINYfor build testing") as the responsible commit. Reverting that patch does indeed fix the problem. Further analysis shows that disablingSLUB_TINYenables KASAN, and that KASAN is responsible for the image size increase.Solve the build problem by disabling KASAN for test builds.
Quoted 6 lines
Excluding KASAN from
COMPILE_TESTbuilds is regrettable.Can we address this some other way? One way might be to alter or disable the
KERNEL_IMAGE_SIZEcheck ifCOMPILE_TEST? That will be sad for anyone who tries to boot aCOMPILE_TESTkernel, but who the heck does that?
Quoted 7 lines
I tried increasing the limit. It didn't work. With the RFC I sent earlier I made it dependent on allmodconfig, but Linus said I should just disable it for test builds (which was the cases anyway until commit
6f110a5e4f99).Personally I don't have a preference either way. I can also do nothing and stop testing allyesconfig. That would help reducing the load on my testbed, so I would be all for it.
How about this?
arch/x86/kernel/vmlinux.lds.S renamed from arch/x86/kernel/vmlinux.lds.S~a +10 -1
@@ -466,10 +466,19 @@ SECTIONS } /* - * The ASSERT() sink to . is intentional, for binutils 2.14 compatibility: + * COMPILE_TEST kernels can be large - CONFIG_KASAN, for example, can cause + * this. Let's assume that nobody will be running a COMPILE_TEST kernel and + * let's assert that fuller build coverage is more valuable than being able to + * run a COMPILE_TEST kernel. + */ +#ifndef CONFIG_COMPILE_TEST +/* +/* + * The ASSERT() sync to . is intentional, for binutils 2.14 compatibility: */ . = ASSERT((_end - LOAD_OFFSET <= KERNEL_IMAGE_SIZE), "kernel image bigger than KERNEL_IMAGE_SIZE"); +#endif /* needed for Clang - see arch/x86/entry/entry.S */ PROVIDE(__ref_stack_chk_guard = __stack_chk_guard);
_
(contains gratuitous s/sink/sync/)
I'd like to add
#else
WARN((_end - LOAD_OFFSET <= KERNEL_IMAGE_SIZE),
"kernel image bigger than KERNEL_IMAGE_SIZE - kernel probably will not work");
#endif /* CONFIG_COMPILE_TEST */
but I lack the patience to figure out how to do that.
Quoted 47 lines · Andrew Morton
Quoted 22 lines · On Wed, 16 Apr 2025 17:17:00 -0700 Guenter Roeck <[email protected]> wrote:
Quoted 14 lines · Andrew Morton
Quoted 11 lines · On Wed, 16 Apr 2025 16:05:59 -0700 Guenter Roeck <[email protected]> wrote:
64-bit allyesconfig builds fail with
x86_64-linux-ld: kernel image bigger than
KERNEL_IMAGE_SIZEBisect points to commit
6f110a5e4f99("DisableSLUB_TINYfor build testing") as the responsible commit. Reverting that patch does indeed fix the problem. Further analysis shows that disablingSLUB_TINYenables KASAN, and that KASAN is responsible for the image size increase.Solve the build problem by disabling KASAN for test builds.
Quoted 6 lines
Excluding KASAN from
COMPILE_TESTbuilds is regrettable.Can we address this some other way? One way might be to alter or disable the
KERNEL_IMAGE_SIZEcheck ifCOMPILE_TEST? That will be sad for anyone who tries to boot aCOMPILE_TESTkernel, but who the heck does that?Quoted 7 lines
I tried increasing the limit. It didn't work. With the RFC I sent earlier I made it dependent on allmodconfig, but Linus said I should just disable it for test builds (which was the cases anyway until commit
6f110a5e4f99).Personally I don't have a preference either way. I can also do nothing and stop testing allyesconfig. That would help reducing the load on my testbed, so I would be all for it.
How about this?
arch/x86/kernel/vmlinux.lds.S renamed from arch/x86/kernel/vmlinux.lds.S~a +4
-1@@ -466,10 +466,19 @@ SECTIONS } /* - * The ASSERT() sink to . is intentional, for binutils 2.14 compatibility: + * COMPILE_TEST kernels can be large - CONFIG_KASAN, for example, can cause + * this. Let's assume that nobody will be running a COMPILE_TEST kernel and + * let's assert that fuller build coverage is more valuable than being able to + * run a COMPILE_TEST kernel.
arch/x86/kernel/vmlinux.lds.S SECTIONS · line 482
Quoted 10 lines
arch/x86/kernel/vmlinux.lds.S renamed from arch/x86/kernel/vmlinux.lds.S~a +6
-0+ */ +#ifndef CONFIG_COMPILE_TEST +/* +/* + * The ASSERT() sync to . is intentional, for binutils 2.14 compatibility: */ . = ASSERT((_end - LOAD_OFFSET <= KERNEL_IMAGE_SIZE), "kernel image bigger than KERNEL_IMAGE_SIZE"); +#endif
Yes, that is what I ended up doing with v3 (thanks for the idea), lacking the comment. Guess I'll need to send v4, but I'll wait a bit to see if there is feedback from others.
Quoted 8 lines
arch/x86/kernel/vmlinux.lds.S renamed from arch/x86/kernel/vmlinux.lds.S~a +0
-0/* needed for Clang - see arch/x86/entry/entry.S */ PROVIDE(__ref_stack_chk_guard = __stack_chk_guard);_
(contains gratuitous s/sink/sync/)
Quoted 8 lines
I'd like to add
#else
WARN((_end -LOAD_OFFSET<=KERNEL_IMAGE_SIZE),
"kernel image bigger thanKERNEL_IMAGE_SIZE- kernel probably will not work");
#endif /*CONFIG_COMPILE_TEST*/but I lack the patience to figure out how to do that.
WARN is a define which declares C code. That doesn't work in linker scripts. I only got #ifdef to work. I did not find a linker script command which would be equivalent to WARN(). Maybe someone else knows if it is possible and how to do it.
Guenter