cpu/intel/common: Fix generated exception if not supported VMX

Reading rdmsr(IA32_FEATURE_CONTROL) in function set_feature_ctrl_lock()
will generate an exception if the CPU do not support this MSR.
Tested on pentium4 (CPUID F65).

Change-Id: I72e138e3bcffe1dcd4e20739a8d07c9abfab4f80
Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
Reviewed-on: https://review.coreboot.org/c/30713
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Matt DeVillier <matt.devillier@gmail.com>
This commit is contained in:
Elyes HAOUAS 2019-01-07 20:39:14 +01:00 committed by Patrick Georgi
parent 8c70dd66da
commit 909870aba6
1 changed files with 7 additions and 0 deletions

View File

@ -72,6 +72,13 @@ void set_feature_ctrl_lock(void)
{
msr_t msr;
int lock = IS_ENABLED(CONFIG_SET_IA32_FC_LOCK_BIT);
uint32_t feature_flag = cpu_get_feature_flags_ecx();
/* Check if VMX is supported before reading or writing the MSR */
if (!((feature_flag & CPUID_VMX) || (feature_flag & CPUID_SMX))) {
printk(BIOS_DEBUG, "Read IA32_FEATURE_CONTROL unsupported\n");
return;
}
msr = rdmsr(IA32_FEATURE_CONTROL);