Skip to content

Commit 6b8d5dd

Browse files
committed
x86/tsc: Do feature check as the very first thing
Do the feature check as the very first thing in the function. Everything else comes after that and is meaningless work if the TSC CPUID bit is not even set. Switch to cpu_feature_enabled() too, while at it. No functional changes. Signed-off-by: Borislav Petkov (AMD) <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 8fe6d84 commit 6b8d5dd

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

arch/x86/kernel/tsc.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,18 +1509,18 @@ void __init tsc_early_init(void)
15091509

15101510
void __init tsc_init(void)
15111511
{
1512+
if (!cpu_feature_enabled(X86_FEATURE_TSC)) {
1513+
setup_clear_cpu_cap(X86_FEATURE_TSC_DEADLINE_TIMER);
1514+
return;
1515+
}
1516+
15121517
/*
15131518
* native_calibrate_cpu_early can only calibrate using methods that are
15141519
* available early in boot.
15151520
*/
15161521
if (x86_platform.calibrate_cpu == native_calibrate_cpu_early)
15171522
x86_platform.calibrate_cpu = native_calibrate_cpu;
15181523

1519-
if (!boot_cpu_has(X86_FEATURE_TSC)) {
1520-
setup_clear_cpu_cap(X86_FEATURE_TSC_DEADLINE_TIMER);
1521-
return;
1522-
}
1523-
15241524
if (!tsc_khz) {
15251525
/* We failed to determine frequencies earlier, try again */
15261526
if (!determine_cpu_tsc_frequencies(false)) {

0 commit comments

Comments
 (0)