Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

x86/tsc: Handle CLOCK_SOURCE_VALID_FOR_HRES correctly

Unconditionally setting the CLOCK_SOURCE_VALID_FOR_HRES for the real TSC
clocksource is wrong as there is no guarantee that the early TSC was
validated for high resolution mode.

Set the flag only when the early TSC was validated as otherwise the
clocksource selection might enable high resolution mode with a TSC of
unknown quality and possibly no way to back out once it is discovered to be
unsuitable.

Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Link: https://patch.msgid.link/20260123231521.790598171@kernel.org

+9 -1
+9 -1
arch/x86/kernel/tsc.c
··· 1200 1200 .read = read_tsc, 1201 1201 .mask = CLOCKSOURCE_MASK(64), 1202 1202 .flags = CLOCK_SOURCE_IS_CONTINUOUS | 1203 - CLOCK_SOURCE_VALID_FOR_HRES | 1204 1203 CLOCK_SOURCE_CAN_INLINE_READ | 1205 1204 CLOCK_SOURCE_MUST_VERIFY | 1206 1205 CLOCK_SOURCE_VERIFY_PERCPU | ··· 1410 1411 have_art = true; 1411 1412 clocksource_tsc.base = &art_base_clk; 1412 1413 } 1414 + 1415 + /* 1416 + * Transfer the valid for high resolution flag if it was set on the 1417 + * early TSC already. That guarantees that there is no intermediate 1418 + * clocksource selected once the early TSC is unregistered. 1419 + */ 1420 + if (clocksource_tsc_early.flags & CLOCK_SOURCE_VALID_FOR_HRES) 1421 + clocksource_tsc.flags |= CLOCK_SOURCE_VALID_FOR_HRES; 1422 + 1413 1423 clocksource_register_khz(&clocksource_tsc, tsc_khz); 1414 1424 unreg: 1415 1425 clocksource_unregister(&clocksource_tsc_early);