x86/rtc: Remove __init for runtime functions
PATCH RESEND v4 1/1 x86/rtc: Remove __init for runtime functions
set_rtc_noop, get_rtc_noop are used runtime, therefore need init removed. Crash was observed on x86 platform where cmos rtc is unused and disabled via device tree. Function was triggered from ntp: sync_hw_clock, although CONFIG_RTC_SYSTOHC=n, however sync_cmos_clock doesn't honour that.
Workqueue: events_power_efficient sync_hw_clock RIP: 0010:set_rtc_noop Call Trace: update_persistent_clock64 sync_hw_clock
Fix by dropping __init and making set/get_rtc_noop available runtime.
---
v4: Update commit subject and message, resend to proper addresses
v3: Update commit message based on Andy's comments (further trim to backtrace, proper tag)
v2: Update commit message based on Andy's comments
arch/x86/kernel/x86_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/x86_init.c +2 -2
@@ -33,8 +33,8 @@ static int __init iommu_init_noop(void) { return 0; }static void iommu_shutdown_noop (void ) { }bool __init bool_x86_init_noop (void ) {return false; }void x86_op_int_noop (int cpu) { } -static __init int set_rtc_noop (const struct timespec64 *now) {return -EINVAL ; } -static __init void get_rtc_noop (struct timespec64 *now) { } +static int set_rtc_noop (const struct timespec64 *now) {return -EINVAL ; } +static void get_rtc_noop (struct timespec64 *now) { }static __initconst const struct of_device_id of_cmos_match[] = { { .compatible ="motorola,mc146818" },
Signature · 1 line
2.30.2
The following commit has been merged into the x86/urgent branch of tip:
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: 775d3c514c5b2763a50ab7839026d7561795924d Gitweb: https://git.kernel.org/tip/775d3c514c5b2763a50ab7839026d7561795924d Author: Matija Glavinic Pecotic <[email protected]> AuthorDate: Thu, 06 Apr 2023 08:26:52 +02:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 13 Apr 2023 14:41:04 +02:00
x86/rtc: Remove __init for runtime functions
set_rtc_noop(), get_rtc_noop() are after booting, therefore their __init annotation is wrong.
A crash was observed on an x86 platform where CMOS RTC is unused and disabled via device tree. set_rtc_noop() was invoked from ntp:sync_hw_clock(), although CONFIG_RTC_SYSTOHC=n, however sync_cmos_clock() doesn't honour that.
Workqueue: events_power_efficient sync_hw_clock RIP: 0010:set_rtc_noop Call Trace: update_persistent_clock64 sync_hw_clock
Fix this by dropping the __init annotation from set/get_rtc_noop().
--- arch/x86/kernel/x86_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/x86_init.c +2 -2
@@ -33,8 +33,8 @@ static int __init iommu_init_noop(void) { return 0; }static void iommu_shutdown_noop (void ) { }bool __init bool_x86_init_noop (void ) {return false; }void x86_op_int_noop (int cpu) { } -static __init int set_rtc_noop (const struct timespec64 *now) {return -EINVAL ; } -static __init void get_rtc_noop (struct timespec64 *now) { } +static int set_rtc_noop (const struct timespec64 *now) {return -EINVAL ; } +static void get_rtc_noop (struct timespec64 *now) { }static __initconst const struct of_device_id of_cmos_match[] = { { .compatible ="motorola,mc146818" },