Skip to contentSkip to conversation

x86/tsc: Add kernel options to disable CPUID and MSR calibrations

PATCH In review Prarit Bhargava 3 participants 4 messages Feb 26, 2020 – Feb 27, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/tsc: Add kernel options to disable CPUID and MSR calibrations

I have had to debug a few unstable x86 systems that required me to block the CPUID and MSR calibrations and only use the PIT calibration. After blocking the calibrations I was able to debug and find bugs in firmware that were eventually fixed and resulted in stable systems.

Patrick Geary also posted a similar patch (see link below) that would have allowed him to boot overclocked CPUs by skipping the CPUID calibration which resulted in unstable boots due to timing issues.

Add kernel options to disable the CPUID and MSR calibrations.

Also allow for comma-separated TSC options, for example,

tsc=no_cpuid_calibration,no_msr_calibration,reliable

Cc Jonathan Corbet <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>
Cc Josh Poimboeuf <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Pawan Gupta <[email protected]>
Cc Juergen Gross <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc Viresh Kumar <[email protected]>
Cc Daniel Drake <[email protected]>
Cc Michael Zhivich <[email protected]>
Cc Peter Zijlstra <[email protected]>
---
 .../admin-guide/kernel-parameters.txt         |  8 +++-
 arch/x86/kernel/tsc.c                         | 44 ++++++++++++++-----
 2 files changed, 41 insertions(+), 11 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +7 -1
index dbc22d684627..0316aadfff08 100644
@@ -4942,7 +4942,7 @@
 			See Documentation/admin-guide/mm/transhuge.rst
 			for more details.
 
-	tsc=		Disable clocksource stability checks for TSC.
+	tsc=option[,option...]	Various TSC options.
 			Format: <string>
 			[x86] reliable: mark tsc clocksource as reliable, this
 			disables clocksource verification at runtime, as well
@@ -4960,6 +4960,12 @@
 			in situations with strict latency requirements (where
 			interruptions from clocksource watchdog are not
 			acceptable).
+			[x86] no_cpuid_calibration: Disable the CPUID TSC
+			calibration.  Used in situations where the CPUID
+			TSC khz does not match the actual CPU TSC khz
+			[x86] no_msr_calibration: Disable the MSR TSC
+			calibration.  Used in situations where the MSR
+			TSC khz does not match the actual CPU TSC khz.
 
 	tsx=		[X86] Control Transactional Synchronization
 			Extensions (TSX) feature in Intel processors that
arch/x86/kernel/tsc.c +34 -10

63 lines not on this page · raw message

Signature · 1 line
2.21.1
#1 lore raw
Quoted 14 lines · Prarit Bhargava
Documentation/admin-guide/kernel-parameters.txt +1 -1
index dbc22d684627..0316aadfff08 100644
@@ -4942,7 +4942,7 @@
 			See Documentation/admin-guide/mm/transhuge.rst
 			for more details.
 
-	tsc=		Disable clocksource stability checks for TSC.
+	tsc=option[,option...]	Various TSC options.
 			Format: <string>
 			[x86] reliable: mark tsc clocksource as reliable, this
 			disables clocksource verification at runtime, as well

Documentation/admin-guide/kernel-parameters.txt line 4968

Quoted 9 lines
Documentation/admin-guide/kernel-parameters.txt +6 -0
@@ -4960,6 +4960,12 @@
 			in situations with strict latency requirements (where
 			interruptions from clocksource watchdog are not
 			acceptable).
+			[x86] no_cpuid_calibration: Disable the CPUID TSC
+			calibration.  Used in situations where the CPUID
+			TSC khz does not match the actual CPU TSC khz
+			[x86] no_msr_calibration: Disable the MSR TSC
+			calibration.  Used in situations where the MSR
+			TSC khz does not match the actual CPU TSC khz.

Do we want to mention that these situations are mostly broken firmware? Also do mention that if you disable these you might not boot due to not having a PIT/HPET at all?

As it stands, I find this text a little too encouraging.

Quoted 2 lines
Documentation/admin-guide/kernel-parameters.txt +0 -0
 	tsx=		[X86] Control Transactional Synchronization
 			Extensions (TSX) feature in Intel processors that
#2 lore raw
Quoted 20 lines · Peter Zijlstra
Quoted 19 lines · Prarit Bhargava
Documentation/admin-guide/kernel-parameters.txt +3 -1
index dbc22d684627..0316aadfff08 100644
@@ -4942,7 +4942,7 @@
 			See Documentation/admin-guide/mm/transhuge.rst
 			for more details.
 
-	tsc=		Disable clocksource stability checks for TSC.
+	tsc=option[,option...]	Various TSC options.
 			Format: <string>
 			[x86] reliable: mark tsc clocksource as reliable, this
 			disables clocksource verification at runtime, as well
@@ -4960,6 +4960,12 @@
 			in situations with strict latency requirements (where
 			interruptions from clocksource watchdog are not
 			acceptable).
+			[x86] no_cpuid_calibration: Disable the CPUID TSC
+			calibration.  Used in situations where the CPUID
Quoted 8 lines

Documentation/admin-guide/kernel-parameters.txt line 4968

Quoted 4 lines
Documentation/admin-guide/kernel-parameters.txt +4 -0
+			TSC khz does not match the actual CPU TSC khz
+			[x86] no_msr_calibration: Disable the MSR TSC
+			calibration.  Used in situations where the MSR
+			TSC khz does not match the actual CPU TSC khz.

Do we want to mention that these situations are mostly broken firmware? Also do mention that if you disable these you might not boot due to not having a PIT/HPET at all?

Right. Same discussion as before.

Also why do we want no_cpuid_calibration and no_msr_calibration? How should Joe User figure out which one to use? This does not make sense. The point is that the BIOS/Firmware supplied value in system registers is bogus. So something like "skip_firmware_calibration" might be better suitable.

Aside of that this really wants to be combined with the ability to supply the actual frequency on the command line as I suggested in the other thread to cope with machines which do not expose PIT/HPET or have broken variants of them.

Thanks,

tglx

#3 lore raw
Quoted 32 lines · Thomas Gleixner
Quoted 20 lines · Peter Zijlstra
Quoted 19 lines · Prarit Bhargava
Documentation/admin-guide/kernel-parameters.txt +3 -1
index dbc22d684627..0316aadfff08 100644
@@ -4942,7 +4942,7 @@
 			See Documentation/admin-guide/mm/transhuge.rst
 			for more details.
 
-	tsc=		Disable clocksource stability checks for TSC.
+	tsc=option[,option...]	Various TSC options.
 			Format: <string>
 			[x86] reliable: mark tsc clocksource as reliable, this
 			disables clocksource verification at runtime, as well
@@ -4960,6 +4960,12 @@
 			in situations with strict latency requirements (where
 			interruptions from clocksource watchdog are not
 			acceptable).
+			[x86] no_cpuid_calibration: Disable the CPUID TSC
+			calibration.  Used in situations where the CPUID
Quoted 8 lines

Documentation/admin-guide/kernel-parameters.txt line 4968

Quoted 4 lines
Documentation/admin-guide/kernel-parameters.txt +4 -0
+			TSC khz does not match the actual CPU TSC khz
+			[x86] no_msr_calibration: Disable the MSR TSC
+			calibration.  Used in situations where the MSR
+			TSC khz does not match the actual CPU TSC khz.

Do we want to mention that these situations are mostly broken firmware? Also do mention that if you disable these you might not boot due to not having a PIT/HPET at all?

Right. Same discussion as before.

Quoted 7 lines

Also why do we want no_cpuid_calibration and no_msr_calibration? How

should Joe User figure out which one to use? This does not make sense. The point is that the BIOS/Firmware supplied value in system registers is bogus. So something like "skip_firmware_calibration" might be better suitable.

no_cpuid_calibration was required for Patrick's case where the CPU was overclocked and therefore the CPUID khz value was invalid, but the MSR value is good. I had to skip both to get to the PIT calibration because I had broken FW.
I don't see how a single skip_firmware_calibration covers these cases.

Quoted 5 lines

Aside of that this really wants to be combined with the ability to supply the actual frequency on the command line as I suggested in the other thread to cope with machines which do not expose PIT/HPET or have broken variants of them.

tglx, can you give a lore link to the thread?

Thanks,

P.

Quoted 6 lines

Thanks,

tglx