x86/split_lock: Rework the initialization flow of split lock detection
authorXiaoyao Li <xiaoyao.li@intel.com>
Wed, 25 Mar 2020 03:09:23 +0000 (11:09 +0800)
committerThomas Gleixner <tglx@linutronix.de>
Fri, 27 Mar 2020 10:43:29 +0000 (11:43 +0100)
commitdbaba47085b0c2aa793ce849750164bd3765e163
treea398007467f441d2f871fba4c150e8a04fa016ca
parent6650cdd9a8ccf00555dbbe743d58541ad8feb6a7
x86/split_lock: Rework the initialization flow of split lock detection

Current initialization flow of split lock detection has following issues:

1. It assumes the initial value of MSR_TEST_CTRL.SPLIT_LOCK_DETECT to be
   zero. However, it's possible that BIOS/firmware has set it.

2. X86_FEATURE_SPLIT_LOCK_DETECT flag is unconditionally set even if
   there is a virtualization flaw that FMS indicates the existence while
   it's actually not supported.

Rework the initialization flow to solve above issues. In detail, explicitly
clear and set split_lock_detect bit to verify MSR_TEST_CTRL can be
accessed, and rdmsr after wrmsr to ensure bit is cleared/set successfully.

X86_FEATURE_SPLIT_LOCK_DETECT flag is set only when the feature does exist
and the feature is not disabled with kernel param "split_lock_detect=off"

On each processor, explicitly updating the SPLIT_LOCK_DETECT bit based on
sld_sate in split_lock_init() since BIOS/firmware may touch it.

Originally-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20200325030924.132881-2-xiaoyao.li@intel.com
arch/x86/kernel/cpu/intel.c