Stefan Reinauer has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/49232 )
Change subject: Fix tsc_freq_mhz() on some platforms ......................................................................
Fix tsc_freq_mhz() on some platforms
On platforms where cpuid_get_max_func() is < 0x15 the guard that was added to get_freq_from_cpuid16h() does not provide any protection from producing the wrong result. Instead, the code returned 0 which leads to silent crashes in the call chain. Utilize CONFIG_CPU_BCLK_MHZ to prevent this from happening.
Signed-off-by: Stefan Reinauer stefan.reinauer@coreboot.org Change-Id: Ic42a057945a48d8bf0641d1418160906cd15a991 --- M src/soc/intel/common/block/timer/timer.c 1 file changed, 10 insertions(+), 3 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/32/49232/1
diff --git a/src/soc/intel/common/block/timer/timer.c b/src/soc/intel/common/block/timer/timer.c index ab41149..e7920ee 100644 --- a/src/soc/intel/common/block/timer/timer.c +++ b/src/soc/intel/common/block/timer/timer.c @@ -93,9 +93,12 @@
unsigned long tsc_freq_mhz(void) { - unsigned long tsc_freq; + int max_func = cpuid_get_max_func(); + unsigned long tsc_freq = 0; + msr_t platform_info;
- tsc_freq = calculate_tsc_freq_from_core_crystal(); + if (max_func >= 0x15) + tsc_freq = calculate_tsc_freq_from_core_crystal();
if (tsc_freq) return tsc_freq; @@ -104,5 +107,9 @@ * Some Intel SoCs like Skylake, Kabylake and Cometlake don't report * the crystal clock, in that case return bus frequency using CPUID.16h */ - return get_freq_from_cpuid16h(); + if (max_func >= 0x16) + return get_freq_from_cpuid16h(); + + platform_info = rdmsr(MSR_PLATFORM_INFO); + return CONFIG_CPU_BCLK_MHZ * ((platform_info.lo >> 8) & 0xff); }