lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sun, 14 Aug 2022 11:25:14 +0200
From:   Ingo Molnar <mingo@...nel.org>
To:     Mateusz Jończyk <mat.jonczyk@...pl>
Cc:     linux-kernel@...r.kernel.org, linux-rtc@...r.kernel.org,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
        "H. Peter Anvin" <hpa@...or.com>,
        Alessandro Zummo <a.zummo@...ertech.it>,
        Alexandre Belloni <alexandre.belloni@...tlin.com>
Subject: Re: [PATCH v4 1/2] x86/rtc: rewrite mach_get_cmos_time to delete
 duplicated code


* Mateusz Jończyk <mat.jonczyk@...pl> wrote:

> There are functions in drivers/rtc/rtc-mc146818-lib.c that handle
> reading from / writing to the CMOS RTC clock. mach_get_cmos_time() in
> arch/x86/kernel/rtc.c did not use them and was mostly a duplicate of
> mc146818_get_time(). Modify mach_get_cmos_time() to use
> mc146818_get_time() and remove the duplicated code.
> 
> mach_get_cmos_time() used a different algorithm than
> mc146818_get_time(), but these functions are equivalent. The major
> differences are:
> 
> - mc146818_get_time() is better refined and handles various edge
>   conditions,
> 
> - when the UIP ("Update in progress") bit of the RTC is set,
>   mach_get_cmos_time() was busy waiting with cpu_relax() while
>   mc146818_get_time() is using mdelay(1) in every loop iteration.
>   (However, there is my commit merged for Linux 5.20 / 6.0 to decrease
>   this period to 100us:
> commit d2a632a8a117 ("rtc: mc146818-lib: reduce RTC_UIP polling period")
>   ),
> 
> - mach_get_cmos_time() assumed that the RTC year is >= 2000, which
>   may not be true on some old boxes with a dead battery,
> 
> - mach_get_cmos_time() was holding the rtc_lock for a long time
>   and could hang if the RTC is broken or not present.
> 
> The RTC writing counterpart, mach_set_rtc_mmss() is already using
> mc146818_get_time() from drivers/rtc. This was done in
>         commit 3195ef59cb42 ("x86: Do full rtc synchronization with ntp")
> It appears that mach_get_cmos_time() was simply forgotten.
> 
> mach_get_cmos_time() is really used only in read_persistent_clock64(),
> which is called only in a few places in kernel/time/timekeeping.c .

LGTM, I've added the following background to the commit description:

   These changes are not supposed to change behavior, but they are not 
   identity transformations either, as mc146818_get_time() is a better but 
   different implementation of the same logic - so regressions are possible 
   in principle.

Queued up both patches in tip:x86/timers and will push it out after 
testing.

Thanks!

	Ingo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ