• Paul E. McKenney's avatar
    clocksource: Set cs_watchdog_read() checks based on .uncertainty_margin · 4ac1dd32
    Paul E. McKenney authored
    Right now, cs_watchdog_read() does clocksource sanity checks based
    on WATCHDOG_MAX_SKEW, which sets a floor on any clocksource's
    .uncertainty_margin.  These sanity checks can therefore act
    inappropriately for clocksources with large uncertainty margins.
    
    One reason for a clocksource to have a large .uncertainty_margin is when
    that clocksource has long read-out latency, given that it does not make
    sense for the .uncertainty_margin to be smaller than the read-out latency.
    With the current checks, cs_watchdog_read() could reject all normal
    reads from a clocksource with long read-out latencies, such as those
    from legacy clocksources that are no longer implemented in hardware.
    
    Therefore, recast the cs_watchdog_read() checks in terms of the
    .uncertainty_margin values of the clocksources involved in the timespan in
    question.  The first covers two watchdog reads and one cs read, so use
    twice the watchdog .uncertainty_margin plus that of the cs.  The second
    covers only a pair of watchdog reads, so use twice the watchdog
    .uncertainty_margin.
    Reported-by: default avatarBorislav Petkov <bp@alien8.de>
    Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
    Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
    Link: https://lore.kernel.org/all/20240802154618.4149953-4-paulmck@kernel.org
    4ac1dd32
clocksource.c 44.1 KB