[PATCH] x86/apic: Mark lapic_cal_handler() __noipa to avoid GCC 16 section mismatch

Jan Brzezanski posted 1 patch 5 hours ago
arch/x86/kernel/apic/apic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] x86/apic: Mark lapic_cal_handler() __noipa to avoid GCC 16 section mismatch
Posted by Jan Brzezanski 5 hours ago
During APIC timer calibration lapic_cal_handler() is temporarily installed
as global_clock_event->event_handler and called from the timer interrupt
path. GCC 16's more aggressive interprocedural analysis specializes that
indirect call into a direct reference from the non-__init interrupt handler
to the __init lapic_cal_handler(), which modpost rejects:

  WARNING: modpost: vmlinux: section mismatch in reference:
    __sysvec_apic_timer_interrupt+0x59 (section: .text) ->
    lapic_cal_handler (section: .init.text)
  ERROR: modpost: Section mismatches detected.

The reference only exists during the __init calibration window, so it is
harmless at runtime, but the direct .text -> .init.text reference GCC 16
synthesises is not allowed. Mark lapic_cal_handler() __noipa so the
compiler keeps it as its own init-section function instead of cloning it
into the interrupt path, while preserving the correct __init annotation.

This is the same approach used for the equivalent GCC 16 section mismatches
in commit 4c9ad387aa2d ("iommu, debugobjects: avoid gcc-16.1 section
mismatch warnings").

Signed-off-by: Jan Brzezanski <jan.brzezanski@nokia.com>
---
 arch/x86/kernel/apic/apic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index aa1e19979..b2e4cb987 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -660,7 +660,7 @@ static __initdata unsigned long lapic_cal_j1, lapic_cal_j2;
 /*
  * Temporary interrupt handler and polled calibration function.
  */
-static void __init lapic_cal_handler(struct clock_event_device *dev)
+static __noipa void __init lapic_cal_handler(struct clock_event_device *dev)
 {
 	unsigned long long tsc = 0;
 	long tapic = apic_read(APIC_TMCCT);

base-commit: 48a5a7ab8d6ab7090564339e039c421f315de912
-- 
2.41.0
Re: [PATCH] x86/apic: Mark lapic_cal_handler() __noipa to avoid GCC 16 section mismatch
Posted by Arnd Bergmann 5 hours ago
On Fri, Jul 24, 2026, at 17:05, Jan Brzezanski wrote:
> During APIC timer calibration lapic_cal_handler() is temporarily installed
> as global_clock_event->event_handler and called from the timer interrupt
> path. GCC 16's more aggressive interprocedural analysis specializes that
> indirect call into a direct reference from the non-__init interrupt handler
> to the __init lapic_cal_handler(), which modpost rejects:
>
>   WARNING: modpost: vmlinux: section mismatch in reference:
>     __sysvec_apic_timer_interrupt+0x59 (section: .text) ->
>     lapic_cal_handler (section: .init.text)
>   ERROR: modpost: Section mismatches detected.
>
> The reference only exists during the __init calibration window, so it is
> harmless at runtime, but the direct .text -> .init.text reference GCC 16
> synthesises is not allowed. Mark lapic_cal_handler() __noipa so the
> compiler keeps it as its own init-section function instead of cloning it
> into the interrupt path, while preserving the correct __init annotation.
>
> This is the same approach used for the equivalent GCC 16 section mismatches
> in commit 4c9ad387aa2d ("iommu, debugobjects: avoid gcc-16.1 section
> mismatch warnings").
>
> Signed-off-by: Jan Brzezanski <jan.brzezanski@nokia.com>

Looks good to me, lets hope we don't get a lot more of
these.

Acked-by: Arnd Bergmann <arnd@arndb.de>