x86/tsc_msr: Fix MSR_FSB_FREQ mask for Cherry Trail devices
authorHans de Goede <hdegoede@redhat.com>
Sun, 23 Feb 2020 14:06:09 +0000 (15:06 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 11 Mar 2020 21:57:39 +0000 (22:57 +0100)
commitc8810e2ffc30c7e1577f9c057c4b85d984bbc35a
tree9f8b54c254eb6da1fc91011030383884e53ff559
parent812c2d7506fde7cdf83cb2532810a65782b51741
x86/tsc_msr: Fix MSR_FSB_FREQ mask for Cherry Trail devices

According to the "Intel 64 and IA-32 Architectures Software Developer's
Manual Volume 4: Model-Specific Registers" on Cherry Trail (Airmont)
devices the 4 lowest bits of the MSR_FSB_FREQ mask indicate the bus freq
unlike on e.g. Bay Trail where only the lowest 3 bits are used.

This is also the reason why MAX_NUM_FREQS is defined as 9, since Cherry
Trail SoCs have 9 possible frequencies, so the lo value from the MSR needs
to be masked with 0x0f, not with 0x07 otherwise the 9th frequency will get
interpreted as the 1st.

Bump MAX_NUM_FREQS to 16 to avoid any possibility of addressing the array
out of bounds and makes the mask part of the cpufreq struct so it can be
set it per model.

While at it also log an error when the index points to an uninitialized
part of the freqs lookup-table.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/20200223140610.59612-2-hdegoede@redhat.com
arch/x86/kernel/tsc_msr.c