From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Richard OGrady <Rich_Ogrady@grayhill.com>
Cc: "a.zummo@towertech.it" <a.zummo@towertech.it>,
"linux-rtc@vger.kernel.org" <linux-rtc@vger.kernel.org>
Subject: Re: Y2038 related bug in rtc subsystem for 32 bit processors
Date: Wed, 23 Nov 2022 00:14:30 +0100 [thread overview]
Message-ID: <Y31X1qOZBkUHfYE6@mail.local> (raw)
In-Reply-To: <BYAPR14MB307829F7F749AAD17473C10BF00D9@BYAPR14MB3078.namprd14.prod.outlook.com>
On 22/11/2022 22:27:39+0000, Richard OGrady wrote:
> While testing Y2038 compatibility on a 32 bit arm processor I came across this potential bug? in drivers/rtc/class.c (line 76 in v6.0.9)
>
>
> tv64<https://elixir.bootlin.com/linux/latest/C/ident/tv64>.tv_sec<https://elixir.bootlin.com/linux/latest/C/ident/tv_sec> = rtc_tm_to_time64<https://elixir.bootlin.com/linux/latest/C/ident/rtc_tm_to_time64>(&tm<https://elixir.bootlin.com/linux/latest/C/ident/tm>);
>
>
>
> #if BITS_PER_LONG<https://elixir.bootlin.com/linux/latest/C/ident/BITS_PER_LONG> == 32
>
> if (tv64<https://elixir.bootlin.com/linux/latest/C/ident/tv64>.tv_sec<https://elixir.bootlin.com/linux/latest/C/ident/tv_sec> > INT_MAX<https://elixir.bootlin.com/linux/latest/C/ident/INT_MAX>) {
>
> err = -ERANGE<https://elixir.bootlin.com/linux/latest/C/ident/ERANGE>;
>
> goto err_read;
>
> }
>
> #endif
>
>
>
> err = do_settimeofday64<https://elixir.bootlin.com/linux/latest/C/ident/do_settimeofday64>(&tv64<https://elixir.bootlin.com/linux/latest/C/ident/tv64>);
>
>
> The #if/#endif block above causes the driver to not sync the system clock with the reading from the hwclock once the rtc reading reflects the Y2038 date and later. I certainly could be wrong but it would seem that the block is over-protective and unnecessary. We commented the block out and the system syncs fine with the rtc when the rtc is set to the year 2039.
>
You are right and this is a workaround for an issue in systemd.
Honestly, the solution is to stop relying on rtc_hctosys and set the
system time from userspace.
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
parent reply other threads:[~2022-11-22 23:14 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <BYAPR14MB307829F7F749AAD17473C10BF00D9@BYAPR14MB3078.namprd14.prod.outlook.com>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y31X1qOZBkUHfYE6@mail.local \
--to=alexandre.belloni@bootlin.com \
--cc=Rich_Ogrady@grayhill.com \
--cc=a.zummo@towertech.it \
--cc=linux-rtc@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).