Re: [PATCH 0/2] rtc: Prevent hctosys from using invalid RTC time
From: Alexandre Belloni
Date: Wed Oct 21 2026 - 03:14:07 EST
Hello,
On 21/10/2026 09:54:33+0530, Akashdeep Kaur wrote:
> The kernel's boot-time RTC synchronization blindly trusts the RTC
> value when setting system time, but RTCs may have invalid time
> depending on the boot path:
>
> - On first cold boot: RTC may have lost power, time is invalid
> - After low-power mode (RTC-only) cold boot: RTC retained power, time
> is valid
>
> On normal cold boot where bootloader or NTP has already established
> correct time, boot-time sync (triggered when RTC driver loads as
> module or probes at boot) can overwrite it with invalid RTC data,
> causing time rollback to 1970. However, on boot from RTC-only power
> mode, the RTC has valid time and boot-time sync should work to
> restore system time from RTC.
>
> This series adds a flag that drivers set dynamically per-boot to
> indicate whether RTC has valid time. Drivers check at probe if RTC
> retained power through this specific boot. Boot-time sync checks this
> flag before setting system time. This enables correct behavior for
> both boot paths while keeping PM suspend/resume compensation
> unaffected.
The proper way to do this is to return -EINVAL in read_time until you
know the date is correct. There is no need for an extra flag for the core.
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com