From 909870aba677bf6a30edc2ab971e312cb5826999 Mon Sep 17 00:00:00 2001 From: Elyes HAOUAS Date: Mon, 7 Jan 2019 20:39:14 +0100 Subject: 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 Reviewed-on: https://review.coreboot.org/c/30713 Tested-by: build bot (Jenkins) Reviewed-by: Matt DeVillier --- src/cpu/intel/common/common_init.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/cpu/intel/common') diff --git a/src/cpu/intel/common/common_init.c b/src/cpu/intel/common/common_init.c index 4f3bcacaf3..0aef3e873c 100644 --- a/src/cpu/intel/common/common_init.c +++ b/src/cpu/intel/common/common_init.c @@ -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); -- cgit v1.2.3