HAOUAS Elyes has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/30713
Change subject: cpu/intel/common: Fix generated exception if VMX is not supported ......................................................................
cpu/intel/common: Fix generated exception if VMX is not supported
Reading rdmsr(IA32_FEATURE_CONTROL) in function et_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 --- M src/cpu/intel/common/common_init.c 1 file changed, 9 insertions(+), 8 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/13/30713/1
diff --git a/src/cpu/intel/common/common_init.c b/src/cpu/intel/common/common_init.c index 4f3bcac..882db3e 100644 --- a/src/cpu/intel/common/common_init.c +++ b/src/cpu/intel/common/common_init.c @@ -23,6 +23,14 @@
void set_vmx_and_lock(void) { + uint32_t feature_flag = cpu_get_feature_flags_ecx(); + + /* Check that the VMX is supported before reading or writing the MSR. */ + if (!((feature_flag & CPUID_VMX) || (feature_flag & CPUID_SMX))) { + printk(BIOS_DEBUG, "CPU doesn't support VMX; exiting\n"); + return; + } + set_feature_ctrl_vmx(); set_feature_ctrl_lock(); } @@ -30,16 +38,9 @@ void set_feature_ctrl_vmx(void) { msr_t msr; - uint32_t feature_flag; + uint32_t feature_flag = cpu_get_feature_flags_ecx(); int enable = IS_ENABLED(CONFIG_ENABLE_VMX);
- feature_flag = cpu_get_feature_flags_ecx(); - /* Check that the VMX is supported before reading or writing the MSR. */ - if (!((feature_flag & CPUID_VMX) || (feature_flag & CPUID_SMX))) { - printk(BIOS_DEBUG, "CPU doesn't support VMX; exiting\n"); - return; - } - msr = rdmsr(IA32_FEATURE_CONTROL);
if (msr.lo & (1 << 0)) {